change logic order for handling no config case
parent
2baa1b4605
commit
c2e654aae2
|
@ -45,6 +45,7 @@ from ._util import resproc, SymbolNotFound, BrokerError
|
||||||
from ..log import get_logger, get_console_log
|
from ..log import get_logger, get_console_log
|
||||||
from ..data import ShmArray
|
from ..data import ShmArray
|
||||||
from ..data._web_bs import open_autorecon_ws, NoBsWs
|
from ..data._web_bs import open_autorecon_ws, NoBsWs
|
||||||
|
from ..clearing._paper_engine import PaperBoi
|
||||||
from ..clearing._messages import (
|
from ..clearing._messages import (
|
||||||
BrokerdPosition, BrokerdOrder, BrokerdStatus,
|
BrokerdPosition, BrokerdOrder, BrokerdStatus,
|
||||||
BrokerdOrderAck, BrokerdError, BrokerdCancel,
|
BrokerdOrderAck, BrokerdError, BrokerdCancel,
|
||||||
|
@ -691,7 +692,30 @@ async def trades_dialogue(
|
||||||
|
|
||||||
# Authenticated block
|
# Authenticated block
|
||||||
async with get_client() as client:
|
async with get_client() as client:
|
||||||
if client._api_key:
|
if not client._api_key:
|
||||||
|
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,
|
||||||
|
):
|
||||||
|
|
||||||
|
client = PaperBoi(
|
||||||
|
'kraken',
|
||||||
|
ems_stream,
|
||||||
|
_buys={},
|
||||||
|
_sells={},
|
||||||
|
|
||||||
|
_reqids={},
|
||||||
|
|
||||||
|
# TODO: load paper positions from ``positions.toml``
|
||||||
|
_positions={},
|
||||||
|
)
|
||||||
|
|
||||||
|
## TODO: maybe add multiple accounts
|
||||||
|
n.start_soon(handle_order_requests, client, ems_stream)
|
||||||
|
|
||||||
acc_name = 'kraken.' + client._name
|
acc_name = 'kraken.' + client._name
|
||||||
trades = await client.get_trades()
|
trades = await client.get_trades()
|
||||||
|
|
||||||
|
@ -755,17 +779,6 @@ 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