Skip to content
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

Coin price <10$ bot deletes last buy price #190

Closed
pedrohusky opened this issue May 20, 2021 · 9 comments · Fixed by #206
Closed

Coin price <10$ bot deletes last buy price #190

pedrohusky opened this issue May 20, 2021 · 9 comments · Fixed by #206
Labels
discussion Topic to discuss enhancement New feature or request

Comments

@pedrohusky
Copy link
Contributor

It should not happen. It should save the last buy price until it sell the coin.

Example:

1 - coin drops below 10$

2 - bot removes the last buy price

3 - coin drops more until buy trigger

4 - bot buys at lowest price

5 - bot waits until profit

6 - bot sells the coin with profit. BUT it sells all the coins holded, included the last one that you still have a loss.

7 - if in step 5 it continues to fall down, it will repeat the steps all over again

@pedrohusky pedrohusky added the bug Something isn't working label May 20, 2021
@chrisleekr
Copy link
Owner

@pedrohusky

First of all, I don't think this is a bug as intended behaviour. I will change to the discussion label.

Secondly, the intention of that feature was to avoid the bot holding residue amount of the coin and do not continue the trade.

After the bot is selling the coin, there will be a very small amount of the coin left. If you remove that feature, it will be remembering the last buy price with the amount you cannot sell.

@chrisleekr chrisleekr added discussion Topic to discuss and removed bug Something isn't working labels May 21, 2021
@pedrohusky
Copy link
Contributor Author

@chrisleekr

Ok, I've understand it. But when the bot sells for example 10.0 DOGE, it will left about 0.01~0.02 DOGE. Ok. But the bot already knows it sold the amount of coins it had bought, so it will remove the last buy price.

It will not pass through the function that calculates if it is below the threshold.

I'll like to help.

@chrisleekr
Copy link
Owner

chrisleekr commented May 21, 2021

@pedrohusky

The bot does not know the order is executed. If you continuously check the order execution status, you will definitely over the API limit.

The bot is checking the amount of coin to decide whether to buy or sell.
It's because getting an account information API call is cheaper than checking the order status.
FYI, the account information is checking every second. Check the below code.

I'll like to help.

Always welcome :)

@pedrohusky
Copy link
Contributor Author

pedrohusky commented May 21, 2021

@chrisleekr

The bot does not know the order is executed. If you continuously check the order execution status, you will definitely over the API limit.

Good to know. Didn't know that.

The bot is checking the amount of coin to decide whether to buy or sell.

And if we store the amount of coins it bought in the mongo DB? Then it should never sell above what it had last bought.

Like that:

Bot buys 10.00 of X coin at 100$ price.

Bot waits to sell. Two outputs may happen.

1 - Coin drops below 10$. Bot verifies if the coin is less than minimum to sell. Bot price is erased.

2 - Coin spike up, bot sells the amount of 10.00. In the same function that sells, it erases the last buy price.

Another outcome:

1 - Coin drops below 10$. Bot verifies if the coin is less than minimum to sell. Bot price is erased.

Then the coin hits the trigger price to buy. Bots buy 10.00 of X coin. Now bot have 20.00 in hand.

Then the coin spikes up and reach the profit trigger. Bot sells but not only the last 10.00 it had bought, but the total amount of 20.00 (even though you are at loss in the first's 10.00 coin bought), making a loss.

Always welcome :)

let's be frends

I couldn't really see a problem having that switch, could you clarify that to me?

And just to letting you know, I've made an addition to your code, had added a checkbox to let you choose wether you want the bot to remove the last buy price when it get below the threshold. Some people at the discord found it useful and I went ahead with the help of a user named Seth. If it's useful to you I can open a pull request.

Like that:

#edit

Oh sorry. My bad.

@chrisleekr
Copy link
Owner

chrisleekr commented May 21, 2021

@pedrohusky

Remove your address bar in the screenshot or restart to reset the local tunnel. Anyone would be able to access your bot.

So in your scenario, you only purchase $10 worth of the coin, right?

2 - Coin spike up, bot sells the amount of 10.00. In the same function that sells, it erases the last buy price.

The bot does not sell the exact amount of $10, the bot will sell whatever you configured the sell trigger percentage.
For example, if the X coin rises to $120, then your base coin X is worth $12, which is acceptable by Binance.
The bot will try to sell all of your coins when reaches the sell trigger percentage.

Then the coin hits the trigger price to buy. Bots buy 10.00 of X coin. Now bot have 20.00 in hand.
Then the coin spikes up and reach the profit trigger. Bot sells but not only the last 10.00 it had bought, but the total amount of 20.00 (even though you are at loss in the first's 10.00 coin bought), making a loss.

It looks like what you are asking is this #158

I couldn't really see a problem having that switch, could you clarify that to me?

The main problem with not removing the last buy price is because the bot will continue the monitor the coin that you cannot place an order.

And just to letting you know, I've made an addition to your code, had added a checkbox to let you choose wether you want the bot to remove the last buy price when it get below the threshold. Some people at the discord found it useful and I went ahead with the help of a user named Seth. If it's useful to you I can open a pull request.

I think it is too early stage to just implement it, let's discuss it further to make sure it is the correct implementation.

@pedrohusky
Copy link
Contributor Author

Remove your address bar in the screenshot or restart to reset the local tunnel. Anyone would be able to access your bot.

Oh sorry, had forgot about it!! Didn't have any bidens to spent anyway.

So in your scenario, you only purchase $10 worth of the coin, right?

Yes. The bot first purchased $10 worth of X coin at the price 5$ for example.

2 - Coin spike up, bot sells the amount of 10.00. In the same function that sells, it erases the last buy price.

The bot does not sell the exact amount of $10, the bot will sell whatever you configured the sell trigger percentage.
For example, if the X coin rises to $120, then your base coin X is worth $12, which is acceptable by Binance.
The bot will try to sell all of your coins when reaches the sell trigger percentage.

Let me clarify

The bot first purchased $10 worth of X coin at the price 5$ for example.

Then the price dropped to 4$. The coin don't worth more than 10$ then the bot will remove the last buy, but hold the 10$ worth of coin.

Then the coin dropped to the buy trigger, bot buys more 10$ worth of X coin at price $3.5

Bot sells the coins holded (the total 20$ worth of them) at price $3.75 (it thinks it is selling them at a 7% profit, but the only profitable are the coins bought at $3.5).

It sold the coins bought at $5 with a loss of -25%. While it sold the coins bought at $3.5 with 7% of profit.

Hope you understand my English

Then the coin hits the trigger price to buy. Bots buy 10.00 of X coin. Now bot have 20.00 in hand.
Then the coin spikes up and reach the profit trigger. Bot sells but not only the last 10.00 it had bought, but the total amount of 20.00 (even though you are at loss in the first's 10.00 coin bought), making a loss.

It looks like what you are asking is this #158

I couldn't really see a problem having that switch, could you clarify that to me?

The main problem with not removing the last buy price is because the bot will continue the monitor the coin that you cannot place an order.

But that way we can at least see our loss percentage, and the bot won't do what I've wrote above.

I'm just speculating, sorry to bother.

@chrisleekr
Copy link
Owner

@pedrohusky

Then the price dropped to 4$. The coin don't worth more than 10$ then the bot will remove the last buy, but hold the 10$ worth of coin.
Then the coin dropped to the buy trigger, bot buys more 10$ worth of X coin at price $3.5
Bot sells the coins holded (the total 20$ worth of them) at price $3.75 (it thinks it is selling them at a 7% profit, but the only profitable are the coins bought at $3.5).
It sold the coins bought at $5 with a loss of -25%. While it sold the coins bought at $3.5 with 7% of profit.

So what you are asking is basically grid trading which is duplicated issue with #158.

Am I right?

But it still does not solve the issue that I said above:

The main problem with not removing the last buy price is because the bot will continue the monitor the coin that you cannot place an order.

What am I missing from your context?

@pedrohusky
Copy link
Contributor Author

First of all, good morning. :)

Then the price dropped to 4$. The coin don't worth more than 10$ then the bot will remove the last buy, but hold the 10$ worth of coin.
Then the coin dropped to the buy trigger, bot buys more 10$ worth of X coin at price $3.5
Bot sells the coins holded (the total 20$ worth of them) at price $3.75 (it thinks it is selling them at a 7% profit, but the only profitable are the coins bought at $3.5).
It sold the coins bought at $5 with a loss of -25%. While it sold the coins bought at $3.5 with 7% of profit.

So what you are asking is basically grid trading which is duplicated issue with #158.

Am I right?

You get it. It almost seems like a grid trading when I read what I wrote. But the point is: the bot should only sell in a profit. If it do not erase the last buy price when it reaches below 10$, it wouldn't buy more coins, and won't sell at a loss.

In a sharp drop like the last days, this function would save a lot of money. Simply because the bot won't lose the last buy price.

My bot had bought 10$ worth of MATIC. Then the sharp drop came and my coin lost its value, making the bot erase the last buy price. No problem until it reached my buy trigger, and bought more 15$ worth of MATIC. Then it sold all of my 25$ worth of MATIC when it reached the second coin batch profit trigger.

But I've only got 20$ back. It sold at a loss of 5$.

But it still does not solve the issue that I said above:

The main problem with not removing the last buy price is because the bot will continue the monitor the coin that you cannot place an order.

What am I missing from your context?

But I still don't get why it keep monitoring the coin that you can't sell is a bad thing. It's just because of API limit?

Btw: A user in discord liked the checkbox to set wether the bot should or not remove the last buy price. And he said it is working perfectly.

@chrisleekr
Copy link
Owner

Hey @pedrohusky

I have been thinking about this last night.

The main issue with your case is buying a minimum amount of $10 which can easily go down to $10. But I assume other traders may want to buy only $10 depending on their investment strategy.

By removing the process of removing the last buy price can cause two issues:

  1. When you trade the coin, it leaves a small amount of coin as explained above. And the bot will continue to keep checking the sell signal because there is still the last buy price.
  2. When you had a coin worth less than $10, even if the coin reaches the sell trigger price, it cannot place an order.

Simply disabling the process of removing the last buy price is not gonna work for the above-mentioned issues. The solution for this is I let the trader be able to customise with disabling the sell when the coin does not meet the minimum notional value.

  • Allow customising the amount of removing the last buy price. As the bot supports other quote assets, it must be dynamically configurable like the max purchase amount. i.e. For the USDT quote asset, the minimum notional amount is $10. You can set it as $5 USDT. The last buy price will not be remove until the coin is not worth $5 USDT.
  • If the coin is worth more than the configured minimum notional amount, then the bot will not remove the last buy price.
  • If the coin is not worth more minimum notional amount, then the bot will not place an order. (this is already doing it)

I think this way you can keep the last buy price less than $10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topic to discuss enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants