basic bot: set unix fileformat, add KBI handling to cancel order submission

basic_buy_bot
Tyler Goodlet 2023-06-26 13:43:59 -04:00
parent 63a6c6efde
commit 5690595064
1 changed files with 146 additions and 143 deletions

View File

@ -79,14 +79,14 @@ async def bot_main():
# init and sync actor-service runtime # init and sync actor-service runtime
maybe_open_pikerd( maybe_open_pikerd(
registry_addr=reg_addr, # registry_addr=reg_addr,
loglevel=ll, loglevel=ll,
debug_mode=False, debug_mode=False,
), ),
tractor.wait_for_actor( tractor.wait_for_actor(
'pikerd', 'pikerd',
arbiter_sockaddr=reg_addr, # arbiter_sockaddr=reg_addr,
), ),
open_ems( open_ems(
@ -104,7 +104,7 @@ async def bot_main():
): ):
print(f'Loaded binance accounts: {accounts}') print(f'Loaded binance accounts: {accounts}')
price: float = 10e3 # non-clearable price: float = 30e3 # non-clearable
size: float = 0.01 size: float = 0.01
oid: str = str(uuid4()) oid: str = str(uuid4())
@ -129,14 +129,17 @@ async def bot_main():
assert not pps assert not pps
assert msgs[-1].oid == oid assert msgs[-1].oid == oid
# cancel the open order try:
await client.cancel(oid) # wait for ctl-c from user..
msgs, pps = await wait_for_order_status( await trio.sleep_forever()
trades_stream, except KeyboardInterrupt:
oid, # cancel the open order
'canceled' await client.cancel(oid)
) msgs, pps = await wait_for_order_status(
trades_stream,
oid,
'canceled'
)
if __name__ == '__main__': if __name__ == '__main__':