chrisleekr / binance-trading-bot

Automated Binance trading bot - Trade multiple cryptocurrencies. Buy low/sell high with Grid Trading. Integrated with TradingView technical analysis
MIT License
5k stars 1.09k forks source link

Calculation of % of available balance asset #118

Closed gilmillasseau closed 3 years ago

gilmillasseau commented 3 years ago

Reopening this discussion https://github.com/chrisleekr/binance-trading-bot/issues/12#issuecomment-826778785_

Things to discuss:

chrisleekr commented 3 years ago

Note that this issue is related with PR #77

And I have mentioned the reason in #12 for the issue.

To re-iterating the issue, let me explain further about the issue.

Let say, I am monitoring two coins - BTCUSDT, ETHUSDT, LTCUSDT

And I have configured 50% as the maximum purchase amount.

Assume I have 100 USDT at the moment

So as you can see each purchase amount is not consistent. That is why I decide to use a static maximum purchase amount.

However, you are having an issue because I removed the maximum purchase amount from the global configuration for this improvement #104

You can still configure the maximum purchase amount in the symbol configuration. I couldn't think of a better way to set the maximum purchase amount in the global configuration.

gilmillasseau commented 3 years ago

Very well explained, thanks.

This is tricky to solve indeed, probably if we had a concept of Portfolio Asset (available + invested) could solve the issue but we don't have that data out of the box I assume.

Assuming we had that data do you think it could potentially solve the issue?

Legend: PA - portfolio asset (available + invested) AA - available asset (available only)

Assume : Current balance: 100USDT Global config for max purchase: 20%

First purchase for BTCUSDT

Second purchase for ETHUSDT

Imagine bot sells first purchase and I have 4% profit (PA: 104 USDT, AA: 84 USDT)

Third purchase for BTCUSDT

Not sure all calculations are correct but I think you get the idea.

chrisleekr commented 3 years ago

That maybe works when you only use single FIAT. Actually, it will be very complicated to check that even single FIAT.

Imagine you have BTC/BNB/USDT/BUSD as quote assets. In addition, you will also do some manual orders as well.

It will be impossible to get the total portfolio assets to calculate.

gilmillasseau commented 3 years ago

Yeah, the cost benefit of doing it probably is not worth it for now.

I think if we have an option to override the default fallback value (100) for now would be great. Every time I restart the service I need to individually put the maxPurchaseAmount for each pair.

chrisleekr commented 3 years ago

@gilmillasseau

Ehhhh? Are you saying, every time you restart maxPurchaseAmount is reset? That should not be happening.

gilmillasseau commented 3 years ago

Sorry I though was on restart, it's when I do docker-compose up -d --build

chrisleekr commented 3 years ago

Even that command, should not lose any customised configuration as that configuration is stored in the mongodb. The whole point of using the persistent database is to not lose configurations & last buy price.

Some other things must be going on. Can you take a video of that?

gilmillasseau commented 3 years ago

Ok so I was able to reproduce:

Is this the expected behaviour? Probably I am using this incorrectly.

image

chrisleekr commented 3 years ago

Yes, as the modal mentioned, it will remove customised symbol configurations if you click "Apply to all symbols".

gilmillasseau commented 3 years ago

Ok, makes sense, I am testing this tool and sometimes I just want to change global configuration after changing the maxPurchaseAmount for each config, can I hardcode somewhere the default to be different than 100?

chrisleekr commented 3 years ago

Hmmmmmmmmmmmmmmm....

Maybe I should revert the max purchase amount field and give the option to set dynamically calculated. @GrigorovskyA also confused about the max purchase amount like you.

Let me think about it.

gilmillasseau commented 3 years ago

Think this will happen often when you are first trying this bot and trying several configs, I can now understand it's only when you want to apply a global config to all pairs that resets the value maxPurchaseAmount to 100.

Let me know if you need more help testing this ;)

GrigorovskyA commented 3 years ago

Yes, this is the case - I have not yet figured out how it would be possible to implement the percentage.

I thought aside that each pair has a name - Coin-Bridge. eg: ethUSDT, wavesBNB,algoBTC And for each bridge, it would be possible to collect information and thus we can get an approximate current balance of the bridge coins on accounts. Bot could to split coinpair - coin-bridge - And in the global configuration, add param max bridge for each bridgecoin from used pairs list - the amount of the maximum price

chrisleekr commented 3 years ago

@GrigorovskyA Right, so are you suggesting, if I put coins like BTCUSDT, ETHBNB, ETHBTC, then there will be three fields for each quote assets?

This may work, I think?

GrigorovskyA commented 3 years ago

I think this is a good option. What do you think? And I like the idea, of course, to set limits on percentages.

chrisleekr commented 3 years ago

I am working on it. I will need some refactoring for implementing this.

image

GrigorovskyA commented 3 years ago

@chrisleekr it's your current bot settings? and which profit of it?

I think it would be cool to raise a discord server(for exmaple) so that people can change their profits and observations. and fumble around useful results and scripts with lists of volatile coins.

gilmillasseau commented 3 years ago

@chrisleekr not related but I will take advantage of this thread to ask something regarding buy signal see this screenshot:

Screenshot 2021-04-28 at 20 53 52

Config

config

If the price was at 556 at 20:12 how bot created an order to buy when price is >= 563?

GrigorovskyA commented 3 years ago

@gilmillasseau read about https://github.com/chrisleekr/binance-trading-bot#buy-scenario 556+1.21% ~ 563

chrisleekr commented 3 years ago

@GrigorovskyA

@chrisleekr it's your current bot settings? and which profit of it?

No, that is my test bot configuration for development.

My live bot configuration is different. I also still look for a working configuration; however, my personal opinion is, there is no single working configuration. It should be different per coin and market trend. And very importantly, choosing a good coin. Last time, I traded XRPDOWN/LTCDOWN and lost money. Do not trade DOWN leverage token!

I think it would be cool to raise a discord server(for example) so that people can change their profits and observations. and fumble around useful results and scripts with lists of volatile coins.

I don't use Discord and don't have much time to involve to chat all the time. Sorry.

chrisleekr commented 3 years ago

@GrigorovskyA @gilmillasseau

Guys, I have reverted the max purchase amount back to the global configuration. See the comment - https://github.com/chrisleekr/binance-trading-bot/pull/77#issuecomment-830126744

chrisleekr commented 3 years ago

@gilmillasseau I think this issue can be closed as I delivered the global configuration back and explained about % buy.

gilmillasseau commented 3 years ago

@chrisleekr I am testing since yesterday, everything is working fine 👍 Nice work.