Rename function to adjust_min_max

This commit is contained in:
Matthias 2019-03-16 20:06:15 +01:00
parent 01733c94fa
commit fc360608b7
3 changed files with 7 additions and 7 deletions

View File

@ -204,7 +204,7 @@ class Trade(_DECL_BASE):
return (f'Trade(id={self.id}, pair={self.pair}, amount={self.amount:.8f}, '
f'open_rate={self.open_rate:.8f}, open_since={open_since})')
def adjust_high_low(self, current_price: float):
def adjust_min_max_rates(self, current_price: float):
"""
Adjust the max_rate and min_rate.
"""

View File

@ -254,7 +254,7 @@ class IStrategy(ABC):
current_rate = low or rate
current_profit = trade.calc_profit_percent(current_rate)
trade.adjust_high_low(current_rate)
trade.adjust_min_max_rates(current_rate)
stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade,
current_time=date, current_profit=current_profit,

View File

@ -627,7 +627,7 @@ def test_adjust_stop_loss(fee):
assert trade.initial_stop_loss == 0.95
def test_adjust_high_low(fee):
def test_adjust_min_max_rates(fee):
trade = Trade(
pair='ETH/BTC',
stake_amount=0.001,
@ -637,22 +637,22 @@ def test_adjust_high_low(fee):
open_rate=1,
)
trade.adjust_high_low(trade.open_rate)
trade.adjust_min_max_rates(trade.open_rate)
assert trade.max_rate == 1
assert trade.min_rate == 1
# check min adjusted, max remained
trade.adjust_high_low(0.96)
trade.adjust_min_max_rates(0.96)
assert trade.max_rate == 1
assert trade.min_rate == 0.96
# check max adjusted, min remains
trade.adjust_high_low(1.05)
trade.adjust_min_max_rates(1.05)
assert trade.max_rate == 1.05
assert trade.min_rate == 0.96
# current rate "in the middle" - no adjustment
trade.adjust_high_low(1.03)
trade.adjust_min_max_rates(1.03)
assert trade.max_rate == 1.05
assert trade.min_rate == 0.96