Rename edge.stoploss to get_stoploss
this will make it clear that it's different from
This commit is contained in:
parent
bddec476f9
commit
6e55a873b3
@ -195,7 +195,7 @@ class Edge:
|
|||||||
|
|
||||||
def stake_amount(self, pair: str, free_capital: float,
|
def stake_amount(self, pair: str, free_capital: float,
|
||||||
total_capital: float, capital_in_trade: float) -> float:
|
total_capital: float, capital_in_trade: float) -> float:
|
||||||
stoploss = self.stoploss(pair)
|
stoploss = self.get_stoploss(pair)
|
||||||
available_capital = (total_capital + capital_in_trade) * self._capital_ratio
|
available_capital = (total_capital + capital_in_trade) * self._capital_ratio
|
||||||
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)
|
||||||
@ -214,7 +214,7 @@ class Edge:
|
|||||||
)
|
)
|
||||||
return round(position_size, 15)
|
return round(position_size, 15)
|
||||||
|
|
||||||
def stoploss(self, pair: str) -> float:
|
def get_stoploss(self, pair: str) -> float:
|
||||||
if pair in self._cached_pairs:
|
if pair in self._cached_pairs:
|
||||||
return self._cached_pairs[pair].stoploss
|
return self._cached_pairs[pair].stoploss
|
||||||
else:
|
else:
|
||||||
|
@ -1078,7 +1078,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
datetime.now(timezone.utc),
|
datetime.now(timezone.utc),
|
||||||
enter=enter,
|
enter=enter,
|
||||||
exit_=exit_,
|
exit_=exit_,
|
||||||
force_stoploss=self.edge.stoploss(trade.pair) if self.edge else 0
|
force_stoploss=self.edge.get_stoploss(trade.pair) if self.edge else 0
|
||||||
)
|
)
|
||||||
for should_exit in exits:
|
for should_exit in exits:
|
||||||
if should_exit.exit_flag:
|
if should_exit.exit_flag:
|
||||||
@ -1172,7 +1172,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
if not stoploss_order:
|
if not stoploss_order:
|
||||||
stop_price = trade.stoploss_or_liquidation
|
stop_price = trade.stoploss_or_liquidation
|
||||||
if self.edge:
|
if self.edge:
|
||||||
stoploss = self.edge.stoploss(pair=trade.pair)
|
stoploss = self.edge.get_stoploss(pair=trade.pair)
|
||||||
stop_price = (
|
stop_price = (
|
||||||
trade.open_rate * (1 - stoploss) if trade.is_short
|
trade.open_rate * (1 - stoploss) if trade.is_short
|
||||||
else trade.open_rate * (1 + stoploss)
|
else trade.open_rate * (1 + stoploss)
|
||||||
|
@ -139,7 +139,7 @@ def test_adjust(mocker, edge_conf):
|
|||||||
assert (edge.adjust(pairs) == ['E/F', 'C/D'])
|
assert (edge.adjust(pairs) == ['E/F', 'C/D'])
|
||||||
|
|
||||||
|
|
||||||
def test_stoploss(mocker, edge_conf):
|
def test_edge_get_stoploss(mocker, edge_conf):
|
||||||
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
||||||
edge = Edge(edge_conf, freqtrade.exchange, freqtrade.strategy)
|
edge = Edge(edge_conf, freqtrade.exchange, freqtrade.strategy)
|
||||||
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
||||||
@ -150,10 +150,10 @@ def test_stoploss(mocker, edge_conf):
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
assert edge.stoploss('E/F') == -0.01
|
assert edge.get_stoploss('E/F') == -0.01
|
||||||
|
|
||||||
|
|
||||||
def test_nonexisting_stoploss(mocker, edge_conf):
|
def test_nonexisting_get_stoploss(mocker, edge_conf):
|
||||||
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
||||||
edge = Edge(edge_conf, freqtrade.exchange, freqtrade.strategy)
|
edge = Edge(edge_conf, freqtrade.exchange, freqtrade.strategy)
|
||||||
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
||||||
@ -162,7 +162,7 @@ def test_nonexisting_stoploss(mocker, edge_conf):
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
assert edge.stoploss('N/O') == -0.1
|
assert edge.get_stoploss('N/O') == -0.1
|
||||||
|
|
||||||
|
|
||||||
def test_edge_stake_amount(mocker, edge_conf):
|
def test_edge_stake_amount(mocker, edge_conf):
|
||||||
|
Loading…
Reference in New Issue
Block a user