-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: Grid trade feature #248
Conversation
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.
Thanks @chrisleekr for this big update!
I added some comments before testing, they are just enhancements and not issues.
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.
I am testing the feature now, and it's working great until now.
However, I figured out these small issues that need to be fixed.
Thanks a lot @chrisleekr, I like your updates. Steps to reproduce the bug:
|
@habibalkhabbaz Updated: I fixed up and added more tests for those cases. |
Just updated my local branch and it seems working very well! |
Finally we have sorting 😍 , let me test this |
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.
I just tested the latest update and I found these small issues.
if (s.sell.difference) { | ||
return (s.sell.difference + 1000) * -10; | ||
} | ||
return s.buy.difference; |
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.
Same comment in line 26
Oh, I didn't see the latest update. |
The reason I don't use The correct order would be like below: It is achieved by adding the condition as below:
And lodash order by |
I think this PR is pretty stable. I will release it tomorrow or this weekend. |
Hey @chrisleekr, it's already closed, but maybe I have found a strange situation, two buy orders have been executed to MATIC, but it's showing that only the first grid was executed |
@elvishp2006 Let's open new issue and follow from there. |
Done @chrisleekr #252 |
Description
The bot is currently trading single buy/single sell.
There was a suggestion from @domnuprofesor to allow multiple buy/sell feature #158
This PR is to cover the feature
How to test:
Note that when you use this branch, there is a migration running over your current configuration.
Once start using this PR, you cannot go back to use the previous version including the master branch.
Todo
This PR is not completed yet as require more features.
Related Issue
#158
Motivation and Context
To provide the feature, massive refactoring was required and changes in setting UI.
The features outlines as below:
Buy
Setting UI
Validation
Scenario
Your 1st grid trading for buying is configured as below:
To make it easier to understand, I will use
$
as a USDT symbol. For the simple calculation, I do not take an account for the commission. In real trading, the quantity may be different.Let's assume the current price is
$105
for1 COIN
.When the current price is down to the lowest price ($100) and lower than ATH(All-Time High) restricted price if enabled, the bot will place new STOP-LOSS-LIMIT order for buying.
Let's assume the market changes as below:
Then the bot will follow the price fall and place new STOP-LOSS-LIMIT order as below:
Let's assume the market changes as below:
Then the bot will execute 1st purchase for the coin. The last buy price will be recorded as
$99.845
. The purchased quantity will be0.5
.Once the coin is purchased, the bot will start monitoring the sell signal or the next grid trading for buying.
Your 2nd grid trading for buying is configured as below:
And if the current price is continuously falling to
$79.876
(20% lower), then the bot will place new STOP-LOSS-LIMIT order for the 2nd grid trading for the coin.Let's assume the market changes as below:
Then the bot will follow the price fall and place new STOP-LOSS-LIMT order as below:
Let's assume the market changes as below:
Then the bot will execute 2nd purchase for the coin. The last buy price will be automatically re-calculated as below:
Sell
Setting UI
Unlike buy, the sell setting will use the percentage of a quantity. If you want to sell all of your coin quantity, then simply configure it as 100.
Validation
The bot will not sell all quantities. If you want to sell all quantities, configure as 1 for the last grid.
Sell Scenario
From the last buy actions, you now have the following balances:
Your 1st grid trading for selling is configured as below:
Let's assume the market changes as below:
As the price is higher than the sell trigger price($87.99), then the bot will place new STOP-LOSS-LIMIT order for selling.
Let's assume the market changes as below:
Then the bot will follow the price rise and place new STOP-LOSS-LIMIT order as below:
Let's assume the market changes as below:
Then the bot will execute 1st sell for the coin. Then the bot will now wait for 2nd selling trigger price ($83.80 * 1.08 = $90.504).
Let's assume the market changes as below:
Then the current price($91) is higher than 2nd selling trigger price ($90.504), the bot will place new STOP-LOSS-LIMIT order as below:
Let's assume the market changes as below:
Then the bot will follow the price rise and place new STOP-LOSS-LIMT order as below:
Let's assume the market changes as below:
Then the bot will execute 2nd sell for the coin.
The final profit would be
Symbol configuration
How Has This Been Tested?
I am currently testing this feature and fixed some unforeseen issues.
It is now fairly stable. However, I will continue to test until I am confident with stability.
Welcome to test and suggest if you find any issue.
Screenshots (if appropriate):