stake_amount in case it doesn’t exist
This commit is contained in:
parent
ee62adf4f7
commit
1d41a91788
@ -161,23 +161,19 @@ class Edge():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def stake_amount(self, pair: str, free_capital: float, total_capital: float) -> float:
|
def stake_amount(self, pair: str, free_capital: float, total_capital: float) -> float:
|
||||||
if pair not in self._cached_pairs:
|
stoploss = self.stoploss(pair)
|
||||||
logger.warning("cannot find %s in calculated pairs, "
|
|
||||||
"stake_amount of strategy is used instead.", pair)
|
|
||||||
return self.config['stake_amount']
|
|
||||||
|
|
||||||
stoploss = self._cached_pairs[pair].stoploss
|
|
||||||
available_capital = total_capital * self._capital_percentage
|
available_capital = total_capital * self._capital_percentage
|
||||||
allowed_capital_at_risk = available_capital * self._allowed_risk
|
allowed_capital_at_risk = available_capital * self._allowed_risk
|
||||||
max_position_size = abs(allowed_capital_at_risk / stoploss)
|
max_position_size = abs(allowed_capital_at_risk / stoploss)
|
||||||
position_size = min(max_position_size, free_capital)
|
position_size = min(max_position_size, free_capital)
|
||||||
logger.info(
|
if pair in self._cached_pairs:
|
||||||
'winrate: %s, expectancy: %s, position size: %s, pair: %s,'
|
logger.info(
|
||||||
' stoploss: %s, available capital: %s.',
|
'winrate: %s, expectancy: %s, position size: %s, pair: %s,'
|
||||||
self._cached_pairs[pair].winrate,
|
' stoploss: %s, available capital: %s.',
|
||||||
self._cached_pairs[pair].expectancy,
|
self._cached_pairs[pair].winrate,
|
||||||
position_size, pair, stoploss, available_capital
|
self._cached_pairs[pair].expectancy,
|
||||||
)
|
position_size, pair, stoploss, available_capital
|
||||||
|
)
|
||||||
return round(position_size, 15)
|
return round(position_size, 15)
|
||||||
|
|
||||||
def stoploss(self, pair: str) -> float:
|
def stoploss(self, pair: str) -> float:
|
||||||
|
Loading…
Reference in New Issue
Block a user