fix hang when kraken is not in config
parent
cb8e97a142
commit
2baa1b4605
|
@ -450,11 +450,14 @@ class Client:
|
||||||
async def get_client() -> Client:
|
async def get_client() -> Client:
|
||||||
|
|
||||||
section = get_config()
|
section = get_config()
|
||||||
|
if section:
|
||||||
client = Client(
|
client = Client(
|
||||||
name=section['key_descr'],
|
name=section['key_descr'],
|
||||||
api_key=section['api_key'],
|
api_key=section['api_key'],
|
||||||
secret=section['secret']
|
secret=section['secret']
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
client = Client()
|
||||||
|
|
||||||
# at startup, load all symbols locally for fast search
|
# at startup, load all symbols locally for fast search
|
||||||
await client.cache_symbols()
|
await client.cache_symbols()
|
||||||
|
@ -688,6 +691,7 @@ async def trades_dialogue(
|
||||||
|
|
||||||
# Authenticated block
|
# Authenticated block
|
||||||
async with get_client() as client:
|
async with get_client() as client:
|
||||||
|
if client._api_key:
|
||||||
acc_name = 'kraken.' + client._name
|
acc_name = 'kraken.' + client._name
|
||||||
trades = await client.get_trades()
|
trades = await client.get_trades()
|
||||||
|
|
||||||
|
@ -751,6 +755,17 @@ async def trades_dialogue(
|
||||||
|
|
||||||
await ems_stream.send(fill_msg.dict())
|
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(
|
async def stream_messages(
|
||||||
ws: NoBsWs,
|
ws: NoBsWs,
|
||||||
|
|
Loading…
Reference in New Issue