remove odd lots from output printing

This commit is contained in:
Joe Lothan 2026-06-15 14:48:23 -04:00
parent a22cd6d9e0
commit b1f9ea514a

View file

@ -66,22 +66,10 @@ def flatten_and_sort(data):
return trades
def format_tape_line(trade):
"""Format a trade like an old ticker tape: SYM shares price"""
sym = trade["sym"]
size = trade["s"]
price = trade["p"]
# Old tickers showed round lots (100s). "2s" meant 200 shares.
# A bare price meant 100 shares (1 round lot).
if size < 100:
vol = f"{size}sh"
elif size % 100 == 0:
lots = size // 100
vol = f"{lots}s" if lots > 1 else ""
else:
vol = f"{size}sh"
def format_tape_line(sym, lots, price):
"""Format a trade like an old ticker tape: SYM lots price.
A bare price means 1 round lot. '2s' means 2 lots (200 shares)."""
vol = f"{lots}s" if lots > 1 else ""
parts = [sym]
if vol:
parts.append(vol)
@ -165,7 +153,7 @@ def main():
print(f"{trade['t']},{trade['sym']},{lots},{trade['p']:.2f}")
else:
ts = trade["t"][:19].replace("T", " ")
line = format_tape_line(trade)
line = format_tape_line(trade["sym"], lots, trade["p"])
print(f"{ts} {line}")
total += 1