5 ms·
Show HN: Prophet – A financial micro-framework in Python
- yummyfajitas 12y agoVery nice. I might replace my own personal framework with this - it's certainly cleaner. 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.
- jcrubino 12y agoHandling tick data even could help and be helped in the case you outlines above.
- Emsu 12y agoI actually really want to support it. If only I could get my hands on some tick data... any ideas?
- radikalus 12y agoI'll ping you on gh
- findjashua 12y agoYou can get 1-minute price bars from Yahoo Finance: http://finance.yahoo.com/_td_charts_api/resource/charts;comparisonTickers=;events=div%7Csplit%7Cearn;gmtz=-8;indicators=quote%7Csma~20%7Csma~40%7Csma~60%7Csma~80%7Csma~5;period1=1414803576;period2=1416701176;queryString=%7B%22s%22%3A%22yhoo%22%7D;range=1d;rangeSelected=undefined;ticker=YHOO;useMock=false?crumb=riKDDTwiAj5 http://finance.yahoo.com/_td_charts_api/resource/charts;comp...
- minimax 12y agoWhy do you say you can't reliably get the closing price? You should be able to send an MOC order to the listing exchange to get the official closing price.
- yummyfajitas 12y agoTo be more precise, you can't reliably get the closing price and also know what it is before you get it. 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.py#L72 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.
- Emsu 12y agoIf you look at: https://github.com/Emsu/prophet/blob/master/prophet/data.py https://github.com/Emsu/prophet/blob/master/prophet/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-commissions 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.
- lrm242 12y agoPlease don't use Adjusted Close for backtesting execution. Adjusted prices are not real. They never happened, and using them will add unknown error to your backtest results. Back adjusted prices are fine for building a model, but when back testing the model and simulating executions, you should always use real prices.
- Emsu 12y agoYou're right. I really need to bite the bullet and generate stock split data. That was the main reason I used adjusted because splits were skewing my tests a lot.
- crimsonalucard 12y agoAnybody know of any good apis to hook this thing into?
- yummyfajitas 12y agoTo start, free historical data from yahoo. Once you've back tested, try executing manually with your online brokerage (I.e. if it says buy, login to etrade and buy). After that upgrade to IB or Lime (depending on your needs).
- Cieplak 12y agoVery cool. I would like it even more if there were tests :) https://github.com/Emsu/prophet/ https://github.com/Emsu/prophet/
- 1stop 12y agoYou posted the github link yourself... (Fork button is top right).
- mikecsh 12y agoCan we stop making these responses every time anyone suggests a feature or critiques an open source project, please
- 1stop 12y agoCan we stop with the "I this doesn't match my ideology" critiques?
- michaelmcmillan 12y agoActually, that's not how tests work. Writing a test after the code has been produced should not be considered a real test. Let me quote Robert C. Martin on this. 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.html http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.htm...
- myg204 12y agoTests written after are still tests. It may not be 'test driven development', but they are still tests, and TDD is not the final answer IMHO.
- jl6 12y agoMight have a name clash issue with Sungard's iWorks Prophet, a commercial financial modelling tool.
- Emsu 12y agoThanks for the heads up.
- radarsat1 12y agoWould love to see a how-to tutorial on using this to test and visualize different strategies on paper.
- Emsu 12y agoI'm adding a tutorial for more complicated strategies to the documentation. What did you have in mind for the visualization? Currently you can just install matplotlib and graph it or export a backtest to json.
- vegabook 12y agodoesn't seem to work on Python 3.
- jsc123 12y agoAre there any frameworks that go well with Prophet?
- Emsu 12y agoThe scipy and statsmodels libaries are nice. CVXOPT would be good for portfolio optimization. You really have to implement your own strategies though.
- ochoseis 12y agoThis looks interesting. I'm familiar with the basics of investing, but have never gotten into quantitative analysis. Does anyone know of a good starting point (book, online course, anything)?
- tummybug 12y agoLooks good, I have been working on something similar recently but may just stop and use this. Would love to see the documentation fleshed out more.
- Emsu 12y agoFleshed out the tutorial a bit more yesterday. Feel free to propose what kind of docs you'd like to see on the issues page. I'm all ears :)