Supported Models
Public
Introduction
This page explains the PublicBrokerageModel, including the asset classes it supports, its default security-level models, and its default markets.
SetBrokerageModel(BrokerageName.Public, AccountType.Cash); SetBrokerageModel(BrokerageName.Public, AccountType.Margin);
self.set_brokerage_model(BrokerageName.PUBLIC, AccountType.CASH) self.set_brokerage_model(BrokerageName.PUBLIC, AccountType.MARGIN)
For more information about this model, see the class reference and implementation.
For more information about this model, see the class reference and implementation.
Orders
The PublicBrokerageModel supports several order types, order properties, and order updates.
Order Types
The following table describes the available order types for each asset class that the PublicBrokerageModel supports:
| Order Type | Equity | Equity Options | Index Options | Crypto |
|---|---|---|---|---|
| Market | ![]() | ![]() | ![]() | ![]() |
| Limit | ![]() | ![]() | ![]() | ![]() |
| Stop market | ![]() | ![]() | ![]() | ![]() |
| Stop limit | ![]() | ![]() | ![]() | ![]() |
| Combo limit | ![]() | ![]() |
Order Properties
The PublicBrokerageModel supports custom order properties. The following table describes the members of the PublicOrderProperties 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 |
OutsideRegularTradingHoursoutside_regular_trading_hours | bool | If set to true, allows the order to trigger or fill outside of regular trading hours. This property applies to Equity limit orders with a day time-in-force only, since Public only accepts limit orders in the extended session. | falseFalse |
UseMarginuse_margin | bool? | Controls the buying power the order uses. If set to true, the order uses margin buying power when the account allows it. If set to false, the order uses cash-only (settled cash) buying power. If you don't set it, orders on margin accounts use margin buying power and orders on cash accounts always use cash-only buying power. | nullNone |
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 PublicOrderProperties
{
TimeInForce = TimeInForce.Day,
OutsideRegularTradingHours = true,
UseMargin = false
});
} def initialize(self) -> None:
# Set the default order properties
self.default_order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED
def on_data(self, slice: Slice) -> None:
# Use default order order properties
self.limit_order(self._symbol, quantity, limit_price)
# Override the default order properties
order_properties = PublicOrderProperties()
order_properties.time_in_force = TimeInForce.DAY
order_properties.outside_regular_trading_hours = True
order_properties.use_margin = False
self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)
Updates
The PublicBrokerageModel supports order updates for single-leg orders. Public doesn't support updating combo (multi-leg) 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
Fills
The PublicBrokerageModel uses the EquityFillModel for Equity trades and the ImmediateFillModel for Equity Options, Index Options, and Crypto trades.
Slippage
The PublicBrokerageModel uses the NullSlippageModel.
Fees
The PublicBrokerageModel uses the PublicFeeModel.
Buying Power
The PublicBrokerageModel uses the SecurityMarginModel for Equity trades and the OptionMarginModel for Equity Option and Index Option trades. For Crypto trades, it uses the CashBuyingPowerModel for cash accounts and the SecurityMarginModel for margin accounts.
If you have a margin account, the PublicBrokerageModel allows up to 2x leverage for Equity trades. The UseMarginuse_margin order property selects the buying power each order uses at the brokerage.
Settlement
The PublicBrokerageModel uses the ImmediateSettlementModel for margin accounts and the DelayedSettlementModel with the default settlement rules for cash accounts with Equity and Equity Options.
// For US Equities with a cash account: security.SetSettlementModel(new DelayedSettlementModel(Equity.DefaultSettlementDays, Equity.DefaultSettlementTime)); // For Equity Options with a cash account: security.SetSettlementModel(new DelayedSettlementModel(Option.DefaultSettlementDays, Option.DefaultSettlementTime)); // For remaining cases: security.SetSettlementModel(new ImmediateSettlementModel());
# For US Equities with a cash account: security.set_settlement_model(DelayedSettlementModel(Equity.DEFAULT_SETTLEMENT_DAYS, Equity.DEFAULT_SETTLEMENT_TIME)) # For Equity Options with a cash account: security.set_settlement_model(DelayedSettlementModel(Option.DEFAULT_SETTLEMENT_DAYS, Option.DEFAULT_SETTLEMENT_TIME)) # For remaining cases: security.set_settlement_model(ImmediateSettlementModel())
Margin Interest Rate
The PublicBrokerageModel uses the NullMarginInterestRateModel.
Account Currency
The PublicBrokerageModel doesn't set a default currency.
To change the algorithm's currency from USD to a different currency, see Set Account Currency.
