Etoro cash-account targets size against combined crypto inventory rather than per-instrument holdings
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 56/100
Research direction
Read Common/Securities/CashBuyingPowerModel.cs:206-219, EtoroBrokerageModel.cs, and SecurityPortfolioModel.cs:75-79 to trace cash-account sizing and instrument holdings. Start by comparing eToro's sizing model with existing position-based sizing and check how spot exchanges use the generic cash model. Add regression coverage for zero and nonzero targets across two instruments sharing a base currency; done when those targets use each instrument's position and spot-exchange behavior remains unchanged.
Written by the indexing model from the issue text.
Description
What happens
On EtoroBrokerageModel(AccountType.Cash), crypto target sizing uses the combined base-currency cash balance instead of the holdings of the requested instrument. eToro's order model treats positions as instrument-specific and rejects a market order that crosses zero, so this can either prevent a close or trade in the wrong direction.
Synthetic reproduction against Lean 2d730d56e (no brokerage connection or live trade):
- USD cash: 10,000.
- BTC cash: 2, conversion rate 10,000 USD/BTC.
- EUR cash: 0, conversion rate 1 USD/EUR.
- BTCUSD and BTCEUR: one BTC held on each, each priced at 10,000 in its quote currency.
- Both securities use the buying-power and fee models returned by
EtoroBrokerageModel(AccountType.Cash); portfolio free-value and minimum-order buffers are zero. - Total portfolio value: 30,000 USD.
Actual output:
CalculateOrderQuantity(BTCUSD, 0) = -2
CanSubmitOrder = false (cross-zero rejection; BTCUSD holds only 1)
CalculateOrderQuantity(BTCUSD, 0.5) = -0.4950495
CanSubmitOrder = true
The zero target should close the one BTCUSD unit, not also attempt to sell the BTC represented by BTCEUR. The 50% target should increase BTCUSD from 10,000 toward 15,000 USD, not reduce it.
Source
Common/Securities/CashBuyingPowerModel.cs:206-219: the zero target returns-BaseCurrency.Amount; other targets compare against the value of that same combined currency balance.Common/Brokerages/EtoroBrokerageModel.cs: inherits this cash-account buying-power model, but itsCanSubmitOrderchecks cross-zero against the instrument's holdings.Common/Securities/SecurityPortfolioModel.cs:75-79: ordinary crypto fills already add units to the shared base-currency cash balance, so this can arise in an uninterrupted running algorithm too.
What a fix must achieve
Keep the cash book's combined coin inventory and valuation, while sizing eToro portfolio targets against the requested instrument's position. Cover a zero and a nonzero target with two instruments sharing the same base currency, and leave spot-exchange behavior unchanged.
Suggestion only: evaluate a position-aware buying-power model for eToro, reusing existing position-based sizing where possible rather than changing the generic spot-cash model.
This is distinct from #1860, which addressed initial virtual holdings: here both holdings are populated and the base-currency balance is correct.
- Dominant language
- C#
- Stars
- 22.6k
- Forks
- 5.4k
- Avg merge
- 11h 39m
- Merged PRs (30d)
- 104
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from QuantConnect/Lean
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
QuantConnect/Lean#10216 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
QuantConnect/Lean#10206 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
QuantConnect/Lean#10199 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
QuantConnect/Lean#10198 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
QuantConnect/Lean#10197 ·
Maintainers usually reply within 1 day
All issues in QuantConnect/Lean
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
dotnet-outdated/dotnet-outdated#871 ·
Maintainers usually reply within 1 day
-
triage/untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
unoplatform/uno#26676 ·
Maintainers usually reply within 1 day
-
.NET bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jhaizhou-ops/S2Arm#2177 · 3 comments ·
Maintainers usually reply within 1 day
-
area-CodeGen-coreclr untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotnet/runtime#138181 · 1 comment ·
Maintainers usually reply within 1 day