public method TradeDeskAut.CloseTradesByInstrument2, CloseTradesByInstrument2Async

Brief

Closes all short or long positions for an instrument on an account by a GTC/IOC order.

Declaration
Visual Basic
Sub CloseTradesByInstrument2 (sInstrument as String, sAccountID as String, bBuy as Boolean, dRate as Double, sQuoteID as String, iAtMarket as Integer, iTIFType as Integer, ByRef psOrderId as Variant, ByRef psDI as Variant)
IDL
[id(401)] HRESULT CloseTradesByInstrument2( [in]BSTR sInstrument, [in]BSTR sAccountID, VARIANT_BOOL vbBuy, [in]double dRate, [in]BSTR sQuoteID, [in]int iAtMarket, [in]int iTIFType, [out]VARIANT *psOrderId, [out]VARIANT *psDI)
Visual Basic
Sub CloseTradesByInstrument2Async (sInstrument as String, sAccountID as String, bBuy as Boolean, dRate as Double, sQuoteID as String, iAtMarket as Integer, iTIFType as Integer, ByRef sRequestID as Variant)
IDL
[id(402)] HRESULT CloseTradesByInstrument2Async( [in]BSTR sInstrument, [in]BSTR sAccountID, VARIANT_BOOL vbBuy, [in]double dRate, [in]BSTR sQuoteID, [in]int iAtMarket, [in]int iTIFType, [out]VARIANT *psRequestId)

Parameters
sInstrument

The instrument the closing positions are opened for.

sAccountID

The identifier of the account the closing positions are opened at.

bBuy

The side of the closing positions.

Note: This is not the side of the close order, but the side of the open positions that should be closed by the order.

So the (sInstrument, sAccountID, bBuy) define the closing positions.

dRate

The rate at which it is desired to close the trades. The rate must be taken from the offers table. Specify 0 to close the trades at the available market price. In this case iAtMarket must also equal 0.

sQuoteID

The identifier of the quote the rate value is taken from. The value can be get from the QuoteID column of the offers table. In case the rate equals 0 this parameter must be empty string.

iAtMarket

The distance in pips from the specified rate within which the trades can be closed at the market price in case market moved at moment of the execution.

If the dRate parameter is a certain rate, specify 0 to close the trade exactly at the specified rate.

If the dRate parameter is 0, specify 0 to close the trade at the available market price.

iTIFType

The Time In Force option. The parameter must have one of the following values:

TradeDeskAut.TIF_GTC

Use this value in case the GTC order must be created.
NOTE: This value must be used only for orders to be executed at the available market price (the dRate parameter is equal to 0). In case the value of the dRate parameter is not equal to 0, specifying TradeDeskAut.TIF_GTC in this parameter will result in this method throwing an exception/error.

TradeDeskAut.TIF_IOC

Use this value in case the IOC order must be created.

TradeDeskAut.TIF_FOK

Use this value in case the FOK order must be created.

See FIX Order Types for more details.

psOrderId / psRequestId

[output] Returns the identifier of the immediate order.
For CloseTradesByInstrument2 this parameter will return OrderID.
For CloseTradesByInstrument2Async this parameter will return RequestID.

psd

[output] Returns "Y" if the order execution is delayed because of dealer intervention. This value can be returned on the dealing desk systems only.
NOTE: Only for CloseTradesByInstrument2 method. See declaration above.

Details

The CloseTradesByInstrument2Async is implemented for asynchronous execution.
Last output parameter will return a RequestID, instead of OrderID (see declaration above).
Event with this RequestID will confirm that command has been executed.

The CloseTradesByInstrument2 and CloseTradesByInstrument2Async methods are defined in the TradeDeskAut class.

back