I have recently switched to redistimeseries and would like to know if filling null data is possible in when I "createrule" in redistimeseries. if yes, i request someone to help with a small piece of code for the same. More details below.
I have been using pandas and sqllite3 to store , retrieve and aggregate live stock ticks (which has last traded price and last traded quantity columns). I use resample and aggregate to calculate OHLC for a different time frame. During aggregation using pandas, i use fillNa to fill the missing ticks (if no ticks received during the entire downsampled time slot). i have attached herewith the working code snipped below.
python code snippet : (reading tick data using pandas sql query from sqllite3)
Basically I resample it using 'OHLC' method and fill the missing values, nothing special about this code.
resampledDF = SymbolTickData['Close'].resample(tf).ohlc(_method='ohlc')
resampledDF['Close'].fillna(method='ffill', inplace=True)
resampledDF['Open'].fillna(resampledDF['Close'], inplace=True)
resampledDF['High'].fillna(resampledDF['Close'], inplace=True)
resampledDF['Low'].fillna(resampledDF['Close'], inplace=True)
With RedisTimeSeries you can fill empty buckets in query time:
Since RedisTimeSeries v1.8.2:
When using
TS.RANGE,TS.REVRANGE,TS.MRANGE, orTS.MREVRANGEto retrieve the value of the previous sample for each empty bucket, use theEMPTYflag together with thelastaggregator.