Merge pull request #1373 from mishaker/fix_edge_stoploss

Should fallback to strategy stoploss if Edge cannot provide.
This commit is contained in:
Matthias 2018-11-29 19:09:25 +01:00 committed by GitHub
commit 49e44d5481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -157,7 +157,12 @@ class Edge():
return position_size return position_size
def stoploss(self, pair: str) -> float: def stoploss(self, pair: str) -> float:
return self._cached_pairs[pair].stoploss if pair in self._cached_pairs:
return self._cached_pairs[pair].stoploss
else:
logger.warning('tried to access stoploss of a non-existing pair, '
'strategy stoploss is returned instead.')
return self.strategy.stoploss
def adjust(self, pairs) -> list: def adjust(self, pairs) -> list:
""" """

View File

@ -152,6 +152,18 @@ def test_stoploss(mocker, default_conf):
assert edge.stoploss('E/F') == -0.01 assert edge.stoploss('E/F') == -0.01
def test_nonexisting_stoploss(mocker, default_conf):
freqtrade = get_patched_freqtradebot(mocker, default_conf)
edge = Edge(default_conf, freqtrade.exchange, freqtrade.strategy)
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
return_value={
'E/F': PairInfo(-0.01, 0.66, 3.71, 0.50, 1.71, 10, 60),
}
))
assert edge.stoploss('N/O') == -0.1
def _validate_ohlc(buy_ohlc_sell_matrice): def _validate_ohlc(buy_ohlc_sell_matrice):
for index, ohlc in enumerate(buy_ohlc_sell_matrice): for index, ohlc in enumerate(buy_ohlc_sell_matrice):
# if not high < open < low or not high < close < low # if not high < open < low or not high < close < low