Lean  $LEAN_TAG$
QuantConnect.Python.BrokerageModelPythonWrapper Class Reference

Provides an implementation of IBrokerageModel that wraps a PyObject object More...

Inheritance diagram for QuantConnect.Python.BrokerageModelPythonWrapper:
[legend]

Public Member Functions

 BrokerageModelPythonWrapper (PyObject model)
 Constructor for initialising the BrokerageModelPythonWrapper class with wrapped PyObject object More...
 
void ApplySplit (List< OrderTicket > tickets, Split split)
 Applies the split to the specified order ticket More...
 
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...
 
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...
 
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...
 
IBenchmark GetBenchmark (SecurityManager securities)
 Get the benchmark for this model More...
 
IFeeModel GetFeeModel (Security security)
 Gets a new fee model that represents this brokerage's fee structure More...
 
IFillModel GetFillModel (Security security)
 Gets a new fill model that represents this brokerage's fill behavior More...
 
decimal GetLeverage (Security security)
 Gets the brokerage's leverage for the specified security More...
 
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...
 
ISlippageModel GetSlippageModel (Security security)
 Gets a new slippage model that represents this brokerage's fill slippage behavior More...
 
bool Shortable (IAlgorithm algorithm, Symbol symbol, decimal quantity)
 Determine if this symbol is shortable More...
 
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...
 
IBuyingPowerModel GetBuyingPowerModel (Security security, AccountType accountType)
 Gets a new buying power model for the security More...
 
IShortableProvider GetShortableProvider (Security security)
 Gets the shortable provider More...
 
IBrokerageModel GetModel ()
 Convenience method to get the underlying IBrokerageModel object from the wrapper. More...
 
IMarginInterestRateModel GetMarginInterestRateModel (Security security)
 Gets a new margin interest rate model for the security More...
 
- Public Member Functions inherited from QuantConnect.Python.BasePythonWrapper< IBrokerageModel >
 BasePythonWrapper (bool validateInterface=true)
 Creates a new instance of the BasePythonWrapper<TInterface> class More...
 
 BasePythonWrapper (PyObject instance, bool validateInterface=true)
 Creates a new instance of the BasePythonWrapper<TInterface> class with the specified instance More...
 
void SetPythonInstance (PyObject instance)
 Sets the python instance More...
 
GetProperty< T > (string propertyName)
 Gets the Python instance property with the specified name More...
 
PyObject GetProperty (string propertyName)
 Gets the Python instance property with the specified name More...
 
void SetProperty (string propertyName, object value)
 Sets the Python instance property with the specified name More...
 
dynamic GetEvent (string name)
 Gets the Python instance event with the specified name More...
 
bool HasAttr (string name)
 Determines whether the Python instance has the specified attribute More...
 
PyObject GetMethod (string methodName)
 Gets the Python instances method with the specified name and caches it More...
 
InvokeMethod< T > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments More...
 
PyObject InvokeMethod (string methodName, params object[] args)
 Invokes the specified method with the specified arguments More...
 
void InvokeVoidMethod (string methodName, params object[] args)
 Invokes the specified method with the specified arguments without returning a value More...
 
IEnumerable< T > InvokeMethodAndEnumerate< T > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments and iterates over the returned values More...
 
Dictionary< TKey, TValue > InvokeMethodAndGetDictionary< TKey, TValue > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments and iterates over the returned values More...
 
InvokeMethodWithOutParameters< T > (string methodName, Type[] outParametersTypes, out object[] outParameters, params object[] args)
 Invokes the specified method with the specified arguments and out parameters More...
 
InvokeMethodAndWrapResult< T > (string methodName, Func< PyObject, T > wrapResult, params object[] args)
 Invokes the specified method with the specified arguments and wraps the result by calling the given function if the result is not a C# object More...
 
virtual bool Equals (BasePythonWrapper< TInterface > other)
 Determines whether the specified instance wraps the same Python object reference as this instance, which would indicate that they are equal. More...
 
override bool Equals (object obj)
 Determines whether the specified object is an instance of BasePythonWrapper<TInterface> and wraps the same Python object reference as this instance, which would indicate that they are equal. More...
 
override int GetHashCode ()
 Gets the hash code for the current instance More...
 

Properties

AccountType AccountType [get]
 Gets or sets 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...
 
- 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...
 

Additional Inherited Members

- Protected Attributes inherited from QuantConnect.Python.BasePythonWrapper< IBrokerageModel >
PyObject Instance
 Gets the underlying python instance More...
 

Detailed Description

Provides an implementation of IBrokerageModel that wraps a PyObject object

Definition at line 35 of file BrokerageModelPythonWrapper.cs.

Constructor & Destructor Documentation

◆ BrokerageModelPythonWrapper()

QuantConnect.Python.BrokerageModelPythonWrapper.BrokerageModelPythonWrapper ( PyObject  model)

Constructor for initialising the BrokerageModelPythonWrapper class with wrapped PyObject object

Parameters
modelModels brokerage transactions, fees, and order

Definition at line 41 of file BrokerageModelPythonWrapper.cs.

Member Function Documentation

◆ ApplySplit()

void QuantConnect.Python.BrokerageModelPythonWrapper.ApplySplit ( List< OrderTicket tickets,
Split  split 
)

Applies the split to the specified order ticket

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

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 103 of file BrokerageModelPythonWrapper.cs.

Here is the call graph for this function:

◆ CanExecuteOrder()

bool QuantConnect.Python.BrokerageModelPythonWrapper.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.

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

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 118 of file BrokerageModelPythonWrapper.cs.

◆ CanSubmitOrder()

bool QuantConnect.Python.BrokerageModelPythonWrapper.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.

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.

Definition at line 134 of file BrokerageModelPythonWrapper.cs.

◆ CanUpdateOrder()

bool QuantConnect.Python.BrokerageModelPythonWrapper.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

Parameters
securityThe security of the order
orderThe order to be updated
requestThe requested updated to be made to the order
messageIf this function returns false, a brokerage message detailing why the order may not be updated
Returns
True if the brokerage would allow updating the order, false otherwise

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 152 of file BrokerageModelPythonWrapper.cs.

◆ GetBenchmark()

IBenchmark QuantConnect.Python.BrokerageModelPythonWrapper.GetBenchmark ( SecurityManager  securities)

Get the benchmark for this model

Parameters
securitiesSecurityService to create the security with if needed
Returns
The benchmark for this brokerage

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 167 of file BrokerageModelPythonWrapper.cs.

◆ GetFeeModel()

IFeeModel QuantConnect.Python.BrokerageModelPythonWrapper.GetFeeModel ( Security  security)

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.

Definition at line 177 of file BrokerageModelPythonWrapper.cs.

◆ GetFillModel()

IFillModel QuantConnect.Python.BrokerageModelPythonWrapper.GetFillModel ( Security  security)

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 187 of file BrokerageModelPythonWrapper.cs.

◆ GetLeverage()

decimal QuantConnect.Python.BrokerageModelPythonWrapper.GetLeverage ( Security  security)

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.

Definition at line 197 of file BrokerageModelPythonWrapper.cs.

◆ GetSettlementModel() [1/2]

ISettlementModel QuantConnect.Python.BrokerageModelPythonWrapper.GetSettlementModel ( Security  security)

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.

Definition at line 207 of file BrokerageModelPythonWrapper.cs.

Here is the caller graph for this function:

◆ GetSettlementModel() [2/2]

ISettlementModel QuantConnect.Python.BrokerageModelPythonWrapper.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 220 of file BrokerageModelPythonWrapper.cs.

Here is the call graph for this function:

◆ GetSlippageModel()

ISlippageModel QuantConnect.Python.BrokerageModelPythonWrapper.GetSlippageModel ( Security  security)

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.

Definition at line 230 of file BrokerageModelPythonWrapper.cs.

◆ Shortable()

bool QuantConnect.Python.BrokerageModelPythonWrapper.Shortable ( IAlgorithm  algorithm,
Symbol  symbol,
decimal  quantity 
)

Determine if this symbol is shortable

Parameters
algorithmThe algorithm running
symbolThe symbol to short
quantityThe amount to short
Returns

Definition at line 243 of file BrokerageModelPythonWrapper.cs.

◆ GetBuyingPowerModel() [1/2]

IBuyingPowerModel QuantConnect.Python.BrokerageModelPythonWrapper.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.

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

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 254 of file BrokerageModelPythonWrapper.cs.

Here is the caller graph for this function:

◆ GetBuyingPowerModel() [2/2]

IBuyingPowerModel QuantConnect.Python.BrokerageModelPythonWrapper.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 267 of file BrokerageModelPythonWrapper.cs.

Here is the call graph for this function:

◆ GetShortableProvider()

IShortableProvider QuantConnect.Python.BrokerageModelPythonWrapper.GetShortableProvider ( Security  security)

Gets the shortable provider

Returns
Shortable provider

Implements QuantConnect.Brokerages.IBrokerageModel.

Definition at line 276 of file BrokerageModelPythonWrapper.cs.

◆ GetModel()

IBrokerageModel QuantConnect.Python.BrokerageModelPythonWrapper.GetModel ( )

Convenience method to get the underlying IBrokerageModel object from the wrapper.

Returns
Underlying IBrokerageModel object

Definition at line 286 of file BrokerageModelPythonWrapper.cs.

◆ GetMarginInterestRateModel()

IMarginInterestRateModel QuantConnect.Python.BrokerageModelPythonWrapper.GetMarginInterestRateModel ( Security  security)

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.

Definition at line 299 of file BrokerageModelPythonWrapper.cs.

Property Documentation

◆ AccountType

AccountType QuantConnect.Python.BrokerageModelPythonWrapper.AccountType
get

Gets or sets the account type used by this model

Definition at line 50 of file BrokerageModelPythonWrapper.cs.

◆ RequiredFreeBuyingPowerPercent

decimal QuantConnect.Python.BrokerageModelPythonWrapper.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.

Definition at line 62 of file BrokerageModelPythonWrapper.cs.

◆ DefaultMarkets

IReadOnlyDictionary<SecurityType, string> QuantConnect.Python.BrokerageModelPythonWrapper.DefaultMarkets
get

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

Definition at line 73 of file BrokerageModelPythonWrapper.cs.


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