Add base_stake_amount_ratio config param to support unlimited stakes.

This commit is contained in:
Reigo Reinmets 2021-12-22 02:19:11 +02:00
parent fa01cbf546
commit 7df3e7ada4
2 changed files with 20 additions and 0 deletions

View File

@ -83,6 +83,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi
| `stake_amount` | **Required.** Amount of crypto-currency your bot will use for each trade. Set it to `"unlimited"` to allow the bot to use all available balance. [More information below](#configuring-amount-per-trade). <br> **Datatype:** Positive float or `"unlimited"`. | `stake_amount` | **Required.** Amount of crypto-currency your bot will use for each trade. Set it to `"unlimited"` to allow the bot to use all available balance. [More information below](#configuring-amount-per-trade). <br> **Datatype:** Positive float or `"unlimited"`.
| `tradable_balance_ratio` | Ratio of the total account balance the bot is allowed to trade. [More information below](#configuring-amount-per-trade). <br>*Defaults to `0.99` 99%).*<br> **Datatype:** Positive float between `0.1` and `1.0`. | `tradable_balance_ratio` | Ratio of the total account balance the bot is allowed to trade. [More information below](#configuring-amount-per-trade). <br>*Defaults to `0.99` 99%).*<br> **Datatype:** Positive float between `0.1` and `1.0`.
| `available_capital` | Available starting capital for the bot. Useful when running multiple bots on the same exchange account.[More information below](#configuring-amount-per-trade). <br> **Datatype:** Positive float. | `available_capital` | Available starting capital for the bot. Useful when running multiple bots on the same exchange account.[More information below](#configuring-amount-per-trade). <br> **Datatype:** Positive float.
| `base_stake_amount_ratio` | When using position adjustment with unlimited stakes, the strategy often requires that some funds are left for additional buy orders. You can define the ratio that the initial buy order can use from the calculated unlimited stake amount. [More information below](#configuring-amount-per-trade). <br>*Defaults to `1.0`.* <br> **Datatype:** Float (as ratio)
| `amend_last_stake_amount` | Use reduced last stake amount if necessary. [More information below](#configuring-amount-per-trade). <br>*Defaults to `false`.* <br> **Datatype:** Boolean | `amend_last_stake_amount` | Use reduced last stake amount if necessary. [More information below](#configuring-amount-per-trade). <br>*Defaults to `false`.* <br> **Datatype:** Boolean
| `last_stake_amount_min_ratio` | Defines minimum stake amount that has to be left and executed. Applies only to the last stake amount when it's amended to a reduced value (i.e. if `amend_last_stake_amount` is set to `true`). [More information below](#configuring-amount-per-trade). <br>*Defaults to `0.5`.* <br> **Datatype:** Float (as ratio) | `last_stake_amount_min_ratio` | Defines minimum stake amount that has to be left and executed. Applies only to the last stake amount when it's amended to a reduced value (i.e. if `amend_last_stake_amount` is set to `true`). [More information below](#configuring-amount-per-trade). <br>*Defaults to `0.5`.* <br> **Datatype:** Float (as ratio)
| `amount_reserve_percent` | Reserve some amount in min pair stake amount. The bot will reserve `amount_reserve_percent` + stoploss value when calculating min pair stake amount in order to avoid possible trade refusals. <br>*Defaults to `0.05` (5%).* <br> **Datatype:** Positive Float as ratio. | `amount_reserve_percent` | Reserve some amount in min pair stake amount. The bot will reserve `amount_reserve_percent` + stoploss value when calculating min pair stake amount in order to avoid possible trade refusals. <br>*Defaults to `0.05` (5%).* <br> **Datatype:** Positive Float as ratio.
@ -303,6 +304,14 @@ To allow the bot to trade all the available `stake_currency` in your account (mi
When using `"stake_amount" : "unlimited",` in combination with Dry-Run, Backtesting or Hyperopt, the balance will be simulated starting with a stake of `dry_run_wallet` which will evolve. When using `"stake_amount" : "unlimited",` in combination with Dry-Run, Backtesting or Hyperopt, the balance will be simulated starting with a stake of `dry_run_wallet` which will evolve.
It is therefore important to set `dry_run_wallet` to a sensible value (like 0.05 or 0.01 for BTC and 1000 or 100 for USDT, for example), otherwise, it may simulate trades with 100 BTC (or more) or 0.05 USDT (or less) at once - which may not correspond to your real available balance or is less than the exchange minimal limit for the order amount for the stake currency. It is therefore important to set `dry_run_wallet` to a sensible value (like 0.05 or 0.01 for BTC and 1000 or 100 for USDT, for example), otherwise, it may simulate trades with 100 BTC (or more) or 0.05 USDT (or less) at once - which may not correspond to your real available balance or is less than the exchange minimal limit for the order amount for the stake currency.
#### Dynamic stake amount with position adjustment
When you want to use position adjustment with unlimited stakes, you must also set `base_stake_amount_ratio` to a reasonable value depending on your strategy.
Typical value would be in the range of 0.1 - 0.5, but depends highly on your strategy and how much you wish to leave into the wallet as position adjustment buffer.
<br>
For example if your position adjustment assumes it can do 2 additional buys with the same stake amounts then your `base_stake_amount_ratio` should be 0.333333 (33.3333%) of your calculated unlimited stake amount.
<br>
Or another example if your position adjustment assumes it can do 1 additional buy with 3x the original stake amount then your `base_stake_amount_ratio` should be 0.25 (25%) of your calculated unlimited stake amount.
--8<-- "includes/pricing.md" --8<-- "includes/pricing.md"
### Understand minimal_roi ### Understand minimal_roi

View File

@ -184,6 +184,17 @@ class Wallets:
return 0 return 0
possible_stake = (available_amount + val_tied_up) / self._config['max_open_trades'] possible_stake = (available_amount + val_tied_up) / self._config['max_open_trades']
# Position Adjustment dynamic base order size
try:
if self._config.get('position_adjustment_enable', False):
base_stake_amount_ratio = self._config.get('base_stake_amount_ratio', 1.0)
if base_stake_amount_ratio > 0.0:
possible_stake = possible_stake * base_stake_amount_ratio
except Exception as e:
logger.warning("Invalid base_stake_amount_ratio", e)
return 0
# Theoretical amount can be above available amount - therefore limit to available amount! # Theoretical amount can be above available amount - therefore limit to available amount!
return min(possible_stake, available_amount) return min(possible_stake, available_amount)