Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Lunar phase
12 responses

It's pretty loony =)

I think it got lucky around the crash of 2008. Change the timeframe, and the result is very different.

Fun share, though. Thanks!

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

I plead ignorance - what's an MFI? Have a link I can read about it?

I haven't looked at the code but I assume it's Money Flow Index. See: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:money_flow_index_mfi

P.

It's an interesting exercise but I'm really not sure I would bet a single dollar on this in real life. However, recently I wrote a star-sign calculator for my gf's astrology website, that calculates where the planets are positioned at a given time: https://www.leinenbock.com/astro-calculations/
I've seen an astrology plugin for ami-broker before and so I thought I share it for anyone who's insane (or genius) enough to try it. My gf believes that you can obviously make money with this :-) Let me know if you have any luck, it would shake my world view if you did.

Wow, that's super interesting! My astrology gf would say that it's totally obvious, but for us number crunchers this is certainly not the case :-) Would you mind sharing the Sharpe ratio of your actual strategy? In terms of the astronomical calculations I use something called the Swiss Ephemeris. This is open source and the original code is written in C or C++ (not sure) but it should tie in with your C# pretty well. I just used the Python wrapper of the program. It's a pretty accurate astronomical calculator and widely used.
In terms of what the underlying reasons for this strategy are, I guess (apart from it being a lucky coincidence) perhaps you could argue that since the moon phases are linked to the both the moon and the sun, and there is a strong gravitational pull from both, there might be some influence of whatever sort.
Anyway, who knows... I have also written a piece of code for my gf that calculates a phenomenon called the 'void of course moon'. Apparently, it's a big thing in the astrology world, I'm not so sure what to make of it, but I tested it against several sources and it is accurate. if you are interested in having a go with it in trading, I'm happy to share it. It's Python but again, it's based on the Swiss Ephemeris.

Thanks for providing the insight.

:) This is a good bit of fun. It reminds me of this paper (published 2007) that predicted the 2008 crash using sunspots:

http://www.growth-dynamics.com/articles/sunspots.pdf

It also raises a great point - that correlation does not imply causation: http://en.wikipedia.org/wiki/Correlation_does_not_imply_causation
I don't think there has been much discussion about this on Quantopian - and it is something to be wary of when trying to find some "magic indicator" that tells you when to buy and sell.

For more spurious correlation examples, check this out:
Does Chocolate Consumption Really Boost Nobel Award Chances? The Peril of Over-Interpreting Correlations in Health Studies

I particularly like the part:
"We found an incredibly high correlation between the number of IKEA furniture stores and Nobel laureates..."

Obviously you are just messing around here, but one thing I've found that can happen on an algorithm run from at least '08 to '11 is that only a few days can make a huge difference. The market was really volatile at one point, I recall one day DJI went up 950 points or so, and other days it went down 500 points. If a strategy happens to trade on the right days in only two or three cases, it can send a ripple effect if the algo uses all available cash to go long when it does go long (like the one above does). Since the algo randomly went up 1000-2000 points or so, it now has more money to bet and from there an average strategy will appear to outpace the market. So that's why you see a small diversion around the recession, then your strategy starts to pull ahead. Not sure if this is obvious to you guys, but I think it's interesting.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

t also raises a great point - that correlation does not imply causation: http://en.wikipedia.org/wiki/Correlation_does_not_imply_causation
I don't think there has been much discussion about this on Quantopian - and it is something to be wary of when trying to find some "magic indicator" that tells you when to buy and sell.

I am very interested in any ideas/pointers/code that addresses the issue of over-fitting algorithms to historical data. It seems to me there should be some sort of Bayesian approach where you can somehow determine the likelihood that your algorithm will work on real, unseen data.

@daniel: Here is a great introduction to Bayesian methods for Python. It gives a great overview of the capability of Bayesian analysis with really nice examples.
http://spin.atomicobject.com/2013/09/09/5-unix-commands/

@daniel I suggest you look at the concept of out-of-sample data and walk forward testing. In my limited experience working with quants in large hedge funds, they have very hard and fast rules about out-of-sample data. Before they test an algo, they define what data will and won't be used, and they do out-of-sample data as the last last step. If the algo fails to win on out of sample data, then they throw it out.

@daniel: In my econometrics course we always used the Akaike information criterion and Bayesian information criterion to prevent overfitting ARMA models - I think its worth looking into these.

Dans suggestion of out-of-sample data is also known as cross validation and there are a variety of methods see wiki. Also keep in mind this:
"Cross-validation only yields meaningful results if the validation set and training set are drawn from the same population. In many applications of predictive modeling, the structure of the system being studied evolves over time. This can introduce systematic differences between the training and validation sets. For example, if a model for predicting stock values is trained on data for a certain five-year period, it is unrealistic to treat the subsequent five-year period as a draw from the same population."

Here is an article that has a good discussion on cross validation: Why every statistician should know about cross-​​validation

@Tom did you post the wrong link?