Lean  $LEAN_TAG$
QuantConnect.Brokerages.DefaultBrokerageModel Class Reference

Provides a default implementation of IBrokerageModel that allows all orders and uses the default transaction models More...

Inheritance diagram for QuantConnect.Brokerages.DefaultBrokerageModel:
[legend]

Public Member Functions

 DefaultBrokerageModel (AccountType accountType=AccountType.Margin)
 Initializes a new instance of the DefaultBrokerageModel class More...
 
virtual bool CanSubmitOrder (Security security, Order order, out BrokerageMessageEvent message)
 Returns true if the brokerage could accept this order. This takes into account order type, security type, and order size limits. More...
 
virtual bool CanUpdateOrder (Security security, Order order, UpdateOrderRequest request, out BrokerageMessageEvent message)
 Returns true if the brokerage would allow updating the order as specified by the request More...
 
virtual bool CanExecuteOrder (Security security, Order order)
 Returns true if the brokerage would be able to execute this order at this time assuming market prices are sufficient for the fill to take place. This is used to emulate the brokerage fills in backtesting and paper trading. For example some brokerages may not perform executions during extended market hours. This is not intended to be checking whether or not the exchange is open, that is handled in the Security.Exchange property. More...
 
virtual void ApplySplit (List< OrderTicket > tickets, Split split)
 Applies the split to the specified order ticket More...
 
virtual decimal GetLeverage (Security security)
 Gets the brokerage's leverage for the specified security More...
 
virtual IBenchmark GetBenchmark (SecurityManager securities)
 Get the benchmark for this model More...
 
virtual IFillModel GetFillModel (Security security)
 Gets a new fill model that represents this brokerage's fill behavior More...
 
virtual IFeeModel GetFeeModel (Security security)
 Gets a new fee model that represents this brokerage's fee structure More...
 
virtual ISlippageModel GetSlippageModel (Security security)
 Gets a new slippage model that represents this brokerage's fill slippage behavior More...
 
virtual ISettlementModel GetSettlementModel (Security security)
 Gets a new settlement model for the security More...
 
ISettlementModel GetSettlementModel (Security security, AccountType accountType)
 Gets a new settlement model for the security More...
 
virtual IBuyingPowerModel GetBuyingPowerModel (Security security)
 Gets a new buying power model for the security, returning the default model with the security's configured leverage. For cash accounts, leverage = 1 is used. More...
 
virtual IShortableProvider GetShortableProvider (Security security)
 Gets the shortable provider More...
 
virtual IMarginInterestRateModel GetMarginInterestRateModel (Security security)
 Gets a new margin interest rate model for the security More...
 
IBuyingPowerModel GetBuyingPowerModel (Security security, AccountType accountType)
 Gets a new buying power model for the security More...
 

Static Public Member Functions

static bool IsValidOrderSize (Security security, decimal orderQuantity, out BrokerageMessageEvent message)
 Checks if the order quantity is valid, it means, the order size is bigger than the minimum size allowed More...
 

Public Attributes

virtual decimal RequiredFreeBuyingPowerPercent => 0m
 Gets the brokerages model percentage factor used to determine the required unused buying power for the account. From 1 to 0. Example: 0 means no unused buying power is required. 0.5 means 50% of the buying power should be left unused. More...
 

Static Public Attributes

static readonly IReadOnlyDictionary< SecurityType, string > DefaultMarketMap
 The default markets for the backtesting brokerage More...
 

Properties

virtual AccountType AccountType [get]
 Gets or sets the account type used by this model More...
 
virtual IReadOnlyDictionary< SecurityType, string > DefaultMarkets [get]
 Gets a map of the default markets to be used for each security type More...
 
- Properties inherited from QuantConnect.Brokerages.IBrokerageModel
AccountType AccountType [get]
 Gets the account type used by this model More...
 
decimal RequiredFreeBuyingPowerPercent [get]
 Gets the brokerages model percentage factor used to determine the required unused buying power for the account. From 1 to 0. Example: 0 means no unused buying power is required. 0.5 means 50% of the buying power should be left unused. More...
 
IReadOnlyDictionary< SecurityType, string > DefaultMarkets [get]
 Gets a map of the default markets to be used for each security type More...
 

Detailed Description

Provides a default implementation of IBrokerageModel that allows all orders and uses the default transaction models

Definition at line 39 of file DefaultBrokerageModel.cs.

Constructor & Destructor Documentation

◆ DefaultBrokerageModel()

QuantConnect.Brokerages.DefaultBrokerageModel.DefaultBrokerageModel ( AccountType  accountType = AccountType.Margin)

Initializes a new instance of the DefaultBrokerageModel class

Parameters
accountTypeThe type of account to be modelled, defaults to QuantConnect.AccountType.Margin

Definition at line 87 of file DefaultBrokerageModel.cs.

Member Function Documentation

◆ CanSubmitOrder()

virtual bool QuantConnect.Brokerages.DefaultBrokerageModel.CanSubmitOrder ( Security  security,
Order  order,
out BrokerageMessageEvent  message 
)
virtual

Returns true if the brokerage could accept this order. This takes into account order type, security type, and order size limits.

For example, a brokerage may have no connectivity at certain times, or an order rate/size limit

Parameters
securityThe security being ordered
orderThe order to be processed
messageIf this function returns false, a brokerage message detailing why the order may not be submitted
Returns
True if the brokerage could process the order, false otherwise

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.CoinbaseBrokerageModel, QuantConnect.Brokerages.InteractiveBrokersBrokerageModel, QuantConnect.Brokerages.BitfinexBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, QuantConnect.Brokerages.FTXBrokerageModel, QuantConnect.Brokerages.AxosClearingBrokerageModel, QuantConnect.Brokerages.TradingTechnologiesBrokerageModel, QuantConnect.Brokerages.SamcoBrokerageModel, QuantConnect.Brokerages.ZerodhaBrokerageModel, QuantConnect.Brokerages.KrakenBrokerageModel, QuantConnect.Brokerages.EzeBrokerageModel, QuantConnect.Brokerages.TradeStationBrokerageModel, QuantConnect.Brokerages.CharlesSchwabBrokerageModel, QuantConnect.Brokerages.OandaBrokerageModel, QuantConnect.Brokerages.FxcmBrokerageModel, QuantConnect.Brokerages.AlpacaBrokerageModel, QuantConnect.Brokerages.ExanteBrokerageModel, QuantConnect.Brokerages.TradierBrokerageModel, QuantConnect.Brokerages.TDAmeritradeBrokerageModel, QuantConnect.Brokerages.RBIBrokerageModel, and QuantConnect.Brokerages.WolverineBrokerageModel.

Definition at line 103 of file DefaultBrokerageModel.cs.

◆ CanUpdateOrder()

virtual bool QuantConnect.Brokerages.DefaultBrokerageModel.CanUpdateOrder ( Security  security,
Order  order,
UpdateOrderRequest  request,
out BrokerageMessageEvent  message 
)
virtual

◆ CanExecuteOrder()

virtual bool QuantConnect.Brokerages.DefaultBrokerageModel.CanExecuteOrder ( Security  security,
Order  order 
)
virtual

Returns true if the brokerage would be able to execute this order at this time assuming market prices are sufficient for the fill to take place. This is used to emulate the brokerage fills in backtesting and paper trading. For example some brokerages may not perform executions during extended market hours. This is not intended to be checking whether or not the exchange is open, that is handled in the Security.Exchange property.

Parameters
securityThe security being traded
orderThe order to test for execution
Returns
True if the brokerage would be able to perform the execution, false otherwise

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.InteractiveBrokersBrokerageModel, QuantConnect.Brokerages.TradingTechnologiesBrokerageModel, QuantConnect.Brokerages.TradierBrokerageModel, QuantConnect.Brokerages.ZerodhaBrokerageModel, and QuantConnect.Brokerages.SamcoBrokerageModel.

Definition at line 140 of file DefaultBrokerageModel.cs.

◆ ApplySplit()

virtual void QuantConnect.Brokerages.DefaultBrokerageModel.ApplySplit ( List< OrderTicket tickets,
Split  split 
)
virtual

Applies the split to the specified order ticket

This default implementation will update the orders to maintain a similar market value

Parameters
ticketsThe open tickets matching the split event
splitThe split event data

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.TradierBrokerageModel.

Definition at line 153 of file DefaultBrokerageModel.cs.

◆ GetLeverage()

virtual decimal QuantConnect.Brokerages.DefaultBrokerageModel.GetLeverage ( Security  security)
virtual

Gets the brokerage's leverage for the specified security

Parameters
securityThe security's whose leverage we seek
Returns
The leverage for the specified security

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.SamcoBrokerageModel, QuantConnect.Brokerages.ZerodhaBrokerageModel, QuantConnect.Brokerages.KrakenBrokerageModel, QuantConnect.Brokerages.InteractiveBrokersBrokerageModel, QuantConnect.Brokerages.ExanteBrokerageModel, QuantConnect.Brokerages.CoinbaseBrokerageModel, QuantConnect.Brokerages.FTXBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, QuantConnect.Brokerages.AlphaStreamsBrokerageModel, QuantConnect.Brokerages.BinanceUSBrokerageModel, and QuantConnect.Brokerages.BitfinexBrokerageModel.

Definition at line 172 of file DefaultBrokerageModel.cs.

Here is the caller graph for this function:

◆ GetBenchmark()

◆ GetFillModel()

virtual IFillModel QuantConnect.Brokerages.DefaultBrokerageModel.GetFillModel ( Security  security)
virtual

Gets a new fill model that represents this brokerage's fill behavior

Parameters
securityThe security to get fill model for
Returns
The new fill model for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 222 of file DefaultBrokerageModel.cs.

Here is the call graph for this function:

◆ GetFeeModel()

virtual IFeeModel QuantConnect.Brokerages.DefaultBrokerageModel.GetFeeModel ( Security  security)
virtual

Gets a new fee model that represents this brokerage's fee structure

Parameters
securityThe security to get a fee model for
Returns
The new fee model for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.TradierBrokerageModel, QuantConnect.Brokerages.SamcoBrokerageModel, QuantConnect.Brokerages.FxcmBrokerageModel, QuantConnect.Brokerages.ZerodhaBrokerageModel, QuantConnect.Brokerages.KrakenBrokerageModel, QuantConnect.Brokerages.OandaBrokerageModel, QuantConnect.Brokerages.TDAmeritradeBrokerageModel, QuantConnect.Brokerages.InteractiveBrokersBrokerageModel, QuantConnect.Brokerages.RBIBrokerageModel, QuantConnect.Brokerages.CoinbaseBrokerageModel, QuantConnect.Brokerages.ExanteBrokerageModel, QuantConnect.Brokerages.WolverineBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, QuantConnect.Brokerages.TradingTechnologiesBrokerageModel, QuantConnect.Brokerages.BitfinexBrokerageModel, QuantConnect.Brokerages.FTXBrokerageModel, QuantConnect.Brokerages.EzeBrokerageModel, QuantConnect.Brokerages.TradeStationBrokerageModel, QuantConnect.Brokerages.AxosClearingBrokerageModel, QuantConnect.Brokerages.CharlesSchwabBrokerageModel, QuantConnect.Brokerages.BinanceFuturesBrokerageModel, QuantConnect.Brokerages.AlpacaBrokerageModel, QuantConnect.Brokerages.BinanceCoinFuturesBrokerageModel, QuantConnect.Brokerages.FTXUSBrokerageModel, and QuantConnect.Brokerages.AlphaStreamsBrokerageModel.

Definition at line 252 of file DefaultBrokerageModel.cs.

◆ GetSlippageModel()

virtual ISlippageModel QuantConnect.Brokerages.DefaultBrokerageModel.GetSlippageModel ( Security  security)
virtual

Gets a new slippage model that represents this brokerage's fill slippage behavior

Parameters
securityThe security to get a slippage model for
Returns
The new slippage model for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.AlphaStreamsBrokerageModel.

Definition at line 281 of file DefaultBrokerageModel.cs.

◆ GetSettlementModel() [1/2]

virtual ISettlementModel QuantConnect.Brokerages.DefaultBrokerageModel.GetSettlementModel ( Security  security)
virtual

Gets a new settlement model for the security

Parameters
securityThe security to get a settlement model for
Returns
The settlement model for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.FxcmBrokerageModel, QuantConnect.Brokerages.OandaBrokerageModel, and QuantConnect.Brokerages.AlphaStreamsBrokerageModel.

Definition at line 291 of file DefaultBrokerageModel.cs.

Here is the caller graph for this function:

◆ GetSettlementModel() [2/2]

ISettlementModel QuantConnect.Brokerages.DefaultBrokerageModel.GetSettlementModel ( Security  security,
AccountType  accountType 
)

Gets a new settlement model for the security

Parameters
securityThe security to get a settlement model for
accountTypeThe account type
Returns
The settlement model for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 320 of file DefaultBrokerageModel.cs.

Here is the call graph for this function:

◆ GetBuyingPowerModel() [1/2]

virtual IBuyingPowerModel QuantConnect.Brokerages.DefaultBrokerageModel.GetBuyingPowerModel ( Security  security)
virtual

Gets a new buying power model for the security, returning the default model with the security's configured leverage. For cash accounts, leverage = 1 is used.

Parameters
securityThe security to get a buying power model for
Returns
The buying power model for this brokerage/security

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.CoinbaseBrokerageModel.

Definition at line 331 of file DefaultBrokerageModel.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetShortableProvider()

virtual IShortableProvider QuantConnect.Brokerages.DefaultBrokerageModel.GetShortableProvider ( Security  security)
virtual

Gets the shortable provider

Returns
Shortable provider

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.AxosClearingBrokerageModel.

Definition at line 355 of file DefaultBrokerageModel.cs.

◆ GetMarginInterestRateModel()

virtual IMarginInterestRateModel QuantConnect.Brokerages.DefaultBrokerageModel.GetMarginInterestRateModel ( Security  security)
virtual

Gets a new margin interest rate model for the security

Parameters
securityThe security to get a margin interest rate model for
Returns
The margin interest rate model for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Reimplemented in QuantConnect.Brokerages.BinanceFuturesBrokerageModel.

Definition at line 368 of file DefaultBrokerageModel.cs.

◆ GetBuyingPowerModel() [2/2]

IBuyingPowerModel QuantConnect.Brokerages.DefaultBrokerageModel.GetBuyingPowerModel ( Security  security,
AccountType  accountType 
)

Gets a new buying power model for the security

Parameters
securityThe security to get a buying power model for
accountTypeThe account type
Returns
The buying power model for this brokerage/security

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 380 of file DefaultBrokerageModel.cs.

Here is the call graph for this function:

◆ IsValidOrderSize()

static bool QuantConnect.Brokerages.DefaultBrokerageModel.IsValidOrderSize ( Security  security,
decimal  orderQuantity,
out BrokerageMessageEvent  message 
)
static

Checks if the order quantity is valid, it means, the order size is bigger than the minimum size allowed

Parameters
securityThe security of the order
orderQuantityThe quantity of the order to be processed
messageIf this function returns false, a brokerage message detailing why the order may be invalid
Returns
True if the order quantity is bigger than the minimum allowed, false otherwise

Definition at line 392 of file DefaultBrokerageModel.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ DefaultMarketMap

readonly IReadOnlyDictionary<SecurityType, string> QuantConnect.Brokerages.DefaultBrokerageModel.DefaultMarketMap
static
Initial value:
= new Dictionary<SecurityType, string>
{
{SecurityType.Base, Market.USA},
{SecurityType.Equity, Market.USA},
{SecurityType.Option, Market.USA},
{SecurityType.Future, Market.CME},
{SecurityType.FutureOption, Market.CME},
{SecurityType.Forex, Market.Oanda},
{SecurityType.Cfd, Market.Oanda},
{SecurityType.Crypto, Market.Coinbase},
{SecurityType.CryptoFuture, Market.Binance},
{SecurityType.Index, Market.USA},
{SecurityType.IndexOption, Market.USA}
}.ToReadOnlyDictionary()

The default markets for the backtesting brokerage

Definition at line 44 of file DefaultBrokerageModel.cs.

◆ RequiredFreeBuyingPowerPercent

virtual decimal QuantConnect.Brokerages.DefaultBrokerageModel.RequiredFreeBuyingPowerPercent => 0m

Gets the brokerages model percentage factor used to determine the required unused buying power for the account. From 1 to 0. Example: 0 means no unused buying power is required. 0.5 means 50% of the buying power should be left unused.

Definition at line 72 of file DefaultBrokerageModel.cs.

Property Documentation

◆ AccountType

virtual AccountType QuantConnect.Brokerages.DefaultBrokerageModel.AccountType
get

Gets or sets the account type used by this model

Definition at line 63 of file DefaultBrokerageModel.cs.

◆ DefaultMarkets

virtual IReadOnlyDictionary<SecurityType, string> QuantConnect.Brokerages.DefaultBrokerageModel.DefaultMarkets
get

Gets a map of the default markets to be used for each security type

Definition at line 78 of file DefaultBrokerageModel.cs.


The documentation for this class was generated from the following file: