Jump to content

Search the Community

Showing results for tags 'trade'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Gain Capital API FAQ
    • General Questions and Discussion

Found 5 results

  1. Hello, I have a service that opens new trades using the /newtradeorder endpoint. This is my request Json: { "Id":0, "IfDone":[ { "Id":0, "Stop":{ "Id":0, "Guaranteed":false, "TriggerPrice":null, "ExpiryDateTimeUTC":null, "Applicability":"gtc", "ParentOrderId":0, "TrailingDistance":10.0, "Associated":false, "Direction":"sell", "Quantity":1000 }, "Limit":{ "Id":0, "Guaranteed":false, "TriggerPrice":106.31527, "ExpiryDateTimeUTC":null, "Applicability":"gtc", "ParentOrderId":0, "TrailingDistance":null, "Associated":false, "Direction":"sell", "Quantity":1000 } } ], "Direction":"buy", "ExpiryDateTimeUTCDate":null, "LastChangedDateTimeUTCDate":null, "OcoOrder":null, "Type":null, "ExpiryDateTimeUTC":null, "Applicability":"gtc", "TriggerPrice":106.31527, "BidPrice":106.251, "AuditId":"LJ40690714", "AutoRollover":false, "MarketId":401484414, "OfferPrice":106.262, "OrderId":0, "Currency":null, "Quantity":1000, "QuoteId":null, "LastChangedDateTimeUTC":null, "PositionMethodId":1, "TradingAccountId":"<removed id>", "MarketName":null, "Status":null, "isTrade":false, "Json":null } Here's my response: { "Status":1, "StatusReason":1, "OrderId":754499310, "Orders":[ { "OrderId":754499310, "StatusReason":1, "Status":3, "OrderTypeId":1, "Price":106.262, "Quantity":1000.0, "TriggerPrice":0.0, "CommissionCharge":0.0, "IfDone":[ ], "GuaranteedPremium":0.0, "OCO":null, "AssociatedOrders":{ "Stop":{ "OrderId":754497194, "StatusReason":1, "Status":2, "OrderTypeId":2, "Price":0.0, "Quantity":9000.0, "TriggerPrice":106.151000, "CommissionCharge":0.0, "IfDone":[ ], "GuaranteedPremium":0.0, "OCO":{ "OrderId":754497195, "StatusReason":1, "Status":2, "OrderTypeId":3, "Price":0.0, "Quantity":9000.0, "TriggerPrice":106.31527, "CommissionCharge":0.0, "IfDone":[ ], "GuaranteedPremium":0.0, "OCO":null, "AssociatedOrders":{ "Stop":null, "Limit":null }, "Associated":true }, "AssociatedOrders":{ "Stop":null, "Limit":null }, "Associated":true }, "Limit":{ "OrderId":754497195, "StatusReason":1, "Status":2, "OrderTypeId":3, "Price":0.0, "Quantity":9000.0, "TriggerPrice":106.31527, "CommissionCharge":0.0, "IfDone":[ ], "GuaranteedPremium":0.0, "OCO":null, "AssociatedOrders":{ "Stop":null, "Limit":null }, "Associated":true } }, "Associated":false } ], "Quote":null, "Actions":[ { "ActionedOrderId":0, "ActioningOrderId":0, "Quantity":1000.0, "ProfitAndLoss":0.0, "ProfitAndLossCurrency":null, "OrderActionTypeId":1 } ], "ErrorMessage":null } The issue: I am trying to open multiple positions (long and short) on the same market. Each of these new positions should have its own unique Stop/Limit with different trigger prices. What is happening now is that any position I open on the same market seems to get overridden by each other. For example: if I open multiple short and long positions in the same Market-- they all seem to default to one position with the same limit and stop: I am wondering what I am doing wrong with my request? Regards, Rony
  2. In a java machine, I am trying to open up trades at specific positions. For the past few weeks I have been having trouble when I have positions opening pips away from the given opening price (IE: We try to call to open a trade on the EUR/USD for 1.11070 and the price it opened at was 1.11062, or 1.10162 opening at 1.10251) We are streaming prices with a light streamer process but our listings are stored in a database filled out by the end user so as of right now there is a query to get information to plug into a trade but the data is going directly into the process that fires the http call. I don;t know if I need to find a faster way of getting information or is this an issue going to Forex's side. A snippet for reference: String response = null; String trade_sql = "SELECT * FROM Listings WHERE "+ "Listings.entry_point = "+offer_price+ " AND Listings.status = 'NOT OPEN' "+ "AND Listings.auto_flag = 'AUTO';"; resultset rs = execQuery(trade_sql); while(rs.next()) { //openTrade(string username, string session, double bidPrice, double entryPoint, int quantity, string marketName, int marketID) response = openTrade(username_cache, session_cache, trading_account_cache bid_price, rs.getDouble("Listings.entry_point"), rs.getInt("Listings.lot_size"), rs.getString("Listings.currency_pair"), rs.getInt("Listings.marketID")); break; } if (response != null) { //Update Listings table and record a log. } // OpenTrade code public static String openTrade(String username, String session, String tradingAccountID, double bidPrice, double entryPoint, int quantity, String marketName, int marketID) { String TradeBaseUrl = "https://ciapi.cityindex.com/TradingAPI/order/newtradeorder"; CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost postRequest = new HttpPost(TradeBaseUrl + "?UserName=" + username + "&Session=" + session); String jsonBody = "{" + "\"MarketID\": " + marketID + ", " + "\"Direction\": \"buy\", " + "\"BidPrice\": " + bidPrice + " , " + "\"OfferPrice\": " + entryPoint + " , " + "\"Quantity\": " + quantity + " , " + "\"OrderID\": 0, " + "\"positionMethodId\": 1, " + "\"TradingAccountId\": " + tradingAccountID + ", " + "\"MarketName\": \"" + marketName + "\", " + "\"isTrade\": true" + "}"; try { postRequest.setEntity(new StringEntity(jsonBody, ContentType.APPLICATION_JSON)); CloseableHttpResponse response = httpclient.execute(postRequest); if (response.getStatusLine().getStatusCode() == 200) { String responseBody = EntityUtils.toString(response.getEntity()); JSONObject json = new JSONObject(responseBody); return json.toString(); } else { System.out.println(response.getStatusLine()); } } catch (IOException e) { System.out.println(e.getMessage()); } finally { try { httpclient.close(); } catch (IOException e) { System.out.println("GainCapitalAPI: ERROR: " + e.getMessage()); } } I don't know if I am going too slow or what my problem is. If anyone could help me out I would be much appreciated.
  3. Hi PM, One of our clients are trying to place a trade and they are getting the trade rejected with a response of: 'Market specification blocked for account operator' Tried to look for this on the api documentation, can you please explain what this means? Kind regards, Kush
  4. The New Trade documentation and the API documentation show several conflicting examples of the inputs contained in the NewTradeOrderRequestDTO which are required for a Market Trade Request to be completed. From what I have read the required inputs are : "MarketID", "OfferPrice", "BidPrice", & "AuditID" are required. I assume what is also required is 'Direction", "Quantity" and "TradingAccountID" and "PriceTolerance" which would be needed to place the trade correctly. However do I need to also include "AutoRollover", "QuoteId", "Close", "Currency" and "Reference" ? I am looking for the bare minimum. I see clearly that the Optional parameters are also "Source", "OrderReference" and "IfDone" so I know I don't need those. Thanks,
  5. Financing

    I notice that on the web interface, I can see the overnight holding charges and cost associated with guaranteed stops. I've looked in all the documentation on the API, and can see nothing that seems appropriate. Does this functionality exist through the API? If so, how do I access this? If not, will this feature be available in the near future?
×