From 7c1e3a7a5ecc86ab570f90c4553e6aabb242e4f9 Mon Sep 17 00:00:00 2001 From: "Brian J. Dowling" Date: Fri, 12 Jul 2019 17:06:31 -0400 Subject: [PATCH] updated example for CI, long lines, etc --- examples/simpleStream.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/simpleStream.py b/examples/simpleStream.py index b5a278e6..1aadf44d 100755 --- a/examples/simpleStream.py +++ b/examples/simpleStream.py @@ -12,12 +12,15 @@ from datetime import datetime # For some fun colors... -from colorama import Fore, Back, Style, init as ColoramaInit +from colorama import Fore, Style, init as ColoramaInit + + ColoramaInit(autoreset=True) # Make this global opt = None + def ts(): return pd.Timestamp.now() @@ -55,7 +58,9 @@ async def on_minute(conn, channel, bar): else: bar_color = f'{Style.BRIGHT}{Fore.WHITE}' - 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}' + print(f'{channel:<6s} {ms2date(bar.end)} {bar.symbol:<10s} ' + f'{percent:>8.2f}% {bar.open:>8.2f} {bar.close:>8.2f} ' + f' {bar.volume:<10d}' f' {(Fore.GREEN+"above VWAP") if close > bar.vwap else (Fore.RED+"below VWAP")}') @@ -65,7 +70,9 @@ async def on_tick(conn, channel, bar): except: # noqa percent = 0 - print(f'{channel:<6s} {ms2date(bar.end)} {bar.symbol:<10s} {percent:>8.2f}% {bar.open:>8.2f} {bar.close:>8.2f} {bar.volume:<10d}') + print(f'{channel:<6s} {ms2date(bar.end)} {bar.symbol:<10s} ' + f'{percent:>8.2f}% {bar.open:>8.2f} {bar.close:>8.2f} ' + f' {bar.volume:<10d}') async def on_data(conn, channel, data): @@ -73,7 +80,6 @@ async def on_data(conn, channel, data): debug("debug: ", pprint.pformat(data)) - def reloadWatch(prog, cmd): async def watch_command(): startingmodtime = os.path.getmtime(prog) @@ -130,6 +136,8 @@ async def watch_command(): try: if opt.all: + # Note to see all these channels, you'd need to add a handler + # above or use --debug! conn.run(['Q.*', 'T.*', 'AM.*', 'A.*']) else: conn.run(['AM.*'])