这个例子展示了如何连接到CQG®创造一个市场秩序。
c =她推出;
启动CQG会话。为仪器订阅、订单和相关事件设置事件处理程序。
startUp(c) streamEventNames = {“InstrumentSubscribed”,...“InstrumentChanged”,“IncorrectSymbol”};为i = 1:length(streamEventNames), {streamEventNames {},...@(变长度输入宗量)cqgrealtimeeventhandler(变长度输入宗量{:})})结束orderEventNames = {“AccountChanged”,“orderchange”,“AllOrdersCanceled”};为i = 1:length(orderEventNames), {orderEventNames {},...@(变长度输入宗量)cqgordereventhandler(变长度输入宗量{:})})结束
认购与欧元银行间同业拆借利率挂钩的证券。
实时(c,“F.US.IE”)暂停(2)
CQGInstrument
对象若要使用仪器创建订单,请导入仪器名称cqgInstrumentName
进入目前的MATLAB®工作区。然后,创建一个CQGInstrument
对象cqgInst
.
cqgInstrumentName = evalin (“基地”,“cqgInstrument”);cqgInst = c.Handle.Instruments.Item (cqgInstrumentName);
设置CQG标志以启用帐户信息检索。
c.Handle.set (“AccountSubscriptionLevel”,“aslNone”);c.Handle.set (“AccountSubscriptionLevel”,“aslAccountUpdatesAndOrders”);暂停(2)accountHandle = c.Handle.Accounts.ItemByIndex(0);
创建一个市场订单,购买认购证券的一股cqgInst
使用帐户凭据accountHandle
.
订单类型= 1;市场订单标志%数量= 1;%数量正是买入,负是卖出oMarket = createOrder (c、cqgInst、订单类型、accountHandle、数量);oMarket。的地方
关闭(c)