o= createOrder(c,s,1,account,quantity)creates aCQGOrderobjectofor a market order ofquantityshares of CQG®instrumentsusing theCQGAccountcredentials objectaccountover the CQG connectionc.
Create and Place a Market Order Using a CQGInstrument Object
To create and place a market order for shares of an instrument with the CQG Trader Com API using aCQGInstrumentobject to specify the instrument, create the connectioncusingcqgandstartUp. Register an event handler for tracking events associated with the connection status. Set up the API configuration properties. Then, register event handlers for tracking events associated with the instrument subscription, order and account. Subscribe to the instrument and create theCQGInstrumentobjectcqgInst. Then, set up the account credentialsaccountHandle. For an example demonstrating these activities, seeCreate CQG Orders. SeeCQG API Reference Guideto learn more about event handlers, API configuration properties, andCQGInstrumentobject.
Create a market order that buys one share of the subscribed securitycqgInstusing the account credentialsaccountHandle.
TheCQGOrderobjectoMarketcontains the order. The CQG API executes the market order using the CQG API functionPlace. After execution, the order status changes.
Close the CQG connection.
shutDown(c)
Create and Place a Market Order Using aCQGInstrument Character Vector
To create and place a market order for shares of an instrument with the CQG Trader Com API, create the connectioncusingcqgandstartUp. Register an event handler for tracking events associated with connection status. Set up the API configuration properties. Then, register event handlers for tracking events associated with instrument subscription, order, and account. Subscribe to the instrument. Then, set up the account credentialsaccountHandle. For an example demonstrating these activities, seeCreate CQG Orders. To learn more about the event handlers and the API configuration properties, see theCQG API Reference Guide.
Create a market order that buys one share of the previously subscribed security'EZC'using the defined account credentialsaccountHandle.
TheCQGOrderobjectoMarketcontains the order. The CQG API executes the market order using the CQG API functionPlace. After execution, the order status changes.
Close the CQG connection.
shutDown(c)
Create and Place a Limit Order
To create and place a limit order for shares of an instrument with the CQG Trader Com API using aCQGInstrumentobject to specify the instrument, create the connectioncusingcqgandstartUp. Register an event handler for tracking events associated with connection status. Set up the API configuration properties. Then, register event handlers for tracking events associated with instrument subscription, order and account. Subscribe to the instrument and create theCQGInstrumentobjectcqgInst. Then, set up the account credentialsaccountHandle. For an example demonstrating these activities, seeCreate CQG Orders. SeeCQG API Reference Guideto learn more about the event handlers, the API configuration properties, and theCQGInstrumentobject.
To create a limit order, you can use the bid price. Extract the CQG bid objectqtBidfrom the previously definedCQGInstrumentobjectcqgInst.
qtBid = cqgInst.get('Bid');
Create a limit order that buys one share of the previously subscribed securitycqgInstusing the previously defined account credentialsaccountHandleandqtBidfor the limit price.
TheCQGOrderobjectoLimitcontains the order. The CQG API executes the limit order using the CQG API functionPlace. After execution, the order status changes.
Close the CQG connection.
shutDown(c)
Create and Place a Stop Order
创建和停止订的股票instrument with the CQG Trader Com API using aCQGInstrumentobject to specify the instrument, create the connectioncusingcqgandstartUp. Register an event handler for tracking events associated with connection status. Set up the API configuration properties. Then, register event handlers for tracking events associated with instrument subscription, order and account. Subscribe to the instrument and create theCQGInstrumentobjectcqgInst. Then, set up the account credentialsaccountHandle. For an example demonstrating these activities, seeCreate CQG Orders. SeeCQG API Reference Guideto learn more about the event handlers, the API configuration properties, and theCQGInstrumentobject.
To create a stop order, you can use the trade price. Extract the CQG trade objectqtTradefrom the previously definedCQGInstrumentobjectcqgInst.
qtTrade = cqgInst.get('Trade');
Create a stop order that buys one share of the previously subscribed securitycqgInstusing the previously defined account credentialsaccountHandleandqtTradefor the stop price.
TheCQGOrderobjectoStopcontains the order. The CQG API executes the stop order using the CQG API functionPlace. After execution, the order status changes.
Close the CQG connection.
shutDown(c)
Create and Place a Stop Limit Order
To create and place a stop limit order for shares of an instrument with the CQG Trader Com API using aCQGInstrumentobject to specify the instrument, create the connectioncusingcqgandstartUp. Register an event handler for tracking events associated with connection status. Set up the API configuration properties. Then, register event handlers for tracking events associated with instrument subscription, order and account. Subscribe to the instrument and create theCQGInstrumentobjectcqgInst. Then, set up the account credentialsaccountHandle. For an example demonstrating these activities, seeCreate CQG Orders. SeeCQG API Reference Guideto learn more about the event handlers, the API configuration properties, and theCQGInstrumentobject.
To create a stop limit order, you can use the bid and trade prices. Extract the CQG bid objectqtBidand the CQG trade objectqtTradefrom the previously definedCQGInstrumentobjectcqgInst.
Create a stop limit order that buys one share of the subscribed securitycqgInstusing the defined account credentialsaccountHandleandqtBidfor the limit price andqtTradefor the stop price.
TheCQGOrderobjectoStopLimitcontains the order. The CQG API executes the stop limit order using the CQG API functionPlace. After execution, the order status changes.
CQG connection, specified as a CQG connection object created usingcqg.
s—CQG instrument name character vector|string scalar|CQGInstrumentobject
CQG instrument name, specified as a character vector, string scalar, orCQGInstrumentobject, denoting the instrument or security for the order transaction. For more information about creating aCQGInstrumentobject, see theCQG API Reference Guide. For a list of CQG instrument names, seeTradable Symbols.
account—CQG account credentials CQGAccountobject
CQG account credentials, specified as aCQGAccountobject. This object encapsulates all data pertinent to your account. For more information about creating aCQGAccountobject, seeCQG API Reference Guide.
quantity—CQG order quantity numeric scalar
CQG order quantity, specified as a numeric scalar denoting the number of shares to order. A positive number denotes a buy and a negative number denotes a sell.
Data Types:double
limitprice—CQG limit price double
CQG limit price, specified as a double denoting the limit order price.
Data Types:double
stopprice—CQG stop price double
CQG stop price, specified as a double denoting the stop order price.
CQG order, returned as aCQGOrderobject. This object encapsulates all data necessary to execute a CQG order. For more information about creating aCQGOrderobject, seeCQG API Reference Guide.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.