Brokerages
Bloomberg EMSX
Introduction
QuantConnect enables you to run your algorithms in live mode with real-time market data.
QuantConnect Cloud supports routing trades to the Bloomberg™ EMSX API Server. In this environment, you can route orders to any of the 1,300+ prime brokerages that Bloomberg supports and you get to leverage the data, server management, and data management from QuantConnect, giving you the best of both worlds. To use Quant Bridge, you need to be a member of an organization on the Trading Firm or Institution tier.
QuantConnect Local Platform can integrate with the Bloomberg™ EMSX API Server or Desktop API (DAPI). This integration allows research, backtesting, opitimization, and live trading through the Bloomberg APIs, on-premises. Quant Bridge is in no way affiliated with or endorsed by Bloomberg™; it is simply an add-on.
Data Providers
The Bloomberg™ EMSX API Server doesn't provide data, so we recommend the QuantConnect data provider, which is free and supplies US Equities, US Equity Options, US Index Options, and Futures data during live trading. It also supplies SPX and VIX Index data, which SPX and VIX Index Options need for the underlying index. For more information about live data providers, see Datasets.
This limitation applies to QuantConnect Cloud, which connects to the EMSX API Server. Local deployments connect to the Bloomberg™ Desktop API (DAPI) instead, so Quant Bridge can source live and historical data from your Bloomberg™ Terminal, within your Bloomberg™ license permissions. Intraday history goes back up to 6 months, and historical open interest and custom data aren't available. For more information, see Quant Bridge.
Orders
Quant Bridge enables you to create and manage Bloomberg™ orders.
Order Types
The following table describes the available order types for each asset class that Quant Bridge supports:
| Order Type | Equity | Equity Options | Index Options | Futures |
|---|---|---|---|---|
| Market | ![]() | ![]() | ![]() | ![]() |
| Market on open | ![]() | |||
| Limit | ![]() | ![]() | ![]() | ![]() |
| Stop market | ![]() | ![]() | ![]() | ![]() |
| Stop limit | ![]() | ![]() | ![]() | ![]() |
Order Properties
We model custom order properties from the Bloomberg EMSX API. The following table describes the members of the QuantBridgeOrderProperties object that you can set to customize order execution:
| Property | Data Type | Description | Default Value |
|---|---|---|---|
TimeInForcetime_in_force | TimeInForce | A TimeInForce instruction to apply to the order. The following instructions are supported:
| TimeInForce.GoodTilCanceledTimeInForce.GOOD_TIL_CANCELED |
Notesnotes | stringstr | The free form instructions that may be sent to the broker. | |
HandlingInstructionhandling_instruction | stringstr | The instructions for handling the order or route. The values can be preconfigured or a value customized by the broker. | |
CustomNotes1custom_notes_1 | stringstr | Custom user order notes 1. For more information about custom order notes, see Custom Notes & Free Text Fields in the EMSX API documentation | |
CustomNotes2custom_notes_2 | stringstr | Custom user order notes 2. | |
CustomNotes3custom_notes_3 | stringstr | Custom user order notes 3. | |
CustomNotes4custom_notes_4 | stringstr | Custom user order notes 4. | |
CustomNotes5custom_notes_5 | stringstr | Custom user order notes 5. | |
Accountaccount | stringstr | The EMSX account. | |
Brokerbroker | stringstr | The EMSX broker code. | |
LocateBrokerlocate_broker | stringstr |
The EMSX locate broker code that identifies the counterparty the shares are borrowed from for a short equity sale (for example, "BMTB").
Maps to the LocBrkr field on the EMSX trading ticket.
Setting this property (or LocateIdlocate_id) on a short equity sale causes the brokerage to emit EMSX_LOCATE_REQ = "Y" alongside.
| |
LocateIdlocate_id | stringstr | The EMSX locate confirmation/ticket Id that the lending broker returns. Maps to the LocId field on the EMSX trading ticket. | |
IsCfdTradeis_cfd_trade | bool |
A flag that books the order as a contract for differences (CFD) instead of a regular trade.
Maps to the CFD option of the Booking Type drop-down on the EMSX trading ticket and sets the EMSX_CFD_FLAG element.
EMSX applies this flag at the order level, not per security.
A regular trade is the EMSX default, so the brokerage only sends the element when you set this property to trueTrue.
| falseFalse |
Strategystrategy | StrategyParameters | An object that represents the EMSX order strategy details. You must append strategy parameters in the order that the EMSX API expects. The following strategy names are supported: "DMA", "DESK", "VWAP", "TWAP", "FLOAT", "HIDDEN", "VOLUMEINLINE", "CUSTOM", "TAP", "CUSTOM2", "WORKSTRIKE", "TAPNOW", "TIMED", "LIMITTICK", "STRIKE" | |
ExecutionInstructionexecution_instruction | stringstr | The execution instruction field. | |
AutomaticPositionSidesautomatic_position_sides | bool | A flag that determines whether to automatically include the position side in the order direction (buy-to-open, sell-to-close, etc.) instead of the default (buy, sell). | |
PositionSideposition_side | OrderPosition?OrderPosition/NoneType |
An OrderPosition object that specifies the position side in the order direction (buy-to-open, sell-to-close, etc.) instead of the default (buy, sell).
This member has precedence over AutomaticPositionSidesautomatic_position_sides.
| |
Exchangeexchange | Exchange | Defines the exchange name for sending the order to. | |
AdditionalPropertiesadditional_properties | BaseExtendedDictionary<string, string>BaseExtendedDictionary[str, str] | The custom EMSX elements to send with the order. The key is the EMSX element name and the value is the element value. The other order properties take precedence, so an entry that targets an element they already set has no effect. The brokerage skips entries that the EMSX schema doesn't define instead of rejecting the order. | An empty dictionary |
The AdditionalPropertiesadditional_properties dictionary lets you set EMSX elements that the preceding properties don't cover, without waiting for a new LEAN release. IsCfdTradeis_cfd_trade reads and writes the EMSX_CFD_FLAG entry of this dictionary, so setting either of them is equivalent. The following example books the orders as CFD trades and adds the odd lot element, which no dedicated property covers:
The dictionary starts empty and you can't replace it with a plain Python dictionary. To add several elements at once, call the update method with a dictionary. To remove all the elements, call the clear method.
For more information about the format that the Bloomberg EMSX API expects, see Create Order and Route Extended Request in the EMSX API documentation and the createOrderAndRouteWithStrat documentation on the MathWorks website.
Get Open Orders
Quant Bridge lets you access open orders.
Monitor Fills
Quant Bridge allows you to monitor orders as they fill through order events.
Updates
Quant Bridge doesn't support order updates, but you can cancel an existing order and then create a new order with the desired arguments. For more information about this workaround, see the Workaround for Brokerages That Don’t Support Updates.
Cancellations
Quant Bridge enables you to cancel open orders.
Handling Splits
If you're using raw data normalization and you have active orders with a limit, stop, or trigger price in the market for a US Equity when a stock split occurs, the following properties of your orders automatically adjust to reflect the stock split:
- Quantity
- Limit price
- Stop price
- Trigger price
Brokerage-Side Orders
By default, your algorithm doesn't record orders that you submit to your account by third-parties instead of through LEAN. To accept these orders, create a custom brokerage message handler.
Fees
Orders filled with Quant Bridge are subject to the fees of the Bloomberg™ Execution Management System and your prime brokerage destination. To view how we model their fees, see Fees.
Margin
Set your cash and holdings state in the wizard when you deploy to the Bloomberg™ EMSX environment. We use these states to model buying power and margin calls to ensure your algorithm stays within the margin requirements.
Fills
In live trading, LEAN routes your orders to the exchange or prime brokerage you select. The order fills and then routes back to you.
To view how we model Bloomberg™ Execution Management System order fills, see Fills.
Compliance
Bloomberg™ is not affiliated with QuantConnect, nor does it endorse Quant Bridge. You need Bloomberg™ EMSX and EMSX API Server permissions to use this brokerage connection, with a Trading Firm or Institutional subscription on QuantConnect.
The following rules apply:
- All users of the integration must hold a Bloomberg License to be defined as an "Entitled User".
- The Bloomberg™ EMSX API Server is for order routing only. It doesn't provide data and can't be used for black-box trading.
The following table shows the activities each of the Bloomberg technologies support:
| Technology | Research | Backtesting | Paper UAT Trading | Live Trading |
|---|---|---|---|---|
| EMSX API Server | ![]() | ![]() | ![]() | ![]() |
Set Up EMSX API Server
The following few sections explain how to download the Bloomberg™ EMSX API Server, install it on a cloud server, and add firewall rules so it can connect to QuantConnect Cloud.
Download the EMSX API Server
Follow these steps to download the EMSX API Server:
- Install the Bloomberg™ Terminal.
- Create a Bloomberg™ Terminal account.
- In the Bloomberg™ Terminal, run
WAPI<GO>. - On the API Developer's Help Site, click .
- On the EMSX API page, under the Server API Process section, click .
- On the Server API Software Install page, click the correct download icons.
- Click .



Install the EMSX API Server
Follow these steps to install the EMSX API Server:
- Spin up an E12x9 AWS instance or higher that your organization controls.
- Run the EMSX API Server installer on the cloud server.
- Ask Bloomberg™ Support to activate your registration key.
- Start the serverapi program.
For more information about this step, see How to install serverapi.exe in the EMSX API Programmers Guide. At the end of the installion, you get a registration key.
On Windows, the default location is C: \ BLP \ ServerApi \ bin \ serverapi.exe.
Set Up Your Account
Follow these steps to set up your EMSX API Server account:
- Contact Bloomberg Support and ask them to enable the Server Side EMSX API.
- Ask Bloomberg Support for your unique user identifier (UUID).
- Contact the EMSX brokerage you plan to use and give them your UUID.
Save it somewhere safe. You will need it when you deploy live algorithms.
Add Firewall Rules
Follow these steps to configure the firewall rules on the AWS instance so that the EMSX API Server can connect to QuantConnect Cloud:
- Click .
- Enter Windows Defender Firewall with Advanced Security and then press Enter.
- In the left panel, click .
- In the right panel, click .
- Follow the prompts to create a program rule for the serverapi.
- In the Windows Defender Firewall with Advanced Security window, double-click the serverapi row.
- In the serverapi window, click the Scope tab.
- In the Remote IP address section, add the QuantConnect Cloud IP address, 207.182.16.137.
- Click .
- Add the QuantConnect Cloud IP address to the other row in the table that has the serverapi name.
Deploy Live Algorithms
You need to set up the Bloomberg™ EMSX API Server before you can deploy cloud algorithms with Quant Bridge.
You must have an available live trading node for each live trading algorithm you deploy.
Follow these steps to deploy a live algorithm:
- Open the project you want to deploy.
- Click the
Deploy Live icon. - On the Deploy Live page, click the Brokerage field and then click from the drop-down menu.
- Click the Connection Type field and then click from the drop-down menu.
- In the Server Auth Id field, enter your unique user identifier (UUID).
- In the EMSX Broker field, enter the EMSX broker to use.
- In the Server Port field, enter the port where the EMSX API Server is listening.
- In the Server Host field, enter the public IP address of the AWS instance that runs the EMSX API Server.
- In the EMSX Account field, enter the account to which LEAN should route orders.
- In the EMSX Team field, enter the team account to receive events of your team's orders.
- In the OpenFIGI Api Key field, enter your API key.
- Click the Environment field and then click one of the options from the drop-down menu.
- In the Region section, click the region where you want to run the algorithm.
- Click the Node field and then click the live trading node that you want to use from the drop-down menu.
- (Optional) In the Data Provider section, click and change the data provider or add additional providers.
- If your brokerage account has existing cash holdings, follow these steps (see video):
- In the Algorithm Cash State section, click .
- Click .
- Enter the currency ticker (for example, USD or CAD) and a quantity.
- If your brokerage account has existing position holdings, follow these steps (see video):
- In the Algorithm Holdings State section, click .
- Click .
- Enter the symbol ID, symbol, quantity, and average price.
- (Optional) Set up notifications.
- Configure the Automatically restart algorithm setting.
- Click .
The UUID is a unique integer identifier that's assigned to each Bloomberg Anywhere user. If you don't know your UUID, contact Bloomberg.
The default port is 8194.
The default value is empty, which means LEAN disregards these notifications.
By enabling automatic restarts, the algorithm will use best efforts to restart the algorithm if it fails due to a runtime error. This can help improve the algorithm's resilience to temporary outages such as a brokerage API disconnection.
The deployment process can take up to 5 minutes. When the algorithm deploys, the live results page displays. If you know your brokerage positions before you deployed, you can verify they have been loaded properly by checking your equity value in the runtime statistics, your cashbook holdings, and your position holdings.
Restarts, including automatic restarts and redeployments, don't save the state of your algorithm. To learn what a restart recovers and how to persist the rest, see State Persistence.
Deployment Details
When you deploy a live algorithm with Quant Bridge, the brokerage shares some details of the deployment, like the account it trades. Use them to tell concurrent deployments apart or to check that the algorithm connected to the account you expect. The details never include credentials.
The following table describes the deployment details that Quant Bridge shares:
| Key | Description |
|---|---|
quant-bridge-server-auth-id | The Server Auth Id, which is the unique user identifier (UUID) of the Bloomberg Anywhere user. |
quant-bridge-emsx-broker | The EMSX broker that receives the orders. |
quant-bridge-emsx-account | The EMSX account to which LEAN routes orders. |
quant-bridge-emsx-team | The EMSX team account that receives events of your team's orders. It's empty if you didn't set one. |
The DeploymentDetailsdeployment_details property of your algorithm is a read-only dictionary of the details. LEAN populates it before it calls the Initializeinitialize method, so you can read it anywhere in your algorithm.
var deploymentDetails = DeploymentDetails.Select(kvp => $"{kvp.Key}:{kvp.Value}");
Log($"deploymentDetails: {string.Join(", ", deploymentDetails)}"); deployment_details = [f'{kvp.key}:{kvp.value}' for kvp in self.deployment_details]
self.log(f'deployment_details: {deployment_details}')
The /live/read API endpoint also returns the details in its deploymentDetails field, so you can read them outside of the algorithm.
