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