Guard against no time field in some provider quotes
parent
5952e7f538
commit
8118a57b9a
|
@ -24,7 +24,10 @@ from typing import AsyncIterator
|
||||||
|
|
||||||
def iterticks(
|
def iterticks(
|
||||||
quote: dict,
|
quote: dict,
|
||||||
types: tuple[str] = ('trade', 'dark_trade'),
|
types: tuple[str] = (
|
||||||
|
'trade',
|
||||||
|
'dark_trade',
|
||||||
|
),
|
||||||
deduplicate_darks: bool = False,
|
deduplicate_darks: bool = False,
|
||||||
|
|
||||||
) -> AsyncIterator:
|
) -> AsyncIterator:
|
||||||
|
@ -47,17 +50,20 @@ def iterticks(
|
||||||
if deduplicate_darks:
|
if deduplicate_darks:
|
||||||
for tick in ticks:
|
for tick in ticks:
|
||||||
ttype = tick.get('type')
|
ttype = tick.get('type')
|
||||||
sig = (
|
|
||||||
tick['time'],
|
|
||||||
tick['price'],
|
|
||||||
tick['size']
|
|
||||||
)
|
|
||||||
|
|
||||||
if ttype == 'dark_trade':
|
time = tick.get('time', None)
|
||||||
darks[sig] = tick
|
if time:
|
||||||
|
sig = (
|
||||||
|
time,
|
||||||
|
tick['price'],
|
||||||
|
tick['size']
|
||||||
|
)
|
||||||
|
|
||||||
elif ttype == 'trade':
|
if ttype == 'dark_trade':
|
||||||
trades[sig] = tick
|
darks[sig] = tick
|
||||||
|
|
||||||
|
elif ttype == 'trade':
|
||||||
|
trades[sig] = tick
|
||||||
|
|
||||||
# filter duplicates
|
# filter duplicates
|
||||||
for sig, tick in trades.items():
|
for sig, tick in trades.items():
|
||||||
|
|
Loading…
Reference in New Issue