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

Function ticker

Solutions/7_4/ticker.py:27–35  ·  view source on GitHub ↗
(portfile, logfile, fmt)

Source from the content-addressed store, hash-verified

25 return rows
26
27def ticker(portfile, logfile, fmt):
28 portfolio = report.read_portfolio(portfile)
29 lines = follow(logfile)
30 rows = parse_stock_data(lines)
31 rows = (row for row in rows if row['name'] in portfolio)
32 formatter = tableformat.create_formatter(fmt)
33 formatter.headings(['Name','Price','Change'])
34 for row in rows:
35 formatter.row([ row['name'], f"{row['price']:0.2f}", f"{row['change']:0.2f}"] )
36
37def main(args):
38 if len(args) != 4:

Callers 1

mainFunction · 0.70

Calls 4

followFunction · 0.90
parse_stock_dataFunction · 0.70
headingsMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected