Lean
$LEAN_TAG$
|
Provides a default implementation of IBrokerageModel that allows all orders and uses the default transaction models More...
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... | |
Provides a default implementation of IBrokerageModel that allows all orders and uses the default transaction models
Definition at line 39 of file DefaultBrokerageModel.cs.
QuantConnect.Brokerages.DefaultBrokerageModel.DefaultBrokerageModel | ( | AccountType | accountType = AccountType.Margin | ) |
Initializes a new instance of the DefaultBrokerageModel class
accountType | The type of account to be modelled, defaults to QuantConnect.AccountType.Margin |
Definition at line 87 of file DefaultBrokerageModel.cs.
|
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
security | The security being ordered |
order | The order to be processed |
message | If this function returns false, a brokerage message detailing why the order may not be submitted |
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.
|
virtual |
Returns true if the brokerage would allow updating the order as specified by the request
security | The security of the order |
order | The order to be updated |
request | The requested update to be made to the order |
message | If this function returns false, a brokerage message detailing why the order may not be updated |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.InteractiveBrokersBrokerageModel, QuantConnect.Brokerages.FTXBrokerageModel, QuantConnect.Brokerages.EzeBrokerageModel, QuantConnect.Brokerages.TradingTechnologiesBrokerageModel, QuantConnect.Brokerages.SamcoBrokerageModel, QuantConnect.Brokerages.AxosClearingBrokerageModel, QuantConnect.Brokerages.ZerodhaBrokerageModel, QuantConnect.Brokerages.FxcmBrokerageModel, QuantConnect.Brokerages.TradierBrokerageModel, QuantConnect.Brokerages.KrakenBrokerageModel, QuantConnect.Brokerages.TradeStationBrokerageModel, QuantConnect.Brokerages.CoinbaseBrokerageModel, QuantConnect.Brokerages.BitfinexBrokerageModel, QuantConnect.Brokerages.AlpacaBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, QuantConnect.Brokerages.TDAmeritradeBrokerageModel, QuantConnect.Brokerages.RBIBrokerageModel, and QuantConnect.Brokerages.WolverineBrokerageModel.
Definition at line 124 of file DefaultBrokerageModel.cs.
|
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.
security | The security being traded |
order | The order to test for execution |
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.
|
virtual |
Applies the split to the specified order ticket
This default implementation will update the orders to maintain a similar market value
tickets | The open tickets matching the split event |
split | The split event data |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.TradierBrokerageModel.
Definition at line 153 of file DefaultBrokerageModel.cs.
|
virtual |
Gets the brokerage's leverage for the specified security
security | The security's whose leverage we seek |
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.AlphaStreamsBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, QuantConnect.Brokerages.BinanceUSBrokerageModel, and QuantConnect.Brokerages.BitfinexBrokerageModel.
Definition at line 172 of file DefaultBrokerageModel.cs.
|
virtual |
Get the benchmark for this model
securities | SecurityService to create the security with if needed |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.KrakenBrokerageModel, QuantConnect.Brokerages.SamcoBrokerageModel, QuantConnect.Brokerages.FxcmBrokerageModel, QuantConnect.Brokerages.OandaBrokerageModel, QuantConnect.Brokerages.InteractiveBrokersBrokerageModel, QuantConnect.Brokerages.CoinbaseBrokerageModel, QuantConnect.Brokerages.AxosClearingBrokerageModel, QuantConnect.Brokerages.FTXBrokerageModel, QuantConnect.Brokerages.TradingTechnologiesBrokerageModel, QuantConnect.Brokerages.BitfinexBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, QuantConnect.Brokerages.BinanceFuturesBrokerageModel, QuantConnect.Brokerages.ExanteBrokerageModel, and QuantConnect.Brokerages.BinanceCoinFuturesBrokerageModel.
Definition at line 211 of file DefaultBrokerageModel.cs.
|
virtual |
Gets a new fill model that represents this brokerage's fill behavior
security | The security to get fill model for |
Implements QuantConnect.Brokerages.IBrokerageModel.
Definition at line 222 of file DefaultBrokerageModel.cs.
|
virtual |
Gets a new fee model that represents this brokerage's fee structure
security | The security to get a fee model for |
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.TradingTechnologiesBrokerageModel, QuantConnect.Brokerages.BitfinexBrokerageModel, QuantConnect.Brokerages.BinanceBrokerageModel, 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.
|
virtual |
Gets a new slippage model that represents this brokerage's fill slippage behavior
security | The security to get a slippage model for |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.AlphaStreamsBrokerageModel.
Definition at line 281 of file DefaultBrokerageModel.cs.
|
virtual |
Gets a new settlement model for the security
security | The security to get a settlement model for |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.FxcmBrokerageModel, QuantConnect.Brokerages.OandaBrokerageModel, and QuantConnect.Brokerages.AlphaStreamsBrokerageModel.
Definition at line 291 of file DefaultBrokerageModel.cs.
ISettlementModel QuantConnect.Brokerages.DefaultBrokerageModel.GetSettlementModel | ( | Security | security, |
AccountType | accountType | ||
) |
Gets a new settlement model for the security
security | The security to get a settlement model for |
accountType | The account type |
Implements QuantConnect.Brokerages.IBrokerageModel.
Definition at line 320 of file DefaultBrokerageModel.cs.
|
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.
security | The security to get a buying power model for |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.CoinbaseBrokerageModel.
Definition at line 331 of file DefaultBrokerageModel.cs.
|
virtual |
Gets the shortable provider
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.AxosClearingBrokerageModel.
Definition at line 355 of file DefaultBrokerageModel.cs.
|
virtual |
Gets a new margin interest rate model for the security
security | The security to get a margin interest rate model for |
Implements QuantConnect.Brokerages.IBrokerageModel.
Reimplemented in QuantConnect.Brokerages.BinanceFuturesBrokerageModel.
Definition at line 368 of file DefaultBrokerageModel.cs.
IBuyingPowerModel QuantConnect.Brokerages.DefaultBrokerageModel.GetBuyingPowerModel | ( | Security | security, |
AccountType | accountType | ||
) |
Gets a new buying power model for the security
security | The security to get a buying power model for |
accountType | The account type |
Implements QuantConnect.Brokerages.IBrokerageModel.
Definition at line 380 of file DefaultBrokerageModel.cs.
|
static |
Checks if the order quantity is valid, it means, the order size is bigger than the minimum size allowed
security | The security of the order |
orderQuantity | The quantity of the order to be processed |
message | If this function returns false, a brokerage message detailing why the order may be invalid |
Definition at line 392 of file DefaultBrokerageModel.cs.
|
static |
The default markets for the backtesting brokerage
Definition at line 44 of file DefaultBrokerageModel.cs.
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.
|
get |
Gets or sets the account type used by this model
Definition at line 63 of file DefaultBrokerageModel.cs.
|
get |
Gets a map of the default markets to be used for each security type
Definition at line 78 of file DefaultBrokerageModel.cs.