Add available_capital parameter
This commit is contained in:
parent
b41c234440
commit
7863746904
@ -113,6 +113,10 @@ CONF_SCHEMA = {
|
|||||||
'maximum': 1,
|
'maximum': 1,
|
||||||
'default': 0.99
|
'default': 0.99
|
||||||
},
|
},
|
||||||
|
'available_capital': {
|
||||||
|
'type': 'number',
|
||||||
|
'minimum': 0,
|
||||||
|
},
|
||||||
'amend_last_stake_amount': {'type': 'boolean', 'default': False},
|
'amend_last_stake_amount': {'type': 'boolean', 'default': False},
|
||||||
'last_stake_amount_min_ratio': {
|
'last_stake_amount_min_ratio': {
|
||||||
'type': 'number', 'minimum': 0.0, 'maximum': 1.0, 'default': 0.5
|
'type': 'number', 'minimum': 0.0, 'maximum': 1.0, 'default': 0.5
|
||||||
|
@ -136,10 +136,16 @@ class Wallets:
|
|||||||
Calculated as
|
Calculated as
|
||||||
(<open_trade stakes> + free amount) * tradable_balance_ratio
|
(<open_trade stakes> + free amount) * tradable_balance_ratio
|
||||||
"""
|
"""
|
||||||
|
val_tied_up = Trade.total_open_trades_stakes()
|
||||||
|
if "available_capital" in self._config:
|
||||||
|
starting_balance = self._config['available_capital']
|
||||||
|
tot_profit = Trade.get_total_closed_profit()
|
||||||
|
available_amount = starting_balance + tot_profit
|
||||||
|
|
||||||
|
else:
|
||||||
# Ensure <tradable_balance_ratio>% is used from the overall balance
|
# Ensure <tradable_balance_ratio>% is used from the overall balance
|
||||||
# Otherwise we'd risk lowering stakes with each open trade.
|
# Otherwise we'd risk lowering stakes with each open trade.
|
||||||
# (tied up + current free) * ratio) - tied up
|
# (tied up + current free) * ratio) - tied up
|
||||||
val_tied_up = Trade.total_open_trades_stakes()
|
|
||||||
available_amount = ((val_tied_up + self.get_free(self._config['stake_currency'])) *
|
available_amount = ((val_tied_up + self.get_free(self._config['stake_currency'])) *
|
||||||
self._config['tradable_balance_ratio'])
|
self._config['tradable_balance_ratio'])
|
||||||
return available_amount
|
return available_amount
|
||||||
@ -152,10 +158,9 @@ class Wallets:
|
|||||||
(<open_trade stakes> + free amount) * tradable_balance_ratio - <open_trade stakes>
|
(<open_trade stakes> + free amount) * tradable_balance_ratio - <open_trade stakes>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Ensure <tradable_balance_ratio>% is used from the overall balance
|
|
||||||
# Otherwise we'd risk lowering stakes with each open trade.
|
free = self.get_free(self._config['stake_currency'])
|
||||||
# (tied up + current free) * ratio) - tied up
|
return min(self.get_total_stake_amount() - Trade.total_open_trades_stakes(), free)
|
||||||
return self.get_total_stake_amount() - Trade.total_open_trades_stakes()
|
|
||||||
|
|
||||||
def _calculate_unlimited_stake_amount(self, available_amount: float,
|
def _calculate_unlimited_stake_amount(self, available_amount: float,
|
||||||
val_tied_up: float) -> float:
|
val_tied_up: float) -> float:
|
||||||
|
Loading…
Reference in New Issue
Block a user