Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Competitive Securities Algorithm

Hey Quantopians, I'm happy to say I've completed my first algorithm and as such can now make my first post. My trading strategy is based on the competitive nature of the three companies I have chosen, Apple, Microsoft, and Google. The algorithm's success is based on the assumption that if two of the companies' prices drop relative to a 3-day volume-weighted price average, then the third company will soon see it's stock grow in value more often than not because the companies are competitive. The algorithm will not buy stock in the third company if that companies stock is less than the 3-day volume-weighted average.

The strategy seems successful, but it is just the basic algorithm for this particular idea and there are a number of ways to improve it. I plan on looking optimizing the vwap length and precise values that determine whether or not a order will be placed. Also I would like to determine what similar conditions will improve the algorithm, such as selling when two companies have dropped in price and the third is dropping.

Please let me know if you have any questions, suggestions, or constructive criticisms.

Noah

P.S. Sorry about the post without the algorithm included.

5 responses

The algo never seems to sell anything, just buy buy buy? It's lucky all three stocks are up over the last ten years!

Great first algo! As you continue to improve upon it, try using order_target() or order_target_percent, which are more robust ordering methods.

For example, if you use order_target_percent(context.ms, 0.33) this will allocate 33% of your portfolio toward Microsoft shares and will scale as your portfolio value fluctuates. This is better than ordering 100 shares every time a threshold is met. Best of luck and welcome to Quantopian!

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.

Simon - Yes haha there may have been some "fortunate" selection involved. But this algorithm is the just the starting point, I'm currently testing to determine the most effective selling conditions to oppose the given buying condition, but I've yet to find anything that is particularly effective. Thanks for the tip though!

Alisa - Thanks for pointing that out, I'll change to one of those methods the next time I get a chance. Happy to be here, and thanks for the help!

Fair enough, but be aware, that "fortunate" selection is THE single problem with back-testing, so if you start off with that, it will just be a world of pain when you get out-of-sample. EDIT: unless the point of your strategy is just another variation on dollar-cost averaging into three stocks you want to own anyway, in which case I retract my point!

Simon - Yes unfortunately this algorithm sometimes falls below the benchmark when I modify the three securities to some other competing companies. My idea was not quite dollar-cost valuation, but was to pick three competing securities and create an algorithm designed to anticipate the movement of each security using the movement of the others.I believe the back-testing success with these three particular companies shows the potential of such a strategy, but it is obviously far from being anything either of us would put money into. I need to put much more work into it before then, implement more conditions, and make it more universal etc. so I can try to stay away from that world of pain!

I hadn't even thought about applying the algorithm to dollar-cost averaging, but it seems like it would be very effective at it. Good catch, I'll look into it. Thanks for the help!