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
Address Missing StableCoin Pairs in Crypto Exchanges #5488
Merged
Martin-Molinero
merged 7 commits into
QuantConnect:master
from
C-SELLERS:bug-5478-usdc-cashbook
Apr 28, 2021
Merged
Address Missing StableCoin Pairs in Crypto Exchanges #5488
Martin-Molinero
merged 7 commits into
QuantConnect:master
from
C-SELLERS:bug-5478-usdc-cashbook
Apr 28, 2021
Conversation
This file contains 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some unit & regression test around the issue so we can assert the fix 👍
C-SELLERS
changed the title
Allow USDC in cashbook without USDC-USD pair
Address Missing StableCoin Pairs in Crypto Exchanges
Apr 27, 2021
Martin-Molinero
approved these changes
Apr 28, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor comments only 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Address issues surrounding adding stable coins to algorithms without direct trading pairs for conversion.
Even though an exchange may not offer a direct conversion from a given account currency and stablecoin (ex. GDAX USD -> USDC) we still want to be able to override some handling of these cases. In this specific example we know at GDAX USD -> USDC is a consistent 1-1 conversion. But at another exchange such as Bitfinex there is a tradable security that reflects small variances in USDC price.
To let these both exist and not have the GDAX case throw we add a condition that if there is no currency conversion security found, we first check a new static variable
*StableCoinsWithoutPairs
in the Currency class that will tell us if a given market should allow theCash
(USDC or other stablecoin) to be added with a 1-1 conversion without tracking a security.*Maybe needs a better name, something more clear? Possibly relating to the fact they are all 1-1 conversion pairs without securities, or maybe a way to add this to SPD?
I also added two missing pairs to the GDAX SPDB for
Source: https://pro.coinbase.com/markets
Related Issue
Closes #5478
Motivation and Context
Reference issue above
The problem is caused by underlying brokerages not having a direct pair for stablecoins from account currency. If they did Lean would generate a subscription to these assets and update its conversion rate as data for that pair flows through the engine.
This solution seeks to bypass the issue for stablecoins that we know hold a direct 1-1 conversion rate with the account currency.
Following this solution we will likely need to consider multi-leg conversions since there isn't a direct path on some of these exchanges.
Requires Documentation Change
N/A
How Has This Been Tested?
Added a unit test that asserts behavior of this issue with a range of cases for each crypto exchange, account currency, and possible stablecoins.
Types of changes
Checklist:
bug-<issue#>-<description>
orfeature-<issue#>-<description>