Add to signal broker won't deliver more data
parent
800fe7446a
commit
b8704e1b7f
|
@ -51,6 +51,25 @@ class NoData(BrokerError):
|
||||||
self.frame_size: int = 1000
|
self.frame_size: int = 1000
|
||||||
|
|
||||||
|
|
||||||
|
class DataUnavailable(BrokerError):
|
||||||
|
'''
|
||||||
|
Signal storage requests to terminate.
|
||||||
|
|
||||||
|
'''
|
||||||
|
# TODO: add in a reason that can be displayed in the
|
||||||
|
# UI (for eg. `kraken` is bs and you should complain
|
||||||
|
# to them that you can't pull more OHLC data..)
|
||||||
|
|
||||||
|
|
||||||
|
class DataThrottle(BrokerError):
|
||||||
|
'''
|
||||||
|
Broker throttled request rate for data.
|
||||||
|
|
||||||
|
'''
|
||||||
|
# TODO: add in throttle metrics/feedback
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def resproc(
|
def resproc(
|
||||||
resp: asks.response_objects.Response,
|
resp: asks.response_objects.Response,
|
||||||
log: logging.Logger,
|
log: logging.Logger,
|
||||||
|
|
|
@ -67,6 +67,10 @@ from ._sampling import (
|
||||||
sample_and_broadcast,
|
sample_and_broadcast,
|
||||||
uniform_rate_send,
|
uniform_rate_send,
|
||||||
)
|
)
|
||||||
|
from ..brokers._util import (
|
||||||
|
NoData,
|
||||||
|
DataUnavailable,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
@ -273,7 +277,19 @@ async def start_backfill(
|
||||||
# and count < mx_fills
|
# and count < mx_fills
|
||||||
):
|
):
|
||||||
count += 1
|
count += 1
|
||||||
array, start_dt, end_dt = await hist(end_dt=start_dt)
|
try:
|
||||||
|
array, start_dt, end_dt = await hist(end_dt=start_dt)
|
||||||
|
|
||||||
|
except NoData:
|
||||||
|
# decrement by the diff in time last delivered.
|
||||||
|
end_dt = start_dt.subtract(seconds=(end_dt - start_dt).seconds)
|
||||||
|
continue
|
||||||
|
|
||||||
|
except DataUnavailable:
|
||||||
|
# broker is being a bish and we can't pull
|
||||||
|
# any more..
|
||||||
|
break
|
||||||
|
|
||||||
to_push = diff_history(
|
to_push = diff_history(
|
||||||
array,
|
array,
|
||||||
start_dt,
|
start_dt,
|
||||||
|
|
Loading…
Reference in New Issue