Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Returns factor needs tweaking

hello,

I used the returns factor to add stocks that are up by at least 30% from todays open vs yesterdays close, but it seems that instead what I get is stocks that were up by 4% from yesterdays close versus the previous days close.

How do I change this so it instead shows me stocks that are up by 30% from todays open vs yesterdays close??

13 responses

Hi Dante,

As your pipeline is recalculated every day in before_trading_start, you won't have access to today's open price. To make this comparison, you will need to use the history() function and compare today's open price to yesterday's close from a universe of <= 500 securities.

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.

Hi Jamie,

So is it possible to do this in the pipeline? Do I put the history function in the handle data or up in the pipeline? How do I connect the factor in my pipeline to this function?

Thank you!

cont.

In fact, is the price and volume data also being taken from the previous day? I need all of the information in my pipleine to come from data starting from todays open. How do I accomplish this???

Could I use an offset to move the time? Or maybe date_rules? This is so frustrating. It took me all week to figure out how to code this section of my algo and now that its done it doesnt even pull the right information. :C

Please? Anyone? :/

I don't think this is possible in Quantopian. :( The only tool which can scan all stocks for price stuff is Pipeline, but it only runs a while before open. Thereafter, you have to choose your universe 'somehow', and can use history, but only up to 500 stocks. So, if you are doing a gap screen, the best you can do is run that screen at 9:31am on 500 stocks of your choosing.

Hello Simon,

How might I achieve this? I only need the scan to run 5 mins after the open and every 5 mins after that till 9:30 AM PST.

Thanks!

Just pick 500 stocks somehow, then call history with "1m" frequency, and compare the opens and closes of those bars.

Hello Simon,

Thank you so much!

Wait, Simon,

i need to compare that 1 m bar to yesterdays closing minue bar will this work?

Never mind, I figured it out!

Dear Frad,

How did you it?

Kind regards,
Munkh

What exactly do you need? I can share it with you.