Jump to content

BUG - API ClosePositionRequest returns OK/200 but does nothing (on demo)


Recommended Posts

Hi, 
I have been integrating your API and I want to close a position (using your example client). For that list the currently open positions [1] and based on received data create a CloseOTCPositionV1Request [2]. After sending the above mentioned request [2], I receive HttpStatus OK/200 along with a CloseOTCPositionV1Response containing a dealReference [3].. Therefore I would expect this position to be closed, but I can repeate this multiple times!!! Also I can see the open position in the UI.

From my perspective this is a bug..

Thanks for clarification

Jaroslav

 

[1] PositionsItem{position=Position{contractSize=10000.0, createdDate='2022/03/07 08:09:11:000', createdDateUTC='2022-03-07T08:09:11', dealId='DIAAAAHUBFF4UAN', size=1.0, direction=BUY, limitLevel=null, level=151.958, currency='JPY', controlledRisk=false, stopLevel=null, trailingStep=null, trailingStopDistance=null}, market=Market{instrumentName='GBP/JPY Mini', epic='CS.D.GBPJPY.MINI.IP', marketStatus=TRADEABLE}}

[2] CloseOTCPositionV1Request{dealId='DIAAAAHUBFF4UAN', epic='null', expiry='null', direction=BUY, size=1.0, level=null, orderType=MARKET, timeInForce=null, quoteId='null'}

[3] RefID = 2EQC69M1FXHPRD0N1

 

INFO  [2022 03 08 - 18:36:40,524] [ForexApp] [main]: IgRestApi Client: re-connecting as sa_demo_forex2
INFO  [2022 03 08 - 18:36:40,833] [ForexApp] [main]: Listing positions..
INFO  [2022 03 08 - 18:36:40,834] [ForexApp] [main]: PositionsItem{position=Position{contractSize=10000.0, createdDate='2022/03/07 08:09:11:000', createdDateUTC='2022-03-07T08:09:11', dealId='DIAAAAHUBFF4UAN', size=2.0, direction=BUY, limitLevel=null, level=151.958, currency='JPY', controlledRisk=false, stopLevel=null, trailingStep=null, trailingStopDistance=null}, market=Market{instrumentName='GBP/JPY Mini', epic='CS.D.GBPJPY.MINI.IP', marketStatus=TRADEABLE}}
TRACE [2022 03 08 - 18:36:40,834] [ForexApp] [main]: Executing close position request for deal = DIAAAAHUBFF4UAN
DEBUG [2022 03 08 - 18:36:40,839] [ForexApp] [main]: json body: {"dealId":"DIAAAAHUBFF4UAN","epic":null,"expiry":null,"direction":"BUY","size":2.0,"level":null,"orderType":"MARKET","timeInForce":null,"quoteId":null}
DEBUG [2022 03 08 - 18:36:40,840] [ForexApp] [main]: conversation context was provided
TRACE [2022 03 08 - 18:36:41,041] [ForexApp] [main]: Executing close position request for deal = DIAAAAHUBFF4UAN ... OK - RefID = 2EQC69M1FXHPRD0N1
Link to comment

 I hope this helps someone - my problem was, that the Direction needs to be oposite from what it is in the Position.. So if Position is in the SELL direction, the ClosePosition needs to be in the BUY Direction.. 
From my perspective, this is a redundant variable which should not be mandatory - If I want to close position, i want the oposite of the open position implicitly..

Link to comment

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
×
×
  • Create New...
us