Back

Pricing Data and Indicators for Futures


Hi Quants, 

I am trying to convert a strategy that uses the SPY for ES contracts less than 91 days out. I am able to get the price working for the consolidator using the code from the github. I use the OnData(Slice slice) method. I would like to find the Williams Percent R and the price for the future. I used OnData(Tradebars data) for the SPY strategy, but this does not work for the futures. What function do I apply to do this for the E-mini future?

Thanks, 

Eric

Update Backtest








Good start! It was smart way to create new consolidators each time a new contract was listed. Now you just need to create a new indicator object and warm it up with your bars.

1

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.


For Futures and Options, we use OnData(Slice). 

public override void OnData(Slice slice)
{
// Logs tickers you can access with slice[symbol]
Log("Slice: " + string.Join(", ", slice.Keys));

// rest of the existing code
}
1

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.


I'm having a little trouble registering the indicator and having a value for the Williams Percent R. Is the futures algorithm only supposed to use the OnData(Slice slice)? I am confused at whether the whole algorithm should be in the for loop of OnData(Slice slice). I thought you would use the for loop to get the futures contract, and then have other functions to do the other alogrithm logic. Here is my attempt at registering the indicator.

where

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 TradeBarConsolidator(TimeSpan.FromMinutes(5));

consolidator.DataConsolidated += OnDataConsolidated;

SubscriptionManager.AddConsolidator(contract.Symbol, consolidator);

_willr = new WilliamsPercentR(contract.Symbol.Value, 9);

RegisterIndicator (contract.Symbol, _willr, consolidator);

Log("Added new consolidator for " + contract.Symbol.Value);
Log("WilliamsPercentR " + _willr);
CurrentOrder = Order (_symbol, quantity);

}

}

}

}

  

0

Hey Eric Bell,

Check the attached implementation.

I made a Dictionary<FuturesContract, WilliamsPercentR> to store all the indicators in case you want to work with more than one future. To check if a new indicator is aggregated correctly, I incremented the consolidator to 12 hours, so the indicator's behavior can be traced in the log.

What I don’t know is how to warmup an indicator that is based in a consolidator. That’s why I check if the indicator is ready before check its value.

Hope it helps

JJD

1

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