Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Simple algo that tries to earn money on speculators

Simple algo that earns money on speculators by assuming the long running stock price of P[N+1] = P[N] + G where P[N] is the current price and G is the growth rate of the stock. The idea is that some people will speculate on the stock and those people will then lose money as the above function predicts the stock price. The algo is much to complcated to build in the current quantopia because of issues with history function and only seems to work on stocks such as the Apple stock.

8 responses

Hi rolf, if you are having issues with history limitations, you may wish to try the framework I wrote, which includes ability to generate/store custom history. https://github.com/Novaleaf/QuantShim

I'd like to try your algo but if you are saying it's much too complicated to build in quantopian, then what are you showing the backtest of? Additionally, ANY long strategy using AAPL will be profitable, so backtesting AAPL should not be considered verification in any way (though if you make a short only strategy, the opposite is true)

Hi Rolf,

Very cool strategy! The history() function requires a static bar_count, you need to specify an integer for the number of days. It will not work to pass in a variable to the bar_count.

One workaround may be to have a large bar_count and then index into the history dataframe based on your dynamic variable.

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.

Very nice resource, thanks for sharing this! I edited the algorithm in order to increase the upside of the returns, and I can hardly believe the results! I have a quick question though. With your model, it takes several months from the starting date for the algorithm to actually start investing in securities. Is there any way to accelerate this (I.E. starting to purchase securities on 5/5/2014; if 4/30/2014 was the starting date)?

Here is some food for thought on the potential returns after tweaking the algorithm slightly.. I realize that initially the losses were well over 100 percent before it started gaining, but I completely fixed that bug with my latest iteration of the algorithm. (I don't know if I will necessarily be sharing the latest one :P)

Trey Durr that's just for illustrations sake lol. Imagine the results with a REIT instead of AAPL when the real estate market fully rebounds and continues to trend upwards.

These types of algorithms can potentially multiply the returns of upward trending stocks.

yeah for sure there is some "data snoop bias" going on.

Can someone tell me where to read more about this strategy in general? There's no citation on where the idea comes from in the algo.

Hi Rolf, similar to Jason's post (May 2), do you know of any reference for this strategy?
Thanks