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

Function ticker

Solutions/8_1/ticker.py:26–34  ·  view source on GitHub ↗
(portfile, logfile, fmt)

Source from the content-addressed store, hash-verified

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