1212from datetime import datetime
1313
1414# For some fun colors...
15- from colorama import Fore , Back , Style , init as ColoramaInit
15+ from colorama import Fore , Style , init as ColoramaInit
16+
17+
1618ColoramaInit (autoreset = True )
1719
1820# Make this global
1921opt = None
2022
23+
2124def ts ():
2225 return pd .Timestamp .now ()
2326
@@ -55,7 +58,9 @@ async def on_minute(conn, channel, bar):
5558 else :
5659 bar_color = f'{ Style .BRIGHT } { Fore .WHITE } '
5760
58- print (f'{ channel :<6} { ms2date (bar .end )} { bar_color } { symbol :<10s} { percent :>8.2f} { bar .open :>8.2f} { bar .close :>8.2f} { bar .volume :<10d} '
61+ print (f'{ channel :<6s} { ms2date (bar .end )} { bar .symbol :<10s} '
62+ f'{ percent :>8.2f} % { bar .open :>8.2f} { bar .close :>8.2f} '
63+ f' { bar .volume :<10d} '
5964 f' { (Fore .GREEN + "above VWAP" ) if close > bar .vwap else (Fore .RED + "below VWAP" )} ' )
6065
6166
@@ -65,15 +70,16 @@ async def on_tick(conn, channel, bar):
6570 except : # noqa
6671 percent = 0
6772
68- print (f'{ channel :<6s} { ms2date (bar .end )} { bar .symbol :<10s} { percent :>8.2f} % { bar .open :>8.2f} { bar .close :>8.2f} { bar .volume :<10d} ' )
73+ print (f'{ channel :<6s} { ms2date (bar .end )} { bar .symbol :<10s} '
74+ f'{ percent :>8.2f} % { bar .open :>8.2f} { bar .close :>8.2f} '
75+ f' { bar .volume :<10d} ' )
6976
7077
7178async def on_data (conn , channel , data ):
7279 if opt .debug or not (channel in ('AM' , 'Q' , 'A' , 'T' )):
7380 debug ("debug: " , pprint .pformat (data ))
7481
7582
76-
7783def reloadWatch (prog , cmd ):
7884 async def watch_command ():
7985 startingmodtime = os .path .getmtime (prog )
@@ -130,6 +136,8 @@ async def watch_command():
130136
131137 try :
132138 if opt .all :
139+ # Note to see all these channels, you'd need to add a handler
140+ # above or use --debug!
133141 conn .run (['Q.*' , 'T.*' , 'AM.*' , 'A.*' ])
134142 else :
135143 conn .run (['AM.*' ])
0 commit comments