Dear sir/madam,
How would you go about implementing an average daily volume? (aka. to detect a volume surge, I'd like to implement IF volume > average daily volume x 1.5)
Thanks.
Dear sir/madam,
How would you go about implementing an average daily volume? (aka. to detect a volume surge, I'd like to implement IF volume > average daily volume x 1.5)
Thanks.
Hi Ivan,
You can use data[sid(...)].volume to get the volume for the current event. Please, see the details here: https://www.quantopian.com/help#api-event-properties
Hi Ed, thanks for your quick reply. I understand that to obtain the current event volume you'd use data[sid(...)].volume. However, I'd like to implement an average daily volume (say 3 days) irrespective of whether the backtester is ran by the minute or by the day. How would you do that?
Hi Ivan,
Good question. I'd still use data[sid].volume, but for minute timeframe I'd calculate sum of minute volumes to get daily volume.
From first look history API can be used for minute time frame, but Quantopian checker doesn't allow to call history when algo runs for daily time frame even if it's called only when run in minute time frame.
I tried to use batch_transform decorator with different window_length, but that also didn't work for me for another reason.
PS: I used get_datetime().hour to understand which time frame algo is in. For daily time frame it's always 0.
Regards,
Ed
Hi,
We've recently released a new API method called history, which will eventually replace batch transform. It currently is available only in minute simulations, but it would be a snap to create daily bars and do your volume check with history. The documentation is here: https://www.quantopian.com/help#ide-history
thanks,
fawce
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.