Jump to content
Sign in to follow this  
SupereeDuperee

Cannot Close Open Position (Consisting Multiple Orders ) Quantity value in 100's or 10's, like 75,120

Recommended Posts

I am trying to CLOSE an open position of EUR/GBP total Quantity 159000 which is accumulation of 4 separate ORDERs - attached ScreenShot.

Here is the JSON that I submit to "order/newtradeorder" API URL

{
   "MarketId":401484335,
   "Currency":null,
   "AutoRollover":false,
   "Direction":"sell",
   "Quantity":159000.0000,
   "QuoteId":0,
   "PositionMethodId":0,
   "BidPrice":1.0001,
   "OfferPrice":999.9999,
   "AuditId":"8870258",
   "TradingAccountId":401235826,
   "IfDone":null,
   "Close":[
      777333435,
      777333437,
      777333438,
      778897685
   ],
   "Reference":null,
   "AllocationProfileId":0,
   "OrderReference":null,
   "Source":null,
   "PriceTolerance":0
}

 

I get the result with error : Status=2, Status Reason=75

{
   "Status":2,
   "StatusReason":75,
   "OrderId":0,
   "Orders":[
      {
         "OrderId":0,
         "StatusReason":158,
         "Status":10,
         "OrderTypeId":1,
         "Price":0.0,
         "Quantity":0.0000,
         "TriggerPrice":0.0,
         "CommissionCharge":0.0,
         "IfDone":[
            
         ],
         "GuaranteedPremium":0.0,
         "OCO":null,
         "AssociatedOrders":{
            "Stop":null,
            "Limit":null
         },
         "Associated":false
      }
   ],
   "Quote":null,
   "Actions":[
      
   ],
   "ErrorMessage":null
}

Where Status Reason 75 = "The total quantity of guaranteed stop orders must be equal to trade
order quantity."

I have tested my Close Position API Calls and it works fine where the QUANTITY is like 123,000. If there are quantity in  Hundredth and Tenth position, like 123,450 Then my API Calls fails. Even though in this example TOTAL Quantity is 159,000 still it fails because the Individual Open Positions have quantity in Hundredths and Tenth position. 

How do I overcome this situation? Thank you.

 

 

FX_MultiTrades.PNG

Share this post


Link to post

Hi Superee,

There's been a slight confusion in the error codes you are using that has sent you on a slight wild goose chase. 

The first set of codes (in green below) are the InstructionStatus and InstructionStatusReason codes. It is the 2nd set of codes (in red below) that are the OrderStatus and OrderStatusReason codes. 158 = Price tolerance exceeded. 

I see your in your trade request that you are overriding the default value of 2 to zero. A value of zero makes your trade request a "Fill or Kill" (FOK) order request. This means execute the trade at the price I am seeing right now and only this price. If the price should move by even 1 pip then kill my order and nothing done. If you loosen the price tolerance back to 2, then you are more likley to have the trade executed, although you can have up to 2 points of slippage.

Note: if you are attempting to trade during volatile periods when the prices are moving very fast, you can still receive a 158 even with a price tolerance of 2. 

Kind Regards, PM

 

image.png

Share this post


Link to post

Yes, I did read that PriceTolerance value "2"  is good to use in another post. Physicsman would using PriceTolerance inflate the price we are buying or selling?

Meaning if there are two trades, one with PriceTolerance set to 2 and another one set to 0. Would there be any price buy/sell differences between those trades?

Share this post


Link to post

Hi SirNewton,

The PriceTolerance does not change the prices you see at all. It only affects the potential prices you can be filled (trade executed) at. That is, with PriceTolerance = 2, you are allowing the system to fill you with up to 2 points of slippage, whereas a Tolerance of zero means fill me at the price I am seeing right now only.

Were the market price to have moved by even 1 point by the time the server receives your order request then the order request is rejected and no trade is executed.

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  
×