Jump to content


  • Content count

  • Joined

  • Last visited

Posts posted by garrettkolson

  1. Hi there,

    I experienced an odd problem this morning.

    I have an entry algorithm set up to place a buy stop entry order 2 pips above the high price of the current bar given a certain set of circumstances - this happened on EUR/USD this morning at 10:14:55 UTC.

    This call returned a red card for an invalid minimum distance to target - well and good. However, the bid/offer prices that caused this to happen (that I'm receiving from Lightstreamer) don't appear to line up with the actual chart data.

    The order trigger level was set for 1.1329, with a bid/offer of 1.13288/1.13304 (which should still have been ok w/ EUR/USD?). However, in reviewing the chart, it looks like these prices weren't actually hit until after 10:15 AM. I'm just trying to understand what happened here, as it appears that the order should have been fine.


  2. Great, that's good to know.

    I'm assuming that throttling also applies to calls to the Order endpoints as well? I ask because I'm writing a method to close all open positions asynchronously, given certain sets of circumstances (if we're within x minutes/seconds of market close, for example).

    Since these positions will presumably be for different markets, with different quantities, directions, etc, I assumed that I can't just stuff all the position ids into one call to order/newtradeorder. However, I'd still like to close all positions as quickly as possible - hence my plan was to queue up all the close orders and make the api calls asynchronously, as opposed to having to do them all one by one.

    So, I guess this question is similar to my first: if I were to do that with (potentially) 10-15 open positions, is it likely that I could get throttled?


  3. Hello,

    I had two questions regarding retrieving market price information:

    1. I'm aware of the different endpoints to retrieve historical price data. However, it looks like these endpoints are designed to be called for one market at a time. My first question is: is there a way to retrieve price data for multiple markets with a single call? I worry about getting throttled if I'm calling /market/{MarketId}/barhistory 15+ times, for example.

    2. I'm also aware that you can subscribe to multiple markets via the Prices stream - is there a limit to the number of markets that you can subscribe to on one stream?



  4. Hi chriss,

    It looks like you're using the interface implementations (Subscription, SubscriptionListener, etc) from the Lightstreamer .NET Standard Client Library v.5.0.*, which appears to be solely compatible with Lightstreamer 7.1.0+. Since GCAPI is using Lightstreamer 7.0.3 (at least it was the last I checked), you'll want to use the .NET Client Library v. 4.0.0.

    I only know this because my app is also written in C#, and I spent a while banging my head on the proverbial wall trying to get my live streaming sorted out properly. :lol:

    It's available in NuGet - you just have to specify Version 4.0.0 when installing.

    And the documentation is here: https://lightstreamer.com/api/ls-dotnetstandard-client/4.0.0/frames.html?frmname=topic&frmfile=index.html


  5. Hi PM,

    After some more testing today, I suspect you are correct - I have placed a few successful orders with wider TriggerPrice targets.

    I actually do have this process automated. My code that places orders receives the latest prices from Lightstreamer just before calling /order/newstoplimitorder. However, when dealing with distances that small, it seems likely that the market will occasionally move within your target distance.

    I've built in a few other checks for this eventuality, as well as some TriggerPrice modifications and retries, should the first order attempt fail for that reason.

    Thank you again for all your help!


  6. Thanks for your answers, PM.

    1. Awesome, I was hoping that was the case.

    2. However, that leads me to a follow-up question related to #2. In my case, since I'm a US client, I'm trying to place orders to buy or sell at a worse price than current (so, stop order), with no attached IfDone. I attach the related stop loss and take profit orders once the first order has become an open position (if it does).

    However, I'm getting the "Minimum Distance to Target" red card upon trying to place the initial non-attached stop order, even though I've specified my trigger as more than the MinDistance from the Offer/Bid.

    So, for example, I tried to place a sell stop on USD/JPY. The Bid Price I received from Lightstreamer was 107.413, so my TriggerPrice was set to 107.398 (distance of .015). The MinDistance for USD/JPY is listed as .014, but I still got red carded for being below minimum distance to target.

    Do you know what I'm doing wrong?



  7. Hi there,

    Right now, I'm calling /market/{marketId}/information only once at the beginning of my session for different market info, particularly the MinDistance property for the market. However, I'm still getting a lot of Red Cards due to being under the minimum distance to the target.

    So, I guess I have two questions:

    1. Is that something I should be calling periodically to get the latest MinDistance? Does the MinDistance for a market change throughout the day, or is that pretty static?

    2. Which price is the MinDistance relevant to? I would assume, for a buy stop order, that the MinDistance would be from the Offer Price, and for a sell stop, it would be from the Bid Price. Is that correct?


  8. EDIT: Forgive me - it looks like this issue has already been addressed here: 

    I need to be more diligent in looking through past threads before posting! Lol. Anyway, I didn't even think to check the JSON formatting, as I'm using probably the most popular of serializer libraries for the language I'm writing in (Newtonsoft.Json for C#). When in doubt, double check your syntax! 

    I can't test this right now, as markets are closed, but if this doesn't solve it come Monday (which would be very surprising), I'm sure I'll be back. :)



    Hi PM,

    I'm having some trouble with the /order/updatetradeorder endpoint as well - I successfully call it with something like the following POST data to add a stop loss order to an open position:


    The call returns 200, and tells me the order was accepted as OK. However, the return data doesn't have any IfDone, or attached orders to the parent order. In checking my Forex.com backend for the demo account, I also don't see any new orders in my list of active orders. 

    Thinking it might just be a weird glitch, I waited until the price hit the trigger price of the attempted stop loss order to see if it triggered anyway. Unfortunately, nothing happened.

    I've tried this with a variety of parameter variations on both stop and limit orders (including setting the ParentOrderId parameter), but haven't had one be successfully added yet, even though the returned order code says that it was accepted in every case.

    Am I missing something in my POST request?





  9. Hi PM,

    Thank you for digging in to all this.

    I tried replicating your calls, and still was unsuccessful in calling /order/cancel and /order/updatestoplimitorder, even with identical parameter and header signatures. This made me really dig through my application, and I finally figured out what the issue was.

    As it turned out, while the headers were "correct", due to a quirk in how I had written the wrapper methods to call those endpoints, the Session token was being appended to the Session header twice just before the call took place. So, it looked like this: "Session: {token}{token}". Obviously, incorrect. Lol.

    Once I fixed that, the calls worked as intended.

    I feel a bit silly. Thank you for taking the time to dig through it.


  10. Hi PM,

    Thanks for your reply. I was actually already including the authentication information in the headers, as well as in the POST body. I've removed it from the body, so it's solely being sent in the headers now, but I'm still having the same issue.

    Strangely, my call to /order/newstoplimitorder is working fine, but /order/updatestoplimitorder and /order/cancel are returning Unauthorized, even though I'm using the same username and session token.

    Any ideas as to what could be causing the issue?


  11. Hi there,

    I have a series of unit tests that run against the methods I've written to call various GCAPI methods.

    One part of this series tests my methods to call the various Trade/Order endpoints. First, I call /order/newstoplimitorder and successfully place a new resting entry order. After a few other things, I call /order/cancel on the entry order (only if the order hasn't already been triggered). This is where I'm getting a little stuck.

    I'm using all the properties described in the documentation, including the Username and Session token I received on authorization (included both in the POST JSON data, and as separate headers). My OrderId property is the order id I received from opening the entry order, and the TradingAccountId was received from calling /UserAccount/ClientAndTradingAccount. This Account id was also successfully used to place the entry order.

    Despite all this, I'm still receiving 401 response codes when calling /order/cancel.

    Here is the POST packet: "{\"OrderId\":724499552,\"Reference\":\"Trade #724499552 setup invalidated\",\"UserName\":\"********\",\"Session\":\"a52f7a51-c01d-4a81-a6db-82eb37c70d06\",\"TradingAccountId\":*********}"

    Can you tell me what I'm doing wrong?