Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by Physicsman

  1. Hello, If you are reading the Bid/Offer prices from the live price stream using an automated process and not manually, in normal markets that should be enough time to reach our servers and fill the trade without error. Only during volatile "fast" markets would there be a chance of the trade request being rejected due to "Price Tolerance" reasons. The Price Tolerance specifies the amount of slippage you are willing to take in order to get a trade done. It is set at 2 by default for all markets. You can override this PriceTolerance value in your trade request call. There is a PriceTolerance field you can set in the newtradeorder call. If you set it to a larger value, such as 100, that should be more than sufficient to have your trade filled even if the market price moves. The markets would have to be extremely volatile to move >100 pips in a second or two for the trade to be rejected. Kind Regards, PM
  2. Hi, For the question in your 2nd post. I presume you meant the Cash values change immediately after you close all your open positions? This is because the back-end processes/calculates your new cash value for each open positoin closed separately, and there is a lag time time to the calculations. Since you are refreshing the APi call every second, you are seeing the Cash value update while it is still calculating the changes from each closed position. The value should stabilise after a short while to the final value of your Cash balance once the back-end has computed your final value from all the closed positions. Just one query: are you using a demo account for your testing? It is recommended you use a demo account while you are testing and setting up your system so you do not use your real-money account until you are ready to Live trade. Kind Regards, PM
  3. Hello, In answer to the question in your first post. The "Cash" displayed on the Web Trader platform is streamed and does not use the REST API GetClientAccountMargin call. The Cash value from the stream on the Web platform is updated after you close/modify your open positions. The GetClientAccountMargin call retrieves the latest current values for your account. That is why if you have open positions and are calling it repeatedly every second, then it will show the latest current value, which will change over time since you have open positions. This is not the recommended way. You should subscribe to the Lightstreamer ClientAccountMargin stream instead. Kind Regards, PM
  4. Buy trade position margin is 0

    Hello, From the screenshot you have what is called a "hedged" trade, where you have equal and opposite sized trades in the same market. In this case you have bought 1000 in EUR/USD and have also sold 1000 in EUR/USD meaning you are effectively market neutral. In these cases, you are only charged margin on one leg of the trade - the first position opened. As you have also said, if you were to then place a further hedge trade for example by selling another 1000 in EUR/USD, then you will be charged margin only on the larger leg - the 2000 Sell position. The remaining 1000 buy position will continue to show zero for margin requirement. Did you mean to create a "hedged" trade or where you trying to buy 1000 to close your sell 1000 position? Kind Regards, PM
  5. Hello, The Bid price is the Sell price for a market and the Offer price is the Buy price. When sending a new trade request, read in from the live price stream the current Bid / Offer price and fill in the BidPrice & OfferPrice fields with those values. Kind Regards, PM
  6. Stream about open positions

    Hello, It sounds as though you are trying to replicate the functionality of the Open Positions panel from our trading platforms in your own application. The normal usage pattern is then: Subscribe to the Orders stream. Call ListOpenPositions to initially populate your Open Positions grid. Upon receving an update to your open positions from the Order stream, call GetOpenPosition to update your Open Positions grid with the latest updates. Kind Regards, PM
  7. Hello, Subscribe to the Orders stream, which will provide an update / information on any orders as soon as they are filled / cancelled etc. Kind Regards, PM
  8. Hello, Unfortunately, Trade/Order notifications cannot be switched off/disabled on the trading platforms. Kind Regards, PM
  9. Placing Multiple Order

    Hello, TrailingStopConversionFactor should also be returned with the MarketInformation call along with the QuantityConversionFactor (see screenshot). fxConversion is the actual conversion rate from the currency base pair you are trading to your account currency. So if you are trading GBP/USD, then USD is the pair base currency, therefore you will need to convert USD to GBP to obtain the PIP value in pounds, instead of a PIP value in USD. Example: quantity 1 CFD contract in GBP/USD is a PIP value of 1USD, which when converted back to account currency in pounds is PIP value = £0.80 approximately. Yes, (TSCF || 1) means use TSCF unless its value is null then use 1 instead. || means OR as you correctly guessed. The code examples are not meant to be used verbatim. The marketIDs differs between brands such as City Index or FOREX.com etc. The examples are just generic representations of how the code should look like approximately. When using the code, you should for example follow the instructions described in: http://docs.labs.gaincapital.com/#How Do I/Find Market ID.htm%3FTocPath%3DHow%20Do%20I...%3F|_____1 to find the correct market ID that you have access. Kind Regards, PM
  10. Placing Multiple Order

    Hello CFDs use the same formula as spot FX so you can use the formula I provided already in my previous answer. Cordially, PM
  11. 500 error?

    Hello Wertmandu, I'm surprised this call worked previously as it should not have done. This is because you are supplying a TradingAccountId of 0, instead of the actual trading account ID. It should only work when it has the correct ID. As a side note: you should send the OrderID as "null" or you can even drop this field entirely. Try the call with the correct TradingAccountId and see if that resolved the problem. Kind Regards, PM
  12. Placing Multiple Order

    Hello Cinemizer, In answer to your question about obtaining account resource information. Usually, you obtain these values as live, updating numbers via the ClientAccountMargin stream. However, if you want a static snapshot of these values, you can use the GetClientAccountMargin HTTP Get call. Kind Regards, PM
  13. Placing Multiple Order

    Hi Cinemizer, In answer to your question about obtaining PIP value. This is calculated from field values obtained by making a GetMarketInformationCall. I believe you are a US client trading spot FX? The formula is then: Spot FX Market: (Quantity * (TrailingStopConversionFactor || 1) * fxConversion) / QuantityConversionFactor Kind Regards, PM
  14. Hi JPL, The API AppKey can be obtained by contacting the client services team. We're not able to create one from a forum rewquest unfortunately. Kind Regards, PM
  15. Market Order

    Hi JPL, Price tolerance is in Pips. The default setting is 2 for all markets. Kind Regards, PM
  16. Market Order

    To clarify, the Market order (Trade) call uses the current market price at the time you send the trade request. The GetLatestPrice Ticks call will provide you the most recent price at the time you send the request (assuming network latency is in the milliseconds to reach the server). You can then use this most recent price in your server side crash close position call. Provided that markets are not moving very fast then they probably will not have moved past the Price Tolerance setting. What you could do is send a suitably large price tolerance value in your trade request so that you can ensure the trade request to close position is accepted and not rejected due to price tolerance exceeded. You can see that there is a PriceTolerance field in the NewTradeOrderReuquestDTO. Kind Regards, PM
  17. Market Order

    Hello JPL, The BidPrice and OfferPrice fields in the market order call are the current market bid/offer prices, not a Limit order price. You need to subscribe via Lightstreamer to receive the live stream of market prices for the market you are trading. You can then feed in the latest bid/offer prices received at the time you send the trade request. For an example, see the trade ticket on any of our trading platforms (which uses the API). The trade ticket displays the live market prices updating, and so will have and can send the market price at the time you send your trade request. NOTE: I see in the POST body pasted in your reply that there is a "TriggerPrice" field. The call to place a market order does not have a "TriggerPrice" field. The permissable fields in a trade request are detailed at: http://docs.labs.gaincapital.com/#Data Types/NewTradeOrderRequestDTO.htm Kind Reagrds, PM
  18. Market Order

    Hello JPL, The API supports both market and limit orders. To send a market order, use the /newtradeorder endpoint http://docs.labs.gaincapital.com/#HTTP Services/Trade.htm%3FTocPath%3DCIAPI%20Reference|HTTP%20Services|Trades%20and%20Orders|_____16 where there is no mandatory order price field. Limit orders use the /newstoplimitorder endpoint where the order price field is mandatory http://docs.labs.gaincapital.com/#HTTP Services/Order.htm%3FTocPath%3DCIAPI%20Reference|HTTP%20Services|Trades%20and%20Orders|_____15. Kind Regards, PM
  19. Hi, Please send to the server as a POST, not as a GET. I would suggest you first login to Lightstreamer and esnure that it works and you are authenticated. After successful login, you can send another call to subscribe to the Prices stream for GBP/USD. For your prices subscription call, the string would look something similar to: LS_mode=MERGE&LS_id=PRICE.154297&LS_schema=MarketId%20TickDate%20Bid%20Offer%20Price%20High%20Low%20Change%20Delta%20ImpliedVolatility%20Direction%20Status%20StatusSummary%20PriceEngine%20Row_Update_Version%20AuditId&LS_data_adapter=PRICES&LS_snapshot=true&LS_table=7&LS_req_phase=426&LS_win_phase=100&LS_op=add&LS_unique=6&LS_session=sessionID& Please refer to the lightstreamer documentation so you know what fields you are sending, and what mode you require etc. Kind Regards, PM
  20. Placing Multiple Order

    Hi Cinemizer, Do you mean placing more than one entry order at a time? You can only place 1 entry order at a time, but if you are placing "Once Cancels the Other" (OCO) or If/Done orders, then more than one order is placed at the same time. However, those additional orders are conditional. Kind Regards, PM
  21. List of TradingAPI EndPoints

    Hello, You can find all the endpoints in the documentation at: http://docs.labs.gaincapital.com/ Kind Regards, PM
  22. Hello Cinemizer, In answer to your post from Saturday. "Target" means the LightStreamer adapter to use. In all cases, this is "STREAMINGALL" as noted in the docs for each of the streams. Similarly, "Channel" means the stream you are listening to. The channel you need is documented for each stream, for example: PRICES.PRICE.{marketIds} is used to subscribe to the price stream for the market with marketID that you enter for the placeholder {marketId}. We only provide information on the REST API in the documentation and the forum since that is our (Gain's) API. Lightstreamer as a 3rd party API we do not directly support here. Kind Regards, PM
  23. Hi Cinemizer, In answer to your post from Friday. To be clear about authentication, you first need to POST a LogOn request to the REST API (ciapi.cityindex.com) using your username and account password. Upon successful logon, you recevie back a session ID. Now, when connecting to Lightstreamer API for streaming prices, as authentication you send you username and use as the password the session ID received from the REST API. Since Lightstreamer does not have a Client Development Kit for your language AutoIT, it's possible you cannot access Lightstreamer streams through AutoIT. At best, you would have to put in work to convert the .NET Client Development Kit to work with AutoIT. Kind Regards, PM
  24. Hello Cinemizer, You'll need to download a Lightstreamer Client development kit appopriate for the programming language you are using from: https://lightstreamer.com/download/#ls70. That link is for the version of Lightstreamer we are using on our servers. Documentation on using Lightstreamer can be found at: https://lightstreamer.com/download/#ls70. The "General Concepts" and "Hello World" tutorials in the Basics section should get you started. After that, the "Web Client Development" file should get you the rest of the way. Note: authentication for Lightstreamer is your username that you use with the REST API, and the Session token you receive back once you have logged into the REST API. Kind Regards, PM
  25. Market Order

    Hi Agent, This will be via the Lightstreamer API. Documentation for working with Lightstreamer in your programming language can be found at their documentation site at: https://lightstreamer.com/doc. The Lightstreamer URL to connect is: https://push.cityindex.com/ Kind Regards, PM