The DataQueueHandler does not support Futures

Back

Hello guys,

I've encountered an issue as i tried to test my strategy live papertrading. I got this error:


2020-10-21 17:04:40 : During the algorithm initialization, the following exception has occurred: System.NotSupportedException: The DataQueueHandler does not support Futures.
at QuantConnect.Le: an.Engine.DataFeeds.LiveTradingDataFeed.CreateUniverseSubscription (QuantConnect.Data.UniverseSelection.SubscriptionRequest request) [0x003ac] in <2c44351298f54fb0bfd0ddebc3f0ef37>:0
at QuantConnect.Le: an.Engine.DataFeeds.LiveTradingDataFeed.CreateSubscription (QuantConnect.Data.UniverseSelection.SubscriptionRequest request) [0x00011] in <2c44351298f54fb0bfd0ddebc3f0ef37>:0
at QuantConnect.Le: an.Engine.DataFeeds.DataManager.AddSubscription (QuantConnect.Data.UniverseSelection.SubscriptionRequest request) [0x00052] in <2c44351298f54fb0bfd0ddebc3f0ef37>:0
at QuantConnect.Le: an.Engine.DataFeeds.DataManager+<>c__DisplayClass14_0.<.ctor>b__0 (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x0010a] in <2c44351298f54fb0bfd0ddebc3f0ef37>:0
at QuantConnect.Se: curities.UniverseManager.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <fbe0165ed4b04ace9f43fc08fd8ce3dc>:0
at QuantConnect.Se: curities.UniverseManager.Add (QuantConnect.Symbol key, QuantConnect.Data.UniverseSelection.Universe universe) [0x00017] in <fbe0165ed4b04ace9f43fc08fd8ce3dc>:0
at QuantConnect.Al: gorithm.QCAlgorithm.OnEndOfTimeStep () [0x00401] in <9d423fd605b2496eae88e08bfd36b048>:0
at (wrapper remoti: ng-invoke-with-check) QuantConnect.Algorithm.QCAlgorithm.OnEndOfTimeStep()
at QuantConnect.Al: gorithm.QCAlgorithm.PostInitialize () [0x00173] in <9d423fd605b2496eae88e08bfd36b048>:0
at QuantConnect.Al: gorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.PostInitialize () [0x00001] in <73a8638bb88246f38b684b040419eb29>:0
at QuantConnect.Le: an.Engine.Setup.BrokerageSetupHandler.Setup (QuantConnect.Lean.Engine.Setup.SetupHandlerParameters parameters) [0x005a5] in <2c44351298f54fb0bfd0ddebc3f0ef37>:0 The DataQueueHandler does not support Futures.
2020-10-21 17:04:41 : Paper Brokerage account base currency:

Does anyone know where it is coming from?

Thanks in advance!

Cheers!

Update Backtest







 
0

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.


It is coming from LiveTradingDataFeed.cs . The exception is thrown at:

else if (request.Universe is FuturesChainUniverse)
{
Log.Trace("LiveTradingDataFeed.CreateUniverseSubscription(): Creating futures chain universe: " + config.Symbol.ToString());

var symbolUniverse = _dataQueueHandler as IDataQueueUniverseProvider;
if (symbolUniverse == null)
{
throw new NotSupportedException("The DataQueueHandler does not support Futures.");
}

If this doesn't make clear what is causing the issue in your case, could you attach your code so that we may find the problem?

 
0

Thank you Aaron,

sure.

from Selection.FutureUniverseSelectionModel import FutureUniverseSelectionModel
from datetime import date, timedelta

class FuturesUniverseSelectionModel(FutureUniverseSelectionModel):

def __init__(self, select_future_chain_symbols):
super().__init__(timedelta(1), select_future_chain_symbols)

def Filter(self, filter):
# return (filter.FrontMonth())
return (filter.Expiration(timedelta(0), timedelta(250)).OnlyApplyFilterAtMarketOpen())
class algorithm(QCAlgorithm):
self.SetStartDate(2010, 1, 1) # Set Start Date

self.SetCash(100000) # Set Strategy Cash

self.UniverseSettings.Resolution = Resolution.Minute
self.SetUniverseSelection(FuturesUniverseSelectionModel(self.SelectFuturesSymbols))

self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
self.Settings.FreePortfolioPercentage = 1

def SelectFuturesSymbols(self, utcTime):
softTickers = [
Futures.Softs.Cocoa,
Futures.Softs.Sugar11CME,
]

grainTickers = [
Futures.Grains.Wheat,
Futures.Grains.Corn,
Futures.Grains.Soybeans,
Futures.Grains.SoybeanMeal,
Futures.Grains.SoybeanOil,
Futures.Grains.Oats,
]



grains = [ Symbol.Create(ticker, SecurityType.Future, Market.CBOT) for ticker in grainTickers ]

softs = [ Symbol.Create(ticker, SecurityType.Future, Market.NYMEX) for ticker in softTickers ]


return grains + softs

 

0

I attached an algo which shows how to add your symbols into something like this example from github.

0


I have the same implementation actually. I took it from there as well. The only change in my code is that i choose expiries by myself as well as the rolling time. I mean it works in the backtest ok, it doesnt work live.

def Filter(self, filter):
return (filter.Expiration(timedelta(0), timedelta(250)).OnlyApplyFilterAtMarketOpen())

 

And the the way i implement contracts in the alpha model is same as in guides.

def Update(self, algorithm, data):
insights = []

for chain in data.FutureChains:
contract = [c for c in chain.Value if c.OpenInterest > 2000]
contracts = sorted(contract, key=lambda k: k.OpenInterest, reverse=True)
if len(contracts) == 0: continue
frontContract = contracts[0]
symbol = frontContract.Symbol

 

0

Apologies on the confusion.

I just checked, for paper trading it is merely not currently possible to use futures (see

https://www.quantconnect.com/docs/live-trading/paper-trading

). If you have a brokerage with a paper trading account (like IBKR), you can use that as a workaround.

1

Oh wow, thanks. I kind of missed that, sorry for stealing your time.

0

Update Backtest





0

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.


Loading...

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!