Back

Futures Contract & TradeBarConsolidator?

Loving the new support for Futures contracts by the way!

Seem to be having some difficulty hooking the SP500 contract to a 5-minute consolidator though. Has anyone had any luck with this yet?

I've wired it all up the best I could and get this when running back test:

Backtest Error: Error initializing algorithm: Type mismatch found between consolidator and symbol. Symbol: /ES expects type ZipEntryName but tried to register consolidator with input type TradeBar

 

 

 

Update Backtest








My attempt to wire up the consolidator

0


Okay, little strange. I had to create a BackTest in order to share my implementation but in order to run a back test I had to comment out the consolidator. 

0

Hey Levi, we hacked something together to address this -- we'll add it to the github project for future people searching.

public class BasicFuturesConsolidationAlgorithm : QCAlgorithm
{
private const string RootSP500 = Futures.Indices.SP500EMini;
public Symbol SP500 = QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.USA);
private HashSet<Symbol> _futureContracts = new HashSet<Symbol>();
public override void Initialize()
{
SetStartDate(2016, 08, 17);
SetEndDate(2016, 08, 20);
SetCash(1000000);

var futureSP500 = AddFuture(RootSP500);
futureSP500.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182));

SetBenchmark(x => 0);
}

public override void OnData(Slice slice)
{
foreach (var chain in slice.FutureChains)
{
foreach (var contract in chain.Value)
{
if (!_futureContracts.Contains(contract.Symbol))
{
_futureContracts.Add(contract.Symbol);

var consolidator = new QuoteBarConsolidator(TimeSpan.FromMinutes(5));
consolidator.DataConsolidated += OnDataConsolidated;
SubscriptionManager.AddConsolidator(contract.Symbol, consolidator);

Log("Added new consolidator for " + contract.Symbol.Value);
}
}
}
}


public void OnDataConsolidated(object sender, QuoteBar quoteBar)
{
Log("OnDataConsolidated called");
Log(quoteBar.ToString());
}
}

 

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.


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...

This discussion is closed