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.

api question : check if instrument is available for trading
 Post subject: api question : check if instrument is available for trading Post rating: 0   New post Posted: Wed 21 Sep, 2016, 22:24 
User avatar

User rating: 0
Joined: Sun 04 Aug, 2013, 10:16
Posts: 48
Location: FranceFrance
Hi !

I would like to know if there is a way to know if an instrument is available for online trading before sending an order.

Is that possible with the API or is the only way to wait for a rejected message ?

thanks in advance

NB: orders are not triggered by an onbar or ontick event of the instrument hence why i'm asking


 
 Post subject: Re: api question : check if instrument is available for trading Post rating: 0   New post Posted: Thu 22 Sep, 2016, 07:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
context.getSubscribedInstruments().contains( Instrument.EURUSD )


 
 Post subject: Re: api question : check if instrument is available for trading Post rating: 0   New post Posted: Thu 22 Sep, 2016, 10:02 
User avatar

User rating: 0
Joined: Sun 04 Aug, 2013, 10:16
Posts: 48
Location: FranceFrance
many thanks for answer

however if you could confirm that i understand correctly, i'd be grateful :

if (context.getSubscribedInstruments().contains( Instrument.XAGUSD )) {
    engine.submitorder(//...
}


so

context.getSubscribedInstruments().contains( Instrument.XAGUSD )
will return false if xagusd is not available for trading at the time of the call of the method and true if it is with almost no chance to see the order being rejected

nb: i obviously took xagusd as example because that instrument if offline many time every day


 
 Post subject: Re: api question : check if instrument is available for trading Post rating: 0   New post Posted: Thu 22 Sep, 2016, 15:09 
User avatar

User rating: 0
Joined: Sun 04 Aug, 2013, 10:16
Posts: 48
Location: FranceFrance
i've looked in the api & maybe i got what i wanted :

import com.dukascopy.api.IInstrumentStatusMessage;

//...

  public void onMessage(IInstrumentStatusMessage message) throws JFException {

      if (message.getType().equals(IMessage.Type.INSTRUMENT_STATUS) && instruments.contains(message.getInstrument())) {

                     
              console.getOut().println(message.getInstrument()+" tradabie : "+message.isTradable());

      }
    }




haven't received that status message yet to confirm I got it right (couldn't find any example on how to use that interface on the web).

thanks for help if i'm missing something


 
 Post subject: Re: api question : check if instrument is available for trading Post rating: 0   New post Posted: Thu 22 Sep, 2016, 21:23 
User avatar

User rating: 0
Joined: Fri 04 Sep, 2015, 19:44
Posts: 34
Location: Slovakia, KE
If(instrument.equals("USDCAD") && period.equals("TEN_MINS")) {
...
}


But you must "Subscribe" first (getting "pointers" to instruments).


 
 Post subject: Re: api question : check if instrument is available for trading Post rating: 0   New post Posted: Thu 22 Sep, 2016, 23:01 
User avatar

User rating: 0
Joined: Sun 04 Aug, 2013, 10:16
Posts: 48
Location: FranceFrance
No of course i'm suscribed to all instruments i need.

what i'm trying to do is to know whether an instrument is tradable on an onbar or ontick event of another instrument.

i didn't get no message from the IInstrumentStatusMessage method...

Please help !


 

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