Hello, thank you for the amazing work!
I recieve New York Stock Exchange trades from a websocket connection in this format:
[Timestamp, Symbol, Price, Size]
``
Timestamp - milisecond unix
Symbol - name of the stock (eg AAPL, MSFT, GOOGL… )
Price - price at which the trade got executed (double)
Size - quantity of shares in the trade (integer)
Example feed from the market:
[1580503106159, “AAPL”, 234.56, 1357]
[1580503106235, “GOOGL”, 899.56, 432]
[1580503106256, “MSFT”, 625.56, 44]
[1580503106304, “AAPL”, 234.78, 67888]
[1580503106304, "AAPL", 232.28, 5378]
What I would like to do is ingest all of the feed into redis time series (2 min of retention) using the timestamp provided from the exchange (its guaranteed to be of incremental value). The goal is to be able to query the time series for particular stock aggregations in OHLCV:
give me Open, High, Low, Close, Volume on 1 minute time bucket
time = minute of the time bucket
Open = first(Price)
High= max(Price)
Low= min(Price)
Close= last(Price)
Volume= sum(Size)
``
If we are to aggregate AAPL trades from te example above, this would be the result:
time=1580485107000
Open = 234.56
High= 234.78
Low= 232.28
Close= 234.78
Volume= 74623
``
I cant figure out how to model the database, particularly how to use keys, labels and values. Do I insert every trade in a single key called “trades” and use label/value to point to the stock name? Do I need a separate key for each stock? Do I use keys or labels for Price and Size? Any help on this matter is greately appreatiated.
Kind Regards