Back

Combining multiple custom data into a custom indicator

I understand we can use Data Consolidators to pipe data to indicators. It seems that we can only pipe one custom data to one indicator.

I may have missed something in the documentation. Can we create two custom datafeed (sourced from quandl) and consolidate both of them into a single custom indicator?

I'm experimenting with creating a (VIX-VXV) contango indicator using daily close prices of VIX and VXV from quandl.

Thanks!
Update Backtest








Good question, Mike's the indicator expert here so I'll defer to him on how to do it "properly".. :)

A quick-dirty solution might be to write a custom data type which combines all the data you need into one object that extends BaseData, and then making an indicator on that object. The downside is you'd need to build the combined object manually and do the updates manually (which is probably more effort than its worth).

At the moment when you use a helper to register an indicator to receive a data stream it creates a new instance of the indicator. Perhaps you could do this manually - and use the same indicator object to register it for two data streams? Example from the QC University Indicators Project

RegisterIndicator("BTC", _rsiCustom, bitcoinIdentityConsolidator, x => x.Value);
RegisterIndicator("SPY", _rsiCustom, new IdentityDataConsolidator(), x => x.Value);
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.


I've thrown together a quick example of a way to use the FunctionalIndicator to do things that may seem difficult otherwise.

What I'm doing here is creating two simple moving average indicators (one for VIX and one for VXV). I then define a FunctionalIndicator which uses these symbols in it's compute method.

See FunctionalIndicator on github.

I pass a function to the constructor that tells it how to ComputeNextValue and determine if it IsReady.

Jared has opened up an issue on github to address this in a more formal manner.

Here's the meat and potatoes:

In the Initialize method...

// the functional indicator takes as arguments two functions,
// the first is a ComputeNextValue function
// the second is an IsReady function
ratio_VXV_VIX = new FunctionalIndicator("ratio",
point => RatioIndicator_ComputeNextValue(point, smaVXV, smaVIX),
ratioIndicator => RatioIndicator_IsReady(ratioIndicator, smaVXV, smaVIX)
);


Defined lower in Main.cs

private decimal RatioIndicator_ComputeNextValue(IndicatorDataPoint data,
IndicatorBase vxv,
IndicatorBase vix)
{
return vxv / vix;
}

private bool RatioIndicator_IsReady(IndicatorBase functionalIndicator,
IndicatorBase vxv,
IndicatorBase vix)
{
return vxv.IsReady && vix.IsReady;
}


Let me know if this works for you!
2


Superb! Thanks!
0

Would someone be willing to provide an example of this in Python?

2

I'd also appreciate an example in python.

1

Same here. I am looking forward with an example in Python. Thanks in advance!

0

Hi All,

As custom data Yahoo VIX and VXV is not available in this algorithm, we've updated this algorithm with the quandl data and simplify the algorithm with Indicator Extensions. This is the C# example

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.


This is the Python example 

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.


Thank you Jing!

0

Thanks, Jing Wu ! Really appreciate the python example you put forward.

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

This discussion is closed