Closed vaa1234 closed 3 years ago
Hi Alexander,
thanks for the issue! I could exactly reproduce the problem, but hadn't yet the time to debug it.
The sharadar-bundle saves the unadjusted price data into the prices.sqlite db and then dividends and splits separately into adjustments.sqlite (the files are under ~/.zipline/data/sharadar/latest). It's the expected zipline way and no extra adjustment is made.
The data ingestion happens in https://github.com/alphaville76/sharadar_db_bundle/blob/master/sharadar/loaders/ingest_sharadar.py and here are some entry points in code to further investigate the problem:
I'm sure it's a bug in pyfolio. I printed every day the portfolio positions, and there were never a day with negative amount. I used also the condition algo.set_long_only() and it also never occurred.
Hi!
I found strange behavior when testing a simple long only strategy. When examining the results of the backtest, there are short sales that should not be.
Here's an example of a strategy. For simplicity, the universe is limited to a fixed set of stocks.
If you look at round trips report, we will see there that there were 34 short sales that shouldn't be.
All of these short sales are related to AAPL.
At first I thought it was a mistake in the pyfolio report, but then I found out that the problem is in AAPL splits.
If you load the price data initially adjusted for dividends and splits into the sharadar_db_bundle, then everything will work as it should.
If the sharadar-bundle makes adjustments ourselves, then this problem arises.
Help to understand this problem. Whether it occurs due to incorrect adjustment calculation in sharadar_db_bundle or are there some errors in quandl prices or something else.
Sincerely, Alexander