From acc8dd66f538541b1e3315969f3707c1cf14ddd6 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 26 Sep 2020 14:20:55 -0400 Subject: [PATCH] Add data._normalize.py ... --- piker/data/_normalize.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 piker/data/_normalize.py 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