Correct get_min_pair_stake_amount formula

If I understand well, the goal is to have stoploss price above the minimum required by the exchange, which is not what has been achieved so far.
Only if amount_reserve_percent = (1 + pad) / (1 - abs(stoploss)) we get final stake amount * (1 - abs(stoploss)) > minimum required.

Here is a code example, with numbers from the example in the doc for this function:

stoploss = 0.1
padding = 0.05
min_required_exchange_cost = 10
min_required_exchange_amount = 12
min_required_exchange = max(min_required_exchange_cost, min_required_exchange_amount)
min_required_with_padding = min_required_exchange * (1 + padding)

min_stake_amount = min_required_exchange * max(min(padding + stoploss + 1, 1.5), 1)
stoploss_price = min_stake_amount*(1-stoploss)
print(f'[OLD LOGIC] stoploss_price ({stoploss_price}) < min_required_with_padding ({min_required_with_padding})')


min_stake_amount = min_required_exchange * max(min((1+padding) / (1-stoploss), 1.5), 1)
stoploss_price = min_stake_amount*(1-stoploss)
print(f'[NEW LOGIC] stoploss_price ({stoploss_price}) > min_required_with_padding ({min_required_with_padding})')
This commit is contained in:
Théo Martin 2021-04-15 00:33:05 +01:00 committed by GitHub
parent 862df2b431
commit 1283f8cfd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -539,7 +539,7 @@ class Exchange:
# reserve some percent defined in config (5% default) + stoploss # reserve some percent defined in config (5% default) + stoploss
amount_reserve_percent = 1.0 + self._config.get('amount_reserve_percent', amount_reserve_percent = 1.0 + self._config.get('amount_reserve_percent',
DEFAULT_AMOUNT_RESERVE_PERCENT) DEFAULT_AMOUNT_RESERVE_PERCENT)
amount_reserve_percent += abs(stoploss) amount_reserve_percent /= 1 - abs(stoploss)
# it should not be more than 50% # it should not be more than 50%
amount_reserve_percent = max(min(amount_reserve_percent, 1.5), 1) amount_reserve_percent = max(min(amount_reserve_percent, 1.5), 1)