Supported Models
Charles Schwab
Introduction
This page explains the CharlesSchwabBrokerageModel
, including the asset classes it supports, its default security-level models, and its default markets.
SetBrokerageModel(BrokerageName.CharlesSchwab, AccountType.Cash); SetBrokerageModel(BrokerageName.CharlesSchwab, AccountType.Margin);
self.set_brokerage_model(BrokerageName.CHARLES_SCHWAB, AccountType.CASH) self.set_brokerage_model(BrokerageName.CHARLES_SCHWAB, AccountType.MARGIN)
To view the implementation of this model, see the LEAN GitHub repository.
Orders
The CharlesSchwabBrokerageModel
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 CharlesSchwabBrokerageModel
supports:
Order Type | Equity | Equity Options | Index Options |
---|---|---|---|
Market | |||
Limit | |||
Stop market |
Order Properties
The CharlesSchwabBrokerageModel
supports custom order properties. The following table describes the members of the CharlesSchwabOrderProperties
object that you can set to customize order execution.
Property | Data Type | Description | Default Value |
---|---|---|---|
TimeInForce time_in_force | TimeInForce | A TimeInForce instruction to apply to the order. The following instructions are supported:
| TimeInForce.GoodTilCanceled TimeInForce.GOOD_TIL_CANCELED |
ExtendedRegularTradingHours extended_regular_trading_hours | bool | If set to true, allows orders to also trigger or fill outside of regular trading hours. | false False |
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 CharlesSchwabOrderProperties { TimeInForce = TimeInForce.Day, ExtendedRegularTradingHours = false }); LimitOrder(_symbol, quantity, limitPrice, orderProperties: new CharlesSchwabOrderProperties { TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day)) }); }
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 = CharlesSchwabOrderProperties() order_properties.time_in_force = TimeInForce.DAY order_properties.extended_regular_trading_hours = True self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties) order_properties.time_in_force = TimeInForce.good_til_date(datetime(year, month, day)) self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)
Updates
The CharlesSchwabBrokerageModel
supports order updates.
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 CharlesSchwabBrokerageModel
uses the EquityFillModel for Equity trades and the ImmediateFillModel for Equity and Index Options trades.
Slippage
The CharlesSchwabBrokerageModel
uses the NullSlippageModel.
Fees
The CharlesSchwabBrokerageModel
uses the CharlesSchwabFeeModel.
Settlement
The CharlesSchwabBrokerageModel
uses the ImmediateSettlementModel for margin accounts and the DelayedSettlementModel with the default settlement rules for cash accounts.
// For cash accounts: security.SetSettlementModel(new DelayedSettlementModel(Equity.DefaultSettlementDays, Equity.DefaultSettlementTime)); // For margin accounts: security.SetSettlementModel(new ImmediateSettlementModel());
# For cash accounts: security.set_settlement_model(DelayedSettlementModel(Equity.DEFAULT_SETTLEMENT_DAYS, Equity.DEFAULT_SETTLEMENT_TIME)) # For margin accounts: security.set_settlement_model(ImmediateSettlementModel())
Margin Interest Rate
The CharlesSchwabBrokerageModel
uses the NullMarginInterestRateModel.