fix hang when kraken is not in config

kraken_orders
Konstantine Tsafatinos 2022-03-28 18:28:19 -04:00
parent cb8e97a142
commit 2baa1b4605
1 changed files with 74 additions and 59 deletions

View File

@ -450,11 +450,14 @@ class Client:
async def get_client() -> Client:
section = get_config()
if section:
client = Client(
name=section['key_descr'],
api_key=section['api_key'],
secret=section['secret']
)
else:
client = Client()
# at startup, load all symbols locally for fast search
await client.cache_symbols()
@ -688,6 +691,7 @@ async def trades_dialogue(
# Authenticated block
async with get_client() as client:
if client._api_key:
acc_name = 'kraken.' + client._name
trades = await client.get_trades()
@ -751,6 +755,17 @@ async def trades_dialogue(
await ems_stream.send(fill_msg.dict())
else:
log.error('Missing Kraken API key: Trades WS connection failed')
await ctx.started(({}, {'paper',}))
async with (
ctx.open_stream() as ems_stream,
trio.open_nursery() as n,
):
## TODO: maybe add multiple accounts
n.start_soon(handle_order_requests, client, ems_stream)
async def stream_messages(
ws: NoBsWs,