@@ -45,17 +45,12 @@ def make_report(portfolio, prices):
45
45
return rows
46
46
47
47
48
- portfolio = read_portfolio ('Data/portfoliodate.csv' )
49
- #portfolio = read_portfolio(input("Enter the filename: "))
50
- prices = read_prices ('Data/prices.csv' )
51
-
52
-
53
- report = make_report (portfolio , prices )
54
- header = ('Name' , 'Shares' , 'Price' , 'Change' )
55
- print ("%10s %10s %10s %10s" % header )
56
- print (("-" * 10 + " " ) * len (header ))
57
- for name , shares , price , change in report :
58
- print (f"{ name :>10s} { shares :>10d} { f'${ price :.2f} ' :>10} { change :>10.2f} " )
48
+ def print_report (report ):
49
+ header = ('Name' , 'Shares' , 'Price' , 'Change' )
50
+ print ("%10s %10s %10s %10s" % header )
51
+ print (("-" * 10 + " " ) * len (header ))
52
+ for name , shares , price , change in report :
53
+ print (f"{ name :>10s} { shares :>10d} { f'${ price :.2f} ' :>10} { change :>10.2f} " )
59
54
60
55
##cost = 0
61
56
#for share in portfolio:
@@ -69,3 +64,13 @@ def make_report(portfolio, prices):
69
64
#print(f"Current value: {curr_val}")
70
65
#print(f"Profit: {curr_val - cost}")
71
66
#
67
+ def main ():
68
+ portfolio = read_portfolio ('Data/portfoliodate.csv' )
69
+ #portfolio = read_portfolio(input("Enter the filename: "))
70
+ prices = read_prices ('Data/prices.csv' )
71
+ report = make_report (portfolio , prices )
72
+ print_report (report )
73
+
74
+ if __name__ == "__main__" :
75
+ main ()
76
+
0 commit comments