Guest User

Untitled

a guest
Feb 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import csv
  2. from decimal import Decimal
  3.  
  4.  
  5. def cvstolist(filename):
  6. price =[]
  7. quant = []
  8.  
  9. with open( filename, 'r') as csvf:
  10. csvobj = csv.reader(csvf)
  11.  
  12. for row in csvobj:
  13. yield row[0], row[1]
  14.  
  15.  
  16.  
  17. chosenloss = 4
  18.  
  19. for price,quant in cvstolist("input.csv"):
  20. perc1 = (Decimal(price) /100)
  21. losspercoin = Decimal(chosenloss)/Decimal(quant)
  22. print('lossprcoin = {}'.format(losspercoin))
  23.  
  24. exitpricechosenloss = Decimal(price) - Decimal(losspercoin)
  25. print('exitpricechosenloss = {}'.format(exitpricechosenloss))
  26. print('perc1 = {}'.format(perc1))
  27. percchosenlosspercoin = exitpricechosenloss / perc1
Add Comment
Please, Sign In to add comment