Closed alex-muci closed 6 years ago
Good points. Adjusted returns from Yahoo can be a bit dodgy I've found; my method is to put it all in a dataframe and do:
ratio = df["adj_close"] / df["close"]
df["close"] *= ratio
df["high"] *= ratio
df["low"] *= ratio
df["open"] *= ratio
df["volume"] /= ratio
But often the first row of a Yahoo split actually has the split adjustment also calculated, so it ends up being like 10x what it should be ... I ended up writing a small script to go through everything and prompt me to correct individual instances of this happening.
Granted it's only like a few stocks per thousand.
A couple of financial suggestions:
Better an Adjusted Close than the simple close to be called in '_update_portfolio' in 'qstrader/qstrader/portfolio.py' I was running a backtesting on a VIX ETF (notoriously famous for splits) and got the wrong results because close prices used rather than adj close ones (which are available with Yahoo)
pct = ((self.equity[-1] - self.equity[-2]) / self.equity[-1]) * 100 in qstrader/qstrader/statistics/simple.py A more natural definition is (new - old) / old, i.e. denominator should be 'self.equity[-2]'