Jump to content
Sign in to follow this  
aperson

Cannot Close position - getting Server Error 500 with no specific details

Recommended Posts

So I've tried a payload like this to close an open Long position: (btw, my other api calls work)

 

body   ={
                "Direction":'sell',
                "TradingAccountId":mytradeaccountID,"MarketName":"GBP/JPY",
                "MarketId":401484385,"Quantity":1000,
                "Close":[id_as_an_integer],"isTrade":true}

}

 

but I get a server error 500 with no specific details. Help!

Share this post


Link to post

Hi,

A valid close request would look like the following:

{
    "MarketId": 401166801,
    "Direction": "sell",
    "Close": [
        799731166
    ],
    "Quantity": 1000,
    "BidPrice": 149.063,
    "AuditId": "EL35455671",
    "OfferPrice": 149.109,
    "TradingAccountId": 401843563
}

Presumably you sent to the following endpoint? 

POST https://ciapi.cityindex.com/TradingAPI/order/newtradeorder

Kind Regards, PM

 

 

Share this post


Link to post

Yes I'm posting to 

https://ciapi.cityindex.com/TradingAPI/order/newtradeorder

Do we need to include the bid, offer, and the AuditId? I was reading some posts about this. Do we need the streaming API to make any trades? The streaming API seems complicated, and I'm not aiming to do very short term trades, so trading off historical data would be ideal. Are these 3 parameters required to be accurate to the current market price to make any trades or is this just an indicator/log to Forex.com about what we saw at the time for the client's optional use and it could be way off, and if we don't care about it then we just put whatever we want in there?

 

Share this post


Link to post

Hello,

It would be safest to send calls with all the parameters as specified, in this case specifically the Bid, Offer and AuditId. It is possible to drop a few of the parameters in some calls, but you could only find that out by experimentation. Hence it is easier and safer to simply send calls with the specified parameters.  

For the close trade call, the Bid and Offer prices are required and must be supplied with your close trade call. 

The call being used is to place a trade at market, which is to say you are trading on the current market price. Hence, you would need a connection through the streaming API call to receive live streaming prices so you know what price you are trading on. Were you to use historical data, then depending on how much time has elapsed since you retrieved the historical prices, the current price on which you are trading could be quite different. 

Kind Regards, PM

Share this post


Link to post

Ok, so clients would get the most accurate current market price for trades by using the streaming API. Are bid and offer prices in the trade call matched with the api backend to check whether the client's current market prices are close enough to the backend's current market prices? If it is, then execute the trade, and if not, would the trade be rejected?  I'm wondering if this is for precise trading or just an optional log for the client or Forex.com to track stuff if we want. Can I put 0 for bid and offer prices if I don't wanna use it? 

Share this post


Link to post

Hello,

You cannot use zero values for bid or offer as they would result in error messages being returned.

Theoretically, you could use some inaccurate non-zero value of the bid/offer and it would work, but there could be unforeseen problems or errors that could occur doing this. It is safest and best to follow the specified calls as intended, but it is your choice.

Kind Regards, PM

Share this post


Link to post

Ok I'll try to list my most accurate current market price for the bid and ask fields. What is the purpose of including the bid and ask? Is it for optional logging or if my bid and ask prices are not accurate, then would the trade not execute? If it is for precision trading, then if the streaming api is off by a little bit and that affects my bid and ask prices to the call, would my trade not process sometimes?

Share this post


Link to post

Hello,

Our backend execution venue uses the supplied bid/offer in the following way:

Quote

In the standard tolerance model, we use the client level as the reference to compare current venue price against and accept/reject accordingly. Sending us the bid/ask is not strictly necessary but it helps with best execution and investigations to have this available.

Kind Regards, PM

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
Sign in to follow this  
×