wertmandu 1 Report post Posted January 4 Hello I have been running into the following json response when my program is attempting to close a position: {"Status":2,"Quote":null,"Orders":[{"Status":10,"CommissionCharge":0,"Associated":false,"StatusReason":81,"AssociatedOrders":{"Stop":null,"Limit":null},"Quantity":0,"OrderId":0,"TriggerPrice":0,"GuaranteedPremium":0,"IfDone":[],"Price":0,"OrderTypeId":1,"OCO":null}],"Actions":[],"StatusReason":75,"OrderId":0,"ErrorMessage":null} So far I have gathered that it means something with Web Min Size. My question is what is Web Min Size? My call on my java backend looks like this: String TradeBaseUrl = "https://ciapi.cityindex.com/TradingAPI/order/newtradeorder/"; CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost postRequest = new HttpPost(TradeBaseUrl + "?UserName=" + username + "&Session=" + session); String direction; if(tradeType.contentEquals("BULL")) direction = "sell"; else if(tradeType.contentEquals("BEAR")) direction = "buy"; else direction = "Not Determined"; String jsonBody = "{" + "\"MarketID\": " + marketID + ", " + "\"Direction\": \""+direction+"\", " + "\"BidPrice\": " + bidPrice + ", " + "\"OfferPrice\": " + offerPrice + ", " + "\"Quantity\": " + quantity + ", " + "\"OrderID\": "+openingID+", " + "\"positionMethodId\": 1, " + "\"TradingAccountId\": " + tradingAccountID + ", " + "\"MarketName\": \"" + marketName + "\", " + "\"isTrade\": true" + "}"; I only started to get these errors when I started testing with quantities greater than 1000. Share this post Link to post
wertmandu 1 Report post Posted January 7 After finding a post from 2019 with user OldWiseAndExperienced, I see that it might have an issue with Quantity, but as I said before I have had success opening and closing trades when it was just 1000 lots. Now I am experimenting with larger quantities between 2000 ~ 3000 + and now I am running into this error. Can anyone provide more information? Here is another example call from Postman that sometimes returns a valid trade close and other times gives me an 81: Position below Web Min Size. "MarketId": 401449252, "MarketName": "GBP/USD", "Direction": "buy", "BidPrice": 1.35646, "OfferPrice": 1.35677, "OrderId": 773976947, "Quantity": 2461, "TradingAccountId": *****, "isTrade": true, "PositionMethodId": 1, "Close": [773976947] I am running out of ideas. If anyone knows anything please let me know. Share this post Link to post
Physicsman 25 Report post Posted January 19 Hello, In your first post, you pasted the JSON response received from the servers. I note that the Quantity field has a value of zero, hence the error code that it is below the minimum trade size. Are you sending a trade close request without a Quantity value? You need to send in the position size you are closing in your close trade request. Quote {"Status":2,"Quote":null,"Orders":[{"Status":10,"CommissionCharge":0,"Associated":false,"StatusReason":81,"AssociatedOrders":{"Stop":null,"Limit":null},"Quantity":0,"OrderId":0,"TriggerPrice":0,"GuaranteedPremium":0,"IfDone":[],"Price":0,"OrderTypeId":1,"OCO":null}],"Actions":[],"StatusReason":75,"OrderId":0,"ErrorMessage":null} Kind Regards, PM Share this post Link to post
wertmandu 1 Report post Posted January 20 I will check to see the code is in fact grabbing the quantity correctly, however I believe that I have not made any changes in that respect for creating the json to send. On the other hand I have only just recently began testing with quantities larger than 1000. I will report back if it is an error with my code attempting to send incorrect information. 1 Physicsman reacted to this Share this post Link to post
wertmandu 1 Report post Posted January 20 I have looked over it and have concluded that I am getting the right quantity size for the call, however now I am noticing a new response like so: {"Status":4,"Quote":null,"Orders":[],"Actions":[],"StatusReason":61,"OrderId":0,"ErrorMessage":null} and dock.labs.gaincapital.com is down, do you know what that one particularly means? Share this post Link to post
Physicsman 25 Report post Posted January 20 Hello, The API documentation site is down temporarily and will be up again hopefully next week. In the meantime, please use the attached PDF file, which is a full export of the documentation from the site. Once the site is back online then you can use that again. I think it will be most helpful to troubleshoot, if you show me the JSON request you are sending to close the trade and the response you receive back from the server. Additionally, if and only if you are using a DEMO account (not a real Live money account), then you can send me via private message your account credentials. I can then try placing a trade and closing the position on the account using API commands. Kind Regards, PM CIAPI User Guide.pdf Share this post Link to post