Closed rgleavenworth closed 2 years ago
Hey, thanks for raising that issue.
I checked the order book and it doesn't seem like the problem comes from rebalancing. Seems strange, I'll investigate it, thanks for reporting it!
Anyway, rebalancing one stock has no real purpose
I'm wondering if there is a logical bug somewhere in rebalance. The portfolio as listed above should be identical in performance with or without reblancing enabled. The intent to run the test was to ensure that rebalance doesn't introduce a different result. Clearly, it does so there is a bug in the code somewhere. I know that rebalancing a portfolio with one stock isn't useful but the goal was to do a regression check.
I've solved the bug and submitted a pull request.
When you set up quarterly rebalance with only one ticker, the strategy and benchmark show different values. This is a bug. They should be completely equal.
The codebase below reproduces the issue. The EOY returns and the timeseries plot of Cumulative returns vs benchmark show that the strategy and benchmark are divergent.
from empyrial import empyrial, Engine portfolio = Engine(
start_date= "2021-01-01", portfolio= ["BTC-USD", "GOOG"], weights = [1, 0.], #equal weighting is set by default benchmark = ["BTC-USD"], #SPY is set by default rebalance = 'quarterly' ) empyrial(portfolio)