I'm using the Algorithm Framework. I've seen examples of filtering using coarse and fine filters, they seem to be geared toward Stocks. Haven't seen many examples for futures, I thought the OpenInterestFutureUniverseSelectionModel.py would be a good frame of reference however there's an ongoing issue with the class.
Suppose I wanted to create a Futures universe with let's say 10 different futures symbols. Then rank the 10 symbols based on volatility and send the highest vol symbol to the Alpha model.
How would one go about writing this functionality?
from AlgorithmImports import *
from Alphas.ConstantAlphaModel import ConstantAlphaModel
from Selection.FutureUniverseSelectionModel import FutureUniverseSelectionModel
from BreakoutHurstAlpha import BreakoutHurstAlpha
### <summary>
### Basic template futures framework algorithm uses framework components
### to define an algorithm that trades futures.
### </summary>
class BasicTemplateFuturesFrameworkAlgorithm(QCAlgorithm):
def Initialize(self):
self.UniverseSettings.Resolution = Resolution.Minute
self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.BackwardsRatio
self.UniverseSettings.DataMappingMode = DataMappingMode.LastTradingDay
# System config dates
self.SetStartDate(2012, 10, 1)
self.SetEndDate(2014, 10, 1)
self.SetCash(100000)
# Universe Model
self.SetUniverseSelection(MyFutureUniverseSelectionModel(self.future_chain_symbol_selector))
# Alpha Model
self.SetAlpha(EmaCrossAlphaModel())
# Portfolio Model
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
# Risk Model
self.SetRiskManagement(TrailingStopRiskManagementModel())
# Execution model
self.SetExecution(ImmediateExecutionModel())
def future_chain_symbol_selector(self, utc_time: datetime) -> List[Symbol]:
return [ Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME),
Symbol.Create(Futures.Metals.Gold, SecurityType.Future, Market.Comex),
Symbol.Create(Futures.Energies.CrudeOilWTI, SecurityType.Future, Market.NYMEX)]
class MyFutureUniverseSelectionModel(FutureUniverseSelectionModel):
def __init__(self, select_future_chain_symbols):
super().__init__(timedelta(1), select_future_chain_symbols)
def Filter(self, filter):
# Filter Symbols here?
return (filter.FrontMonth().OnlyApplyFilterAtMarketOpen())
Nico Xenox
Hey dsherman,
future universes subscribe to future chains and dont filter like coarse or fine selection(link). Also it depends what volatility you want to calculate. If it is the implied volatility (future options) you could subscribe to each future chain, filter for example the front month futures and sort the chains via implied volatility. You can access them via the optionchain under contracts > Values > Implied Volatility (link). If you're talking about historical volatility you will have to do a history request and calculate the volatility by your own. After calculating the values and saving them for each future you can then sort them and select the highest. (link)
Hope it helps ;)
Dsherman
Thanks Nico,
That was helpful. Do you have any sort of ETA on the completion of OpenInterestFutureUniverseSelectionModel for python?
Derek Melchin
Hi Dsherman,
We don't currently have an ETA. To track our progress in adding the functionality, subscribe to the following GitHub Issue:
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Dsherman
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!