Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Historical Pipeline Factor Values

Hello,

I'm currently trying to perform a check for whether or not a certain criteria was met in the past 10 days using pipeline factors. For example, was the RSI > 70 in the past 10 days? Right now my code looks something like this (it's not working, of course):

RSIbase = RSI(inputs = [USEquityPricing.close], window_length = 14)
RSIhigh_10_days = RSIbase > 70 | RSIbase[-1] > 70 | RSIbase[-2] > 70, ... | RSIbase[-10] > 70

Checking just for the RSIbase works fine, it's getting the RSIbase for yesterday, and all days prior to that which isn't working, and I can't seem to find any examples doing something similar. Is there any way to actually do this?

Thanks,
David

2 responses

Hi David,

Currently there's no easy way to access the historical value of Factors in Pipeline. If you want to achieve functionality like this, I would suggest saving the results of the RSI column of your pipeline_output in a new DataFrame which stores the last 10 results. Then you can do something like this:

rsi_high_10_days = (rsi_df > 70).any(axis=0)  

Let me know if you're able to get this working.

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.

This is intriguing, I am also trying to store historical factor data and process it later -- could you please post a code sample of how you would store that data that you reference in rsi_df?

Thanks,
Marc