I'm finding it an difficult task to maintain a database of stock prices. My main problem is how to efficiently handle splits and dividends. Is it better to handle this in a database with adjusted price columns or to do it in memory after fetching the data? Doing SQL row updates can be quite slow. I'm thinking it may be easier to handle it in the backtesting software itself rather than constantly updating a database.
-
$\begingroup$ Personally I’m always in favour of keeping the rawest data possible, so that you can retrieve point-in-time prices as needed. You’d then need to maintain additional time series of adjustment factors for splits, divs, and other corp actions as needed. At runtime you can retrieve adjusted/unadjusted data by loading everything then doing the product of the relevant time series as needed for example prices x div_factor x split_factor. $\endgroup$ – Ivan Apr 2 '18 at 18:33