diff --git a/piker/data/_normalize.py b/piker/data/_normalize.py new file mode 100644 index 00000000..9f73858d --- /dev/null +++ b/piker/data/_normalize.py @@ -0,0 +1,21 @@ +""" +Stream format enforcement. +""" +from typing import AsyncIterator, Optional + +import numpy as np + + +def iterticks( + quote: dict, + type: str = 'trade', +) -> AsyncIterator: + """Iterate through ticks delivered per quote cycle. + """ + # print(f"{quote}\n\n") + ticks = quote.get('ticks', ()) + if ticks: + for tick in ticks: + # print(tick) + if tick.get('type') == type: + yield tick