Make a list of (name, shares, price, change) tuples given a portfolio list and prices dictionary.
(portfolio, prices)
| 37 | return prices |
| 38 | |
| 39 | def make_report_data(portfolio, prices): |
| 40 | ''' |
| 41 | Make a list of (name, shares, price, change) tuples given a portfolio list |
| 42 | and prices dictionary. |
| 43 | ''' |
| 44 | rows = [] |
| 45 | for stock in portfolio: |
| 46 | current_price = prices[stock['name']] |
| 47 | change = current_price - stock['price'] |
| 48 | summary = (stock['name'], stock['shares'], current_price, change) |
| 49 | rows.append(summary) |
| 50 | return rows |
| 51 | |
| 52 | # Read data files and create the report data |
| 53 |