public method TradeDeskAut.CloseTrade2, CloseTrade2Async

Brief

Closes a trade by a GTC/IOC order.

Does not work for United States based accounts. Please read NFA Compliance Rule 2-43(b). In case if this function is used Order2Go API will throw an Exception/Error.

Please read: How to close positions on United States based (FIFO) accounts.

Declaration
Visual Basic
Sub CloseTrade2 (sTradeID as String, iAmount as Integer, dRate as Double, wcsQuoteID as String, iAtMarket as Integer, iTIFType as Integer, ByRef sOrderID as Variant, ByRef sDI as Variant)
IDL
[id(399)] HRESULT CloseTrade2( [in]BSTR sTradeID, [in]int iAmount, [in]double dRate, [in]BSTR sQuoteID, [in]int iAtMarket, [in]int iTIFType, [out]VARIANT* sOrderID, [out]VARIANT *sDI)
Visual Basic
Sub CloseTrade2Async (sTradeID as String, iAmount as Integer, dRate as Double, wcsQuoteID as String, iAtMarket as Integer, iTIFType as Integer, ByRef sRequestID as Variant)
IDL
[id(400)] HRESULT CloseTrade2Async( [in]BSTR sTradeID, [in]int iAmount, [in]double dRate, [in]BSTR sQuoteID, [in]int iAtMarket, [in]int iTIFType, [out]VARIANT *psRequestId)

Parameters
sTradeID

The identifier of the existing trade.

iAmount

The amount which it is desired to close.

The amount must be equal to or greater than and must be divisible by the BaseUnitSize value.

The BaseUnitSize value can be retrieved using TradingSettingsProviderAut.GetBaseUnitSize.

The trade can be closed partially.

dRate

The rate at which it is desired to close the trade. The rate must be taken from the offers table.

Specify 0 to close the trade at the available market price.

wcsQuoteID

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 trade 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 CloseTrade2 this parameter will return OrderID.
For CloseTrade2Async 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 CloseTrade2 method. See declaration above.

Details

The CloseTrade2Async method 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 CloseTrade2 and CloseTrade2Async methods are defined in the TradeDeskAut class.

back