Jump to content

Recommended Posts

Hi, I searched and tried, I can't figure out how to simply place a trade.

I want to place a trade by simply giving the Currency, Quantity,  and add a max/min price which should not let my trade execute if exceeded.

URL: https://ciapi.cityindex.com/TradingAPI/order/newtradeorder.
This is my body request: 

"{\"MarketId\":400616149,\"Currency\":null,\"AutoRollover\":false,\"Direction\":\"buy\",\"Quantity\":1.0,\"QuoteId\":null,\"PositionMethodId\":1,\"BidPrice\":1.1080,\"OfferPrice\":1.1060,\"AuditId\":null,\"TradingAccountId\":XXXXXXXXX,\"Close\":null,\"Reference\":null,\"AllocationProfileId\":0,\"OrderReference\":null,\"Source\":null,\"PriceTolerance\":5}"

This is the response:

{StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Pragma: no-cache
  ActionedBy: ISW58
  Connection: keep-alive
  Cache-Control: no-cache
  Date: Tue, 19 Jun 2018 20:47:03 GMT
  Server: Web
  Server: Server
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Content-Length: 100
  Content-Type: application/json; charset=utf-8
  Expires: -1
}}

Probably obvious to some/all of you, nothing is happening, no trade no opening position, nothing happening in my account.

I have no idea what's the MarketId (I guess it's in my example referred to EUR/USD - but not sure), I'm also not sure about Quantity (probably amount of positions), QuoteId is in my guess the Id of the Currency, And also no idea about PriceTolerance and another few which I just filled out. so if all these are not required then please just help, otherwise please gimme some specified link to all this explaining.

Share this post


Link to post

Hi,

In the API documentation page describing the Trade request, the Parameters Type is a link to the page that describes each of the parameters NewTradeOrerRequestDTO - see the screenshot below.

To find the Market ID for the market you wish to trade, use the process as described in How Do I Find Market ID?

I believe you have a US trading account? The Market ID you are using is only for British based accounts so that would likely be why you are not seeing any trades in your account.   

image.png

 

Kind Regards, PM!

Share this post


Link to post

I got the list of Market IDs, see image attached, I tried using EUR USD but still getting the same response, which this is the body of it:

{"Status":4,"StatusReason":12,"OrderId":0,"Orders":[],"Quote":null,"Actions":[],"ErrorMessage":null}

I want to just "Place a trade". Thanks!

sss.PNG

Share this post


Link to post

Hi,

Looking up the InstructionStatusReason code in your response at API Code Lookup Values, shows that you have the Bid Price higher than the Offer Price! :huh:

Checking the JSON code in your trade request in the first post of this thread shows: ... \"BidPrice\":1.1080,\"OfferPrice\":1.1060, ..., where indeed the Bid price has been set as higher than the Offer price.

The standard process is to subscribe (via Lightstreamer) to the streaming live prices for the market you are looking to trade. When you are sending your trade request, read the current Bid and Offer prices from the stream and send those values in as the BidPrice/OfferPrice in the trade request. 

Were you to just change the values around of 1.1080 and 1.1060, your trade request is still going to be rejected because the prices in the request are far away from the current market price. As I type the current price for EUR/USD is 1.15855 by 1.15863.  

Kind Regards, PM! 

 

Share this post


Link to post

Still struggling, Again, what I urgently need to achieve is, that to simply "Place a Market buy/sell" , after then I can go watch all your tutorials for future development. 

And if I can add a limit to it so it should not be placed in case the limit already succeeded, this would be great, but I don't want to use the 'limit order' because I want to immediately open the position and also I don't want to be needed to set the rate value between those 2 values in the Entry order (don't know exactly what these values stands for).

Please provide me the best and easiest way to get this simple Trade placed, simply place Market order by current rate.

Thanks.

 

Share this post


Link to post

I edited my previous post about 45 minutes ago please make sure you read it after then.

I'm currently getting the 75 code about the red card, I understand that by using the value retrieved from the streaming will be ok, but will it always be ok, or can it possibly still change at the same split second of the trade being placed and will result in a red card...?

- please answer also my previous question about if possible adding a 'Limit rate' to a Market order - or any other order - but should always be executed immediately - something that will work like a request that will be opening a position if not limit-exceeded and will be declined if exceeded, which this was the way it worked in your previous gain capital library.

Thanks again!!

Share this post


Link to post

This is actually the request:

{"MarketId":401484347,"Currency":null,"AutoRollover":false,"Direction":"buy","Quantity":1.0,"QuoteId":null,"PositionMethodId":1,"BidPrice":1.16056,"OfferPrice":1.16069,"AuditId":null,"TradingAccountId":401392253,"Close":null,"Reference":null,"AllocationProfileId":0,"OrderReference":null,"Source":null,"PriceTolerance":5}


And this is the response:

{"Status":2,"StatusReason":75,"OrderId":0,"Orders":[{"OrderId":0,"StatusReason":8,"Status":10,"OrderTypeId":1,"Price":0.0,"Quantity":1.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}

And attached you can see the live bid/offer rates at the time placed (not the order I used, just showing the rates)

Pro.jpg

Share this post


Link to post

Hi,

If I understand the quoted post correctly, you want to place a trade via Market Order to immediately open a position at the current buy or sell price, and you will accept slippage on this trade to a certain amount of pips that you define? 

As an example, you want to buy EUR/USD at the current price of say 1.1642, and you are willing to accept up to 5 points of slippage (1.1647), but anymore slippage then you want to cancel the request?

If that is the case, you use Trade request, which is a market order to buy or sell at the current price. You'll want to include the PriceTolerance parameter and set that equal to for example 5. This means you will be filled on your trade if the market is within 5 pips of slippage to execute the trade. If the market has moved more than 5 pips, the trade request is rejected and cancelled. 

17 hours ago, mayerspitz said:

Still struggling, Again, what I urgently need to achieve is, that to simply "Place a Market buy/sell" , after then I can go watch all your tutorials for future development. 

And if I can add a limit to it so it should not be placed in case the limit already succeeded, this would be great, but I don't want to use the 'limit order' because I want to immediately open the position and also I don't want to be needed to set the rate value between those 2 values in the Entry order (don't know exactly what these values stands for).

Please provide me the best and easiest way to get this simple Trade placed, simply place Market order by current rate.

Thanks.

 

 

Share this post


Link to post

Hi,

If you use the PriceTolerance parameter then even if the market has moved a few pips from the current price by the time your order arrives at our servers, if it is within the PriceTolerance value you set the market order is still executed and filled. Only if the market price has moved beyond the PriceTolerance value you set will the trade request then be rejected.

11 hours ago, mayerspitz said:

I edited my previous post about 45 minutes ago please make sure you read it after then.

I'm currently getting the 75 code about the red card, I understand that by using the value retrieved from the streaming will be ok, but will it always be ok, or can it possibly still change at the same split second of the trade being placed and will result in a red card...?

- please answer also my previous question about if possible adding a 'Limit rate' to a Market order - or any other order - but should always be executed immediately - something that will work like a request that will be opening a position if not limit-exceeded and will be declined if exceeded, which this was the way it worked in your previous gain capital library.

Thanks again!!

 

Share this post


Link to post

Hi,

The OrderStatusReason code of 8 states that your trade request is below the minimum order quantity. the minimum trade size is 1,000 for spot EUR/USD, whereas in your trade request you have put the Quantity as 1.0. 

Please change the quantity in the request to the minimum size for this market to resolve this particular error. 

11 hours ago, mayerspitz said:

This is actually the request:


{"MarketId":401484347,"Currency":null,"AutoRollover":false,"Direction":"buy","Quantity":1.0,"QuoteId":null,"PositionMethodId":1,"BidPrice":1.16056,"OfferPrice":1.16069,"AuditId":null,"TradingAccountId":401392253,"Close":null,"Reference":null,"AllocationProfileId":0,"OrderReference":null,"Source":null,"PriceTolerance":5}


And this is the response:


{"Status":2,"StatusReason":75,"OrderId":0,"Orders":[{"OrderId":0,"StatusReason":8,"Status":10,"OrderTypeId":1,"Price":0.0,"Quantity":1.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}

And attached you can see the live bid/offer rates at the time placed (not the order I used, just showing the rates)

Pro.jpg

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×