Brokerages

Bloomberg EMSX

Introduction

QuantConnect enables you to run your algorithms in live mode with real-time market data. We have successfully hosted more than 200,000 live algorithms and have had more than $22B in volume traded on our servers since 2015.

Terminal link icon

QuantConnect can integrate with the Bloomberg™ Server API (SAPI) or Desktop API (DAPI) in different cloud environments. This integration allows research, backtesting, opitimization, and live trading through the Bloomberg APIs. Terminal Link is in no way affiliated with or endorsed by Bloomberg™; it is simply an add-on. Add Terminal link to your organization to access the 1,300+ prime brokerages in the Bloomberg Execution Management System network.

QuantConnect Cloud only supports routing trades to the Bloomberg™ Server API. In this environment, you can route orders to any of the 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 Terminal Link, you need to be a member of an organization on the Trading Firm or Institution tier.

Account Types

Terminal Link supports order routing via the Bloomberg™ EMSX network. It's a margin account that's similiar to a FIX API, where you set the buying power in the wizard when you're deploying to a professional prime brokerage account.

Data Providers

To use the Bloomberg™ EMSX network and SAPI on QuantConnect, you must use the QuantConnect data provider.

Asset Classes

Terminal Link supports trading the following asset classes:

Orders

Terminal Link enables you to create and manage Bloomberg™ orders.

Order Types

The following table describes the available order types for each asset class that Terminal Link supports:

Order TypeEquityEquity OptionsFuturesIndex Options
Marketgreen checkgreen checkgreen checkgreen check
Limitgreen checkgreen checkgreen checkgreen check
Stop marketgreen checkgreen checkgreen checkgreen check
Stop limitgreen checkgreen checkgreen checkgreen check

Order Properties

We model custom order properties from the Bloomberg EMSX API. The following table describes the members of the TerminalLinkOrderProperties object that you can set to customize order execution:

PropertyData TypeDescriptionDefault Value
TimeInForcetime_in_forceTimeInForceA TimeInForce instruction to apply to the order. The following instructions are supported:
  • DayDAY
  • GoodTilCanceledGOOD_TIL_CANCELED
  • GoodTilDategood_til_date
TimeInForce.GoodTilCanceledTimeInForce.GOOD_TIL_CANCELED
NotesnotesstringstrThe free form instructions that may be sent to the broker.
HandlingInstructionhandling_instructionstringstrThe instructions for handling the order or route. The values can be preconfigured or a value customized by the broker.
CustomNotes1custom_notes_1stringstrCustom user order notes 1. For more information about custom order notes, see Custom Notes & Free Text Fields in the EMSX API documentation
CustomNotes2custom_notes_2stringstrCustom user order notes 2.
CustomNotes3custom_notes_3stringstrCustom user order notes 3.
CustomNotes4custom_notes_4stringstrCustom user order notes 4.
CustomNotes5custom_notes_5stringstrCustom user order notes 5.
AccountaccountstringstrThe EMSX account.
BrokerbrokerstringstrThe EMSX broker code.
StrategystrategyStrategyParameters 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_instructionstringstrThe execution instruction field.
AutomaticPositionSidesautomatic_position_sidesboolA 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_sideOrderPosition?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.
ExchangeexchangeExchangeDefines the exchange name for sending the order to.

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

Terminal Link lets you access open orders.

Monitor Fills

Terminal Link allows you to monitor orders as they fill through order events.

Updates

Terminal Link 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

Terminal Link 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 Terminal Link 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 Terminal Link. A Bloomberg™ SAPI permission and EMSX permission is required to use this brokerage connection, along 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 SAPI will only be used for order routing and no data is permitted. The Bloomberg SAPI cannot be used for black-box trading.

The following table shows the activities each of the Bloomberg technologies support:

TechnologyResearchBacktestingPaper UAT TradingLive Trading
Server APIgreen checkgreen checkgreen checkgreen check

Set Up SAPI

The following few sections explain how to download the Bloomberg™ Server API (SAPI), install it on a cloud server, and add firewall rules so it can connect to QuantConnect Cloud.

Download SAPI

Follow these steps to download the SAPI:

  1. Install the Bloomberg™ Terminal.
  2. Create a Bloomberg™ Terminal account.
  3. In the Bloomberg™ Terminal, run WAPI<GO>.
  4. On the API Developer's Help Site, click EMSX API.
  5. On the EMSX API page, under the Server API Process section, click Link.
  6. On the Server API Software Install page, click the correct download icons.
  7. Click System Requirements.

Install the SAPI

Follow these steps to install the SAPI:

  1. Spin up an E12x9 AWS instance or higher that your organization controls.
  2. Run the SAPI installer on the cloud server.
  3. 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.

  4. Ask Bloomberg™ Support to activate your registration key.
  5. Start the serverapi program.
  6. On Windows, the default location is C: \ BLP \ ServerApi \ bin \ serverapi.exe.

Set Up Your Account

Follow these steps to set up your SAPI account:

  1. Contact Bloomberg Support and ask them to enable the Server Side EMSX API.
  2. Ask Bloomberg Support for your unique user identifier (UUID).
  3. Save it somewhere safe. You will need it when you deploy live algorithms.

  4. Contact the EMSX brokerage you plan to use and give them your UUID.

Add Firewall Rules

Follow these steps to configure the firewall rules on the AWS instance so that the SAPI can connect to QuantConnect Cloud:

  1. Click Start.
  2. Enter Windows Defender Firewall with Advanced Security and then press Enter.
  3. In the left panel, click Inbound Rules.
  4. In the right panel, click New Rule....
  5. Follow the prompts to create a program rule for the serverapi.
  6. In the Windows Defender Firewall with Advanced Security window, double-click the serverapi row.
  7. In the serverapi window, click the Scope tab.
  8. In the Remote IP address section, add the QuantConnect Cloud IP address, 207.182.16.137.
  9. Click OK.
  10. 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 SAPI before you can deploy cloud algorithms with Terminal Link.

You must have an available live trading node for each live trading algorithm you deploy.

Follow these steps to deploy a live algorithm:

  1. Open the project you want to deploy.
  2. Click the Lightning icon Deploy Live icon.
  3. On the Deploy Live page, click the Brokerage field and then click Terminal Link from the drop-down menu.
  4. Click the Connection Type field and then click SAPI from the drop-down menu.
  5. In the Server Auth Id field, enter your unique user identifier (UUID).
  6. The UUID is a unique integer identifier that's assigned to each Bloomberg Anywhere user. If you don't know your UUID, contact Bloomberg.

  7. In the EMSX Broker field, enter the EMSX broker to use.
  8. In the Server Port field, enter the port where SAPI is listening.
  9. The default port is 8194.

  10. In the Server Host field, enter the public IP address of the SAPI AWS server.
  11. In the EMSX Account field, enter the account to which LEAN should route orders.
  12. In the EMSX Team field, enter the team account to receive events of your team's orders.
  13. The default value is empty, which means LEAN disregards these notifications.

  14. In the OpenFIGI Api Key field, enter your API key.
  15. Click the Environment field and then click one of the options from the drop-down menu.
  16. Click the Node field and then click the live trading node that you want to use from the drop-down menu.
  17. (Optional) In the Data Provider section, click Show and change the data provider or add additional providers.
  18. If your brokerage account has existing cash holdings, follow these steps (see video):
    1. In the Algorithm Cash State section, click Show.
    2. Click Add Currency.
    3. Enter the currency ticker (for example, USD or CAD) and a quantity.
  19. If your brokerage account has existing position holdings, follow these steps (see video):
    1. In the Algorithm Holdings State section, click Show.
    2. Click Add Holding.
    3. Enter the symbol ID, symbol, quantity, and average price.
  20. (Optional) Set up notifications.
  21. Configure the Automatically restart algorithm setting.
  22. 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.

  23. Click Deploy.

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.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: