public method TradeDeskAut.OpenTrade3, OpenTrade3Async

Brief

Opens a trade by a GTC/IOC order and, if requested, creates a stop or limit or both orders (simple or pegged) on this trade and allows making stop/limit trailing.

Partial functionality for United States based accounts. Specifying any values for Stop and Limit (besides 0) in this function will result in this function throwing an Exception/Error. Please read NFA Compliance Rule 2-43(b).

Declaration
Visual Basic
Sub OpenTrade3 (wcsAccountID as String, wcsInstrument as String, bIsBuy as Boolean, iAmount as Integer, dRate as Double, wcsQuoteID as String, iAtMarket as Integer, iSLType as Integer, dStop as Double, dLimit as Double, iTrailMinMoveStop as Integer, iTrailMinMoveLimit as Integer, iTIFType as Integer, ByRef psOrderId as Variant, ByRef psd as Variant)
IDL
[id(405)] HRESULT OpenTrade3( [in]BSTR sAccountID, [in]BSTR sInstrument, [in]VARIANT_BOOL bBuy, [in]int iAmount, [in]double dRate, [in]BSTR sQuoteID, [in]int iAtMarket, [in]int iSLFlag, [in]double dStop, [in]double dLimit, [in]int iTrailMinMoveStop, [in]int iTrailMinMoveLimit, [in]int iTIFType, [out]VARIANT* psOrderId, [out]VARIANT* psDI)
Visual Basic
Sub OpenTrade3Async (wcsAccountID as String, wcsInstrument as String, bIsBuy as Boolean, iAmount as Integer, dRate as Double, wcsQuoteID as String, iAtMarket as Integer, iSLType as Integer, dStop as Double, dLimit as Double, iTrailMinMoveStop as Integer, iTrailMinMoveLimit as Integer, iTIFType as Integer, ByRef psRequestId as Variant)
IDL
[id(406)] HRESULT OpenTrade3Async( [in]BSTR sAccountID, [in]BSTR sInstrument, [in]VARIANT_BOOL vbBuy, [in]int iAmount, [in]double dRate, [in]BSTR sQuoteID, [in]int iAtMarket, [in]int iSLType, [in]double dStop, [in]double dLimit, [in]int iTrailMinMoveStop, [in]int iTrailMinMoveLimit, [in]int iTIFType, [out]VARIANT* psRequestId)

Parameters
wcsAccountID

The identifier of the account. The account must exist in the accounts table. Use the AccountID column to get the identifier of the account.

wcsInstrument

The instrument the trade must be opened in. The value must be one of the values of the Instrument column of the offers table. The offers of the instrument must be subscribed.

bIsBuy

The flag indicating whether the trade must be opened using the buy order (True, long position) or sell order (False, short position).

iAmount

The amount of the order.

Please note that limitations on the amount might be applicable:



All these limitations except BaseUnitSize can be zero. Zero value means that the limitation for that specific parameter is not applied at all.

dRate

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

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

wcsQuoteID

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

iAtMarket

The distance in pips from the specified rate within which the trade can be opened at the market price in case market moved at the moment of the order's execution.

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

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

iSLType

The type of the associated stop and limit order. The value defines interpretation of dStop and dLimit parameters. Can be combination of the following values:

TradeDeskAut.SL_NONE

Use this value in case neither the stop nor limit orders must be added.

TradeDeskAut.SL_STOP

Use this value in case the simple stop order must be added.

TradeDeskAut.SL_LIMIT

Use this value in case the simple limit order must be added.

TradeDeskAut.SL_PEGSTOPOPEN

Use this value in case the stop order must be the pegged stop order and its offset must be added to the open price (see Order Types for information about pegged orders).

The offset is specified in pips.

For buy positions, the stop order must be below open price minus current spread, i.e. offset must be negative and must be less than "-" spread.

For sell positions, the stop order must be above open price plus current spread, i.e. offset must be positive and must be bigger than spread.

TradeDeskAut.SL_PEGSTOPCLOSE

Use this value in case the stop order must be the pegged stop order and its offset must be added to the close price (see Order Types for information about pegged orders).

The offset is specified in pips.

For buy positions, the stop order must be below close price, i.e. offset must be negative.

For sell positions, the stop order must be above close price, i.e. offset must be positive.

TradeDeskAut.SL_PEGLIMITOPEN

Use this value in case the limit order must be the pegged limit order and its offset must be added to the open price (see Order Types for information about pegged orders).

The offset is specified in pips.

For buy positions, the limit order must be above the open price, i.e. offset must be positive.

For sell positions, the limit order must be below the open price, i.e. offset must be negative.

TradeDeskAut.SL_PEGLIMITCLOSE

Use this value in case the limit order must be the pegged limit order and its offset must be added to the close price (see Order Types for information about pegged orders).

The offset is specified in pips.

For buy positions, the limit order must be above the close price plus current spread, i.e. offset must be positive and must be bigger than spread.

For sell positions, the limit order must be below the close price minus current spread. i.e. offset must be negative and must be less than "-" spread.

You can concatinate these values using arithmetical addition. For example:

To set the simple limit order only, specify in this parameter:
tradeDesk.SL_LIMIT

To set the simple limit and the simple stop orders, specify in this parameter:
tradeDesk.SL_LIMIT + tradeDesk.SL_STOP

To set the pegged stop order the offset of which will be added to the open price, specify in this parameter:
tradeDesk.SL_PEGSTOPOPEN

To set the pegged stop order the offset of which will be added to the close price and the simple limit, specify in this parameter:
tradeDesk.SL_LIMIT + tradeDesk.SL_PEGSTOPCLOSE

dStop

The rate or the offset in pips for the stop order which must be created for the trade. The interpretation of the parameter depends on the value of the iSLType parameter.

The distance between the stop level and the current close price must be greater than the the minimal conditional distance.

The value of the minimal conditional distance you can retrieve using methods of TradingSettingsProviderAut interface.

United States based accounts must specify 0 in this parameter. Please read NFA Compliance Rule 2-43(b). In case any other value is used Order2Go API will throw an Exception/Error.

dLimit

The rate or the offset in pips for the limit order which must be created for the trade. The interpretation of the parameter depends on the value of the iSLType parameter.

The distance between the limit level and the current close price must be greater than the minimal conditional distance.

The value of the minimal conditional distance you can retrieve using methods of TradingSettingsProviderAut interface.

United States based accounts must specify 0 in this parameter. Please read NFA Compliance Rule 2-43(b). In case any other value is used Order2Go API will throw an Exception/Error.

iTrailMinMoveStop

Controls the trailing stop order.

In case the stop order is not specified, specify 0 in this parameter.

In case the stop order must not be a trailing stop, specify 0 in this parameter.

In case the stop order must be trailing with a dynamic step, specify 1 in this parameter.

In case the stop order must be trailing with a fixed step, specify the size in pips of the market movement after which the order must be moved following the market. The value must be from the TradingSettingsProviderAut.GetMinTrailingStepForStop value to the TradingSettingsProviderAut.GetMaxTrailingStepForStop value.

Note that trailing stop orders can be not available on the server. To check whether trailing stop orders with a dynamic step are available, use the PermissionCheckerAut.CanUseDynamicTrailingForStop method. To check whether trailing stop orders with a fixed step are available, use the PermissionCheckerAut.CanUseFluctuateTrailingForStop method.

United States based accounts must specify 0 in this parameter. Please read NFA Compliance Rule 2-43(b). In case any other value is used Order2Go API will throw an Exception/Error.

iTrailMinMoveLimit

Controls the trailing limit order.

In case the limit order is not specified, specify 0 in this parameter.

In case the limit order must not be trailing, specify 0 in this parameter.

In case the limit order must be trailing with a dynamic step, specify 1 in this parameter.

In case the limit order must be trailing with a fixed step, specify the size in pips of the market movement after which the order must be moved following the market. The value must be from the TradingSettingsProviderAut.GetMinTrailingStepForLimit value to the TradingSettingsProviderAut.GetMaxTrailingStepForLimit value.

Note that trailing limit orders can be not available on the server. To check whether trailing limit orders with a dynamic step are available, use the PermissionCheckerAut.CanUseDynamicTrailingForLimit method. To check whether trailing limit orders with a fixed step are available, use the PermissionCheckerAut.CanUseFluctuateTrailingForLimit method.

United States based accounts must specify 0 in this parameter. Please read NFA Compliance Rule 2-43(b). In case any other value is used Order2Go API will throw an Exception/Error.

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 OpenTrade3 this parameter will return OrderID.
For OpenTrade3Async this parameter will return RequestID.

psd

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

Details

Unlike the OpenTrade and OpenTrade2/OpenTrade2Async methods, the OpenTrade3/OpenTrade3Async methods allow you to:

The OpenTrade3Async 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 OpenTrade3 and OpenTrade3Async methods are defined in the TradeDeskAut class.

back