pmorissette/bt

I tried working around this by passing in a set of dates corresponding to the time period I want to rebalance on

aelkholy opened this issue · 0 comments

[Did not mean to close this adding my comment, so reopening]

So I have the following code:

strategy = bt.Strategy("strategy", [
                            bt.algos.RunDaily(),
                            bt.algos.SelectWhere(indicator_df),
                            bt.algos.WeighTarget(reset_to_datetime(weights_df)),
                            bt.algos.Rebalance()
                        ])
default_t = bt.Backtest(strategy, reset_to_datetime(stocks_df), initial_capital=initial_capital)
default_res = bt.run(default_t)

Stocks_df, indicator_df and weights_df all have daily data in them. Changing the line from bt.algos.RunDaily() to bt.algos.RunYearly gives me the same results when I was expecting the rebalancing frequency to change.

I tried working around this by passing in a set of dates corresponding to the time period I want to rebalance on

strategy = bt.Strategy("strategy", [
                                    bt.algos.RunOnDate(dates),
                                    bt.algos.SelectWhere(indicator_df),
                                    bt.algos.WeighTarget(reset_to_datetime(weights_df)),
                                    bt.algos.Rebalance()
                                ])

This throws an error here because it's checking if the date is in a list containing one element, which is a pd.datetimeindex I believe.

Originally posted by @aelkholy in #387 (comment)