Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is there a full example

Is there a full example of a simple system with entry and exits to get someone started with this platform. I have been on and off and never managed to do anything. I have tried a simple inside day break out but code is a mess

def initialize(context):  
    context.SPY = symbol("SPY")  
def handle_data(context, data):  
    highv = history(2, "1d", "high")[context.SPY]  
    lowv  = history(2, "1d", "low")[context.SPY]  
    if (highv.iloc[-1] < highv.iloc[-2] and lowv.iloc[-1] > lowDv.iloc[-2]) and (close_price > highv.iloc[-2]):  
        order_target_percent(context.SPY, 1)  
    if data[context.stock].price > entry*1.03:  
        order(context.stock, 0)  
    if data[context.stock].price < entry*0.97:  
        order(context.stock, 0)  

Can anyone help? Thanks

3 responses

Hi Ricardo,

I think you should check out the Getting Started tutorials. They have been updated to the most recent version of Quantopian, and should guide you through all the new features.

You also might want to check out the API Documentation and Lecture Series for more information about the platform.

Thanks,
Lotanna Ezenwa

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.

Documentation is more specs and not for someone that wants to get familiar with the platform. There are no clear examples and this raises some issues about reliability of backtests. If this platform has indeed 85,000 users, then at least one should be there to look at my code.

Hi Ricardo,

The Getting Started Tutorial is definitely the place to start. It covers the basics of the API and has plenty of examples! There are also some sample algorithms at the bottom of the API documentation.

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.