xingetouzi / rqalpha-mod-fxdayu-source

rqalpha拓展数据和事件源,支持分钟级别回测,实时交易,支持quantos数据源
94 stars 51 forks source link

Base frequency for history_bars #1

Closed damondd closed 6 years ago

damondd commented 7 years ago

According to below code, is base frequency not supported yet when use 1m or 1h?

def history_bars(self, instrument, bar_count, frequency, fields, dt,
                 skip_suspended=True, include_now=False,
                 adjust_type='pre', adjust_orig=None):
    if self.is_base_frequency(instrument, frequency):
        bar_data = self.raw_history_bars(instrument, frequency, end_dt=dt, length=bar_count)
    else:

...

def raw_history_bars(self, instrument, frequency, start_dt=None, end_dt=None, length=None):
    raise NotImplementedError
BurdenBear commented 7 years ago

Hello. this module already support m, h, d now, as long as this is coresponding data in your mongodb . The code section your provided mainly to handle "none-base" frequency, which mean frequency's multiplier not equal to 1, such like ["5m", "2h", "3d"] and so on. That is to say, base frequency just contains ["1m", "1h", "1d"] now. We only persistent data of base frequency in our database(mongdb) , The OddDataSource class, whose method you post here, is just do transform bar of base frequency to no-base frequency using pandas.resample, remaining real geting data method "raw_history_bars" to be done in its subclass, so method itself raise NotImplementedError. I am sorry that there is no comment in detail. If you are interesting about how to organize the data in your database, and deploy this module, you can refer to our website http://www.fxdayu.com/tutorials.html . Thx for attention :)

damondd commented 7 years ago

thanks for the detailed explanation, it's quite clear now, will give a try.