Skip to content

Commit

Permalink
updated example for CI, long lines, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
bdowling committed Jul 12, 2019
1 parent c958759 commit 7c1e3a7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/simpleStream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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")}')


Expand All @@ -65,15 +70,16 @@ 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):
if opt.debug or not (channel in ('AM', 'Q', 'A', 'T')):
debug("debug: ", pprint.pformat(data))



def reloadWatch(prog, cmd):
async def watch_command():
startingmodtime = os.path.getmtime(prog)
Expand Down Expand Up @@ -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.*'])
Expand Down

0 comments on commit 7c1e3a7

Please sign in to comment.