Hello,
Im quite new to Quantconnect and I was asking myself if there’s a possibility to use let’s say a year of historical data to calculate the volatility for every stock of the universe on earnings day. Also would it be possible to go from that date a few days back(T-7) and use the data of Q1/2/3 and 4(volatility).
Idea: Filter stocks with universe, use one year of historical data to calculate the mean of days to enter with a straddle for each stock.
calculation: find lowest volatility point of Q1 / 2 /3 and 4 within a week to month and calculate the mean of days for one stock.
Thanks,
Nico
Varad Kabade
Hi Nico Xenox,
We can use the standard deviation indicator warmed up using historical data to get the volatility for any security.
The information about the earnings day can be found in the fine fundamental data for the given security. Refer to the following doc for more information.
We can use the IndicatorExtensions helper methods to get the delayed volatility values. Refer to the following snippet:
Here self.vol is a dictionary keyed by the Symbol object and the STD indicator created using the constructor as the value to update the self.delayedVol we need to update the self.volRefer to the following example algorithm.
Best,
Varad Kabade
Nico Xenox
I took some time off and tried the whole thing in the research notebook. Im was trying to archieve what i wrote in the first post by using two approaches:
1. Get amount of days from T=0 for the lowest number of standarddeviation (T-30)
2. Get amount of days from T=0 in decending value
Thats what i got:
As you can see i tried it using just one stock and not a whole universe. I tried implementing it into QC but i dont know how to change this line of code.
Also if I import pandas and the other libraries into QC i simply can paste the code that i wrote into QC, right?
Louis Szeto
Hi Nico
This line won't work in a QCAlgorithm instance of a backtest. This is just a helper method of data visualization of indicator values in the research environment. You'll need a rolling window to store each updated indicator value in a backtest.
And you'll need modifications of the above code to put a backtest in production. Refer to the docs to do so.
Best
Louis
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Nico Xenox
Thanks Guys
I will try that, I really appreciate the help. I'm doing a school project and with your help I'm slowly understanding more and more stuff.
Nico Xenox
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!