我正在尝试进行一些计算,以将其添加到具有OHLC数据的同一数据框中。
我已经成功地在1分钟内获得了OHLC的正确数据。
dfPrice = df.set_index('new_date').groupby(['symbol'])['price'].resample('1Min').ohlc()
我现在需要解决的问题是如何对相同数据重新采样并添加体积加权平均值。调查使我相信可以使用.agg(),但我不知道该怎么做。
我有这些数据,当然这里是有趣的数量和价格列。
rowno db_id market_id identifier broker_buying broker_selling volume price trade_id trade_type trade_ts symbol file_date new_date diff diff_minutes diff_seconds
147061 1035588 11 365 150 117.3 000449258 AUTO 1546875260149 VOLV A 20190107 2019-01-07 15:34:20.149000 56060149000000 934 56060
147062 1035589 11 365 300 117.8 000374830 AUTO 1546871700432 VOLV A 20190107 2019-01-07 14:35:00.432000 52500432000000 875 52500
147063 1035590 11 365 SWB 399 117.8 000310635 AUTO 1546867246532 VOLV A 20190107 2019-01-07 13:20:46.532000 48046532000000 801 48047