Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Learning - Trying to use Q500US

I've got a piece of code that looks at a single stock and see's if it's price action meets certain requirments before trading starts each day, if it does then it looks for a trigger during that day and buys. If somebody could show me an example of how something like this might be done using the Q500US list it would be appreciated. Too keep things "simple" the strategy would work like this:

Before trading starts:
-Check if the previous 2 days made new highs
-If they did, then save the previous days high for use as a trigger for when to buy today, and save previous days low for a stop-out trigger

In handle_data
-If price >= trigger price then go long
-If price of an open postion drops below the low of the candle that triggered the buy (2nd day with a new high) then sell
-If an open position is up 10% then sell

This is just a dummy strategy I dreamt up to try and get all the required info I'd need to apply it to a strategy I am working on. Thanks for taking the time to look at this and I look forward to your replies!

2 responses

You're thinking about this in a modular way, and that's a very good thing.

I'd start with your rules in before_trading_starts. You want to build a pipeline that starts with the Q500US, and you can add your two previous highs as CustomFactors, and use those factors as filters to narrow down the tradeable universe even more tightly.

Once you've got that piece of code you'll have a reliable way of looking at your universe. I wouldn't worry about the buy/sell rules until you get your pipeline going.

Have you done the Pipeline Tutorial? Once you've done that tutorial, you should be all set to make your CustomFactors.

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.

Thanks for the reply Dan. I have done the pipeline tutorial yes, but that was right after the first tutorial which was actually my first time dealing with python.

I'll be going through that tutorial again in the near future as I've got a bit more of a grasp of what's happening now.

Thanks for your suggestions, I'll play with that and see where I end up.