Jump to content

All Activity

This stream auto-updates     

  1. Last week
  2. Hello, Yes they should be identical. to help us investigate, please tell us: which Market ID you were using when this happened (the times of the Lightstreamer ticks) also, please send me a PM of your username only Many thanks, PM
  3. Hi I am experiencing differences between price ticks recorded from lightstreamer, and ticks recieved from GetLastestPriceTIcks. I am finding that sometimes not all the ticks recieved from the stream during a period will be present in the data recieved when calling GetLastestPriceTIcks covering the same period. Should these sources be identical? regards
  4. Earlier
  5. Not able to set the stop loss

    I forgot to address your other query about minimum order distance. The minimum order distance is a restriction set on every market, not a limitation of the API. For most markets it is quite small, for example EUR/USD is 0.8 pips outside the spread. You can view the minimum order distance by sending a ListMarketInformation call for the markets you are interested in trading. In the reponse, there will be a field MinDistance, that shows how close to the current market spread you can place your stop or limit orders.
  6. Not able to set the stop loss

    Hi Danilo, Since you mentioned you have a test account (NOT a Live account), please send me a DM with the test account credentials. I can then use that test account to send the API requests to perform Steps 1, 2, and 3 as you have described. We can see what happens and investigate from there as needed. http://docs.labs.gaincapital.com/ is the correct URL. The other one is the old address - we moved the API documentation to http://docs.labs.gaincapital.com/ so no need to use the other address. Kind Regards, PM
  7. Thank you so much for your kind words and feedback. I tried the suggestion and still end up getting same error. Please confirm the order Id to pass in Step 3 will be order Id of trade order OR stop loss order. Also as you mentioned "Some markets have a minimum distance for stop/limit orders away from the the current price" so is this a forex API restrictions or a market restrictions? Also as per forex person this is only applicable for UK accounts but I am not able to set even if my test account is not UK based. Also I see two document links so which one is correct? http://docs.labs.gaincapital.com/ http://docs.labs.cityindex.com/ Thanks
  8. Not able to set the stop loss

    Hello Danilo, I very much appreciate your laying out the exact steps you are taking and the requests/responses. It makes everything very clear and significantly easier to troubleshoot. Thank you! Looking through your requests I believe I have found the reason why your step 3 (editing the stop loss trigger) price is failing. In your update stop request, the OrderID of the Stop loss (received in the response to step 2) must be supplied. Your request has: "OrderId": 0 It should be for example based on the stop loss order ID you received from step 2: "OrderId": 711777646, // stop order id Note 1 In your step 2 when you are first adding a stop loss to your open position, although it appears to be working you should set the order ID as null instead of zero. "OrderId": null, Note 2 You mentioned using the web trading platform to attempt moving the stop loss and receiving a validation warning preventing you from moving the stop loss. I presume this is because you attempted to update the stop level too close to the current price? Some markets have a minimum distance for stop/limit orders away from the the current price. Kind Regards, PM
  9. Thank you for your reply. My use case is 1) execute a postion 2) then set the stop loss 3) update the stop loss Pls find below request response. I corrected the Quantity issue but still end up same error. Per my understanding the issue is with the value of stop loss I am trying to update. It was set to 1.9922 in step 2 and I tried to update it to 1.99380. I am using /updatetradeorder API. When I tried to set the value 1.99380 from forex web application , they have also not allowed me with some validations that max value is so and so. Requesting you to please have a look and let me know what is the mistake that I am doing. I tried contacting support guys and they said that this stop loss price restrictions is applicable to UK accounts and they confirmed that mine account is not UK. Not sure what is wrong here. // Execute buy order { "MarketName": "XYZ", "TradingAccountId": XXXXX, "MarketId": 401484388, "Quantity": 1000, "OrderId": 0, "Direction": "buy", "OfferPrice": 1.9939, "BidPrice": 1.99315, "PriceTolerance": 10, "PositionMethodId": 1, "AuditId": "ed6c6c6f-a368-4d54-8b87-59c564f991dc", "AutoRollover": false, "isTrade": true } // success response { "Status": 1, // OK "StatusReason": 1, // OK "OrderId": 711777646, // Order ID "Orders": [ { "OrderId": 711777646, "StatusReason": 1, // OK "Status": 3, // OPen "OrderTypeId": 1, // Trade "Price": 1.9939, // Open Price "Quantity": 1000.0, // Qty "TriggerPrice": 0.0, "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false } ], "Quote": null, "Actions": [ { "ActionedOrderId": 0, "ActioningOrderId": 0, "Quantity": 1000.0, "ProfitAndLoss": 0.0, "ProfitAndLossCurrency": null, "OrderActionTypeId": 1 } ], "ErrorMessage": null } // Set Stop Loss { "IfDone": [ { "Stop": { // Set Stop "ExpiryDateTimeUTC": null, "Guaranteed": false, "Direction": "sell", "Quantity": 1000, // Qty "Applicability": "GTC", "TriggerPrice": 1.9922, // price to set stop loss "OrderId": 0 } } ], "Direction": "buy", "ExpiryDateTimeUTCDate": null, "LastChangedDateTimeUTCDate": null, "OcoOrder": null, "Type": null, "ExpiryDateTimeUTC": null, "Applicability": "GTC", "TriggerPrice": 1.9939, // open price of parent order "BidPrice": 2.43708, // dummy "AutoRollover": false, "MarketId": 401484388, "OfferPrice": 2.43708, // dummy "AuditId": "a8aaec68-2957-45d8-b89f-bd1ffc58d67a", "OrderId": 711777646, "Currency": null, "Quantity": 1000, "QuoteId": null, "LastChangedDateTimeUTC": null, "PositionMethodId": 1, "TradingAccountId": XXXX, "Status": null, "isTrade": true } // Response { "Status": 1, // OK "StatusReason": 1, // OK "OrderId": 711777646, // Parent Order Id "Orders": [ // parent order details { "OrderId": 711777646, // order id "StatusReason": 1, // ok "Status": 3, // open "OrderTypeId": 1, // trade "Price": 1.9939, // order price "Quantity": 1000.0, // qty "TriggerPrice": 0.0, "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false }, // stop { "OrderId": 711777649, // stop order id "StatusReason": 1, // ok "Status": 2, // accepted "OrderTypeId": 2, // stop "Price": 0.0, "Quantity": 1000.0, "TriggerPrice": 1.9922, // stop price "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false } ], "Quote": null, "Actions": [], "ErrorMessage": null } // update stop loss { "IfDone": [ { "Stop": { "ExpiryDateTimeUTC": null, "Guaranteed": false, "Direction": "sell", "Quantity": 1000, "Applicability": "GTC", "TriggerPrice": 1.99380, // updating price to 1.99380 from 1.99220 "OrderId": 0 } } ], "Direction": "buy", "ExpiryDateTimeUTCDate": null, "LastChangedDateTimeUTCDate": null, "OcoOrder": null, "Type": null, "ExpiryDateTimeUTC": null, "Applicability": "GTC", "TriggerPrice": 1.9939, "BidPrice": 2.43708, "AutoRollover": false, "MarketId": 401484388, "OfferPrice": 2.43708, "AuditId": "462d21b4-5ec9-4ab9-a32e-0545c299bda2", "OrderId": 711777646, "Currency": null, "Quantity": 1000, "QuoteId": null, "LastChangedDateTimeUTC": null, "PositionMethodId": 1, "TradingAccountId": XXXXX, "Status": null, "isTrade": true } // response FAIL { "Status": 2, // Red Card "StatusReason": 75, // Check the values "OrderId": 711777646, "Orders": [ { "OrderId": 711777646, "StatusReason": 1, "Status": 3, "OrderTypeId": 1, "Price": 1.9939, "Quantity": 1000.0, "TriggerPrice": 0.0, "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false } ], "Quote": null, "Actions": [], "ErrorMessage": null }
  10. Watchlist retrive market information

    Hello, Good to see you already spotted the solution. Since you are POSTing the call, the parameter is added in the POST body instead of in the query string. Kind Regards, PM
  11. Watchlist retrive market information

    hurk I need to use post method as mentioned in docs (only starting REST programing) so code would look like this: data_json = {'IncludeMarketInformation':'True'} full_url='https://ciapi.cityindex.com/TradingAPI/watchlists' r_post = self.session.post(url=full_url, json=data_json)
  12. Hi, On python I am trying to to get all my wathclists WITH the market information for each item in a list. In order to get the list of all my watchlist I use the following URL: https://ciapi.cityindex.com/TradingAPI/watchlists Which does return a list of wathclist dict. When i try and have the market information included i use the following URL: https://ciapi.cityindex.com/TradingAPI/watchlists?IncludeMarketInformation=True Which does not return the market information for each items in my list. Any what is wrong in my URL? I use the following docs: http://docs.labs.cityindex.com/#HTTP Services/GetWatchlists2.htm?Highlight=watchlist http://docs.labs.cityindex.com/#Data Types/ListWatchlistRequestDTO.htm#kanchor1406 Thank you
  13. Not able to set the stop loss

    Hi Danilo, I see 2 anomalies in the pasted JSON request and response that is most puzzling indeed. The request is to place an entry order to Sell with quantity 2 should the market price reach 1.99237. Yet the response is that of a trade where you have opened a position at 1.99237 with quantity 1000!?! 1) How did you manage to send an entry order that results in placing a trade with an open position instead? 2) How did sending the entry order request with quantity = 2 result in a trade with open position quantity = 1000? The only thing we have managed to answer is why the stop loss attached is accepted in this case. It is because the open position has quantity = 1000 and the stop loss quantity also = 1000, so you do not receive the Error 75 as you did in the previous case. My suggestions are to ensure that you are sending the entry order requests to the /newstoplimitorder endpoint, and to ensure that the quantities of the stop loss and entry orders are equal. This will result in a full close should the stop loss order be triggered. The system will never accept orders when you have an open position of quantity = 2 and a stop loss of quantity = 1000. Kind Regards, PM
  14. Thanks for your reply. But I see another request with same diff is worked fine { "IfDone": [ { "Stop": { "ExpiryDateTimeUTC": null, "Guaranteed": false, "Direction": "buy", "Quantity": 1000, "Applicability": "GTC", "TriggerPrice": 1.99467, "OrderId": 0 } } ], "Direction": "sell", "ExpiryDateTimeUTCDate": null, "LastChangedDateTimeUTCDate": null, "OcoOrder": null, "Type": null, "ExpiryDateTimeUTC": null, "Applicability": "GTC", "TriggerPrice": 1.99237, "BidPrice": 2.43708, "AutoRollover": false, "MarketId": 401484388, "OfferPrice": 2.43708, "AuditId": "a60a608e-5641-4a3d-9a50-a8bbf85ec9c0", "OrderId": 711005695, "Currency": null, "Quantity": 2, "QuoteId": null, "LastChangedDateTimeUTC": null, "PositionMethodId": 1, "TradingAccountId": 402373909, "Status": null, "isTrade": true } { "Status": 1, "StatusReason": 1, "OrderId": 711005695, "Orders": [ { "OrderId": 711005695, "StatusReason": 1, "Status": 3, "OrderTypeId": 1, "Price": 1.99237, "Quantity": 1000.0, "TriggerPrice": 0.0, "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false }, { "OrderId": 711005696, "StatusReason": 1, "Status": 2, "OrderTypeId": 2, "Price": 0.0, "Quantity": 1000.0, "TriggerPrice": 1.99467, "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false } ], "Quote": null, "Actions": [], "ErrorMessage": null }
  15. Not able to set the stop loss

    Hello, I "prettified" the JSON in your request and saw that the you did have mismatching trade quantities. Your entry order has a quantity of 2, whereas the stop you are trying to attach to the entry order has a trade size of 1000. The stop must have a trade size equal to the original entry order, if you want the stop to fully close, or less than the entry order size if your stop is only a partial close. Kind Regards, PM
  16. Hello , Please find request and response . Please have a look and let me know if what is wrong in it. Request - {"IfDone":[{"Stop":{"ExpiryDateTimeUTC":null,"Guaranteed":false,"Direction":"buy","Quantity":1000,"Applicability":"GTC","TriggerPrice":1.9621,"OrderId":0}}],"Direction":"sell","ExpiryDateTimeUTCDate":null,"LastChangedDateTimeUTCDate":null,"OcoOrder":null,"Type":null,"ExpiryDateTimeUTC":null,"Applicability":"GTC","TriggerPrice":1.9629,"BidPrice":2.43708,"AutoRollover":false,"MarketId":401484388,"OfferPrice":2.43708,"AuditId":"bb2ad99c-354e-4acc-a9aa-429bafd2057c","OrderId":709910755,"Currency":null,"Quantity":2,"QuoteId":null,"LastChangedDateTimeUTC":null,"PositionMethodId":1,"TradingAccountId":402373909,"Status":null,"isTrade":true} Response {"Status":2,"StatusReason":75,"OrderId":709910755,"Orders":[{"OrderId":709910755,"StatusReason":1,"Status":3,"OrderTypeId":1,"Price":1.9629,"Quantity":1000.0,"TriggerPrice":0.0,"CommissionCharge":0.0,"IfDone":[],"GuaranteedPremium":0.0,"OCO":null,"AssociatedOrders":{"Stop":null,"Limit":null},"Associated":false}],"Quote":null,"Actions":[],"ErrorMessage":null}
  17. Python Library for GC API

    Hi Ricky, Many thanks for sharing the Library, it's very kind of you! I'm sure other Python users will be very appreciative of your generosity! Kind Regards, PM
  18. Hi, I have just made a python library for trading with GC API because I could not find one: https://github.com/rickykim93/gcapi-python I use this to forward test my strategies. Let me know if anyone is interested in seeing examples of using this such as calculating RSI, scraping, news reaction,etc (should I add in documentation or as code contribution in like a "example" folder?) and feel free to contribute or provide suggestions/improvements. Thanks.
  19. Not able to set the stop loss

    Hi Danilo, Is that OrderStatusReason code 75 you are talking about or InstructionStatusReason code? OrderStatusReason code 75 states "The total quantity of guaranteed stop orders must be equal to trade order quantity." Have you accidentally set the total quantity of all your stops to be greater than the total position you have open? You can find all the lookup codes at: http://docs.labs.gaincapital.com/#APICodesList.htm%3FTocPath%3DGetting%20Started|Lookup%20Values|_____1 If it is the InstructionStatusReason code of 75 you are receiving, then what is the corresponding OrderStatusReason code? The OrderStatusReason code provides the explanatory information as to why your orders were rejected/failed. Kind Regards, PM
  20. Hello Setting of stop loss limit starts failing with reason code 75. tried contacting support and they informed that this restriction is applied to account registered for UK and non UK accounts does not have this restrictions. They created a new practice account for us to solve this issue and it worked for some days but all of sudden I start getting status code 75 again. Any lead on this behavior or solution to the problem? Thanks
  21. GCAPI REST Details

    Hi Jflaggs, There isn't an error on your side. The quote you are referring to is talking more about the minimum time frame you can expect a session to be active, if the user does not manually log out. We run a task to clear out any leftover sessions on the back-end every so often, but until that task is run a session will remain open unless the user has manually closed it. This is why you are still seeing open sessions. Kind Regards, PM
  22. GCAPI REST Details

    Thanks for your insight. Regarding issue number 2, I can come up with an algorithm to manually manage user sessions. However, my issue still exists that my session token has now been active for about 2 weeks but you gave a previous answer that "If you close the connection without logging off, then the ID will generally be valid until end of day". Is there anything I can do on my side to prevent this discrepancy? It seems like this might be a server side bug. Please note this is for the Live endpoint and again, I've yet to see it expire after 2 weeks. Forum Discussion "Session Expiration": http://faq.labs.gaincapital.com/topic/1915-session-expiration/?tab=comments#comment-3369
  23. GCAPI REST Details

    Hello JFlaggs, 1) The REST API is not designed to update live market prices by calling for example GetLatestPriceTicks repeatedly. These calls are designed for retrieving price history to use in analysis etc. You should use the Streaming part of the API via the 3rd part Lightstreamer. Subscribe to the markets that you wish to view live streaming prices, and they are then streamed to you updating as the market prices update. 2) We don't have a call to retrieve all active sessions for a given user name. The closest we have is by using the ValidateSession call to check whether a session is still active for a given username. To delete a session manually, use the DeleteSession call for each session that you wish to close. 3) Throttling / Rate Limitation is mentioned in the section at the bottom of the GCAPI Basics page. Kind Regards, PM
  24. Price Alerts: Post fail

    Hi Bryson, Many thanks for updating us and we're happy to hear that you solved it. We very much appreciate your feedback regarding the API documentation - it is very helpful! A note has been made to improve it along the lines you have suggested at the next documentation refresh. Kind Regards, PM
  25. Get Order ID

    Hi M133, If you send a ListOpenPostions call, this returns all your current open positions including the Order IDs. Similarly, sending a ListActiveStopLimitOrders call will return all your active orders including the Order IDs. Kind Regards, PM
  26. Hello,I have some questions regarding implementation of the GCAPI. I am implementing a REST only client. Please confirm which API call is appropriate forgetting the most up to date price values periodically at ~100 milliseconds. Currently I am making calls to the following endpoints to update the client application. Please advise which is most appropriate or if they are equivalent. Is there a way to get all active sessions for a given user name and app key? During development I have created multiple sessions and they have all been active for about three days now. I would like to delete all client sessions. The documentation states that "You can manually delete a Session token, or leave it to be automatically deleted". The forum discussion also states that "If you close the connection without logging off, then the ID will generally be valid until end of day". But again, I have seen several session tokens remain valid for three days (and counting) which is not acceptable for my client application. An example situation might be: A user logs in and a token is created. Later, the application crashes without logging out. The user restarts the application, and a new session token is created. Now there are TWO valid session tokens active, however, the user can only log out from ONE. Please advise on how to delete all sessions upon logging out. What is the policy for API call frequency? Typically, API documentation has explicit limitations for how frequently you can make calls to a particular endpoint (usually based on the weight of each API call) before the session or IP address is automatically rate-limited by the server. Where can I find this information in the GCAPI documentation? Thanks a bunch for your help.
  27. Price Alerts: Post fail

    Thanks for your help. Turns out the thing that I was missing was that I was putting the payload as Parameters. When I moved the data to the body of the json send it worked just fine. I have checked the API docs again, and I note that the documentation refers to parameters, but in this case makes no mention of placing the contents in the json body. Further, the documentation does not provide an example in this case as it does for many other scripts. I have found the examples in the past very useful. Would recommend an update to make that particular reference page a little clearer! Appreciate the help all the same. Your example above is what prompted me to try placing the data in the body. Regards, Bryson.
  1. Load more activity