EtoroBrokerageModel
QuantConnect.Brokerages.EtoroBrokerageModel
EtoroBrokerageModel(account_type: AccountType = ...)
Bases: DefaultBrokerageModel
Represents a brokerage model specific to eToro.
Constructor for eToro brokerage model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_type
|
AccountType
|
Cash or Margin; a cash account gives every security leverage 1 and takes no other, a margin account starts at the leverage of get_leverage and takes another with SetLeverage |
...
|
required_free_buying_power_percent
required_free_buying_power_percent: float
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.
default_markets
default_markets: Dict[SecurityType, str]
Gets a map of the default markets to be used for each security type
DEFAULT_MARKET_MAP
DEFAULT_MARKET_MAP: Dict[SecurityType, str] = ...
The default markets for the backtesting brokerage
can_submit_order
can_submit_order(
security: Security,
order: Order,
message: Optional[BrokerageMessageEvent],
) -> Tuple[bool, BrokerageMessageEvent]
Returns true if the brokerage could accept this order. This takes into account order type, security type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security of the order |
required |
order
|
Order
|
The order to be processed |
required |
message
|
Optional[BrokerageMessageEvent]
|
If this function returns false, a brokerage message detailing why the order may not be submitted |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, BrokerageMessageEvent]
|
True if the brokerage could process the order, false otherwise. |
can_update_order
can_update_order(
security: Security,
order: Order,
request: UpdateOrderRequest,
message: Optional[BrokerageMessageEvent],
) -> Tuple[bool, BrokerageMessageEvent]
Returns true for a price change of a stop market or a limit order, the stop loss or the take profit of a position, which eToro moves on the position; the order may come without its entry, read from the position after a restart. The new price is checked as at submission, see IsExitPriceSupported. Any other update is refused, eToro has no order update; an order is cancelled and placed again instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security of the order |
required |
order
|
Order
|
The order to be updated |
required |
request
|
UpdateOrderRequest
|
The requested update to be made to the order |
required |
message
|
Optional[BrokerageMessageEvent]
|
If this function returns false, a brokerage message detailing why the order may not be updated |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, BrokerageMessageEvent]
|
True for a price change of an exit order, false otherwise. |
get_fee_model
get_leverage
get_leverage(security: Security) -> float
Gets the leverage a security starts at: 1 on a cash account; on a margin account 30 on a currency pair, the highest eToro offers, and Lean's default elsewhere, 2 on equities and 1 on crypto, inside what eToro offers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security |
required |
Returns:
| Type | Description |
|---|---|
float
|
The leverage the security starts at. |
apply_split
apply_split(
tickets: List[OrderTicket], split: Split
) -> None
Applies the split to the specified order ticket
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tickets
|
List[OrderTicket]
|
The open tickets matching the split event |
required |
split
|
Split
|
The split event data |
required |
can_execute_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:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security being traded |
required |
order
|
Order
|
The order to test for execution |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the brokerage would be able to perform the execution, false otherwise. |
get_benchmark
get_benchmark(securities: SecurityManager) -> IBenchmark
Get the benchmark for this model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
securities
|
SecurityManager
|
SecurityService to create the security with if needed |
required |
Returns:
| Type | Description |
|---|---|
IBenchmark
|
The benchmark for this brokerage. |
get_buying_power_model
get_buying_power_model(
security: Security,
) -> IBuyingPowerModel
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:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get a buying power model for |
required |
Returns:
| Type | Description |
|---|---|
IBuyingPowerModel
|
The buying power model for this brokerage/security. |
get_fill_model
get_fill_model(security: Security) -> IFillModel
Gets a new fill model that represents this brokerage's fill behavior
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get fill model for |
required |
Returns:
| Type | Description |
|---|---|
IFillModel
|
The new fill model for this brokerage. |
get_margin_interest_rate_model
get_margin_interest_rate_model(
security: Security,
) -> IMarginInterestRateModel
Gets a new margin interest rate model for the security
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get a margin interest rate model for |
required |
Returns:
| Type | Description |
|---|---|
IMarginInterestRateModel
|
The margin interest rate model for this brokerage. |
get_settlement_model
get_settlement_model(
security: Security,
) -> ISettlementModel
Gets a new settlement model for the security
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get a settlement model for |
required |
Returns:
| Type | Description |
|---|---|
ISettlementModel
|
The settlement model for this brokerage. |
get_shortable_provider
get_shortable_provider(
security: Security,
) -> IShortableProvider
get_slippage_model
get_slippage_model(security: Security) -> ISlippageModel
Gets a new slippage model that represents this brokerage's fill slippage behavior
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get a slippage model for |
required |
Returns:
| Type | Description |
|---|---|
ISlippageModel
|
The new slippage model for this brokerage. |
unsupported_contingent_orders_shape
unsupported_contingent_orders_shape(
reason: str,
) -> BrokerageMessageEvent
Helper to create the message of a set of contingent orders with a shape not supported by the brokerage
validate_contingent_order
validate_contingent_order(
order: Order,
supported_contingency_types: IReadOnlySet[
ContingencyType
],
message: Optional[BrokerageMessageEvent],
supports_combo_orders: bool = True,
supports_multiple_symbols: bool = True,
supports_nesting: bool = True,
maximum_order_count: int = ...,
) -> Tuple[bool, BrokerageMessageEvent]
Validates the contingencies of the given order are of a type supported by the brokerage
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
Order
|
The order to validate |
required |
supported_contingency_types
|
IReadOnlySet[ContingencyType]
|
The contingency types supported by the brokerage |
required |
message
|
Optional[BrokerageMessageEvent]
|
If this function returns false, a brokerage message detailing why the order may not be submitted |
required |
supports_combo_orders
|
bool
|
True if combo orders can be part of a set of contingent orders |
True
|
supports_multiple_symbols
|
bool
|
True if the orders in the set can be for different symbols |
True
|
supports_nesting
|
bool
|
True if an order triggered by another can trigger others in turn |
True
|
maximum_order_count
|
int
|
The maximum number of orders in the set |
...
|
Returns:
| Type | Description |
|---|---|
Tuple[bool, BrokerageMessageEvent]
|
True if the order is not a contingent order or all its contingencies are supported. |
validate_contingent_orders_not_supported
validate_contingent_orders_not_supported(
order: Order, message: Optional[BrokerageMessageEvent]
) -> Tuple[bool, BrokerageMessageEvent]
Rejects contingent orders (OCO, OTO, OUO, brackets), for the brokerage models of brokerages which don't support them
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
Order
|
The order to validate |
required |
message
|
Optional[BrokerageMessageEvent]
|
If this function returns false, a brokerage message detailing why the order may not be submitted |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, BrokerageMessageEvent]
|
False if the order is a contingent order. |
is_valid_order_size
is_valid_order_size(
security: Security,
order_quantity: float,
message: Optional[BrokerageMessageEvent],
) -> Tuple[bool, BrokerageMessageEvent]
Checks if the order quantity is valid, it means, the order size is bigger than the minimum size allowed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security of the order |
required |
order_quantity
|
float
|
The quantity of the order to be processed |
required |
message
|
Optional[BrokerageMessageEvent]
|
If this function returns false, a brokerage message detailing why the order may be invalid |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, BrokerageMessageEvent]
|
True if the order quantity is bigger than the minimum allowed, false otherwise. |