Brokerages
Trading Technologies
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. Brokerages supply a connection to the exchanges so that you can automate orders using LEAN. You can use multiple data feeds in live trading algorithms.
Trading Technologies (TT) was founded by Gary Kemp in 1994 with the goal to create professional trading software, infrastructure, and data solutions for a wide variety of users. TT provides access to trading Futures, Options, and Crypto. TT also provides a charting platform, infrastructure services, and risk management tools. TT is not actually a brokerage. The firm is a brokerage router with access to more than 30 execution destinations.
To view the implementation of the TT integration, see the Lean.Brokerages.TradingTechnologies repository.
Modeling
The TradingTechnologiesBrokerageModel
does not have specific modeling for fees and slippage because TT is not a real brokerage. In live trading, TT reports the total fees of your orders after each order fill. Pass a different BrokerageName
to SetBrokerageModel
to backtest your algorithm with fee and slippage modeling. The brokerage model you set should support the asset classes and orders in your algorithm.
SetBrokerageModel(BrokerageName.TradingTechnologies, AccountType.Cash); SetBrokerageModel(BrokerageName.TradingTechnologies, AccountType.Margin);
self.SetBrokerageModel(BrokerageName.TradingTechnologies, AccountType.Cash) self.SetBrokerageModel(BrokerageName.TradingTechnologies, AccountType.Margin)
Create an Account
Follow the account creation wizard on the TT website to create a TT account.
Paper Trading
Our TT integration does not support paper trading through the TT Simulation environment, but you can follow these steps to simulate it:
- In the
Initialize
method of your algorithm, add one of the precedingSetBrokerageModel
method calls. - Deploy your algorithm with the QuantConnect Paper Trading brokerage.
Asset Classes
Our TT integration supports trading Futures.
AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, Market.CME);
self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, Market.CME)
If you call the SetBrokerageModel
method with the correct BrokerageName
, then you don't need to pass a Market
argument to the AddFuture
method because the brokerage model has a default market.
Assets Available
Refer to the US Futures dataset to see the assets available.
Orders
We model the TT API by supporting several order types, the TimeInForce
order property, and order updates. When you deploy live algorithms, you can place manual orders through the IDE.
Order Types
The following table describes the available order types for each asset class that TT supports:
Order Type | Futures |
---|---|
MarketOrder | ![]() |
LimitOrder | ![]() |
StopMarketOrder | ![]() |
StopLimitOrder | ![]() |
MarketOrder(_symbol, quantity); LimitOrder(_symbol, quantity, limitPrice); StopMarketOrder(_symbol, quantity, stopPrice); StopLimitOrder(_symbol, quantity, stopPrice, limitPrice);
self.MarketOrder(self.symbol, quantity) self.LimitOrder(self.symbol, quantity, limit_price) self.StopMarketOrder(self.symbol, quantity, stop_price) self.StopLimitOrder(self.symbol, quantity, stop_price, limit_price)
TT enforces the following order rules:
- If you are buying (selling) with a
StopMarketOrder
or aStopLimitOrder
, the stop price of the order must be greater (less) than the current security price. - If you are buying (selling) with a
StopLimitOrder
, the limit price of the order must be greater (less) than the stop price.
Time In Force
We model the TimeInForce
order property from the TT API. TT supports the Day
and GoodTilCanceled
TimeInForce
properties.
public override void Initialize() { // Set the default order properties DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled; } public override void OnData(Slice slice) { // Use default order order properties LimitOrder(_symbol, quantity, limitPrice); // Override the default order properties LimitOrder(_symbol, quantity, limitPrice, orderProperties: new OrderProperties { TimeInForce = TimeInForce.Day }); }
def Initialize(self) -> None: # Set the default order properties self.DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled def OnData(self, slice: Slice) -> None: # Use default order order properties self.LimitOrder(self.symbol, quantity, limit_price) # Override the default order properties order_properties = OrderProperties() order_properties.TimeInForce = TimeInForce.Day self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties)
Updates
We model the TT API by supporting order updates. You can define the following members of UpdateOrderFields
object to update active orders:
Quantity
LimitPrice
StopPrice
Tag
var ticket = StopLimitOrder(symbol, quantity, stopPrice, limitPrice, tag); var orderFields = new UpdateOrderFields {
Quantity = newQuantity,
LimitPrice = newLimitPrice,
StopPrice = newStopPrice,
Tag = newTag
}; ticket.Update(orderFields);
ticket = self.StopLimitOrder(symbol, quantity, stop_price, limit_price, tag)
update_fields = UpdateOrderFields() update_fields.Quantity = new_quantity
update_fields.LimitPrice = new_limit_price
update_fields.StopPrice = new_stop_price update_fields.Tag = new_tag ticket.Update(update_fields)
Fees
We model the order fees of TT, which are $0. To check the latest fees, see the Pricing page on the TT website.
For default backtest fee model, see Trading Technologies Supported Models.
Margin
We model buying power and margin calls to ensure your algorithm stays within the margin requirements and only submits valid orders to TT in live trading.
Buying Power
The DefaultBrokerageModel
allows up to 1x leverage on Futures trades.
Margin Calls
Regulation T margin rules apply. When the amount of margin remaining in your portfolio drops below 5% of the total portfolio value, you receive a warning. When the amount of margin remaining in your portfolio drops to zero or goes negative, the portfolio sorts the generated margin call orders by their unrealized profit and executes each order synchronously until your portfolio is within the margin requirements.
Slippage
Orders through TT do not experience slippage in backtests. In live trading, your orders may experience slippage.
For default backtest slippage model, see Trading Technologies Supported Models.
Fills
We fill market orders immediately and completely in backtests. In live trading, if the quantity of your market orders exceeds the quantity available at the top of the order book, your orders are filled according to what is available in the order book.
For default fill model, see Trading Technologies Supported Models.
Security and Stability
When you deploy live algorithms with TT, we don't save your brokerage account credentials.
We call the TT API to place live trades. Sometimes the API may be down. Check the TT status page to see if the API is currently working.
Deploy Live Algorithms
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 that 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.
- Enter your TT user name, account name, routing sender, session password, app key, and app secret.
- Click the Environment field and then click one of the environments from the drop-down menu.
- Click the Node field and then click the live trading node that you want to use from the drop-down menu.
- 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.
- (Optional) Set up notifications.
- Configure the Automatically restart algorithm setting.
- Click .
Our TT integration routes orders via the TT FIX 4.4 Connection. Contact your TT representative to set the exchange where you would like your orders sent. Your account details are not saved on QuantConnect.
Our integration fetches your positions using the REST endpoint, so the app key and app secret are your REST App credentials.
The following table shows the supported environments:
Environment | Description |
---|---|
Live | Trade in the production environment |
UAT | Trade in the User Acceptance Testing environment |
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.