Compare commits
13 Commits
a06fe473cf
...
b58a714965
| Author | SHA1 | Date |
|---|---|---|
|
|
b58a714965 | |
|
|
90964487ec | |
|
|
621707582c | |
|
|
abad8f751b | |
|
|
ba7d45dbd2 | |
|
|
491bb66912 | |
|
|
329d212e00 | |
|
|
17fdae4654 | |
|
|
446558f3ad | |
|
|
e55637ae44 | |
|
|
6ad9d6e149 | |
|
|
32786c5894 | |
|
|
9247746a79 |
|
|
@ -991,6 +991,9 @@ _statuses: dict[str, str] = {
|
||||||
# TODO: see a current ``ib_insync`` issue around this:
|
# TODO: see a current ``ib_insync`` issue around this:
|
||||||
# https://github.com/erdewit/ib_insync/issues/363
|
# https://github.com/erdewit/ib_insync/issues/363
|
||||||
'Inactive': 'pending',
|
'Inactive': 'pending',
|
||||||
|
|
||||||
|
# XXX, uhh wut the heck is this?
|
||||||
|
'ValidationError': 'error',
|
||||||
}
|
}
|
||||||
|
|
||||||
_action_map = {
|
_action_map = {
|
||||||
|
|
@ -1063,8 +1066,19 @@ async def deliver_trade_events(
|
||||||
# TODO: for some reason we can receive a ``None`` here when the
|
# TODO: for some reason we can receive a ``None`` here when the
|
||||||
# ib-gw goes down? Not sure exactly how that's happening looking
|
# ib-gw goes down? Not sure exactly how that's happening looking
|
||||||
# at the eventkit code above but we should probably handle it...
|
# at the eventkit code above but we should probably handle it...
|
||||||
|
event_name: str
|
||||||
|
item: (
|
||||||
|
Trade
|
||||||
|
|tuple[Trade, Fill]
|
||||||
|
|CommissionReport
|
||||||
|
|IbPosition
|
||||||
|
|dict
|
||||||
|
)
|
||||||
async for event_name, item in trade_event_stream:
|
async for event_name, item in trade_event_stream:
|
||||||
log.info(f'Relaying `{event_name}`:\n{pformat(item)}')
|
log.info(
|
||||||
|
f'Relaying {event_name!r}:\n'
|
||||||
|
f'{pformat(item)}\n'
|
||||||
|
)
|
||||||
match event_name:
|
match event_name:
|
||||||
case 'orderStatusEvent':
|
case 'orderStatusEvent':
|
||||||
|
|
||||||
|
|
@ -1075,11 +1089,12 @@ async def deliver_trade_events(
|
||||||
trade: Trade = item
|
trade: Trade = item
|
||||||
reqid: str = str(trade.order.orderId)
|
reqid: str = str(trade.order.orderId)
|
||||||
status: OrderStatus = trade.orderStatus
|
status: OrderStatus = trade.orderStatus
|
||||||
status_str: str = _statuses[status.status]
|
status_str: str = _statuses.get(
|
||||||
|
status.status,
|
||||||
|
'error',
|
||||||
|
)
|
||||||
remaining: float = status.remaining
|
remaining: float = status.remaining
|
||||||
if (
|
if status_str == 'filled':
|
||||||
status_str == 'filled'
|
|
||||||
):
|
|
||||||
fill: Fill = trade.fills[-1]
|
fill: Fill = trade.fills[-1]
|
||||||
execu: Execution = fill.execution
|
execu: Execution = fill.execution
|
||||||
|
|
||||||
|
|
@ -1110,6 +1125,12 @@ async def deliver_trade_events(
|
||||||
# all units were cleared.
|
# all units were cleared.
|
||||||
status_str = 'closed'
|
status_str = 'closed'
|
||||||
|
|
||||||
|
elif status_str == 'error':
|
||||||
|
log.error(
|
||||||
|
f'IB reported error status for order ??\n'
|
||||||
|
f'{status.status!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
# skip duplicate filled updates - we get the deats
|
# skip duplicate filled updates - we get the deats
|
||||||
# from the execution details event
|
# from the execution details event
|
||||||
msg = BrokerdStatus(
|
msg = BrokerdStatus(
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,14 @@ def has_holiday(
|
||||||
'''
|
'''
|
||||||
tz: str = con_deats.timeZoneId
|
tz: str = con_deats.timeZoneId
|
||||||
exch: str = con_deats.contract.primaryExchange
|
exch: str = con_deats.contract.primaryExchange
|
||||||
cal: ExchangeCalendar = xcals.get_calendar(exch)
|
|
||||||
|
# XXX, ad-hoc handle any IB exchange which are non-std
|
||||||
|
# via lookup table..
|
||||||
|
std_exch: dict = {
|
||||||
|
'ARCA': 'ARCX',
|
||||||
|
}.get(exch, exch)
|
||||||
|
|
||||||
|
cal: ExchangeCalendar = xcals.get_calendar(std_exch)
|
||||||
end: datetime = period.end
|
end: datetime = period.end
|
||||||
# _start: datetime = period.start
|
# _start: datetime = period.start
|
||||||
# ?TODO, can rm ya?
|
# ?TODO, can rm ya?
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,10 @@ from piker.brokers import NoData
|
||||||
from piker.accounting import (
|
from piker.accounting import (
|
||||||
MktPair,
|
MktPair,
|
||||||
)
|
)
|
||||||
from piker.log import get_logger
|
from piker.log import (
|
||||||
|
get_logger,
|
||||||
|
get_console_log,
|
||||||
|
)
|
||||||
from ..data._sharedmem import (
|
from ..data._sharedmem import (
|
||||||
maybe_open_shm_array,
|
maybe_open_shm_array,
|
||||||
ShmArray,
|
ShmArray,
|
||||||
|
|
@ -1368,6 +1371,10 @@ async def manage_history(
|
||||||
engages.
|
engages.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
get_console_log(
|
||||||
|
name=__name__,
|
||||||
|
level=loglevel,
|
||||||
|
)
|
||||||
# TODO: is there a way to make each shm file key
|
# TODO: is there a way to make each shm file key
|
||||||
# actor-tree-discovery-addr unique so we avoid collisions
|
# actor-tree-discovery-addr unique so we avoid collisions
|
||||||
# when doing tests which also allocate shms for certain instruments
|
# when doing tests which also allocate shms for certain instruments
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue