binance: raise `NoData` on null hist arrays
Like we do with other history backends to indicate lack of a data set. This avoids any raise that will will bring down the backloader task with some downstream error. Raise a `ValueError` on no time index for now.nix-headless-fix
parent
b7883325a9
commit
19c343e8b2
|
@ -48,6 +48,7 @@ import tractor
|
||||||
|
|
||||||
from piker.brokers import (
|
from piker.brokers import (
|
||||||
open_cached_client,
|
open_cached_client,
|
||||||
|
NoData,
|
||||||
)
|
)
|
||||||
from piker._cacheables import (
|
from piker._cacheables import (
|
||||||
async_lifo_cache,
|
async_lifo_cache,
|
||||||
|
@ -254,22 +255,28 @@ async def open_history_client(
|
||||||
|
|
||||||
# NOTE: always query using their native symbology!
|
# NOTE: always query using their native symbology!
|
||||||
mktid: str = mkt.bs_mktid
|
mktid: str = mkt.bs_mktid
|
||||||
array = await client.bars(
|
array: np.ndarray = await client.bars(
|
||||||
mktid,
|
mktid,
|
||||||
start_dt=start_dt,
|
start_dt=start_dt,
|
||||||
end_dt=end_dt,
|
end_dt=end_dt,
|
||||||
)
|
)
|
||||||
|
if array.size == 0:
|
||||||
|
raise NoData('No frame for {start_dt} -> {end_dt}\n')
|
||||||
|
|
||||||
times = array['time']
|
times = array['time']
|
||||||
if (
|
if not times.any():
|
||||||
end_dt is None
|
raise ValueError(
|
||||||
):
|
'Bad frame with null-times?\n\n'
|
||||||
inow = round(time.time())
|
f'{times}'
|
||||||
|
)
|
||||||
|
|
||||||
|
if end_dt is None:
|
||||||
|
inow: int = round(time.time())
|
||||||
if (inow - times[-1]) > 60:
|
if (inow - times[-1]) > 60:
|
||||||
await tractor.pause()
|
await tractor.pause()
|
||||||
|
|
||||||
start_dt = from_timestamp(times[0])
|
start_dt = from_timestamp(times[0])
|
||||||
end_dt = from_timestamp(times[-1])
|
end_dt = from_timestamp(times[-1])
|
||||||
|
|
||||||
return array, start_dt, end_dt
|
return array, start_dt, end_dt
|
||||||
|
|
||||||
yield get_ohlc, {'erlangs': 3, 'rate': 3}
|
yield get_ohlc, {'erlangs': 3, 'rate': 3}
|
||||||
|
|
Loading…
Reference in New Issue