Repository navigation
Add eToro Brokerage Integration #9886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Romazes
wants to merge
25
commits into
QuantConnect:master
Choose a base branch
from
Romazes:feature-brokerage-etoro
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,029
−3
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3611006
feature: add etoro brokerage name and order properties
Romazes 3a973e5
feature: add etoro fee model
Romazes d2fc417
feature: add etoro brokerage model
Romazes d8ffe40
feature: add etoro keys and live environment to config
Romazes 5038d57
test: add etoro brokerage model and fee model tests
Romazes 8b1c91d
refactor: use the lean update message in the etoro brokerage model
Romazes e9a9a49
refactor: drop the etoro demo environment key from the launcher config
Romazes 1b0e0f2
feature: bring back the etoro demo environment key in the launcher co…
Romazes 4fb0c34
fix: brokerage order tests name the invalid reason on a status timeout
Romazes 7fbad03
fix: the etoro brokerage model accepts currency pairs
Romazes 73e1416
fix: etoro brokerage model gives every security leverage 1
Romazes 2e3430b
fix: etoro model defaults to a cash account, leverage needs a stop
Romazes 38d8a74
fix: etoro crypto fee in the quote currency of the pair
Romazes a7160e3
feature: a contingent order set exposes its absolute quantities
Romazes 64c0614
feature: etoro stop loss and take profit as contingent exit orders
Romazes fc768d7
feature: etoro model keeps a crypto stop loss at least 10% from the p…
Romazes cc2987c
test: etoro model counts as supporting contingent orders
Romazes 8921806
feature: etoro model updates a stop market or a limit order by type
Romazes ada43a3
test: brokerage test harness applies a quantity update
Romazes 46f6c5e
fix: etoro model refuses an exit order on the side of its entry
Romazes 74e4977
refactor: etoro order properties type removed until it has a field
Romazes 5334ab3
fix: etoro model starts a currency pair at 30 on a margin account
Romazes 468d705
test: brokerage test harness guards a quantity update like the transa…
Romazes e3c8ccc
refactor: contingent set keeps one quantities view
Romazes 6f696b7
fix: etoro model keeps an exit price on its side of the market
Romazes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | ||
| * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| using QuantConnect.Securities; | ||
|
|
||
| namespace QuantConnect.Orders.Fees | ||
| { | ||
| /// <summary> | ||
| /// Represents a fee model specific to eToro. | ||
| /// </summary> | ||
| /// <see href="https://www.etoro.com/en-us/trading/fees/"/> | ||
| /// <remarks> | ||
| /// Stock and ETF trades are commission free. Crypto trades pay 1% of the trade value on every buy and sell. | ||
| /// The stock commission on the global fees page (https://www.etoro.com/trading/fees/) depends on the country | ||
| /// of residence and the exchange; the model uses the US page, which charges nothing. | ||
| /// </remarks> | ||
| public class EtoroFeeModel : FeeModel | ||
| { | ||
| /// <summary> | ||
| /// Crypto fee rate on the trade value, charged on every buy and sell. | ||
| /// From https://www.etoro.com/en-us/trading/fees/: | ||
| /// "A standardized 1% commission is charged each time you buy or sell a cryptoasset on etoro." | ||
| /// </summary> | ||
| private const decimal _cryptoFeeRate = 0.01m; | ||
|
|
||
| /// <summary> | ||
| /// Gets the order fee for a given security and order. | ||
| /// </summary> | ||
| /// <param name="parameters">The parameters including the security and order details.</param> | ||
| /// <returns>A <see cref="OrderFee"/> in the quote currency of the security.</returns> | ||
| public override OrderFee GetOrderFee(OrderFeeParameters parameters) | ||
| { | ||
| var order = parameters.Order; | ||
| var security = parameters.Security; | ||
|
|
||
| // From https://www.etoro.com/en-us/trading/fees/: "We charge zero commissions when you buy or sell a stock." | ||
| if (security.Type != SecurityType.Crypto) | ||
| { | ||
| return OrderFee.Zero; | ||
| } | ||
|
|
||
| var tradeValue = security.Price * security.SymbolProperties.ContractMultiplier * order.AbsoluteQuantity; | ||
| return new OrderFee(new CashAmount(tradeValue * _cryptoFeeRate, security.QuoteCurrency.Symbol)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.