Jump to content

All Activity

This stream auto-updates     

  1. Yesterday
  2. Hello, If you are trading the bot for your own account then no, you do not require a license. Kind Regards, PM
  3. UpdateTrade

    Hi Garrett, It does appear to be missing square brackets is the culprit. Glad you managed to spot this and hope it has fixed the problem already. If it is still causing an error please inform us and we can investigate further. Kind Regards, PM
  4. Last week
  5. I was reading an article about developing a trading platform for other people requiring a license, but didn't see anything about an individual needing one for his own bot to trade his own retail account, but just wanna double check. Does my bot require registration / licensing before I can trade this live because it deals with money??
  6. UpdateTrade

    EDIT: Forgive me - it looks like this issue has already been addressed here: I need to be more diligent in looking through past threads before posting! Lol. Anyway, I didn't even think to check the JSON formatting, as I'm using probably the most popular of serializer libraries for the language I'm writing in (Newtonsoft.Json for C#). When in doubt, double check your syntax! I can't test this right now, as markets are closed, but if this doesn't solve it come Monday (which would be very surprising), I'm sure I'll be back.
  7. Cancel Order

    Hi Garrett, Very hppy to hear you managed to figure out the problem and fix it. Glad that I could be of a little help. Kind Regards, PM
  8. Cancel Order

    Hi PM, Thank you for digging in to all this. I tried replicating your calls, and still was unsuccessful in calling /order/cancel and /order/updatestoplimitorder, even with identical parameter and header signatures. This made me really dig through my application, and I finally figured out what the issue was. As it turned out, while the headers were "correct", due to a quirk in how I had written the wrapper methods to call those endpoints, the Session token was being appended to the Session header twice just before the call took place. So, it looked like this: "Session: {token}{token}". Obviously, incorrect. Lol. Once I fixed that, the calls worked as intended. I feel a bit silly. Thank you for taking the time to dig through it. Garrett
  9. Cancel Order

    Hi Garrett, Using the account details you kindly provided, I performed the following steps in the Postman API development tool. 1) Placed an entry order. 2) Cancelled the order that I just placed in step 1. NOTE: the headers used in calls 1, 2 and 3 are the same. 3) After placing a new entry order again, I then sent an /updatestoplimitorder call to modify the entry order. Important note: this call is only used to modify entry orders. If it is a stop loss or take profit limit order attached to an open position that you want to edit, use the /updatetradeorder call. Please try sending your calls using the same set of parameters/headers to see if you can replicate these successful calls. Kind Regards, PM
  10. Cancel Order

    Hi, Are you using a test or demo (NOT a live real money) account for your development? If it is a test/demo account only, please send me a private message with the account credentials. I can use it to send some cancel and update order calls to observe what happens. Many thanks, PM
  11. Cancel Order

    Hi PM, Thanks for your reply. I was actually already including the authentication information in the headers, as well as in the POST body. I've removed it from the body, so it's solely being sent in the headers now, but I'm still having the same issue. Strangely, my call to /order/newstoplimitorder is working fine, but /order/updatestoplimitorder and /order/cancel are returning Unauthorized, even though I'm using the same username and session token. Any ideas as to what could be causing the issue? Thanks!
  12. Earlier
  13. Cancel Order

    Hi, I see that you are including the authentication data in the POST body. The authentication information should be sent in the headers or in the query string, NOT in the POST body. Please try moving the authentication out of the body and into the header and that should resolve the issue. Kind Regards, PM
  14. Cancel Order

    Unfortunately, I seem to be having the same problem with calling /order/updatestoplimitorder now as well. :/ Please help!
  15. Cancel Order

    Hi there, I have a series of unit tests that run against the methods I've written to call various GCAPI methods. One part of this series tests my methods to call the various Trade/Order endpoints. First, I call /order/newstoplimitorder and successfully place a new resting entry order. After a few other things, I call /order/cancel on the entry order (only if the order hasn't already been triggered). This is where I'm getting a little stuck. I'm using all the properties described in the documentation, including the Username and Session token I received on authorization (included both in the POST JSON data, and as separate headers). My OrderId property is the order id I received from opening the entry order, and the TradingAccountId was received from calling /UserAccount/ClientAndTradingAccount. This Account id was also successfully used to place the entry order. Despite all this, I'm still receiving 401 response codes when calling /order/cancel. Here is the POST packet: "{\"OrderId\":724499552,\"Reference\":\"Trade #724499552 setup invalidated\",\"UserName\":\"********\",\"Session\":\"a52f7a51-c01d-4a81-a6db-82eb37c70d06\",\"TradingAccountId\":*********}" Can you tell me what I'm doing wrong? Thanks! Garrett
  16. Hello, Chart indicators are not an object or service that is requested from the API. They are calculated based on the price data using the formula specific to the indicator. A couple of places that provide the formula to calculate the EMA: https://www.investopedia.com/terms/e/ema.asp https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average Kind Regards, PM
  17. I'm just trying to fetch the exponential moving average for a specific currency and timeframe from the api. Is this mentioned somewhere in the docs? I couldn't find it thanks..
  18. 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.
  19. Visual Basic .NET

    Hello, The documentation for the API is at: http://docs.labs.gaincapital.com/ Unfortunately, it does not provide a guided tour or examples of how to build an application in VB.NET to perform the operations you described. The API is designed for experienced developers to use. Kind Regards, PM
  20. I would like to create an application in Visual Basic .NET that gets streaming quotes, places orders, sets stops, etc. Does anyone have experience doing this? There doesn't seem to be much documentation or examples out there. Thanks!
  21. Hi Tiger, I think the main issue with the snippet above is that you are trying to connect to the Pre-Production Environment (PPE) rather than the Live environment. Accounts are not cross compatible across environments - hence the 401 Unauthorized. PPE is used internally only, so your account (whether a demo or actual Live account) can only connect to the Live environment. Try switching the URL to the Live environment: https://ciapi.cityindex.com/tradingapi/ Kind Regards, PM
  22. Hello, I am mainly a database and desktop application developer, so REST API is new to me. When using the below C# code I keep getting error 401 - Unauthorized back. Is the code even remotely close to trying to obtain a valid token? I added XXXX instead of the actual credentials. Do you have a full example like below that will get a token back? string myJson = "{'Username': 'DAXXXXXXX','Password':'XXXXXX','AppKey':'K.XXXXXX'}"; using (var client = new HttpClient()) { var response = await client.PostAsync( "https://ciapipreprod.cityindextest9.co.uk/TradingAPI/session", new StringContent(myJson, Encoding.UTF8, "application/json")); }
  23. UpdateTrade

    Hi, I have answers to your Q2 from and also Q4. Q4) Yes, you can have 2 Live accounts. I suggest contacting Client Services and ask them how you would go about opening a 2nd account when you already have one. They can then inform you of the process. Q2) The order stream contains the 3 responses. Since you are using the API and listening on the LS order stream you will receive a reponse for the Sell Limit order, position 1 being closed, and position 2 with the trade size modification. The reason why the web platform skips showing a notification of the position 1 close is because the order steam response for position 1 gives the opening price and not the closing price. We decided not to show this notification as it could confuse the client when they see the opening price rather than the closing price. Kind Regards, PM
  24. UpdateTrade

    Hello PM, First off, thanks so much for the prompt and clear replies. I really appreciate it! Yeah, as you pointed out, my systems could trade opposite directions, hedging/flatting my account position, while they each believe they are still in the market. Obviously I'm not making a lot of money when that's going on, but the systems do manage themselves and will close out what they think is their position at some point, always resulting in a true zero position in the platform. So I coded up a new workflow which I think solves most of my problems. When my platform submits an new order/trade via the REST APIs, it correlates the returned broker order ID to my platform's internal ID. I track those orders, including those which were last known as active. Any time I get an order update via the LS interface, I query the REST APIs for all active orders. I compare the new list of active orders vs my most recent list of active orders. Determine what's gone, whether or not it was because they were filled or cancelled, and forward the updates to my platform. I then also go through the active orders and make sure they are in the same state they were last time I tracked them. Any changes are forwarded to the platform. This seems to get past a lot of the issues. It's not pretty/ideal, but not dealing with a pretty/ideal situation (special thanks to my government!). What it doesn't solve is the opposite order sizing issue. AKA question #3 above, which you confirmed is the case. I'm left wondering if I should open a second trading account if I really want/need to go both directions as a US customer. I could set the platform to use account X for all systems attempting to long the market and account Y for all systems attempting to short the market. When running lots of systems together in the past, I have been put in the market both directions, sometimes with varying contract sizings, on the same forex pair. Trying to get ahead of that, even if the answer is there is simply no way to do it. That leaves me with question #4 ... can an individual have two accounts? Thanks!
  25. UpdateTrade

    Hi, Since my reply to your Q1 is related to my answer to Q3, I shall answer Q3 first then Q1. 3) Yes this is expected behaviour. Several years ago, the US regulator passed a rule/law that forbade US clients from opening simultaneous long and short positions in the same Forex pair, which in the spot Forex world is known as "Hedging". Additionally, this lead to the First In First Out (FIFO) rule, where if you have multiple buy trades in GBP/USD for example, placing sell trades always closes the first trade you opened, then the 2nd etc. 1) As you mentioned in your Q3, your systems may trade in opposite directions in the same market. This could lead you to being flat a market whereas your systems "think" you have 2 positions open. EG: system 1 buys 10,000 in GBP/USD and then a little later system 2 sells 10,000 in GBP/USD. Your account is now actually flat with zero open position in GBP/USD. Hence, trading multiple systems on the same market is not advisable. Better would be 1 trading system per forex pair so that they never interfere with each other. From what you wrote (quoted below), it sounds as though you are thinking of mapping the close trade to system Y instead of booking it to X, even though the fill notification is for X? I think this could get very confusing if you have multiple open positions (in the same direction of course) for both System X and Y. I'm sorry it couldn't be better news, but our hands are tied by the regulators in this case. Will update you on Q2 as soon as I hear back from the dev team. Kind Regards, PM
  26. UpdateTrade

    Hello, Quick post to keep you updated. For question 2, I passed that on to the development team to look into and will reply when I have their answer. I'm also looking at your questions 1 & 3 and will reply again when I have a response to those as well! Kind Regards, PM
  27. UpdateTrade

    PM, Thanks for the response. The US client rules make it quite difficult to code multiple algorithms to trade against the APIs. I'll take some solace in the fact that I'm seeing what's expected, I suppose The platform I've written runs many systems at the same time. This US client mechanic is problematic. If system X enters the market, then system Y enters the market, then system Y hits an exit condition, I'll see system X's orders get the fill notifications. I've been playing with some other angles of attack. The platform keeps records of all orders it places. My best thought at this point is to, any time I get an order update from LS, query the REST APIs for all active orders (including stops/limits). Compare what I know I've placed and was most recently active vs what I get back from the APIs. There's still room for error there, unfortunately. But it seems to be my best shot, from what I can tell. Question 1: Should there be any concerns with that that you know about? I have another question as well. I was testing out doing this in some fashion last night and came upon another mechanic that surprised me. Here's what I did: Placed a market buy for 1000 on the GBPUSD Placed a market buy for 1000 on the GBPUSD Placed a market buy for 1000 on the GBPUSD Placed a sell limit for 1500 on the GBPUSD I wanted to see if I'd get the first order's position fully closed + the second order's position half closed. I did confirm that through the web interface - when my sell limit triggered, the first buy closed completely and the second buy had half quantity remaining. What surprised me was that I didn't receive any notification on the first order being filled. When my sell limit triggered, my platform only received a notification of the second market buy having half of its position closed. There was nothing about the first order sent back to me at any point. Question 2: Is that expected? Even if, as a US client, I'm forced to move against my position by forex pair, it seems odd that I wouldn't get a notification when one of my orders gets closed. If this is expected, can you suggest how I should determine what I got filled at on the closed position I got no callback on? Is it safe to assume the fill price is exactly the same as the order I did get a callback on? Do I have to query a closed order API or something along those lines? Last question. If I do the same setup as above - put three market buy orders on for 1000 on the GBPUSD, it seems I can't then put on a market sell order against the GBPUSD for any position which does not fully close one or more of those original market buy orders. In other words, I can't put a market sell order on the GBPUSD for 1500 or 2250 or 750. I can only put it on for 1000, 2000, or 3000. Question 3: Can you confirm this is expected? This one seems particularly nasty in that if I have multiple systems running on my platform and one decides to short a given market while others are currently long - something which would not at all be unexpected with algorithmic trading - I could face rejections which interrupt trading. Sorry for all the questions. I've never faced so many oddities when integrating with a broker before. I understand it's my account limitations, being a US citizen, and not your platform. Just trying to figure them all out. I'm really being thrown for a loop! Thanks!
  1. Load more activity
×