Pre-loop clients to build out pps tables, handle missing commission field
parent
999ae5a1c6
commit
73d2e7716f
|
@ -1245,7 +1245,6 @@ async def open_client_proxies() -> tuple[
|
||||||
]:
|
]:
|
||||||
async with (
|
async with (
|
||||||
tractor.trionics.maybe_open_context(
|
tractor.trionics.maybe_open_context(
|
||||||
# acm_func=open_client_proxies,
|
|
||||||
acm_func=tractor.to_asyncio.open_channel_from,
|
acm_func=tractor.to_asyncio.open_channel_from,
|
||||||
kwargs={'target': load_clients_for_trio},
|
kwargs={'target': load_clients_for_trio},
|
||||||
|
|
||||||
|
|
|
@ -462,8 +462,8 @@ async def trades_dialogue(
|
||||||
with (
|
with (
|
||||||
ExitStack() as lstack,
|
ExitStack() as lstack,
|
||||||
):
|
):
|
||||||
|
# load ledgers and pps for all detected client-proxies
|
||||||
for account, proxy in proxies.items():
|
for account, proxy in proxies.items():
|
||||||
|
|
||||||
assert account in accounts_def
|
assert account in accounts_def
|
||||||
accounts.add(account)
|
accounts.add(account)
|
||||||
acctid = account.strip('ib.')
|
acctid = account.strip('ib.')
|
||||||
|
@ -478,6 +478,7 @@ async def trades_dialogue(
|
||||||
open_pps('ib', acctid)
|
open_pps('ib', acctid)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for account, proxy in proxies.items():
|
||||||
client = aioclients[account]
|
client = aioclients[account]
|
||||||
|
|
||||||
# process pp value reported from ib's system. we only use these
|
# process pp value reported from ib's system. we only use these
|
||||||
|
@ -971,7 +972,9 @@ def norm_trade_records(
|
||||||
for tid, record in ledger.items():
|
for tid, record in ledger.items():
|
||||||
|
|
||||||
conid = record.get('conId') or record['conid']
|
conid = record.get('conId') or record['conid']
|
||||||
comms = record.get('commission') or -1*record['ibCommission']
|
comms = record.get('commission')
|
||||||
|
if comms is None:
|
||||||
|
comms = -1*record['ibCommission']
|
||||||
price = record.get('price') or record['tradePrice']
|
price = record.get('price') or record['tradePrice']
|
||||||
|
|
||||||
# the api doesn't do the -/+ on the quantity for you but flex
|
# the api doesn't do the -/+ on the quantity for you but flex
|
||||||
|
|
Loading…
Reference in New Issue