Multiple Strategies with different start date
-
Hello @backtrader
First of all thanks a lot for creating BT, what an amazing tool!I came across the following problem:
Currently I have a strategy that I want to duplicate and have a portfolio of the same strategy but with different start dates.
Strategy 1: Startdate 2013-01-01
Strategy 2: Startdate 2013-02-01
Strategy 3: Startdate 2013-03-01The strategy does a rebalancing each 3 months and I want with the different start dates that one of the 3 strategies does a rebalancing each month, because the holding period of 3 months is over.
I also want a global money management that each strategy can trade with 1/3 of the capital. I can't figure out how I can do that.
Would really appreciate if someone could help me with that, thanks a lot!
-
There is a post which shows monthly rebalancing.
Strategies using 1/3 of the capital
- The easiest way is to divide it at the time of the creation of
cerebro
and adding eachStrategy
- If not, strategies that are winning have to rebalance, using a maximum of the total net asset value, to free capital for the losing strategies. To avoid the inherent problem of sequential evaluation and that losing strategies could be looked at before, the sell orders have to be executed on a given day and the buy orders (with freed capital from the selling) on the next day.
- The previous thing adds a problem which is that the data cannot be used with a monthly period because the next day would be the next evaluated bar, i.e.: the next month actually.
Evaluating at the end of the month
-
Given that the gregorian calendar has months of different length, the best way is to use the first day seen of a month (which must not be
1
if it's a weekend or a bank holiday) and execute the rebalancing. -
You simply need to keep a sentinel value keeping the last month (or
None
at the start) in which rebalancing was done and act when the month changes
Different starting dates and 3-month period
-
Because you have 3 different dates and they are set 1 month apart, this is actually granted, because you won't receive data in your
next
until the 3 strategies deliver data. -
The 1st time you will see data is on 2013-03-01 and you can use
3
as the sentinel for the last execution -
When the date changes to April and with it to
4
, you may execute the 1st rebalancing.
- The easiest way is to divide it at the time of the creation of
-
@backtrader Thanks a lot for your answer and time! I will have a look at it.