Trade FOREX with FXCM

  • Award-Winning Platform
  • 24/7 Customer Support
  • Trade Directly on Charts
  • Free $50K Practice Account
Register


Results 1 to 6 of 6

Thread: Problem retrieving get open orders in multiple calls

  1. #1
    Join Date
    Jun 2009
    Posts
    6

    Problem retrieving get open orders in multiple calls

    Hi all,

    I'm building a concurrent application using java api where multiple objects use same trading functions and for testing purposes I'm trying to get trading status in successive calls using the following scheme:

    submit request -> wait for response -> submit same request again -> wait for response -> etc...

    While "get accounts", "get open positions" and "get closed positions" work without any problem, there's no way to make it working with "get open orders" call...no matter what I always get response for first two requests only, then any successive request to get open orders is never answered.
    Already tried sending request with both OrderMassStatusRequest object and direct call to getOpenOrders() function but nothing changes. Provided that code used to handle such requests is the same for each kind of request I really can't get what's going on...

    Is anybody experiencing same problem? I'm using latest build of Java API (243)

    Thanks in advance.

  2. #2
    Join Date
    Jun 2009
    Posts
    6
    Just tried with this simple piece of code:

    public boolean getOpenOrders()
    {
    try {
    requestID = gateway.requestOpenOrders();
    }
    catch(Exception e) {
    return false;
    }
    return true;
    }

    public void handleMessageArrived(ITransportable aMessage)
    {
    if(aMessage instanceof ExecutionReport) {
    getOpenOrders();
    }
    }


    Again, while requestAccounts(), requestOpenPositions() and requestClosedPositions() work without any problem, only first two requestOpenOrders() requests work, while successive ones are not answered. Even if interleaving requestOpenOrders() requests with other request types, other requests are correctly answered but not "open orders" ones, regardless of the time interval or the number of requests of other types between them.
    Really can't get where is problem. Connection is active, as MarketDataSnapshot messages are correctly received too...

    Tested with API build 242 too, but problem persists...

  3. #3
    FXCM Help is offline DailyFX Administrator
    Join Date
    Jan 2006
    Posts
    2,140
    Looks like this would create recursive calls to the servers, and after a while this will not work.

    You can an execution report when you ask for the open orders(currently standing orders waiting to be executed) and so when you call it once and there is a current pending order, it will continuously call to get the open orders.

    This might be what is causing your issue. Please move the function and see if this is still true.

  4. #4
    Join Date
    Jun 2009
    Posts
    6
    Thank you very much for your response.
    I tried following your guidelines but wasn't able to solve the problem, as it kept responding only to first 2 requests even if adding new pending orders.

    Anyhow I found out that if setting a clOrdID to the OrderMassStatusRequest message, all consecutive requests (regardless of how many) are correctly answered, though in this case any order must be executed with same clOrdID in order to retrieve them (otherwise those with a different clOrdID won't be received).

  5. #5
    Join Date
    Jun 2009
    Posts
    6
    Tried with other fields that can be set for an OrderMassStatusRequest:

    - clOrdID : works
    - secondaryClOrdID: works
    - execID: exception from the server (no data found)
    - account: no response after first two requests
    - instrument: no reponse after first two requests

    maybe I should reconsider how I am using clOrdID and secondaryClOrdID in my current implementation to take advantage of this and try to fix my problem...

  6. #6
    FXCM Help is offline DailyFX Administrator
    Join Date
    Jan 2006
    Posts
    2,140
    You really should only have to call the OrderMassStatusRequest only once, when you login. All subsequent messages should be returned to you in real time through the execution reports.

    If you are not getting the messages in real time, please make sure you are calling fxcmGateway.requestTradingSessionStatus(); after you login to subscribe your session to receive updates.

    Please let us know if you have any questions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.