~luisbg/booty/trunk

« back to all changes in this revision

Viewing changes to src/booty

  • Committer: Luis de Bethencourt
  • Date: 2009-01-08 00:35:46 UTC
  • Revision ID: luisbg@rorschach-20090108003546-w3tfm2uyrvkln25t
pulling stock info from file

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
num_stocks = []
17
17
purchase_prices = []
18
18
 
19
 
stocks.append("SAN.MC")
20
 
num_stocks.append(444)
21
 
purchase_prices.append(6.66)
 
19
stocks_file = open("/home/luisbg/.booty/stocks")
22
20
 
23
 
stocks.append("SAN.MC")
24
 
num_stocks.append(30)
25
 
purchase_prices.append(6.79)
 
21
EOF = False
 
22
while EOF == False:
 
23
    line = stocks_file.readline()
 
24
    if line != '':
 
25
        stocks.append(line[:-1])
 
26
        num_stocks.append(int(stocks_file.readline()[:-1]))
 
27
        purchase_prices.append(float(stocks_file.readline()[:-1]))
 
28
    else:
 
29
        EOF = True
26
30
 
27
31
# email info
28
32
fromaddr = "finance <luisbg@ubuntu.com>" 
40
44
# Print all the information and add it to the mail
41
45
c = 0
42
46
total = 0
 
47
balance_total = 0
43
48
for elements in stocks:
44
49
    quote = float(ystockquote.get_price(stocks[c]))
45
50
    diff = quote - purchase_prices[c]
67
72
    print value_str
68
73
 
69
74
    total += value
 
75
    balance_total += balance
70
76
    msg = msg + quote_str + " \n" + "\n" + balance_str + "\n" + value_str + "\n\n"
71
77
    print ""
72
78
 
73
79
    c += 1
74
80
 
75
 
total_str = "Total:    " + str(total) + "€"
 
81
total_str = "Total:    " + str(total) + "€   (+" + str(balance_total) + ")"
76
82
print total_str
77
83
msg = msg + total_str
78
84