Drop prints, break on latest clear match tick

basic_buy_bot
Tyler Goodlet 2023-06-26 16:26:33 -04:00
parent 46b22958f0
commit f1eb76d29f
1 changed files with 18 additions and 10 deletions

View File

@ -22,10 +22,12 @@ from piker.data import (
Flume, Flume,
open_feed, open_feed,
Feed, Feed,
ShmArray, # ShmArray,
) )
# TODO: handle other statuses:
# - fills, errors, and
async def wait_for_order_status( async def wait_for_order_status(
trades_stream: tractor.MsgStream, trades_stream: tractor.MsgStream,
oid: str, oid: str,
@ -139,9 +141,9 @@ async def bot_main():
async def trailer( async def trailer(
order: Order, order: Order,
): ):
# ref shm OHLCV array # ref shm OHLCV array history, if you want
s_shm: ShmArray = flume.rt_shm # s_shm: ShmArray = flume.rt_shm
m_shm: ShmArray = flume.hist_shm # m_shm: ShmArray = flume.hist_shm
# NOTE: if you wanted to frame ticks by type like the # NOTE: if you wanted to frame ticks by type like the
# the quote throttler does. # the quote throttler does.
@ -149,12 +151,15 @@ async def bot_main():
async for quotes in quote_stream: async for quotes in quote_stream:
for fqme, quote in quotes.items(): for fqme, quote in quotes.items():
for tick in quote.get('ticks', ()): # print(quote['symbol'])
print( for tick in reversed(
f'{fqme} ticks:\n{pformat(tick)}\n\n' quote.get('ticks', ())
f'last 1s OHLC:\n{s_shm.array[-1]}\n' ):
f'last 1m OHLC:\n{m_shm.array[-1]}\n' # print(
) # f'{fqme} ticks:\n{pformat(tick)}\n\n'
# # f'last 1s OHLC:\n{s_shm.array[-1]}\n'
# # f'last 1m OHLC:\n{m_shm.array[-1]}\n'
# )
# always keep live limit 2% below last # always keep live limit 2% below last
# clearing price # clearing price
@ -172,6 +177,9 @@ async def bot_main():
oid, oid,
'open' 'open'
) )
# if multiple clears per quote just
# skip to the next quote?
break
# setup order dialog via first msg # setup order dialog via first msg