Show HN: Prophet – A financial micro-framework in Python
blog.michaelsu.io
blog.michaelsu.io
If we lose the production code, we end up with a better designed system that stays clean because it has tests. If we lose the tests, then the production code rots and the team slows down in a never ending spiral of lost productivity.
So we can conclude that if it became a choice between the tests or the production code, we'd rather preserve the tests. And this means that the tests are a more important component of the system than the production code is. Because the tests are the specs.
http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.htm...these are still tests just as much as if they'd been written first, it's just a different methodology.
A suggestion I'd make. Rather than simply taking a price series (which seems to be based on daily data), it might be useful to build based on the open/close/high/low series. Then allow the trades to happen at a random price between high/low rather than simply the close.
I find this more reflective of the uncertainty in trading since there is no reliable way to actually trade at the close price.
http://finance.yahoo.com/_td_charts_api/resource/charts;comp...
If I understand the code right, it looks at the closing price and then decides if it wants to buy.
https://github.com/Emsu/prophet/blob/master/prophet/backtest...
Look at lines 72 and 79. The data in the examples comes from YahooCloseData in data.py.
There's a PandasDataGenerator which is a wrapper around the pandas libary's DataReader. For the Yahoo source, you can have the following data options: "Open", "High", "Low", "Close", "Volume", "Adj Close". The YahooCloseData generator actually uses "Adj Close". You can implement high, low or open by copying the YahooCloseData generator and getting the respective key instead of "Adj Close". Feel free to contribute these generators upstream too :)
If you're looking for modeling out the uncertainty, see the slippage section in:
http://prophet.michaelsu.io/en/latest/advanced.html#slippage...
If you have a dataset that provides more frequent than daily data, you can store the sell order on your order generator and process it the next tick. That combined with slippage and commission will probably give you the most accurate trading model.
Let me know if you have any other thoughts on how it can be better modeled.
Back adjusted prices are fine for building a model, but when back testing the model and simulating executions, you should always use real prices.