mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.93k stars 855 forks source link

Adj Close and pct rtrn #182

Closed alex-muci closed 6 years ago

alex-muci commented 7 years ago

A couple of financial suggestions:

ryankennedyio commented 7 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.