This is what I'm using to add the data to my tick data frame:
dfTick = {
'time': data['time'],
'mid': data['mid'],
}
tick = pd.DataFrame(dfTick).set_index('time')
tick.index = pd.DatetimeIndex(tick.index)
current_candle = current_candle.append(tick)
This is the tick data in the dataframe:
mid
time
2021-04-08 01:37:05.803333138+00:00 0.76097
2021-04-08 01:37:20.152602558+00:00 0.76094
2021-04-08 01:37:53.382876759+00:00 0.76097
2021-04-08 01:37:56.856087693+00:00 0.76094
2021-04-08 01:37:57.148063649+00:00 0.76090
2021-04-08 01:38:16.598799961+00:00 0.76087
2021-04-08 01:38:30.978559522+00:00 0.76092
2021-04-08 01:38:33.302859897+00:00 0.76096
2021-04-08 01:38:43.222445326+00:00 0.76099
2021-04-08 01:39:08.770058921+00:00 0.76104
2021-04-08 01:39:32.495760219+00:00 0.76100
2021-04-08 01:39:32.694723608+00:00 0.76096
2021-04-08 01:39:34.243899267+00:00 0.76099
I'm using this to make the candles (I'm making 5min candle and appending it to another frame):
current_candle['mid'].resample(5M).ohlc()
This is what I'm getting out:
open high low close
time
2021-04-30 00:00:00+00:00 0.76097 0.76104 0.76087 0.76099
In current_candle['mid'].resample('5M').ohlc()
, M
means month. You may want 5min
.