Jump to content
Sign in to follow this  
SirNewton

Closing trade

Recommended Posts

Hello Physicsman, have a question using Close key value pair to close an existing trade.

See: https://docs.labs.gaincapital.com/#Data Types/NewTradeOrderRequestDTO.htm

Close integer[]

List of existing open trade order IDs that require part or full closure.

I tied it out on Postman with below JSON object:

{
  "MarketId"401484406,
  "Currency"null,
  "AutoRollover"false,
  "Direction""sell",
  "Quantity"1000,
  "QuoteId"0,
  "PositionMethodId"0,
  "BidPrice"1.0001,
  "OfferPrice"1.5001,
  "AuditId""939239####",
  "TradingAccountId"##########,
  "IfDone"null,
  "Close": ["779386607"],
  "Reference"null,
  "AllocationProfileId"0,
  "OrderReference"null,
  "Source"null,
  "PriceTolerance"0,
  "isTrade":true
}

And the response I get:

{
    "Status"4,
    "StatusReason"112,
    "OrderId"0,
    "Orders": [],
    "Quote"null,
    "Actions": [],
    "ErrorMessage"null
}
 
I looked up 112 StatusReason and according the documentation:
I see it say, "NFA FIFO Account - Target closure restricted."
What am I doing wrong here? How do I use Close with API NewTradeOrderRequest to close an existing trade?
 
Thank you.

 

Share this post


Link to post

Hi SirNewton,

A couple of clarifying questions:

  1. Are you a US client? 
  2. Did you have more than one open position in the same market, and you were attempting to close one of those open positions specifically?

The error message you are seeing is related to the case when the answers to both questions above are true. US clients are forced by the US regulator to close positions in a First In First Out (FIFO) order. For example, if you buy GBP/USD, then a little time later add to your buy position, and after some more time buy a 3rd position in GBP/USD. As a US client you must close the positions in the order you opened them. If you try to close say the 2nd or 3rd position out of sequence, then you will receive this error message.

If the above doesn't apply to you we can investigate further. 

Kind Regards, PM

Share this post


Link to post
  1. Are you a US client? Yes, I am in the US. And I am a US client.
  2. Did you have more than one open position in the same market, and you were attempting to close one of those open positions specifically? Yes, I had several open in the same market and was trying to close one specifically. When I don't include anything in the CLOSE, it seems to close a random trade. I was hoping to use CLOSE to close a specific trade.

Thank you.

Share this post


Link to post

Hi SirNewton,

When you didn't include anything in the Close field the system should be closing your positions in the order they were opened going from first to second..., rather than closing them at random. 

Reading through the following link on the rule, it looks as though the NFA's aim of implementing this FIFO rule was to prevent clients from "hedging", which is to have simultaneous offsetting long and short positions in the same market. 

https://www.investopedia.com/terms/n/nfa-compliance-rule-2-43b.asp

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  
×