Added solution code
This commit is contained in:
20
Solutions/7_4/pcost.py
Normal file
20
Solutions/7_4/pcost.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# pcost.py
|
||||
|
||||
import report
|
||||
|
||||
def portfolio_cost(filename):
|
||||
'''
|
||||
Computes the total cost (shares*price) of a portfolio file
|
||||
'''
|
||||
portfolio = report.read_portfolio(filename)
|
||||
return portfolio.total_cost
|
||||
|
||||
def main(args):
|
||||
if len(args) != 2:
|
||||
raise SystemExit('Usage: %s portfoliofile' % args[0])
|
||||
filename = args[1]
|
||||
print('Total cost:', portfolio_cost(filename))
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
main(sys.argv)
|
||||
Reference in New Issue
Block a user