binance-trading-bot icon indicating copy to clipboard operation
binance-trading-bot copied to clipboard

Maximum purchase amount set to %

Open Dutchblue020 opened this issue 3 years ago • 8 comments

Hi,

I have a feature request special for the "maximum purchase amount" that you can set. It will be nice to set a % value of the balance in place of a fixed amount.

With this option you gan use the profit with the next trade (for example when you set it to 100% of the balance).

Dutchblue020 avatar Apr 02 '21 17:04 Dutchblue020

+1 here... Would be a nice addition, specially once #52 gets implemented.

chopeta avatar Apr 02 '21 18:04 chopeta

Hey @Dutchblue020

Thanks for your suggestion.

As I mentioned in issue #12, percentage buy calculation is tricky.

For instance, if you have a $100 USDT and I set 50%, then the first purchase would be $50 USDT. And for 2nd purchase, it would be $25 of left $50. So I just decided to go with a simple maximum purchase.

chrisleekr avatar Apr 03 '21 02:04 chrisleekr

Good point Chris. You're absolutely right. Unless @Dutchblue020 has another suggestion on how to go about this, I think we can close it.

Do you agree @Dutchblue020 ?

chopeta avatar Apr 04 '21 23:04 chopeta

@chrisleekr @chopeta

const percent = process.env.PERCENT_PER_TRADE
const use = openOrders == 0 ? (percent/100) * balance : balance / (100/percent - openOrders)

fqueis avatar Apr 06 '21 21:04 fqueis

@fqueis Interesting point.

Although, your formula is just accounted for the case that you have open orders.

So for example,

Trade 1:

  • Opening balance $100, Percentage 50%
  • Purchased BTCUSDT $50, the order is executed, no open orders.
  • Closing balance $50

Trade 2:

  • Opening balance $50, Percentage 50%
  • Purchased ETHUSDT $25, the order is executed
  • Closing balance $25

As you can see above case, the buying amount is not consistent.

How can we overcome this inconsistency?

chrisleekr avatar Apr 07 '21 11:04 chrisleekr

@chrisleekr yeah it keeps the open trades to split the entering amount by a certain percentage.

Btw your example is wrong. See:

Trade 1:

  • Open trades: 0
  • Balance: $100, percent: 50%
  • Balance used in this trade: $50

Trade 2 (if the first one is not closed yet):

  • Open trades: 1
  • Balance: $50, percent: 50%
  • Balance used in this trade: $50

Edit: Maybe the var name (openOrders) left you in doubt, I should have used openTrades

fqueis avatar Apr 07 '21 16:04 fqueis

Oh, so you meant, we should track trade history for the coin?

chrisleekr avatar Apr 09 '21 03:04 chrisleekr

Oh, so you meant, we should track trade history for the coin?

Not exactly.

From your documentation:

Buy signal: The bot will continuously monitor the lowest value for the period of the candles. Once the current price reaches the lowest price, then the bot will place a STOP-LOSS-LIMIT order to buy.

When this order get filled you'll have one openTrade

Sell signal: If there is enough balance for selling and the last buy price is recorded in the bot, then the bot will start monitoring the sell signal. Once the current price reaches the trigger price, then the bot will place a STOP-LOSS-LIMIT order to sell.

When this same coin get sold and the order is filled, the openTrade goes back to zero

fqueis avatar Apr 09 '21 20:04 fqueis