Alias and Instrument info cannot be correlated

Custom indicators, trading strategies, data export and recording and more...
zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Alias and Instrument info cannot be correlated

Post by zcsoka » Fri Oct 01, 2021 7:45 am

Greetings,

I am trying to correlate the instrument information provided by onInstrumentadded and onCurrentInstrument. The onInstrumentAdded provides the InstrumentInfo object, but its exchange, full name, type and symbol information cannot be derived to the alias, what is provided by the onCurrentInstrument. I suppose it is the failure of the connector modules, that they do not deliver the correct information. Previously I could neglect the exchange information and I could trim the names down to the ticker symbol by removing the exchange part, but right now I want to use the add-on for crypto, where the ticker symbols might be identical. Do you have any tricks to automatically derive one from the other?

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Alias and Instrument info cannot be correlated

Post by Svyatoslav » Fri Oct 01, 2021 8:30 am

Hi. I'm not 100% sure what you are trying to achieve. Are you trying to understand which alias the MultiInstrumentListener# onInstrumentAdded belongs to? If so - you get onCurrentInstrument right before that call (same as with other types of updates - you will get onCurrentInstrument first, and actual call after), so just store it in some field.

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Alias and Instrument info cannot be correlated

Post by zcsoka » Fri Oct 01, 2021 9:18 am

Actually that is what I am doing, I am managing additions right now in onCurrentInstrument, I just wanted to make it cleaner and use the onInstrumentAdded, but I could not due to the different data it delivers. Then I will leave my code as it is and get the added instruments in onCurrentInstrument, I just found it strange that they deliver different information, what cannot be correlated. Thanks for the quick answer.

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Alias and Instrument info cannot be correlated

Post by Svyatoslav » Fri Oct 01, 2021 11:01 am

Sorry, still not sure I follow. Think of the alias as of a key that identifies an instrument. There is no guaranteed relation between that key and the instrument itself - that's just an identifier.
So, you get identifier for the next callback inside onCurrentInstrument, then store it and you get actual callback next. It's done this way to avoid having two interfaces for " MultiInstrumentListener " modules and "single instrument" ones (with alias in callbacks and without).

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Alias and Instrument info cannot be correlated

Post by zcsoka » Fri Oct 01, 2021 12:51 pm

Understood, thanks for the clarification. 

Post Reply