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

Auto buy bnb when it is below a certain threshold #5562

Open
hansen1015 opened this issue Sep 11, 2021 · 12 comments
Open

Auto buy bnb when it is below a certain threshold #5562

hansen1015 opened this issue Sep 11, 2021 · 12 comments
Labels
Enhancement Enhancements to the bot. Get lower priority than bugs by default.

Comments

@hansen1015
Copy link

Is it possible to add functionality to auto buy bnb for trading fee when the bnb balance is below a certain value?

Thank you

@xmatthias xmatthias added the Enhancement Enhancements to the bot. Get lower priority than bugs by default. label Sep 11, 2021
@xmatthias
Copy link
Member

it's currently not implemented, and i don't see a big deal in buying enough manually.

Feel free to impement if you think it's a must (i don't think so)
But please in a coin/exchange-agnostic way, which means you configure "BNB" for binance, and maybe FTT for FTX (not sure that's correct) ...
so it'll also work for other exchanges which have similar "fee" coins.

@Merinorus
Copy link
Contributor

Also interested by this feature, I will try to look into it if no one does it before.
I'm thinking about this in the config.json:

{
"reduced_fee_currency": "BNB",
"reduced_fee_max_ratio": 0.01,
"reduced_fee_min_ratio": 0.005
}

The bot would buy up to 1% of the stake if it drops below 0.5%. What do you think?

@xmatthias
Copy link
Member

i'd make it absolute BNB to be honest.

you'll not need an insane amount of BNB ... just enough to keep the bot paying for it in BNB.
Assuming you use compounding, 1% of stake-amount can be anything from 0.2$ (20$ stake) up to 1000$ (10k$ stake) ...

@Merinorus
Copy link
Contributor

Merinorus commented Sep 25, 2021

Well then I would lower the ratio to 0.15% for instance. In Binance, the fees are 0,075% in BNB for each trade, so assuming you buy then sell all your stake it would cost about 0,15% of your stake in BNB.
Let's say I have a 100$ stake wi 90% tradable balance ratio. The bot would buy 0.15% * 90% * 100$ = 0,135$ worth of BNB. It's too low anyway so the bot would buy the minimum allowed amount (maybe 10$, I don't know how much it is).
Now let's say it compounds up to 100 000$. Then the bot would buy 0.15% * 90% * 100 000$ = 135$, which would be adequate for this stake amount.

Maybe we could provide both solution (percentage and fixed amount) with amount advices of default values. Indeed, a 1% stake amount is way too much for this use case.

Edit: I just checked how some other exchanges behave.

  • Binance: Reduced fees if paid with BNB (0.075 instead of 0.1 % at level 0)
  • Bittrex: Reduced fees with increased volume only
  • Coinbase pro: Reduced fees with increased volume only
  • FTX: FTX allows reduced fees if you hold a fixed amount of FTT in dollar, even if it seems not as interesting as Binance: https://help.ftx.com/hc/en-us/articles/360024479432-Fees
  • Gates.io: Reduced fees with increased volume only
  • Kraken: Reduced fees with increased volume only
  • Kucoin: Reduced fees if paid with KCS (0.08 instead of 0.1% at level 0)

So according to these examples this feature would be really useful for Binance and Kucoin only. And I would stay on the percentage strategy with a default values table, eg. 0.15% for BInance and 0.16% fur Kucoin. For FTX you should only buy a fixed amount of FTT and a huge amount (at least 100$ to a 3% discount, 1000$ for 5% discount, 100k$ for a 25% discount like Binance lol). And FTT is not used to pay fees so there is no point using this auto buy feature for FTX.

Example of config.json:

"exchange":{
    "name": "binance",
    "reduced_fees_strategy"{
        "enable": true,
        "process_throttle_secs": 3600,
        "currency": "BNB",
        "upper_limit_ratio": 0.0015,
//      "upper_limit_fixed_amount": 0.01,
        "lower_limit_ratio": 0.0005,
//      "lower_limit_fixed_amount": 0.001,
    }
}

Don't know if it makes sense. Some user could use this feature in another way, ie having a part of they wallet holding another currency (BTC, ETH...)

We could as well make a list of coins the bot would buy up to a set threshold.

Edit 2021-11-06: Anyone, feel free to contribute, I don't feel I'll do it in the next few months.

@xmatthias
Copy link
Member

xmatthias commented Sep 25, 2021

having a "list of currencies" will not make much sense - as you'll have only one fee currency.

to be fair - if your bot compounds form 1000$ to 100.000$ - you'll have other problems if you never changed any parameters (like increasing parallel trades). (trades will not fill, or you'll move the market if using market orders).

the problem is - most people won't think about 100_000$ - but about a 1000$ (or even 100$) wallet.
In which case, the "upper" limit will not be your % - but the minimum you can buy (which is ~10-15$ - depending on the price...).
I'm also not sure on naming (upper/lower) ... while lower_limit makes sense (think - "minimum stock amount" in ERP terms) - "upper_limit" is is not clear - and is really "how much to order at once" ... and may not be respected (minimum order sizes again).

in the end - i think these are details though which we can work out as part of the work on a Pull Request.

@Merinorus
Copy link
Contributor

This one seems a bit complicated for me. I have another suggestion in the meantime: when the BNB amount is too low, a line should be added to the Telegram answers to some commands, only when specified on the config file.
Eg:
/balance

[...]
Estimated Value:
 BUSD: 602.700 (168.70%)
 EUR: 531.417 (168.70%)
/!\ BNB amount is low. Please check and add some in order to lower your trading fees.

@NoahGago
Copy link

NoahGago commented Dec 6, 2021

Forgive me if this doesn't make sense, but is it possible to buy the BNB at the time of the trades that you would need it for? It seems that the proposed solutions are buying the BNB percentage when you're running low however whilst looking into this issue I pondered the idea of simply buying it based on the actual trade amount. Unless I'm mistaken it's always the same percentage as per:

Screen Shot 2021-12-06 at 1 42 28 PM

@xmatthias
Copy link
Member

xmatthias commented Dec 6, 2021

@NoahGago that won't be possible (at least not buying just the amount necessary).

Fees are usually 0.1% of a trade - that's 1$ for a 1000$ trade.
Now 1000$ per trade is quite high for many users of freqtrade (usually you'll want to spread your money out into more smaller buckets, BUT it'll obviously depend on your total capital you're willing to give freqtrade)

Minimum trade amounts are usually around 10-12$ (depending on market fluctuation, among others) - so you can't buy "what you need" - but you must buy it "up front" - or rather, accept to keep it around for some time.

While this won't exclude "buy when needed" - i think we need to be careful with timing here - adding a call (and waiting for the order to fill) right before a trade can mean you've wasted the opportunity, unless you're going for market orders (even then, you'll potentially be a few seconds later than without this, as you're now making 2 (or 3) additional network calls - all while you'd really wanted to buy BTC.

@NoahGago
Copy link

NoahGago commented Dec 8, 2021

Quick question, if one were to implement this feature like this one pictured above

Screen Shot 2021-12-08 at 12 42 07 PM

or something similar to this, we would have to add checks to exchange/binance.py accordingly correct? Asking as a new and very interested freqtrade user

@xmatthias
Copy link
Member

To be honest, i'm not convinced that this is a "good first issue" for new contributions, and might potentially lead to frustrations in the process (i don't think this is an easy feature to contribute).

I'd not focus it on binance alone - as other exchanges have their own Fee coins too, so ideally, the implementation would be exchange-agnostic for the most part (and therefore more likely in exchange/exchange.py). It can obviously also have exchange-specific parts which are moved to the respective exchange-classes - but surely not the "main" implementation.

@segatrade
Copy link

segatrade commented Apr 18, 2023

This is good feature

"exchange":{
"name": "binance",
"reduced_fees_strategy"{
"enable": true,
"process_throttle_secs": 3600,
"currency": "BNB",
"upper_limit_ratio": 0.0015,
"lower_limit_ratio": 0.0005,

Percents are better than absolute, because deposit can change
"lower_limit_ratio": 0.0015, - let always pay commission to buy and sell ( but always > then minimal binance stake 10$)
"upper_limit_ratio": 2, - to have some additional x2 based on lower = 0.0030
"process_throttle_secs": 60, - 60 more stable for any strategy

@hotrungnhan
Copy link

hotrungnhan commented Jan 16, 2024

+1 for keeping auto trading in the long term.
Example case:
My strategies focus on a short trade, performing around 15 trades per day, with unlimited stack, and 10 concurrent trades.
Cost around 0.225% of the total balance each day
I want to keep the BNB amount at least 2% of the total balance, and min at 0.1%, it will cost around 10% of BNB per day and need to be refilled after 10 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhancements to the bot. Get lower priority than bugs by default.
Projects
None yet
Development

No branches or pull requests

7 participants
@Merinorus @xmatthias @hansen1015 @NoahGago @segatrade @hotrungnhan and others