Back

Manage multiple custom Data

Hi,

In onData you can search for the symbol with the data[symbol].
But I created my own LocalData set how do I slice it there?
I saw that there is something like TradeBars but how or where do I tell OnData to use my custom TradeBars if that would be the way to go?
Also when I would manage to have like my "LocalDataSet[symbol]" how can I add all the indicators nicely foreach of the data I am pulling?

public override void Initialize()
{
SetStartDate(2015, 1, 2);
SetEndDate(DateTime.Now.Date.AddDays(-1));
SetCash(100000);

AddData<LocalData>(_brentCrudeOil, Resolution.Daily);
AddData<LocalData>(_vix, Resolution.Daily);

sma = SMA(_brentCrudeOil, 10, Resolution.Daily);
ema = EMA(_brentCrudeOil, 50, Resolution.Daily);
}

public void OnData(LocalData data)
{

if (!sma.IsReady || !ema.IsReady)
{
return;
}

}

 

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.


Hi Amir,

One way to solve the indexing problem is instead of having the same class in these lines: 

AddData<LocalData>(_brentCrudeOil, Resolution.Daily);
AddData<LocalData>(_vix, Resolution.Daily);

I would suggest giving them separate classes, e.g.:

AddData<BrentData>(_brentCrudeOil, Resolution.Daily);
AddData<VixData>(_vix, Resolution.Daily);

Then, we can have one OnData methods for each source:

OnData(BrentData data){...}
OnData(VixData data){...}

However, if this doesn’t work, please attach your code, or preferably, a backtest.If the custom data inherits from TradeBar (e.g. class CustomBar : TradeBar { ... }) then we can use the custom trade bars if we define the function OnData(CustomBar) { ... }.

Best,
Shile Wen

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