Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Get the Instrument from IInstrumentStatusMessage
 Post subject: Get the Instrument from IInstrumentStatusMessage Post rating: 0   New post Posted: Wed 13 Dec, 2017, 11:27 
User avatar

User rating: 0
Joined: Fri 11 Sep, 2015, 15:43
Posts: 8
Location: Italy, Roma
Hi,
suppose I've started a strategy and I've subscribed many instruments in the onStart() method.
Suppose that no order are open.
With a frequency of about 30s, I should receive in the onMessage() method several IInstrumentStatusMessage objects: one for each instrument I'm subscribed to. As far as I understood, by checking if IInstrumentStatusMessage.isTradable() is the only one way to double-check if an instrument is tradable or not at a certain moment before trying to submit an order.

My question is: which is the best way to understand which is the instrument each IInstrumentStatus message is referring to?
I've seen that by printing the IMessage object, the instrument is available in the output String, but I would like to know if there is any other "more direct and reliable" way to get the reference instrument for each IInstrumentStatusMessage received.

Thank you.

Regards,
Marco


 
The Best Answer  Post subject: Re: Get the Instrument from IInstrumentStatusMessage Post rating: 0   New post Posted: Thu 04 Jan, 2018, 13:32 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Here is an example:
    public void onMessage(IMessage message) throws JFException {
        if(message instanceof IInstrumentStatusMessage) {
            IInstrumentStatusMessage instrumentMessage = (IInstrumentStatusMessage) message;
            console.getOut().println(instrumentMessage.getInstrument() + ", isTradable:"+ instrumentMessage.isTradable());
        }
    }


 
 Post subject: Re: Get the Instrument from IInstrumentStatusMessage Post rating: 0   New post Posted: Thu 04 Jan, 2018, 14:17 
User avatar

User rating: 0
Joined: Fri 11 Sep, 2015, 15:43
Posts: 8
Location: Italy, Roma
Thanks a lot


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com