Attempt to better handle history throttles using flag
parent
8395a1fcfe
commit
3e125625b1
|
@ -1340,8 +1340,7 @@ async def get_bars(
|
|||
fails = 0
|
||||
bars: Optional[list] = None
|
||||
|
||||
for _ in range(3):
|
||||
try:
|
||||
async def get():
|
||||
|
||||
bars, bars_array = await proxy.bars(
|
||||
fqsn=fqsn,
|
||||
|
@ -1351,10 +1350,16 @@ async def get_bars(
|
|||
raise SymbolNotFound(fqsn)
|
||||
|
||||
next_dt = bars[0].date
|
||||
print(f'ib datetime {next_dt}')
|
||||
log.info(f'ib datetime {next_dt}')
|
||||
|
||||
return (bars, bars_array, next_dt), fails
|
||||
|
||||
in_throttle: bool = False
|
||||
|
||||
for _ in range(10):
|
||||
try:
|
||||
return await get()
|
||||
|
||||
except RequestError as err:
|
||||
_err = err
|
||||
|
||||
|
@ -1382,7 +1387,7 @@ async def get_bars(
|
|||
|
||||
# try to decrement start point and look further back
|
||||
next_dt = bars[0].date
|
||||
print(f'ib datetime {next_dt}')
|
||||
log.info(f'ib datetime {next_dt}')
|
||||
continue
|
||||
|
||||
elif 'No market data permissions for' in err.message:
|
||||
|
@ -1401,7 +1406,10 @@ async def get_bars(
|
|||
# TODO: should probably create some alert on screen
|
||||
# and then somehow get that to trigger an event here
|
||||
# that restarts/resumes this task?
|
||||
if not in_throttle:
|
||||
await tractor.breakpoint()
|
||||
|
||||
in_throttle = True
|
||||
fails += 1
|
||||
continue
|
||||
|
||||
|
@ -1455,7 +1463,7 @@ async def backfill_bars(
|
|||
# on that until we have the `marketstore` daemon in place in which
|
||||
# case the shm size will be driven by user config and available sys
|
||||
# memory.
|
||||
count: int = 16,
|
||||
count: int = 22,
|
||||
|
||||
task_status: TaskStatus[trio.CancelScope] = trio.TASK_STATUS_IGNORED,
|
||||
|
||||
|
|
Loading…
Reference in New Issue