0

这就是我用来将数据添加到我的刻度数据框的方法:

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)

这是数据框中的刻度数据:

                                         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

我正在使用它来制作蜡烛(我正在制作 5 分钟的蜡烛并将其附加到另一个框架):

current_candle['mid'].resample(5M).ohlc()

这就是我要出来的:

                           open     high      low    close
time
2021-04-30 00:00:00+00:00  0.76097  0.76104  0.76087  0.76099
4

1 回答 1

0

current_candle['mid'].resample('5M').ohlc()中,M表示月份。你可能想要5min.

于 2021-04-08T04:53:21.323 回答