tscreators 1 Report post Posted June 13, 2018 i am using this url its giving 404 error . var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://ciapi.cityindex.com/TradingAPI/order/newtradetorder"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; httpWebRequest.Headers.Add("UserName", "DM943054"); httpWebRequest.Headers.Add("Session", ConfigurationManager.AppSettings["sessionID"].ToString()); Share this post Link to post
Physicsman 25 Report post Posted June 13, 2018 Hi, When logging into the REST part of the API, or when sending account credentials to the REST API with any call - you use the account password. The call you are trying to make is to the REST API so will required your actual account password and not the SessionID. It is only when logging into Lighstreamer, that the SessionID is used as the password. Kind Regards, PM! Share this post Link to post
tscreators 1 Report post Posted June 13, 2018 hi , i am getting same error after using my actual password . let me know if username password wrong then it will show page not found 404 ? . as i know 404 mean url not located . thanks regards tscreators Share this post Link to post
Physicsman 25 Report post Posted June 13, 2018 Hi, I just spotted the problem - it's a pesky typo. In your pasted code you have: (HttpWebRequest)WebRequest.Create("https://ciapi.cityindex.com/TradingAPI/order/newtradetorder"); newtradeorder has an extra "t" after trade and before order. Deleting the extra "t" should resolve the problem. Kind Regards, PM! Share this post Link to post
tscreators 1 Report post Posted June 13, 2018 hi , kindly update this issue in your http://docs.labs.cityindex.com/#How Do I/Trades Orders.htm%3FTocPath%3DHow%20Do%20I...%3F|_____4 url in document because T already there . regards tscreators Share this post Link to post
Physicsman 25 Report post Posted June 14, 2018 Hello, Thanks for informing us - will have the typo corrected for the next refresh. Kind Regards, PM! Share this post Link to post
tscreators 1 Report post Posted June 14, 2018 hi there , i am getting 401 authorization error . POST https://ciapi.cityindex.com/tradingapi/order/newtradeorder?UserName=*****&session=******* i used session and password both but still showing error . same session value i used to get TradingAccountId and its working . regard tscreators Share this post Link to post
Physicsman 25 Report post Posted June 14, 2018 Hi, A 401 HTTP status code usually indicates that the session token has expired. Please send a call to /session to "logon" to the API and read the new session token from the response. You can then use the new session token in your order call. Kind Regards, PM! Share this post Link to post
tscreators 1 Report post Posted June 14, 2018 hi , still showing same issue . when i use this url with get its working fine https://ciapi.cityindex.com/TradingAPI/useraccount/ClientAndTradingAccount?UserName=DM943054&session=" + session while i am using this url with post its showing 401 unauthorized https://ciapi.cityindex.com/tradingapi/order/newtradeorder?UserName=DM943054&session=" + session even i check with postman its showing error kindly check it on your end . its working or not . regards tscreators Share this post Link to post
Physicsman 25 Report post Posted June 15, 2018 Hi, I used Postman to successfully place a trade using /newtradeorder. Details below. Request Headers Request Body Response Body Finally, I checked on our web platform for this account and can see the open position that was just placed using the API call via Postman as detailed above. Share this post Link to post
tscreators 1 Report post Posted June 18, 2018 Hi, Streaming data changing so quickly due to this when i am giving order its not working. Is there any parameter which i will use to select order on current bid if its not matched to my selected value Share this post Link to post
Physicsman 25 Report post Posted June 19, 2018 Hi, There is a PriceTolerance parameter in the NewTradeOrderRequestDTO that you send in the trade request. The parameter controls the amount of slippage you are willing to accept to successfully execute a trade. If you have code that automatically reads in the prices and then sends a trade request automatically, it should usually send it in time to have a valid price from the incoming stream. Obviously, this depends upon the market and how busy it is at that moment in time. Kind Regards, PM! Share this post Link to post
tscreators 1 Report post Posted June 19, 2018 hi , http://prntscr.com/jwu7yx in above url there is screenshot from where you can see the result even i used PriceTolerance default value 2 , still i am getting same error regards tscreators Share this post Link to post
Physicsman 25 Report post Posted June 20, 2018 Hi, Thank you for sending the screenshot - it helps greatly. The returned OrderStatusReasonCode of 10 is bizarre since that indicates the market is closed! However, you are trying to trade the spot USD/JPY market which is open 24hours during weekdays. The API lookup codes are documented at API Lookup Codes. Using my account I've successfully placed a trade in that market. To help with troubleshooting: 1) Please send the entirety of your trade request body so I can see and check each of the properties and values you are using in your trade request. For example, the pasted image below is the trade request body I used to successfully place a trade in the USD/JPY spot market. 2) Send my by private message the credentials for your demo account that you are using. I want to use that account and see if I can place the trade again in that market and see what happens. Kind Regards, PM! Share this post Link to post
tscreators 1 Report post Posted June 20, 2018 hi there , i am using this json mention below { "IfDone":null, "Direction":"buy", "ExpiryDateTimeUTCDate":null, "LastChangedDateTimeUTCDate":null, "OcoOrder":null, "Type":null, "TriggerPrice":null, "BidPrice":1.31728, "MarketId":401449254, "OfferPrice":1.31741, "OrderId":0, "Currency":null, "Quantity":1000, "LastChangedDateTimeUTC":null, "PositionMethodId":1, "TradingAccountId":401384419, "MarketName":"USD/JPY", "Status":null} regards tscreators Share this post Link to post
Physicsman 25 Report post Posted June 20, 2018 Hi, I found the error. Your bid and offer prices are not the current bid/offer prices for the USD/JPY market. It appears you have entered the prices for GBP/USD or some other market. I've successfully placed a trade using your account credentials and the entirety of the JSON you posted above, changing just the bid/offer prices to the current bid/offer (at the time of writing) for USD/JPY. You can see the trade open and close in your account history now. Normally, you want to subscribe to the live streaming prices for the markets you are looking to trade (via Lightstreamer), read in the current bid/offer prices and use those values in the BidPrice and OfferPrice fields of your trade request. { "IfDone":null, "Direction":"buy", "ExpiryDateTimeUTCDate":null, "LastChangedDateTimeUTCDate":null, "OcoOrder":null, "Type":null, "TriggerPrice":null, "BidPrice":110.09, "MarketId":401449254, "OfferPrice":110.10, "OrderId":0, "Currency":null, "Quantity":1000, "LastChangedDateTimeUTC":null, "PositionMethodId":1, "TradingAccountId":401384419, "MarketName":"USD/JPY", "Status":null } Kind Regards, PM Share this post Link to post
tscreators 1 Report post Posted June 20, 2018 hi there , thank you very much now its working . regards tscreators 1 Physicsman reacted to this Share this post Link to post
greig 0 Report post Posted June 20, 2018 Hi, When i take a position manually and "Hedge" is set to yes as default on the demo, I can go long and short at the same time. However when i take a position via the API it does not hedge so I can not go long and short and the same time. Even though the default setting on the account is set to yes. I cannot see a field when taking a position for this. Please can you advise where I need to change to ensure this will Hedge as per the account manually. Thanks Share this post Link to post
Physicsman 25 Report post Posted June 21, 2018 Hello, In your trade or order request, set the property PositionMethodId == 2. This enables hedge mode so that you can have simultaneous open long and short positions in the same market. The default value of this property is 1, which is non-hedge mode allowing only long OR short positions in a market at one time. Kind Regards, PM Share this post Link to post