Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How can I get a template strategy that satisfies all the constraints of the contest?

I am a new comer for quantopian.I already have a market-timing strategy that works very well in real trading.My question is that I have my python code of that strategy.How can I get some template code,so that I can directly add my market-timing strategy to these templates and then get's the strategy satisfy the constraints of the contest and enter the contest?
Is there any strategy that passes the basic constraints of the contest?
Thanks.

4 responses

It's all there. You just have to sift through the tutorials, lectures and the many many examples which people have posted.

Welcome!

One template to start with is the long short algorithm template we provide in our quant finance lectures. Another is from our Getting Started Tutorial. Specifically Lesson 7 has a full algorithm template. We definitely recommend all new community members try out that Getting Started tutorial.

Good luck,
Josh

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 have the same problem, i have strategy that runs very successfully, but i cannot convert my logic into an algorithm that can meet the Contest requirement. Especially I am struggling on the "alpha", "objective" in order_optimal_portfolio() function, the "optimized" order is much different from order() itself. To use order_optimal-portfolio(), i have to make an "objective", to make objective, i need to make alpha, i want to make alpha referring to BOLL or MACD data but have no idea how to implement it.
Have read much samples and tutorial but still cannot make one successful simulation cause I have no python background.

Can anyone give a very simple template, implement below very basic objective so that we can copy and paste ours in it:
1. QTU as the context stocks
2. daily scan all the stocks in the context, put the stocks whose price is just cross above BOLL's middle in a buy_list. put the stocks whose price is just cross below BOLL's middle in a sell_list.
3. buy those in buy_list. sell those in sell_list.
4. Meet contest requirements like order with order_optimal_portfolio().
it is very easy with "order()" function, but so hard with order_optimal_portfolio().
appreciate if anyone can help. The key is investment strategy, the coding/programming should not be a barrier to stop us from the contest.

I'm afraid the contest and this website is all about coding. And I'm afraid it is correct that it should be. You have to decide how to make movements in and around the standard deviation bands a "factor". The optimisation process then minimises or maximises that factor. In other words it chooses a portfolio, a vector of stock weightings, based upon how well stocks reflect this "alpha" factor.

You might find it helpful to read up on optimisation methods. Gradient descent. Calculus. Machine learning.

I don't think there are any short cuts really. For better or worse Quantopian have decided upon a specific investment approach and it is down to you to understand that approach and how to code it.

I'm not wishing to sound unhelpful but systematic investment is not something you pick up overnight. And portfolio optimisation is not that simple a topic.

But if arts clowns like me can pick it up, anyone can. And don't get put off by my Ecclesiates cynicism. I'm sure there is gold to be discovered in Quantopians approach somewhere.