remove odd lots from output printing
This commit is contained in:
parent
a22cd6d9e0
commit
b1f9ea514a
1 changed files with 5 additions and 17 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue