The EMSX API provides Bloomberg users with the ability to manage and automate Equities, Futures and Options trading.
Bloomberg Professional Services_Execution Management System
서버측 EMSX API는 단말이 없어 ID를 만들어야함. 24시간 동안 돌릴 수 있음.
단말기와 서버의 차이점.
d_authsvc = "//blp/apiauth";
session.openServiceAsync(d_authsvc);
DAPI:
session.sendRequest(request, requestID);
session.subscribe(subscriptions);
Server:
session.sendRequest(request, Identity, requestID);
session.subscribe(subscriptions, Identity);
DAPI:
#d_service="//blp/emapisvc"
d_service="//blp/emapisvc_beta"
d_host="localhost"
d_port=8194
Server:
#EMSX/IOI API Server authentication
d_service = "//blp/emapisvc_beta"
d_auth = "//blp/apiauth"
d_host = "1.2.3.4" #static ip address of the server
d_port = 8195
d_user = "MyAuthIDOrEMRSID"
auth를 따로 만들어야함.
Please follow the following steps to install and register the installer with Bloomberg Enterprise Solutions with the assistance from EMSX Implementation team.
serverapiinstaller.exe를 받아 서버를 설치해야 함.
The EMSX API supports 99.9% of the features supported in EMSX<GO> function.
EVENT_STATUS | Message Type | Description |
---|---|---|
EVENT_STATUS = 1 | Heartbeat Message | HB_MESSAGE |
EVENT_STATUS = 4 | Initial Paint Message on all subscription fields | INIT_PAINT |
EVENT_STATUS = 6 | New Order or Route Message on all subscription fields | NEW_ORDER_ROUTE |
EVENT_STATUS = 7 | This field dynamically updates for existing Order and route | UPD_ORDER_ROUTE |
EVENT_STATUS = 8 | Order and route deletion message | DELETION_MESSAGE |
EVENT_STATUS = 11 | The end of the initial paint message | INIT_PAINT_END |
Order Status | Description |
---|---|
ASSIGN | The route has been cancelled or rejected without fills. |
CANCEL | The order has been cancelled, no shares filled. |
FILLED | All shares have been filled, no idle quantity. |
NEW | The order has been added/staged; no routes have been created. |
PARTFILLED | The order has idle or unfilled shares. |
SENT | The route has been sent to the broker but has not been acknowledged. |
WORKING | The route has been sent and acknowledged by the broker |
# EMSXSubscriptions.py
import blpapi
import sys
ORDER_ROUTE_FIELDS = blpapi.Name("OrderRouteFields")
SLOW_CONSUMER_WARNING = blpapi.Name("SlowConsumerWarning")
SLOW_CONSUMER_WARNING_CLEARED = blpapi.Name("SlowConsumerWarningCleared")
SESSION_STARTED = blpapi.Name("SessionStarted")
SESSION_TERMINATED = blpapi.Name("SessionTerminated")
SESSION_STARTUP_FAILURE = blpapi.Name("SessionStartupFailure")
SESSION_CONNECTION_UP = blpapi.Name("SessionConnectionUp")
SESSION_CONNECTION_DOWN = blpapi.Name("SessionConnectionDown")
SERVICE_OPENED = blpapi.Name("ServiceOpened")
SERVICE_OPEN_FAILURE = blpapi.Name("ServiceOpenFailure")
SUBSCRIPTION_FAILURE = blpapi.Name("SubscriptionFailure")
SUBSCRIPTION_STARTED = blpapi.Name("SubscriptionStarted")
SUBSCRIPTION_TERMINATED = blpapi.Name("SubscriptionTerminated")
EXCEPTIONS = blpapi.Name("exceptions")
FIELD_ID = blpapi.Name("fieldId")
REASON = blpapi.Name("reason")
CATEGORY = blpapi.Name("category")
DESCRIPTION = blpapi.Name("description")
#d_service="//blp/emapisvc"
d_service="//blp/emapisvc_beta"
d_host="localhost"
d_port=8194
orderSubscriptionID=blpapi.CorrelationId(98)
routeSubscriptionID=blpapi.CorrelationId(99)
class SessionEventHandler(object):
def processEvent(self, event, session):
try:
if event.eventType() == blpapi.Event.ADMIN:
self.processAdminEvent(event)
elif event.eventType() == blpapi.Event.SESSION_STATUS:
self.processSessionStatusEvent(event,session)
elif event.eventType() == blpapi.Event.SERVICE_STATUS:
self.processServiceStatusEvent(event,session)
elif event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS:
self.processSubscriptionStatusEvent(event, session)
elif event.eventType() == blpapi.Event.SUBSCRIPTION_DATA:
self.processSubscriptionDataEvent(event)
else:
self.processMiscEvents(event)
except:
print ("Exception: %s" % sys.exc_info()[0])
return False
def processAdminEvent(self,event):
print ("Processing ADMIN event")
for msg in event:
if msg.messageType() == SLOW_CONSUMER_WARNING:
print ("Warning: Entered Slow Consumer status")
elif msg.messageType() == SLOW_CONSUMER_WARNING_CLEARED:
print ("Slow consumer status cleared")
def processSessionStatusEvent(self,event,session):
print ("Processing SESSION_STATUS event")
for msg in event:
if msg.messageType() == SESSION_STARTED:
print ("Session started...")
session.openServiceAsync(d_service)
elif msg.messageType() == SESSION_STARTUP_FAILURE:
print ("Error: Session startup failed", file=sys.stderr)
elif msg.messageType() == SESSION_TERMINATED:
print ("Error: Session has been terminated")
elif msg.messageType() == SESSION_CONNECTION_UP:
print ("Session connection is up")
elif msg.messageType() == SESSION_CONNECTION_DOWN:
print ("Error: Session connection is down")
def processServiceStatusEvent(self,event,session):
print ("Processing SERVICE_STATUS event")
for msg in event:
if msg.messageType() == SERVICE_OPENED:
print ("Service opened...")
self.createOrderSubscription(session)
elif msg.messageType() == SERVICE_OPEN_FAILURE:
print ("Error: Service failed to open", file=sys.stderr)
def processSubscriptionStatusEvent(self, event, session):
print ("Processing SUBSCRIPTION_STATUS event")
for msg in event:
if msg.messageType() == SUBSCRIPTION_STARTED:
if msg.correlationIds()[0].value() == orderSubscriptionID.value():
print ("Order subscription started successfully")
self.createRouteSubscription(session)
elif msg.correlationIds()[0].value() == routeSubscriptionID.value():
print ("Route subscription started successfully")
elif msg.messageType() == SUBSCRIPTION_FAILURE:
print ("Error: Subscription failed", file=sys.stderr)
print ("MESSAGE: %s" % (msg), file=sys.stderr)
reason = msg.getElement("reason");
errorcode = reason.getElementAsInteger("errorCode")
description = reason.getElementAsString("description")
print ("Error: (%d) %s" % (errorcode, description), file=sys.stderr)
elif msg.messageType() == SUBSCRIPTION_TERMINATED:
print ("Error: Subscription terminated", file=sys.stderr)
print ("MESSAGE: %s" % (msg), file=sys.stderr)
def processSubscriptionDataEvent(self, event):
#print ("Processing SUBSCRIPTION_DATA event")
for msg in event:
if msg.messageType() == ORDER_ROUTE_FIELDS:
event_status = msg.getElementAsInteger("EVENT_STATUS")
if event_status == 1:
if msg.correlationIds()[0].value() == orderSubscriptionID.value():
#print ("O", end=".",)
print ("O."),
pass
elif msg.correlationIds()[0].value() == routeSubscriptionID.value():
#print ("R", end=".",)
print ("R."),
pass
elif event_status == 11:
if msg.correlationIds()[0].value() == orderSubscriptionID.value():
print ("Order - End of initial paint")
elif msg.correlationIds()[0].value() == routeSubscriptionID.value():
print ("Route - End of initial paint")
else:
print ("")
if msg.correlationIds()[0].value() == orderSubscriptionID.value():
api_seq_num = msg.getElementAsInteger("API_SEQ_NUM") if msg.hasElement("API_SEQ_NUM") else 0
emsx_account = msg.getElementAsString("EMSX_ACCOUNT") if msg.hasElement("EMSX_ACCOUNT") else ""
emsx_amount = msg.getElementAsInteger("EMSX_AMOUNT") if msg.hasElement("EMSX_AMOUNT") else 0
emsx_arrival_price = msg.getElementAsFloat("EMSX_ARRIVAL_PRICE") if msg.hasElement("EMSX_ARRIVAL_PRICE") else 0
emsx_asset_class = msg.getElementAsString("EMSX_ASSET_CLASS") if msg.hasElement("EMSX_ASSET_CLASS") else ""
emsx_assigned_trader = msg.getElementAsString("EMSX_ASSIGNED_TRADER") if msg.hasElement("EMSX_ASSIGNED_TRADER") else ""
emsx_avg_price = msg.getElementAsFloat("EMSX_AVG_PRICE") if msg.hasElement("EMSX_AVG_PRICE") else 0
emsx_basket_name = msg.getElementAsString("EMSX_BASKET_NAME") if msg.hasElement("EMSX_BASKET_NAME") else ""
emsx_basket_num = msg.getElementAsInteger("EMSX_BASKET_NUM") if msg.hasElement("EMSX_BASKET_NUM") else 0
emsx_block_id = msg.getElementAsString("EMSX_BLOCK_ID") if msg.hasElement("EMSX_BLOCK_ID") else ""
emsx_broker = msg.getElementAsString("EMSX_BROKER") if msg.hasElement("EMSX_BROKER") else ""
emsx_broker_comm = msg.getElementAsFloat("EMSX_BROKER_COMM") if msg.hasElement("EMSX_BROKER_COMM") else 0
emsx_bse_avg_price = msg.getElementAsFloat("EMSX_BSE_AVG_PRICE") if msg.hasElement("EMSX_BSE_AVG_PRICE") else 0
emsx_bse_filled = msg.getElementAsInteger("EMSX_BSE_FILLED") if msg.hasElement("EMSX_BSE_FILLED") else 0
emsx_buyside_lei = msg.getElementAsString("EMSX_BUYSIDE_LEI") if msg.hasElement("EMSX_BUYSIDE_LEI") else ""
emsx_cfd_flag = msg.getElementAsString("EMSX_CFD_FLAG") if msg.hasElement("EMSX_CFD_FLAG") else ""
emsx_client_identification = msg.getElementAsString("EMSX_CLIENT_IDENTIFICATION") if msg.hasElement("EMSX_CLIENT_IDENTIFICATION") else ""
emsx_comm_diff_flag = msg.getElementAsString("EMSX_COMM_DIFF_FLAG") if msg.hasElement("EMSX_COMM_DIFF_FLAG") else ""
emsx_comm_rate = msg.getElementAsFloat("EMSX_COMM_RATE") if msg.hasElement("EMSX_COMM_RATE") else 0
emsx_currency_pair = msg.getElementAsString("EMSX_CURRENCY_PAIR") if msg.hasElement("EMSX_CURRENCY_PAIR") else ""
emsx_custom_note1 = msg.getElementAsString("EMSX_CUSTOM_NOTE1") if msg.hasElement("EMSX_CUSTOM_NOTE1") else ""
emsx_custom_note2 = msg.getElementAsString("EMSX_CUSTOM_NOTE2") if msg.hasElement("EMSX_CUSTOM_NOTE2") else ""
emsx_custom_note3 = msg.getElementAsString("EMSX_CUSTOM_NOTE3") if msg.hasElement("EMSX_CUSTOM_NOTE3") else ""
emsx_custom_note4 = msg.getElementAsString("EMSX_CUSTOM_NOTE4") if msg.hasElement("EMSX_CUSTOM_NOTE4") else ""
emsx_custom_note5 = msg.getElementAsString("EMSX_CUSTOM_NOTE5") if msg.hasElement("EMSX_CUSTOM_NOTE5") else ""
emsx_date = msg.getElementAsInteger("EMSX_DATE") if msg.hasElement("EMSX_DATE") else 0
emsx_day_avg_price = msg.getElementAsFloat("EMSX_DAY_AVG_PRICE") if msg.hasElement("EMSX_DAY_AVG_PRICE") else 0
emsx_day_fill = msg.getElementAsInteger("EMSX_DAY_FILL") if msg.hasElement("EMSX_DAY_FILL") else 0
emsx_dir_broker_flag = msg.getElementAsString("EMSX_DIR_BROKER_FLAG") if msg.hasElement("EMSX_DIR_BROKER_FLAG") else ""
emsx_exchange = msg.getElementAsString("EMSX_EXCHANGE") if msg.hasElement("EMSX_EXCHANGE") else ""
emsx_exchange_destination = msg.getElementAsString("EMSX_EXCHANGE_DESTINATION") if msg.hasElement("EMSX_EXCHANGE_DESTINATION") else ""
emsx_exec_instruction = msg.getElementAsString("EMSX_EXEC_INSTRUCTION") if msg.hasElement("EMSX_EXEC_INSTRUCTION") else ""
emsx_fill_id = msg.getElementAsInteger("EMSX_FILL_ID") if msg.hasElement("EMSX_FILL_ID") else 0
emsx_filled = msg.getElementAsInteger("EMSX_FILLED") if msg.hasElement("EMSX_FILLED") else 0
emsx_gpi = msg.getElementAsString("EMSX_GPI") if msg.hasElement("EMSX_GPI") else ""
emsx_gtd_date = msg.getElementAsInteger("EMSX_GTD_DATE") if msg.hasElement("EMSX_GTD_DATE") else 0
emsx_hand_instruction = msg.getElementAsString("EMSX_HAND_INSTRUCTION") if msg.hasElement("EMSX_HAND_INSTRUCTION") else ""
emsx_idle_amount = msg.getElementAsInteger("EMSX_IDLE_AMOUNT") if msg.hasElement("EMSX_IDLE_AMOUNT") else 0
emsx_investor_id = msg.getElementAsString("EMSX_INVESTOR_ID") if msg.hasElement("EMSX_INVESTOR_ID") else ""
emsx_isin = msg.getElementAsString("EMSX_ISIN") if msg.hasElement("EMSX_ISIN") else ""
emsx_limit_price = msg.getElementAsFloat("EMSX_LIMIT_PRICE") if msg.hasElement("EMSX_LIMIT_PRICE") else 0
emsx_mifid_ii_instruction = msg.getElementAsString("EMSX_MIFID_II_INSTRUCTION") if msg.hasElement("EMSX_MIFID_II_INSTRUCTION") else ""
emsx_mod_pend_status = msg.getElementAsString("EMSX_MOD_PEND_STATUS") if msg.hasElement("EMSX_MOD_PEND_STATUS") else ""
emsx_notes = msg.getElementAsString("EMSX_NOTES") if msg.hasElement("EMSX_NOTES") else ""
emsx_nse_avg_price = msg.getElementAsFloat("EMSX_NSE_AVG_PRICE") if msg.hasElement("EMSX_NSE_AVG_PRICE") else 0
emsx_nse_filled = msg.getElementAsInteger("EMSX_NSE_FILLED") if msg.hasElement("EMSX_NSE_FILLED") else 0
emsx_order_as_of_date = msg.getElementAsInteger("EMSX_ORDER_AS_OF_DATE") if msg.hasElement("EMSX_ORDER_AS_OF_DATE") else 0
emsx_order_as_of_time_microsec = msg.getElementAsFloat("EMSX_ORDER_AS_OF_TIME_MICROSEC") if msg.hasElement("EMSX_ORDER_AS_OF_TIME_MICROSEC") else 0
emsx_ord_ref_id = msg.getElementAsString("EMSX_ORD_REF_ID") if msg.hasElement("EMSX_ORD_REF_ID") else ""
emsx_order_type = msg.getElementAsString("EMSX_ORDER_TYPE") if msg.hasElement("EMSX_ORDER_TYPE") else ""
emsx_originate_trader = msg.getElementAsString("EMSX_ORIGINATE_TRADER") if msg.hasElement("EMSX_ORIGINATE_TRADER") else ""
emsx_originate_trader_firm = msg.getElementAsString("EMSX_ORIGINATE_TRADER_FIRM") if msg.hasElement("EMSX_ORIGINATE_TRADER_FIRM") else ""
emsx_percent_remain = msg.getElementAsFloat("EMSX_PERCENT_REMAIN") if msg.hasElement("EMSX_PERCENT_REMAIN") else 0
emsx_pm_uuid = msg.getElementAsInteger("EMSX_PM_UUID") if msg.hasElement("EMSX_PM_UUID") else 0
emsx_port_mgr = msg.getElementAsString("EMSX_PORT_MGR") if msg.hasElement("EMSX_PORT_MGR") else ""
emsx_port_name = msg.getElementAsString("EMSX_PORT_NAME") if msg.hasElement("EMSX_PORT_NAME") else ""
emsx_port_num = msg.getElementAsInteger("EMSX_PORT_NUM") if msg.hasElement("EMSX_PORT_NUM") else 0
emsx_position = msg.getElementAsString("EMSX_POSITION") if msg.hasElement("EMSX_POSITION") else ""
emsx_principle = msg.getElementAsFloat("EMSX_PRINCIPAL") if msg.hasElement("EMSX_PRINCIPAL") else 0
emsx_product = msg.getElementAsString("EMSX_PRODUCT") if msg.hasElement("EMSX_PRODUCT") else ""
emsx_queued_date = msg.getElementAsInteger("EMSX_QUEUED_DATE") if msg.hasElement("EMSX_QUEUED_DATE") else 0
emsx_queued_time = msg.getElementAsInteger("EMSX_QUEUED_TIME") if msg.hasElement("EMSX_QUEUED_TIME") else 0
emsx_queued_time_microsec = msg.getElementAsFloat("EMSX_QUEUED_TIME_MICROSEC") if msg.hasElement("EMSX_QUEUED_TIME_MICROSEC") else 0
emsx_reason_code = msg.getElementAsString("EMSX_REASON_CODE") if msg.hasElement("EMSX_REASON_CODE") else ""
emsx_reason_desc = msg.getElementAsString("EMSX_REASON_DESC") if msg.hasElement("EMSX_REASON_DESC") else ""
emsx_remain_balance = msg.getElementAsFloat("EMSX_REMAIN_BALANCE") if msg.hasElement("EMSX_REMAIN_BALANCE") else 0
emsx_route_id = msg.getElementAsInteger("EMSX_ROUTE_ID") if msg.hasElement("EMSX_ROUTE_ID") else 0
emsx_route_price = msg.getElementAsFloat("EMSX_ROUTE_PRICE") if msg.hasElement("EMSX_ROUTE_PRICE") else 0
emsx_sec_name = msg.getElementAsString("EMSX_SEC_NAME") if msg.hasElement("EMSX_SEC_NAME") else ""
emsx_sedol = msg.getElementAsString("EMSX_SEDOL") if msg.hasElement("EMSX_SEDOL") else ""
emsx_sequence = msg.getElementAsInteger("EMSX_SEQUENCE") if msg.hasElement("EMSX_SEQUENCE") else 0
emsx_settle_amount = msg.getElementAsFloat("EMSX_SETTLE_AMOUNT") if msg.hasElement("EMSX_SETTLE_AMOUNT") else 0
emsx_settle_date = msg.getElementAsInteger("EMSX_SETTLE_DATE") if msg.hasElement("EMSX_SETTLE_DATE") else 0
emsx_si = msg.getElementAsString("EMSX_SI") if msg.hasElement("EMSX_SI") else ""
emsx_side = msg.getElementAsString("EMSX_SIDE") if msg.hasElement("EMSX_SIDE") else ""
emsx_start_amount = msg.getElementAsInteger("EMSX_START_AMOUNT") if msg.hasElement("EMSX_START_AMOUNT") else 0
emsx_status = msg.getElementAsString("EMSX_STATUS") if msg.hasElement("EMSX_STATUS") else ""
emsx_step_out_broker = msg.getElementAsString("EMSX_STEP_OUT_BROKER") if msg.hasElement("EMSX_STEP_OUT_BROKER") else ""
emsx_stop_price = msg.getElementAsFloat("EMSX_STOP_PRICE") if msg.hasElement("EMSX_STOP_PRICE") else 0
emsx_strategy_end_time = msg.getElementAsInteger("EMSX_STRATEGY_END_TIME") if msg.hasElement("EMSX_STRATEGY_END_TIME") else 0
emsx_strategy_part_rate1 = msg.getElementAsFloat("EMSX_STRATEGY_PART_RATE1") if msg.hasElement("EMSX_STRATEGY_PART_RATE1") else 0
emsx_strategy_part_rate2 = msg.getElementAsFloat("EMSX_STRATEGY_PART_RATE2") if msg.hasElement("EMSX_STRATEGY_PART_RATE2") else 0
emsx_strategy_style = msg.getElementAsString("EMSX_STRATEGY_STYLE") if msg.hasElement("EMSX_STRATEGY_STYLE") else ""
emsx_strategy_type = msg.getElementAsString("EMSX_STRATEGY_TYPE") if msg.hasElement("EMSX_STRATEGY_TYPE") else ""
emsx_ticker = msg.getElementAsString("EMSX_TICKER") if msg.hasElement("EMSX_TICKER") else ""
emsx_tif = msg.getElementAsString("EMSX_TIF") if msg.hasElement("EMSX_TIF") else ""
emsx_time_stamp = msg.getElementAsInteger("EMSX_TIME_STAMP") if msg.hasElement("EMSX_TIME_STAMP") else 0
emsx_time_stamp_microsec = msg.getElementAsFloat("EMSX_TIME_STAMP_MICROSEC") if msg.hasElement("EMSX_TIME_STAMP_MICROSEC") else 0
emsx_trad_uuid = msg.getElementAsInteger("EMSX_TRAD_UUID") if msg.hasElement("EMSX_TRAD_UUID") else 0
emsx_trade_desk = msg.getElementAsString("EMSX_TRADE_DESK") if msg.hasElement("EMSX_TRADE_DESK") else ""
emsx_trader = msg.getElementAsString("EMSX_TRADER") if msg.hasElement("EMSX_TRADER") else ""
emsx_trader_notes = msg.getElementAsString("EMSX_TRADER_NOTES") if msg.hasElement("EMSX_TRADER_NOTES") else ""
emsx_ts_ordnum = msg.getElementAsInteger("EMSX_TS_ORDNUM") if msg.hasElement("EMSX_TS_ORDNUM") else 0
emsx_type = msg.getElementAsString("EMSX_TYPE") if msg.hasElement("EMSX_TYPE") else ""
emsx_underlying_ticker = msg.getElementAsString("EMSX_UNDERLYING_TICKER") if msg.hasElement("EMSX_UNDERLYING_TICKER") else ""
emsx_user_comm_amount = msg.getElementAsFloat("EMSX_USER_COMM_AMOUNT") if msg.hasElement("EMSX_USER_COMM_AMOUNT") else 0
emsx_user_comm_rate = msg.getElementAsFloat("EMSX_USER_COMM_RATE") if msg.hasElement("EMSX_USER_COMM_RATE") else 0
emsx_user_fees = msg.getElementAsFloat("EMSX_USER_FEES") if msg.hasElement("EMSX_USER_FEES") else 0
emsx_user_net_money = msg.getElementAsFloat("EMSX_USER_NET_MONEY") if msg.hasElement("EMSX_USER_NET_MONEY") else 0
emsx_user_work_price = msg.getElementAsFloat("EMSX_WORK_PRICE") if msg.hasElement("EMSX_WORK_PRICE") else 0
emsx_working = msg.getElementAsInteger("EMSX_WORKING") if msg.hasElement("EMSX_WORKING") else 0
emsx_yellow_key = msg.getElementAsString("EMSX_YELLOW_KEY") if msg.hasElement("EMSX_YELLOW_KEY") else ""
print ("ORDER MESSAGE: CorrelationID(%d) Status(%d)" % (msg.correlationIds()[0].value(),event_status))
print ("MESSAGE: %s" % (msg))
elif msg.correlationIds()[0].value() == routeSubscriptionID.value():
api_seq_num = msg.getElementAsInteger("API_SEQ_NUM") if msg.hasElement("API_SEQ_NUM") else 0
emsx_amount = msg.getElementAsInteger("EMSX_AMOUNT") if msg.hasElement("EMSX_AMOUNT") else 0
emsx_apa_mic = msg.getElementAsString("EMSX_APA_MIC") if msg.hasElement("EMSX_APA_MIC") else ""
emsx_avg_price = msg.getElementAsFloat("EMSX_AVG_PRICE") if msg.hasElement("EMSX_AVG_PRICE") else 0
emsx_broker = msg.getElementAsString("EMSX_BROKER") if msg.hasElement("EMSX_BROKER") else ""
emsx_broker_comm = msg.getElementAsFloat("EMSX_BROKER_COMM") if msg.hasElement("EMSX_BROKER_COMM") else 0
emsx_broker_lei = msg.getElementAsString("EMSX_BROKER_LEI") if msg.hasElement("EMSX_BROKER_LEI") else ""
emsx_broker_si = msg.getElementAsString("EMSX_BROKER_SI") if msg.hasElement("EMSX_BROKER_SI") else ""
emsx_broker_status = msg.getElementAsString("EMSX_BROKER_STATUS") if msg.hasElement("EMSX_BROKER_STATUS") else ""
emsx_bse_avg_price = msg.getElementAsFloat("EMSX_BSE_AVG_PRICE") if msg.hasElement("EMSX_BSE_AVG_PRICE") else 0
emsx_bse_filled = msg.getElementAsInteger("EMSX_BSE_FILLED") if msg.hasElement("EMSX_BSE_FILLED") else 0
emsx_buyside_lei = msg.getElementAsString("EMSX_BUYSIDE_LEI") if msg.hasElement("EMSX_BUYSIDE_LEI") else ""
emsx_clearing_account = msg.getElementAsString("EMSX_CLEARING_ACCOUNT") if msg.hasElement("EMSX_CLEARING_ACCOUNT") else ""
emsx_clearing_firm = msg.getElementAsString("EMSX_CLEARING_FIRM") if msg.hasElement("EMSX_CLEARING_FIRM") else ""
emsx_client_identification = msg.getElementAsString("EMSX_CLIENT_IDENTIFICATION") if msg.hasElement("EMSX_CLIENT_IDENTIFICATION") else ""
emsx_comm_diff_flag = msg.getElementAsString("EMSX_COMM_DIFF_FLAG") if msg.hasElement("EMSX_COMM_DIFF_FLAG") else ""
emsx_comm_rate = msg.getElementAsFloat("EMSX_COMM_RATE") if msg.hasElement("EMSX_COMM_RATE") else 0
emsx_currency_pair = msg.getElementAsString("EMSX_CURRENCY_PAIR") if msg.hasElement("EMSX_CURRENCY_PAIR") else ""
emsx_custom_account = msg.getElementAsString("EMSX_CUSTOM_ACCOUNT") if msg.hasElement("EMSX_CUSTOM_ACCOUNT") else ""
emsx_day_avg_price = msg.getElementAsFloat("EMSX_DAY_AVG_PRICE") if msg.hasElement("EMSX_DAY_AVG_PRICE") else 0
emsx_day_fill = msg.getElementAsInteger("EMSX_DAY_FILL") if msg.hasElement("EMSX_DAY_FILL") else 0
emsx_exchange_destination = msg.getElementAsString("EMSX_EXCHANGE_DESTINATION") if msg.hasElement("EMSX_EXCHANGE_DESTINATION") else ""
emsx_exec_instruction = msg.getElementAsString("EMSX_EXEC_INSTRUCTION") if msg.hasElement("EMSX_EXEC_INSTRUCTION") else ""
emsx_execute_broker = msg.getElementAsString("EMSX_EXECUTE_BROKER") if msg.hasElement("EMSX_EXECUTE_BROKER") else ""
emsx_fill_id = msg.getElementAsInteger("EMSX_FILL_ID") if msg.hasElement("EMSX_FILL_ID") else 0
emsx_filled = msg.getElementAsInteger("EMSX_FILLED") if msg.hasElement("EMSX_FILLED") else 0
emsx_gpi = msg.getElementAsString("EMSX_GPI") if msg.hasElement("EMSX_GPI") else ""
emsx_gtd_date = msg.getElementAsInteger("EMSX_GTD_DATE") if msg.hasElement("EMSX_GTD_DATE") else 0
emsx_hand_instruction = msg.getElementAsString("EMSX_HAND_INSTRUCTION") if msg.hasElement("EMSX_HAND_INSTRUCTION") else ""
emsx_is_manual_route = msg.getElementAsInteger("EMSX_IS_MANUAL_ROUTE") if msg.hasElement("EMSX_IS_MANUAL_ROUTE") else 0
emsx_last_capacity = msg.getElementAsString("EMSX_LAST_CAPACITY") if msg.hasElement("EMSX_LAST_CAPACITY") else ""
emsx_last_fill_date = msg.getElementAsInteger("EMSX_LAST_FILL_DATE") if msg.hasElement("EMSX_LAST_FILL_DATE") else 0
emsx_last_fill_time = msg.getElementAsInteger("EMSX_LAST_FILL_TIME") if msg.hasElement("EMSX_LAST_FILL_TIME") else 0
emsx_last_fill_time_microsec = msg.getElementAsFloat("EMSX_LAST_FILL_TIME_MICROSEC") if msg.hasElement("EMSX_LAST_FILL_TIME_MICROSEC") else 0
emsx_last_market = msg.getElementAsString("EMSX_LAST_MARKET") if msg.hasElement("EMSX_LAST_MARKET") else ""
emsx_last_price = msg.getElementAsFloat("EMSX_LAST_PRICE") if msg.hasElement("EMSX_LAST_PRICE") else 0
emsx_last_shares = msg.getElementAsInteger("EMSX_LAST_SHARES") if msg.hasElement("EMSX_LAST_SHARES") else 0
emsx_leg_fill_date_added = msg.getElementAsInteger("EMSX_LEG_FILL_DATE_ADDED") if msg.hasElement("EMSX_LEG_FILL_DATE_ADDED") else 0
emsx_leg_fill_price = msg.getElementAsFloat("EMSX_LEG_FILL_PRICE") if msg.hasElement("EMSX_LEG_FILL_PRICE") else 0
emsx_leg_fill_seq_no = msg.getElementAsInteger("EMSX_LEG_FILL_SEQ_NO") if msg.hasElement("EMSX_LEG_FILL_SEQ_NO") else 0
emsx_leg_fill_shares = msg.getElementAsFloat("EMSX_LEG_FILL_SHARES") if msg.hasElement("EMSX_LEG_FILL_SHARES") else 0
emsx_leg_fill_side = msg.getElementAsString("EMSX_LEG_FILL_SIDE") if msg.hasElement("EMSX_LEG_FILL_SIDE") else ""
emsx_leg_fill_ticker = msg.getElementAsString("EMSX_LEG_FILL_TICKER") if msg.hasElement("EMSX_LEG_FILL_TICKER") else ""
emsx_leg_fill_time_added = msg.getElementAsInteger("EMSX_LEG_FILL_TIME_ADDED") if msg.hasElement("EMSX_LEG_FILL_TIME_ADDED") else 0
emsx_limit_price = msg.getElementAsFloat("EMSX_LIMIT_PRICE") if msg.hasElement("EMSX_LIMIT_PRICE") else 0
emsx_mifid_ii_instruction = msg.getElementAsString("EMSX_MIFID_II_INSTRUCTION") if msg.hasElement("EMSX_MIFID_II_INSTRUCTION") else ""
emsx_misc_fees = msg.getElementAsFloat("EMSX_MISC_FEES") if msg.hasElement("EMSX_MISC_FEES") else 0
emsx_ml_id = msg.getElementAsString("EMSX_ML_ID") if msg.hasElement("EMSX_ML_ID") else ""
emsx_ml_leg_quantity = msg.getElementAsInteger("EMSX_ML_LEG_QUANTITY") if msg.hasElement("EMSX_ML_LEG_QUANTITY") else 0
emsx_ml_num_legs = msg.getElementAsInteger("EMSX_ML_NUM_LEGS") if msg.hasElement("EMSX_ML_NUM_LEGS") else 0
emsx_ml_percent_filled = msg.getElementAsFloat("EMSX_ML_PERCENT_FILLED") if msg.hasElement("EMSX_ML_PERCENT_FILLED") else 0
emsx_ml_ratio = msg.getElementAsFloat("EMSX_ML_RATIO") if msg.hasElement("EMSX_ML_RATIO") else 0
emsx_ml_remain_balance = msg.getElementAsFloat("EMSX_ML_REMAIN_BALANCE") if msg.hasElement("EMSX_ML_REMAIN_BALANCE") else 0
emsx_ml_strategy = msg.getElementAsString("EMSX_ML_STRATEGY") if msg.hasElement("EMSX_ML_STRATEGY") else ""
emsx_ml_total_quantity = msg.getElementAsInteger("EMSX_ML_TOTAL_QUANTITY") if msg.hasElement("EMSX_ML_TOTAL_QUANTITY") else 0
emsx_notes = msg.getElementAsString("EMSX_NOTES") if msg.hasElement("EMSX_NOTES") else ""
emsx_nse_avg_price = msg.getElementAsFloat("EMSX_NSE_AVG_PRICE") if msg.hasElement("EMSX_NSE_AVG_PRICE") else 0
emsx_nse_filled = msg.getElementAsInteger("EMSX_NSE_FILLED") if msg.hasElement("EMSX_NSE_FILLED") else 0
emsx_order_type = msg.getElementAsString("EMSX_ORDER_TYPE") if msg.hasElement("EMSX_ORDER_TYPE") else ""
emsx_otc_flag = msg.getElementAsString("EMSX_OTC_FLAG") if msg.hasElement("EMSX_OTC_FLAG") else ""
emsx_p_a = msg.getElementAsString("EMSX_P_A") if msg.hasElement("EMSX_P_A") else ""
emsx_percent_remain = msg.getElementAsFloat("EMSX_PERCENT_REMAIN") if msg.hasElement("EMSX_PERCENT_REMAIN") else 0
emsx_principal = msg.getElementAsFloat("EMSX_PRINCIPAL") if msg.hasElement("EMSX_PRINCIPAL") else 0
emsx_queued_date = msg.getElementAsInteger("EMSX_QUEUED_DATE") if msg.hasElement("EMSX_QUEUED_DATE") else 0
emsx_queued_time = msg.getElementAsInteger("EMSX_QUEUED_TIME") if msg.hasElement("EMSX_QUEUED_TIME") else 0
emsx_queued_time_microsec = msg.getElementAsFloat("EMSX_QUEUED_TIME_MICROSEC") if msg.hasElement("EMSX_QUEUED_TIME_MICROSEC") else ""
emsx_reason_code = msg.getElementAsString("EMSX_REASON_CODE") if msg.hasElement("EMSX_REASON_CODE") else ""
emsx_reason_desc = msg.getElementAsString("EMSX_REASON_DESC") if msg.hasElement("EMSX_REASON_DESC") else ""
emsx_remain_balance = msg.getElementAsFloat("EMSX_REMAIN_BALANCE") if msg.hasElement("EMSX_REMAIN_BALANCE") else 0
emsx_route_as_of_date = msg.getElementAsInteger("EMSX_ROUTE_AS_OF_DATE") if msg.hasElement("EMSX_ROUTE_AS_OF_DATE") else 0
emsx_route_as_of_time_microsec = msg.getElementAsFloat("EMSX_ROUTE_AS_OF_TIME_MICROSEC") if msg.hasElement("EMSX_ROUTE_AS_OF_TIME_MICROSEC") else 0
emsx_route_create_date = msg.getElementAsInteger("EMSX_ROUTE_CREATE_DATE") if msg.hasElement("EMSX_ROUTE_CREATE_DATE") else 0
emsx_route_create_time = msg.getElementAsInteger("EMSX_ROUTE_CREATE_TIME") if msg.hasElement("EMSX_ROUTE_CREATE_TIME") else 0
emsx_route_create_time_microsec = msg.getElementAsFloat("EMSX_ROUTE_CREATE_TIME_MICROSEC") if msg.hasElement("EMSX_ROUTE_CREATE_TIME_MICROSEC") else 0
emsx_route_id = msg.getElementAsInteger("EMSX_ROUTE_ID") if msg.hasElement("EMSX_ROUTE_ID") else 0
emsx_route_last_update_time = msg.getElementAsInteger("EMSX_ROUTE_LAST_UPDATE_TIME") if msg.hasElement("EMSX_ROUTE_LAST_UPDATE_TIME") else 0
emsx_route_last_update_time_microsec = msg.getElementAsFloat("EMSX_ROUTE_LAST_UPDATE_TIME_MICROSEC") if msg.hasElement("EMSX_ROUTE_LAST_UPDATE_TIME_MICROSEC") else 0
emsx_route_price = msg.getElementAsFloat("EMSX_ROUTE_PRICE") if msg.hasElement("EMSX_ROUTE_PRICE") else 0
emsx_route_ref_id = msg.getElementAsString("EMSX_ROUTE_REF_ID") if msg.hasElement("EMSX_ROUTE_REF_ID") else ""
emsx_sequence = msg.getElementAsInteger("EMSX_SEQUENCE") if msg.hasElement("EMSX_SEQUENCE") else 0
emsx_settle_amount = msg.getElementAsFloat("EMSX_SETTLE_AMOUNT") if msg.hasElement("EMSX_SETTLE_AMOUNT") else 0
emsx_settle_date = msg.getElementAsInteger("EMSX_SETTLE_DATE") if msg.hasElement("EMSX_SETTLE_DATE") else 0
emsx_status = msg.getElementAsString("EMSX_STATUS") if msg.hasElement("EMSX_STATUS") else ""
emsx_stop_price = msg.getElementAsFloat("EMSX_STOP_PRICE") if msg.hasElement("EMSX_STOP_PRICE") else 0
emsx_strategy_end_time = msg.getElementAsInteger("EMSX_STRATEGY_END_TIME") if msg.hasElement("EMSX_STRATEGY_END_TIME") else 0
emsx_strategy_part_rate1 = msg.getElementAsFloat("EMSX_STRATEGY_PART_RATE1") if msg.hasElement("EMSX_STRATEGY_PART_RATE1") else 0
emsx_strategy_part_rate2 = msg.getElementAsFloat("EMSX_STRATEGY_PART_RATE2") if msg.hasElement("EMSX_STRATEGY_PART_RATE2") else 0
emsx_strategy_start_time = msg.getElementAsInteger("EMSX_STRATEGY_START_TIME") if msg.hasElement("EMSX_STRATEGY_START_TIME") else 0
emsx_strategy_style = msg.getElementAsString("EMSX_STRATEGY_STYLE") if msg.hasElement("EMSX_STRATEGY_STYLE") else ""
emsx_strategy_type = msg.getElementAsString("EMSX_STRATEGY_TYPE") if msg.hasElement("EMSX_STRATEGY_TYPE") else ""
emsx_tif = msg.getElementAsString("EMSX_TIF") if msg.hasElement("EMSX_TIF") else ""
emsx_time_stamp = msg.getElementAsInteger("EMSX_TIME_STAMP") if msg.hasElement("EMSX_TIME_STAMP") else 0
emsx_time_stamp_microsec = msg.getElementAsFloat("EMSX_TIME_STAMP_MICROSEC") if msg.hasElement("EMSX_TIME_STAMP_MICROSEC") else 0
emsx_trade_reporting_indicator = msg.getElementAsString("EMSX_TRADE_REPORTING_INDICATOR") if msg.hasElement("EMSX_TRADE_REPORTING_INDICATOR") else ""
emsx_transaction_reporting_mic = msg.getElementAsString("EMSX_TRANSACTION_REPORTING_MIC") if msg.hasElement("EMSX_TRANSACTION_REPORTING_MIC") else ""
emsx_type = msg.getElementAsString("EMSX_TYPE") if msg.hasElement("EMSX_TYPE") else ""
emsx_urgency_level = msg.getElementAsInteger("EMSX_URGENCY_LEVEL") if msg.hasElement("EMSX_URGENCY_LEVEL") else ""
emsx_user_comm_amount = msg.getElementAsFloat("EMSX_USER_COMM_AMOUNT") if msg.hasElement("EMSX_USER_COMM_AMOUNT") else 0
emsx_user_comm_rate = msg.getElementAsFloat("EMSX_USER_COMM_RATE") if msg.hasElement("EMSX_USER_COMM_RATE") else 0
emsx_user_fees = msg.getElementAsFloat("EMSX_USER_FEES") if msg.hasElement("EMSX_USER_FEES") else 0
emsx_user_net_money = msg.getElementAsFloat("EMSX_USER_NET_MONEY") if msg.hasElement("EMSX_USER_NET_MONEY") else 0
emsx_waiver_flag = msg.getElementAsString("EMSX_WAIVER_FLAG") if msg.hasElement("EMSX_WORKING") else ""
emsx_working = msg.getElementAsInteger("EMSX_WORKING") if msg.hasElement("EMSX_WORKING") else 0
emsx_route_as_of_date = msg.getElementAsInteger("EMSX_ROUTE_AS_OF_DATE") if msg.hasElement("EMSX_ROUTE_AS_OF_DATE") else 0
print ("ROUTE MESSAGE: CorrelationID(%d) Status(%d)" % (msg.correlationIds()[0].value(),event_status))
print ("MESSAGE: %s" % (msg))
else:
print ("Error: Unexpected message", file=sys.stderr)
def processMiscEvents(self, event):
print ("Processing " + event.eventType() + " event")
for msg in event:
print ("MESSAGE: %s" % (msg))
def createOrderSubscription(self, session):
print ("Create Order subscription")
#orderTopic = d_service + "/order;team=TKTEAM?fields="
orderTopic = d_service + "/order?fields="
orderTopic = orderTopic + "API_SEQ_NUM,"
orderTopic = orderTopic + "EMSX_ACCOUNT,"
orderTopic = orderTopic + "EMSX_AMOUNT,"
orderTopic = orderTopic + "EMSX_ARRIVAL_PRICE,"
orderTopic = orderTopic + "EMSX_ASSET_CLASS,"
orderTopic = orderTopic + "EMSX_ASSIGNED_TRADER,"
orderTopic = orderTopic + "EMSX_AVG_PRICE,"
orderTopic = orderTopic + "EMSX_BASKET_NAME,"
orderTopic = orderTopic + "EMSX_BASKET_NUM,"
orderTopic = orderTopic + "EMSX_BLOCK_ID,"
orderTopic = orderTopic + "EMSX_BROKER,"
orderTopic = orderTopic + "EMSX_BROKER_COMM,"
orderTopic = orderTopic + "EMSX_BSE_AVG_PRICE,"
orderTopic = orderTopic + "EMSX_BSE_FILLED,"
orderTopic = orderTopic + "EMSX_BUYSIDE_LEI,"
orderTopic = orderTopic + "EMSX_CFD_FLAG,"
orderTopic = orderTopic + "EMSX_CLIENT_IDENTIFICATION,"
orderTopic = orderTopic + "EMSX_COMM_DIFF_FLAG,"
orderTopic = orderTopic + "EMSX_COMM_RATE,"
orderTopic = orderTopic + "EMSX_CUSTOM_NOTE1,"
orderTopic = orderTopic + "EMSX_CUSTOM_NOTE2,"
orderTopic = orderTopic + "EMSX_CUSTOM_NOTE3,"
orderTopic = orderTopic + "EMSX_CUSTOM_NOTE4,"
orderTopic = orderTopic + "EMSX_CUSTOM_NOTE5,"
orderTopic = orderTopic + "EMSX_CURRENCY_PAIR,"
orderTopic = orderTopic + "EMSX_DATE,"
orderTopic = orderTopic + "EMSX_DAY_AVG_PRICE,"
orderTopic = orderTopic + "EMSX_DAY_FILL,"
orderTopic = orderTopic + "EMSX_DIR_BROKER_FLAG,"
orderTopic = orderTopic + "EMSX_EXCHANGE,"
orderTopic = orderTopic + "EMSX_EXCHANGE_DESTINATION,"
orderTopic = orderTopic + "EMSX_EXEC_INSTRUCTION,"
orderTopic = orderTopic + "EMSX_FILL_ID,"
orderTopic = orderTopic + "EMSX_FILLED,"
orderTopic = orderTopic + "EMSX_GPI,"
orderTopic = orderTopic + "EMSX_GTD_DATE,"
orderTopic = orderTopic + "EMSX_HAND_INSTRUCTION,"
orderTopic = orderTopic + "EMSX_IDLE_AMOUNT,"
orderTopic = orderTopic + "EMSX_INVESTOR_ID,"
orderTopic = orderTopic + "EMSX_ISIN,"
orderTopic = orderTopic + "EMSX_LIMIT_PRICE,"
orderTopic = orderTopic + "EMSX_MIFID_II_INSTRUCTION,"
orderTopic = orderTopic + "EMSX_MOD_PEND_STATUS,"
orderTopic = orderTopic + "EMSX_NOTES,"
orderTopic = orderTopic + "EMSX_NSE_AVG_PRICE,"
orderTopic = orderTopic + "EMSX_NSE_FILLED,"
orderTopic = orderTopic + "EMSX_ORD_REF_ID,"
orderTopic = orderTopic + "EMSX_ORDER_AS_OF_DATE,"
orderTopic = orderTopic + "EMSX_ORDER_AS_OF_TIME_MICROSEC,"
orderTopic = orderTopic + "EMSX_ORDER_TYPE,"
orderTopic = orderTopic + "EMSX_ORIGINATE_TRADER,"
orderTopic = orderTopic + "EMSX_ORIGINATE_TRADER_FIRM,"
orderTopic = orderTopic + "EMSX_PERCENT_REMAIN,"
orderTopic = orderTopic + "EMSX_PM_UUID,"
orderTopic = orderTopic + "EMSX_PORT_MGR,"
orderTopic = orderTopic + "EMSX_PORT_NAME,"
orderTopic = orderTopic + "EMSX_PORT_NUM,"
orderTopic = orderTopic + "EMSX_POSITION,"
orderTopic = orderTopic + "EMSX_PRINCIPAL,"
orderTopic = orderTopic + "EMSX_PRODUCT,"
orderTopic = orderTopic + "EMSX_QUEUED_DATE,"
orderTopic = orderTopic + "EMSX_QUEUED_TIME,"
orderTopic = orderTopic + "EMSX_QUEUED_TIME_MICROSEC,"
orderTopic = orderTopic + "EMSX_REASON_CODE,"
orderTopic = orderTopic + "EMSX_REASON_DESC,"
orderTopic = orderTopic + "EMSX_REMAIN_BALANCE,"
orderTopic = orderTopic + "EMSX_ROUTE_ID,"
orderTopic = orderTopic + "EMSX_ROUTE_PRICE,"
orderTopic = orderTopic + "EMSX_SEC_NAME,"
orderTopic = orderTopic + "EMSX_SEDOL,"
orderTopic = orderTopic + "EMSX_SEQUENCE,"
orderTopic = orderTopic + "EMSX_SETTLE_AMOUNT,"
orderTopic = orderTopic + "EMSX_SETTLE_DATE,"
orderTopic = orderTopic + "EMSX_SI,"
orderTopic = orderTopic + "EMSX_SIDE,"
orderTopic = orderTopic + "EMSX_START_AMOUNT,"
orderTopic = orderTopic + "EMSX_STATUS,"
orderTopic = orderTopic + "EMSX_STEP_OUT_BROKER,"
orderTopic = orderTopic + "EMSX_STOP_PRICE,"
orderTopic = orderTopic + "EMSX_STRATEGY_END_TIME,"
orderTopic = orderTopic + "EMSX_STRATEGY_PART_RATE1,"
orderTopic = orderTopic + "EMSX_STRATEGY_PART_RATE2,"
orderTopic = orderTopic + "EMSX_STRATEGY_START_TIME,"
orderTopic = orderTopic + "EMSX_STRATEGY_STYLE,"
orderTopic = orderTopic + "EMSX_STRATEGY_TYPE,"
orderTopic = orderTopic + "EMSX_TICKER,"
orderTopic = orderTopic + "EMSX_TIF,"
orderTopic = orderTopic + "EMSX_TIME_STAMP,"
orderTopic = orderTopic + "EMSX_TIME_STAMP_MICROSEC,"
orderTopic = orderTopic + "EMSX_TRAD_UUID,"
orderTopic = orderTopic + "EMSX_TRADE_DESK,"
orderTopic = orderTopic + "EMSX_TRADER,"
orderTopic = orderTopic + "EMSX_TRADER_NOTES,"
orderTopic = orderTopic + "EMSX_TS_ORDNUM,"
orderTopic = orderTopic + "EMSX_TYPE,"
orderTopic = orderTopic + "EMSX_UNDERLYING_TICKER,"
orderTopic = orderTopic + "EMSX_USER_COMM_AMOUNT,"
orderTopic = orderTopic + "EMSX_USER_COMM_RATE,"
orderTopic = orderTopic + "EMSX_USER_FEES,"
orderTopic = orderTopic + "EMSX_USER_NET_MONEY,"
orderTopic = orderTopic + "EMSX_WORK_PRICE,"
orderTopic = orderTopic + "EMSX_WORKING,"
orderTopic = orderTopic + "EMSX_YELLOW_KEY"
subscriptions = blpapi.SubscriptionList()
subscriptions.add(topic=orderTopic,correlationId=orderSubscriptionID)
session.subscribe(subscriptions)
def createRouteSubscription(self, session):
print ("Create Route subscription")
#routeTopic = d_service + "/route;team=EMSX_API?fields="
routeTopic = d_service + "/route?fields="
routeTopic = routeTopic + "API_SEQ_NUM,"
routeTopic = routeTopic + "EMSX_AMOUNT,"
routeTopic = routeTopic + "EMSX_APA_MIC,"
routeTopic = routeTopic + "EMSX_AVG_PRICE,"
routeTopic = routeTopic + "EMSX_BROKER,"
routeTopic = routeTopic + "EMSX_BROKER_COMM,"
routeTopic = routeTopic + "EMSX_BROKER_LEI,"
routeTopic = routeTopic + "EMSX_BROKER_SI,"
routeTopic = routeTopic + "EMSX_BSE_AVG_PRICE,"
routeTopic = routeTopic + "EMSX_BSE_FILLED,"
routeTopic = routeTopic + "EMSX_BROKER_STATUS,"
routeTopic = routeTopic + "EMSX_BUYSIDE_LEI,"
routeTopic = routeTopic + "EMSX_CLEARING_ACCOUNT,"
routeTopic = routeTopic + "EMSX_CLEARING_FIRM,"
routeTopic = routeTopic + "EMSX_CLIENT_IDENTIFICATION,"
routeTopic = routeTopic + "EMSX_COMM_DIFF_FLAG,"
routeTopic = routeTopic + "EMSX_COMM_RATE,"
routeTopic = routeTopic + "EMSX_CURRENCY_PAIR,"
routeTopic = routeTopic + "EMSX_CUSTOM_ACCOUNT,"
routeTopic = routeTopic + "EMSX_DAY_AVG_PRICE,"
routeTopic = routeTopic + "EMSX_DAY_FILL,"
routeTopic = routeTopic + "EMSX_EXCHANGE_DESTINATION,"
routeTopic = routeTopic + "EMSX_EXEC_INSTRUCTION,"
routeTopic = routeTopic + "EMSX_EXECUTE_BROKER,"
routeTopic = routeTopic + "EMSX_FILL_ID,"
routeTopic = routeTopic + "EMSX_FILLED,"
routeTopic = routeTopic + "EMSX_GPI,"
routeTopic = routeTopic + "EMSX_GTD_DATE,"
routeTopic = routeTopic + "EMSX_HAND_INSTRUCTION,"
routeTopic = routeTopic + "EMSX_IS_MANUAL_ROUTE,"
routeTopic = routeTopic + "EMSX_LAST_CAPACITY,"
routeTopic = routeTopic + "EMSX_LAST_FILL_DATE,"
routeTopic = routeTopic + "EMSX_LAST_FILL_TIME,"
routeTopic = routeTopic + "EMSX_LAST_FILL_TIME_MICROSEC,"
routeTopic = routeTopic + "EMSX_LAST_MARKET,"
routeTopic = routeTopic + "EMSX_LAST_PRICE,"
routeTopic = routeTopic + "EMSX_LAST_SHARES,"
routeTopic = routeTopic + "EMSX_LEG_FILL_DATE_ADDED,"
routeTopic = routeTopic + "EMSX_LEG_FILL_PRICE,"
routeTopic = routeTopic + "EMSX_LEG_FILL_SEQ_NO,"
routeTopic = routeTopic + "EMSX_LEG_FILL_SHARES,"
routeTopic = routeTopic + "EMSX_LEG_FILL_SIDE,"
routeTopic = routeTopic + "EMSX_LEG_FILL_TICKER,"
rotueTopic = routeTopic + "EMSX_LEG_FILL_TIME_ADDED,"
routeTopic = routeTopic + "EMSX_LIMIT_PRICE,"
routeTopic = routeTopic + "EMSX_MIFID_II_INSTRUCTION,"
routeTopic = routeTopic + "EMSX_MISC_FEES,"
routeTopic = routeTopic + "EMSX_ML_ID,"
routeTopic = routeTopic + "EMSX_ML_LEG_QUANTITY,"
routeTopic = routeTopic + "EMSX_ML_NUM_LEGS,"
routeTopic = routeTopic + "EMSX_ML_PERCENT_FILLED,"
routeTopic = routeTopic + "EMSX_ML_RATIO,"
routeTopic = routeTopic + "EMSX_ML_REMAIN_BALANCE,"
routeTopic = routeTopic + "EMSX_ML_STRATEGY,"
routeTopic = routeTopic + "EMSX_ML_TOTAL_QUANTITY,"
routeTopic = routeTopic + "EMSX_NOTES,"
routeTopic = routeTopic + "EMSX_NSE_AVG_PRICE,"
routeTopic = routeTopic + "EMSX_NSE_FILLED,"
routeTopic = routeTopic + "EMSX_ORDER_TYPE,"
routeTopic = routeTopic + "EMSX_OTC_FLAG,"
routeTopic = routeTopic + "EMSX_P_A,"
routeTopic = routeTopic + "EMSX_PERCENT_REMAIN,"
routeTopic = routeTopic + "EMSX_PRINCIPAL,"
routeTopic = routeTopic + "EMSX_QUEUED_DATE,"
routeTopic = routeTopic + "EMSX_QUEUED_TIME,"
routeTopic = routeTopic + "EMSX_QUEUED_TIME_MICROSEC,"
routeTopic = routeTopic + "EMSX_REASON_CODE,"
routeTopic = routeTopic + "EMSX_REASON_DESC,"
routeTopic = routeTopic + "EMSX_REMAIN_BALANCE,"
routeTopic = routeTopic + "EMSX_ROUTE_AS_OF_DATE,"
routeTopic = routeTopic + "EMSX_ROUTE_AS_OF_TIME_MICROSEC,"
routeTopic = routeTopic + "EMSX_ROUTE_CREATE_DATE,"
routeTopic = routeTopic + "EMSX_ROUTE_CREATE_TIME,"
routeTopic = routeTopic + "EMSX_ROUTE_CREATE_TIME_MICROSEC,"
routeTopic = routeTopic + "EMSX_ROUTE_ID,"
routeTopic = routeTopic + "EMSX_ROUTE_LAST_UPDATE_TIME,"
routeTopic = routeTopic + "EMSX_ROUTE_LAST_UPDATE_TIME_MICROSEC,"
routeTopic = routeTopic + "EMSX_ROUTE_PRICE,"
routeTopic = routeTopic + "EMSX_ROUTE_REF_ID,"
routeTopic = routeTopic + "EMSX_SEQUENCE,"
routeTopic = routeTopic + "EMSX_SETTLE_AMOUNT,"
routeTopic = routeTopic + "EMSX_SETTLE_DATE,"
routeTopic = routeTopic + "EMSX_STATUS,"
routeTopic = routeTopic + "EMSX_STOP_PRICE,"
routeTopic = routeTopic + "EMSX_STRATEGY_END_TIME,"
routeTopic = routeTopic + "EMSX_STRATEGY_PART_RATE1,"
routeTopic = routeTopic + "EMSX_STRATEGY_PART_RATE2,"
routeTopic = routeTopic + "EMSX_STRATEGY_START_TIME,"
routeTopic = routeTopic + "EMSX_STRATEGY_STYLE,"
routeTopic = routeTopic + "EMSX_STRATEGY_TYPE,"
routeTopic = routeTopic + "EMSX_TIF,"
routeTopic = routeTopic + "EMSX_TIME_STAMP,"
routeTopic = routeTopic + "EMSX_TIME_STAMP_MICROSEC,"
routeTopic = routeTopic + "EMSX_TRADE_REPORTING_INDICATOR,"
routeTopic = routeTopic + "EMSX_TRANSACTION_REPORTING_MIC,"
routeTopic = routeTopic + "EMSX_TYPE,"
routeTopic = routeTopic + "EMSX_URGENCY_LEVEL,"
routeTopic = routeTopic + "EMSX_USER_COMM_AMOUNT,"
routeTopic = routeTopic + "EMSX_USER_COMM_RATE,"
routeTopic = routeTopic + "EMSX_USER_FEES,"
routeTopic = routeTopic + "EMSX_USER_NET_MONEY,"
routeTopic = routeTopic + "EMSX_WAIVER_FLAG,"
routeTopic = routeTopic + "EMSX_WORKING"
subscriptions = blpapi.SubscriptionList()
subscriptions.add(topic=routeTopic,correlationId=routeSubscriptionID)
session.subscribe(subscriptions)
def main():
sessionOptions = blpapi.SessionOptions()
sessionOptions.setServerHost(d_host)
sessionOptions.setServerPort(d_port)
print ("Connecting to %s:%d" % (d_host,d_port))
eventHandler = SessionEventHandler()
session = blpapi.Session(sessionOptions, eventHandler.processEvent)
if not session.startAsync():
print ("Failed to start session.")
return
try:
# Wait for enter key to exit application
print ("Press ENTER to quit")
input()
finally:
session.stop()
if __name__ == "__main__":
print ("Bloomberg - EMSX API Example - EMSXSubscriptions")
try:
main()
except KeyboardInterrupt:
print ("Ctrl+C pressed. Stopping...")
__copyright__ = """
Copyright 2013. Bloomberg Finance L.P.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above
copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""