How to process data by quarter?
-
I want to resample or replay data by quarter, but find that
bt.TimeFrame
only support'Days', 'Weeks', 'Months', 'Years'
,there is no'Quarters'
option.I know a simple way to process data quarterly is use
compression
, for example:tframes = dict( daily=bt.TimeFrame.Days, weekly=bt.TimeFrame.Weeks, monthly=bt.TimeFrame.Months) cerebro.replaydata(data,timeframe=tframes['monthly'],compression=3)
You have to make sure the data is started on January,or the result will only compression by 3 continuous months, not by quarter.
I hope someone could help me to solve this problem.
-
@jrothschild33 said in How to process data by quarter?:
You have to make sure the data is started on January,or the result will only compression by 3 continuous months, not by quarter.
AFAIU this is the only option right now. Properly solving this should involve extending Backtrader to support yet another TimeFrame with all the ensuing consequences.
Others may correct me of cause.