MCPcopy Create free account
hub / github.com/dabeaz-course/practical-python / portfolio_cost

Function portfolio_cost

Solutions/3_14/pcost.py:5–10  ·  view source on GitHub ↗

Computes the total cost (shares*price) of a portfolio file

(filename)

Source from the content-addressed store, hash-verified

3import report
4
5def portfolio_cost(filename):
6 '''
7 Computes the total cost (shares*price) of a portfolio file
8 '''
9 portfolio = report.read_portfolio(filename)
10 return sum([s['shares']*s['price'] for s in portfolio])
11
12import sys
13if len(sys.argv) == 2:

Callers 1

pcost.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected