Skip to content

Add eToro Brokerage Integration - #9886

Open
Romazes wants to merge 13 commits into
QuantConnect:masterfrom
Romazes:feature-brokerage-etoro
Open

Romazes wants to merge 13 commits into
QuantConnect:masterfrom
Romazes:feature-brokerage-etoro

Conversation

@Romazes

@Romazes Romazes commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Registers the eToro brokerage in Lean core for the plugin Lean.Brokerages.Etoro.

  • BrokerageName.Etoro, wired in BrokerageModel.Create and the reverse lookup.
  • EtoroBrokerageModel: equity (US stocks and ETFs), crypto and forex; market orders only; contingent orders refused; CanUpdateOrder false, because eToro has no order update.
    • Defaults to AccountType.Cash, so every security starts at leverage 1. An algorithm sets more with SetLeverage, and the plugin sends that leverage with the order.
    • An order that opens a position needs EtoroOrderProperties.StopLossRate when it is a short sale or its leverage is above 1. eToro answers 400 without it: "StopLossRate must be provided when Leverage is greater than 1 or for SellShort transactions".
    • A market sell beyond the long holdings is refused as a cross-zero order; eToro closes positions by units.
  • EtoroOrderProperties.StopLossRate: the absolute price at which eToro closes the position.
  • EtoroFeeModel: crypto pays 1% of the trade value on every buy and sell (eToro US fees page; a live 85.75 USD BTC buy paid 0.86 USD). Stocks, ETFs and forex pay nothing (eToro US: "We charge zero commissions when you buy or sell a stock"; live EURUSD fills paid no fee).
  • Messages.EtoroBrokerageModel: the short sale and the leverage texts.
  • Launcher/config.json: etoro-api-url, etoro-api-key, etoro-user-key, etoro-demo-environment and the live-etoro environment.
  • BrokerageTests.PlaceOrderWaitForStatus: on a timeout, the failure names each order's expected and actual status and its Invalid message.

Related Issue

N/A. Plugin: https://github.com/QuantConnect/Lean.Brokerages.Etoro/pull/5 and https://github.com/QuantConnect/Lean.Brokerages.Etoro/pull/9

Motivation and Context

The eToro plugin needs its brokerage name, model, order properties and fee model in Lean core, so Lean routes orders to it, refuses what eToro cannot execute before the order leaves the algorithm, and prices fees in backtests. The stop loss rate for a short sale or a leveraged position is the one eToro rule an algorithm has to satisfy itself.

Requires Documentation Change

Yes: an eToro brokerage page (supported assets and order types, the demo environment flag, the cash account default and SetLeverage, StopLossRate for short sales and leverage above 1).

How Has This Been Tested?

  • EtoroBrokerageModelTests (33 cases): supported and unsupported security and order types, the stop loss rate for a short sale and for leverage above 1, a cross-zero sell, CanUpdateOrder, GetFeeModel, the leverage by account type and security type, the cash default.
  • EtoroFeeModelTests (6 cases): zero for equity, 1% of the trade value for crypto, including the live 85.75 USD BTC buy.
  • Live through the plugin (plugin PR Fix for indicators to support custom data based on TradeBar class #9): short sales on NOK and EURUSD with a stop opened and closed; a stop loss close reached Lean as an order placed outside Lean.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@Romazes Romazes self-assigned this Oct 9, 2026
@Romazes Romazes added feature New functionality or support for a new security; not a bug report. Brokerage labels Oct 9, 2026
Comment thread Common/Orders/Fees/EtoroFeeModel.cs Resolved
@Romazes
Romazes force-pushed the feature-brokerage-etoro branch from 9e93415 to f7312a1 Compare October 19, 2026 16:03
- BrokerageName.Etoro as the last enum member
- EtoroOrderProperties with StopLossRate, the absolute price at which eToro closes a short position
- crypto pays 1% of the trade value on every buy and sell, from the eToro US fees page
- stocks and ETFs are commission free on the eToro US fees page, so the equity fee is zero
- Equity and Crypto with Market orders only, no contingent orders
- a short sale needs a positive StopLossRate in EtoroOrderProperties
- a market sell beyond the long holdings is refused as a cross-zero order
- CanUpdateOrder returns false, eToro has no order update
- Messages.EtoroBrokerageModel for the two model texts
- BrokerageName.Etoro wired in the brokerage model factory
- etoro-api-url, etoro-api-key, etoro-user-key and etoro-demo-environment
- live-etoro environment with EtoroBrokerage as brokerage and data queue handler
- CanSubmitOrder: supported and unsupported security and order types, short sale stop loss rate, cross-zero sell
- CanUpdateOrder returns false and GetFeeModel returns EtoroFeeModel
- EtoroFeeModel: zero for equity, 1% of the trade value for crypto including the live 85.75 USD BTC buy
- CanUpdateOrder answers Messages.DefaultBrokerageModel.OrderUpdateNotSupported
- the custom update message and the short-sale comment are removed
PlaceOrderWaitForStatus keeps the Invalid order events and, when the expected status does not come within the timeout, fails with each order's expected and actual status plus its Invalid message. The status handler is unhooked in a finally block, so every failure path removes it.
- why: the etoro plugin advertises Forex (etoro.json assets, symbol
  mapper on Market.Oanda) and streams and downloads it, but this model
  refused every Forex order as an unsupported security type, so a Forex
  algorithm could read prices and never trade
- Forex joins Equity and Crypto in the supported security types; the
  market order, short sale stop loss and cross-zero rules apply the same
- the fee stays zero for Forex: eToro charges currencies the spread only,
  no commission
- the Forex test case moves from the unsupported list to the market
  order accepted list
- why: eToro opens every position at leverage 1, since no leverage is
  sent with an order and the account eligibility lists only "real long
  [1]" for every instrument; the model inherited the margin defaults
  (equity 2, forex 50), so Lean counted buying power eToro does not give
- GetLeverage returns 1, as the Coinbase model does
- a test checks equity, crypto and forex
- why: the eToro order now carries the leverage of the security; a
  margin account gives equities 2 and forex 50 by default, so a plain
  order would open a leveraged position, and eToro refuses a leverage
  above 1 without a stop loss
- the model defaults to AccountType.Cash and uses the base GetLeverage,
  1 for a cash account; an algorithm sets more with SetLeverage
- CanSubmitOrder refuses an opening order at a leverage above 1 without
  a StopLossRate, for a buy and for a short sale
- tests: the leverage by account type and security type, the cash
  default, and the stop loss rule
@Romazes
Romazes force-pushed the feature-brokerage-etoro branch from b945d01 to 2e3430b Compare November 3, 2026 21:11
- why: the fee was 1% of the trade value but always labelled USD, while
  the trade value of a pair is in its quote currency, so a BTCEUR trade
  got its EUR fee booked as USD
- the fee uses security.QuoteCurrency.Symbol, as the Coinbase, Binance,
  Bitfinex and Bybit fee models do; Lean converts it to the account
  currency
- a test checks BTCUSD (fee in USD) and BTCEUR (fee in EUR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Brokerage feature New functionality or support for a new security; not a bug report.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants