This method creates a new order with the specified parameters.
The result of this method is the same as the one from CQGCEL.CreateOrder, however it allows to create an order by providing the full instrument name without prior need to subscribe to the instrument.
Visual Basic |
---|
Public Function CreateOrderByInstrumentName( _ ByVal order_type As eOrderType, _ ByVal instrument_name As String, _ ByVal cqg_account As CQGAccount, _ ByVal order_quantity As Long, _ Optional ByVal order_side As eOrderSide = osdUndefined, _ Optional ByVal limit_price As Double = 0, _ Optional ByVal stop_price As Double = 0, _ Optional ByVal ue_name_part As String = "" _ ) As CQGOrder |
- order_type
Value Description otLimit Limit order.
otMarket Market order.
otStop Stop order.
otStopLimit Stop Limit order.
otUndefined Undefined order type.
Type of the order
The CQGOrder.Properties collection depends on the order type.
Depending on it, calling the CQGOrder.PrepareModify method will return different results.
- instrument_name
The detailed instrument name to be be used when creating the order. For example, F.US.EP.M20, C.US.CLE.U21.100 (U21 is September 2021; 100 is a strike), C.US.CLE.M20.N100 (M20 is June 2020; N100 is a negative strike: -100).
The full instrument name (e.g. F.US.EPZ16) is also supported for backward compatibility, but its using is depricated.
- cqg_account
- The account on which the order will be place.
- order_quantity
This parameter can be signed or unsigned - depending on the CQGAPIConfig.UseOrderSide settings.
- order_side
Value Description osdBuy Side properties return this value if CQGAPIConfig.UseOrderSide is set to True. Depending on the owner, osdBuy value is returned in case of:
- the object is a CQGTrade referring to a buy trade
- the object is a CQGPosition referring to a long position.
- the object is a CQGOrder referring to an order of buy type.
- the object is a CQGFill referring to a fill of buy type.
osdSell Side properties return this value if CQGAPIConfig.UseOrderSide is set to True. Depending on the owner, osdSell value is returned in case of:
- the object is a CQGTrade referring to a sell trade
- the object is a CQGPosition referring to a short position.
- the object is a CQGOrder referring to an order of sell type.
- the object is a CQGFill referring to a fill of sell type.
osdUndefined Side properties return this value if CQGAPIConfig.UseOrderSide is set to False. Side of the order
Not used if CQGAPIConfig.UseOrderSide is set to false.
- limit_price
The limit price of the order
- stop_price
The stop price of the order
- ue_name_part
Part of the user-friendly name.
Other parts of UEName are automatically generated.
Returns the newly created CQGOrder object if successful, otherwise throws an exception.
The example below shows how to place market order using this method.
Option Explicit Private WithEvents cel As CQGCEL '... m_CEL.APIConfiguration.UseOrderSide = False Dim account As CQGAccount = m_CEL.Accounts.ItemByIndex(0) Dim orderQuantity As Integer = -1 ' Negative value means a sell order Dim order As CQG.CQGOrder order = m_CEL.CreateOrderByInstrumentName(CQG.eOrderType.otMarket, "F.US.EPZ16", account, orderQuantity) order.Place()
CQGCEL m_CEL = new CQGCEL(); //... m_CEL.APIConfiguration.UseOrderSide = false; CQGAccount account = m_CEL.Accounts.ItemByIndex[0]; int orderQuantity = -1; // Negative value means a sell order CQGOrder order = m_CEL.CreateOrderByInstrumentName(eOrderType.otMarket, "F.US.EPZ16", account, orderQuantity); order.Place();