创建和管理彭博EMSXRoute
This example shows how to connect to Bloomberg®EMSX,设置路线订阅,创建和路由订单,并与路线交互。
For details about Bloomberg EMSX, see theEMSX API程序员指南using theWAPI
连接至彭博EMSX
连接到彭博社EMSX测试服务。使用当前事件队列内容使用ProcessEvent
。
C= emsx('// blp/emapisvc_beta');processEvent(c)
C= emsx with properties: Session: [1x1 com.bloomberglp.blpapi.Session] Service: [1x1 com.bloomberglp.blpapi.impl.aQ] Ipaddress: 'localhost' Port: 8194 SessionConnectionUp = { server = localhost/127.0.0.1:8194 } SessionStarted = { } ServiceOpened = { serviceName = //blp/emapisvc_beta }
MATLAB®返回C
作为与彭博社EMSX测试服务的连接,以下内容:
彭博社EMSX会话对象
彭博社EMSX服务对象
运行彭博社EMSX测试服务的机器的IP地址
运行彭博EMSX测试服务的机器的端口号
ProcessEvent
显示与连接到彭博EMSX相关的事件。
设置路线订阅
设置彭博社EMSX字段的路线订阅EMSX_BRORK
andemsx_working
使用彭博EMSX连接C
。返回现有路线的状态。
字段= {'emsx_broker',,,,'EMSX_WORKING'};[事件,subs] =路由(C,字段)
events = msg_type:{5x1 cell} msg_sub_type:{5x1 cell} event_status:[5x1 int32] ... subs = com.bloomberglp.blpapi.subscriptionlist@463b9287
事件
包含事件队列中当前事件的字段。潜艇
Contains the Bloomberg EMSX subscription list object.
创建和路线顺序
创建订单请求结构命令
定义顺序参数。该代码为IBM的100股创建了买入订单®。此代码使用经纪人BB
有效的时间DAY
和任何手指令。使用使用的股份数量转换为32位签名的整数int32
。
order.emsx_ticker ='IBM';order.emsx_amount = int32(100);order.emsx_order_type ='Mkt';命令。EMSX_BRORK='bb';order.emsx_tif ='天';命令。EMSX_HAND_INSTRUCTION ='任何';命令。EMSX_SIDE =“买入”;
使用彭博社EMSX连接创建和路由订单C
和订单请求结构命令
。
事件= createorderAndRoute(c,order)
事件= EMSX_SEQUENCE: 335877 EMSX_ROUTE_ID: 1 MESSAGE: 'Order created and routed'
The default event handler processes the events associated with creating and routing the order.CreateOrderAndRoute
返回事件
作为包含这些字段的结构:
彭博社EMSX订单编号
彭博社EMSXroute identifier
彭博社EMSX消息
修改路线
定义莫德鲁特
包含这些字段的结构:
彭博社EMSX订单序列编号
EMSX_Sequence
彭博社EMSX股票符号
emsx_ticker
彭博社EMSXnumber of shares
EMSX_AMOUNT
彭博社EMSXroute identifier
EMSX_ROUTE_ID
This code modifies the route to 50 shares of IBM for order sequence number335877
and route identifier1
。使用数字转换为32位签名的整数int32
。
modroute.emsx_sequence = int32(335877)modroute.emsx_ticker ='IBM';modroute.emsx_amount = int32(50);modroute.emsx_route_id = int32(1);
使用彭博EMSX连接修改路线C
并修改路线请求莫德鲁特
。
事件= modifyRoute(c,modroute)
事件= EMSX_SEQUENCE: 0 EMSX_ROUTE_ID: 0 MESSAGE: 'Route modified'
默认事件处理程序处理与修改路由相关的事件。modifyRoute
返回事件
作为包含这些字段的结构:
彭博社EMSX订单编号
彭博社EMSXroute identifier
彭博社EMSX消息
删除修改的路线
定义结构路线
that contains the order sequence numberEMSX_Sequence
和路线编号EMSX_ROUTE_ID
与修改后的路线相关联。
Routenum.EMSX_Sequence = 0;Routenum.EMSX_ROUTE_ID = 0;
使用彭博EMSX连接删除路线C
and delete route number structure路线
。
事件= deleteroute(C,Routenum)
事件=状态:'1'消息:'发送给经纪人的路由取消请求'
默认事件处理程序处理与删除路由相关的事件。DELETEROUTE
返回事件
作为包含这些字段的结构:
彭博社EMSXstatus
彭博社EMSX消息
停止路线订阅
Unsubscribe from route events using the Bloomberg EMSX subscription list object潜艇
。
c.session.unsubscribe(subs)
关彭博EMSX连接
关闭(c)
也可以看看
EMSX
|关
|CreateOrderAndRoute
|modifyRoute
|DELETEROUTE
|routes
|路由订单