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.

How to check if an instrument is tradable
 Post subject: How to check if an instrument is tradable Post rating: 0   New post Posted: Wed 14 Dec, 2011, 20:52 

User rating: 0
Joined: Wed 14 Dec, 2011, 20:47
Posts: 2
Location: US
Does anyone know how to check if an instrument is tradable?


 
 Post subject: Re: How to check if an instrument is tradable Post rating: 0   New post Posted: Thu 15 Dec, 2011, 09:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
When instrument status changes, strategy receives IInstrumentStatusMessage:

     public void onMessage(IMessage message) throws JFException {
        if(message.getType().equals(IMessage.Type.INSTRUMENT_STATUS)){
            IInstrumentStatusMessage im = (IInstrumentStatusMessage)message;
            if(im.isTradable() == true) {
                println(im.getInstrument() + " is tradable");
            } else {
                println(im.getInstrument() + " is not tradable");
            }
        }
    }
   
    private void println(Object o) {
        console.getOut().println(o);
    }


 
 Post subject: Re: How to check if an instrument is tradable Post rating: 0   New post Posted: Thu 15 Dec, 2011, 10:18 

User rating: 0
Joined: Wed 14 Dec, 2011, 20:47
Posts: 2
Location: US
Thanks for your sample code!

How about the following case:
The strategy just starts to run and an instrument(let's say NZD/CHF) is not tradable at this moment,
but NZD/CHF will be tradable 5 hours later,
so before I get the message(5 hours later), is there any way to check if NZD/CHF is tradable?


 
 Post subject: Re: How to check if an instrument is tradable Post rating: 0   New post Posted: Thu 15 Dec, 2011, 14:51 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Currently it is not possible, but it is planned to implement it in the future.


 

Jump to:  

  © 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