Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
52 week high

Hi was wondering if anyone can help me with the following. Trying to obtain a 52 week high in my pipeline. Any ideas on how this can be done? for every stock in USEquityPricing i would like to calculate current price - 52 week high / 52 week high. can this be done? thank you

5 responses

Here's an example pipeline that computes the 52-week high for each asset (using end-of-day daily prices). I also included a version of your factor that uses yesterday's close price as the 'current price' in your description.

Let me know if this helps.

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.

thank you very much this is exactly what I was hoping to achieve. I was trying to construct my own custom factor initially but failed at first attempt. I have a question regarding the 'close_prices' parameter you use. what exactly is that and in general what is the values parameter supposed to do [def compute(self, today, asset_ids, out, values):]

also how comes we can initiate the window_length right at the beginning and not when we call the custom factor in our pipeline.

is there a video or any other resource that could guide me better on this other than the documentation. Thank you for helping

The close price is coming from USEquityPricing.close.latest which is a column (close) on a pipeline dataset (USEquityPricing). Each day that a pipeline is computed (in the morning), it will retrieve the close price from the end of the previous trading day.

If you haven't read through it yet, the Pipeline tutorial is the best resource for learning about this stuff. Lesson 10 focuses on CustomFactors and explains the values variable(s), but I'd recommend starting from the first lesson to understand the basics of pipeline first.

Let me know if this helps.

Just cause I'm finding this, the links to the pipeline tutorial are incorrect. Here's the corrected link to lesson 10 https://www.quantopian.com/tutorials/pipeline#lesson10

Aren't you getting problems with USEquityPricing.close.latest during splits? I see it not being split adjusted (it jumps). Or does using it a factor+a window take care of that?