SmartQuant Discussion
http://www.smartquant.com/forums/

Accessing other instrument data to build lead-lag strategy
http://www.smartquant.com/forums/viewtopic.php?f=86&t=15005
Page 1 of 1

Author:  takumisasakura [ Fri Aug 07, 2020 5:00 am ]
Post subject:  Accessing other instrument data to build lead-lag strategy

I have some difficulty accessing the other instrument data. Here is what I would like to do with

Using data

@ES 5 sec past
@NQ 5 sec past data

Run the strategy based on the @ES but refer the @NQ 5 sec ago data (close) to comes out with the lead-lag

Hopefully community can help me to solve this.

Author:  skuvv [ Fri Aug 07, 2020 11:14 am ]
Post subject:  Re: Accessing other instrument data to build lead-lag strate

Hi takumisasakura,
I don't understand what you mean, can you please provide more details?

I think in your case you would better to use 'Strategy' type of strategy instead of 'InstrumentStrategy'. (if you want access bars of other instruments).
When you subscribe to both instruments you will receive both bars OnBar.
Then you can store them in their own BarSeries and access bars as you wish (eg: barSeries.Ago(5).Close)
You can take a look at Rebalance strategy for example.

Author:  takumisasakura [ Fri Aug 07, 2020 5:56 pm ]
Post subject:  Re: Accessing other instrument data to build lead-lag strate

What basically I would like to do is simply just refer some other instrument historical data (bar) to make trade decision in the instrument I am going to trade, not trading 2 instrument in the once, just I need to access the other instrument series historical data.

Example only trades @ES but use @NQ historical bar price as indicator to trade.

So what I need is the way of accessing the other instrument data during running some once instrument in scenario.
Is the "Strategy" can use as this usage as I mentioned? within the scenario putting two instrument, then it will send the 2 bar series in once, so the strategy can receive two bar data in the same event handler?

P.S
Is there any examples about FX Hedging trades? If it doesn't have please ignore.

Author:  skuvv [ Mon Aug 10, 2020 10:01 am ]
Post subject:  Re: Accessing other instrument data to build lead-lag strate

You can use the method that I advised you.
However, it depends on how you use the historical data.
It may be better to direct access of necessary historical data:
Code:
DataSeries dataSeries = DataManager.GetDataSeries(instrument, DataObjectType.Bar, BarType.Time, 300);


Code:
int index1 = dataSeries.GetIndex(FirstDateTime, IndexOption.Prev);
int index2 = dataSeries.GetIndex(LastDateTime, IndexOption.Next);

            for (int i = Index1; i <= Index2; i++)
            {
                Bar bar = dataSeries[i];
            }

Author:  takumisasakura [ Mon Aug 10, 2020 11:35 am ]
Post subject:  Re: Accessing other instrument data to build lead-lag strate

Thank you very much for your help.
Really appreciate.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/