I try to use william vix fix indicator.
the wvf = highest(close price of period)-low price / highest(close price of period) * 100
I can get one wvf, but how can I get the standard deviation of a list of rolling wvf and use it?
def __init__(self, symbol, k1, k2, range_period, consolidator_resolution):
self.symbol = symbol
self.range_window = RollingWindow[TradeBar](range_period)
self.consolidator = TradeBarConsolidator(consolidator_resolution)
def on_data_consolidated(sender, consolidated):
self.range_window.add(consolidated)
if self.range_window.is_ready:
hh = max([x.high for x in self.range_window])
hc = max([x.close for x in self.range_window])
lc = min([x.close for x in self.range_window])
ll = min([x.low for x in self.range_window])
self.wvf = ((hc - consolidated.low)/hc) * 100
hwvf = max([x.wvf for x in self.range_window])
Mia Alissi
To calculate the standard deviation of a list of rolling William's VIX Fix (WVF) values, you can use the
STD
helper method from theQCAlgorithm
class. This method calculates the standard deviation of a given data over a specified period.First, you need to create a Rolling Window to store the WVF values. Then, in your
on_data_consolidated
function, after calculating the WVF, you add it to the Rolling Window. Once the Rolling Window is ready, you can calculate the standard deviation of the WVF values.Here is a modification of your code to include the standard deviation calculation:
Please note that this is a basic example and you might need to adjust it according to your specific needs. For more information about creating custom indicators, you can refer to the QuantConnect documentation.
As for the code review, it seems that the code is generally well-structured and follows the QuantConnect API. However, without more context or specific issues to look for, it's hard to provide a more detailed review. If you're encountering any errors or unexpected behavior, please provide more details so we can better assist you.
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.
Whuang8799
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!