Use ticker_interval defined in Strategy() instead of a mix between strategy and config file (#540)
This commit is contained in:
parent
c94f55807b
commit
e6732e01e1
@ -77,6 +77,13 @@ class Analyze(object):
|
|||||||
"""
|
"""
|
||||||
return self.strategy.populate_sell_trend(dataframe=dataframe)
|
return self.strategy.populate_sell_trend(dataframe=dataframe)
|
||||||
|
|
||||||
|
def get_ticker_interval(self) -> int:
|
||||||
|
"""
|
||||||
|
Return ticker interval to use
|
||||||
|
:return: Ticker interval value to use
|
||||||
|
"""
|
||||||
|
return self.strategy.ticker_interval
|
||||||
|
|
||||||
def analyze_ticker(self, ticker_history: List[Dict]) -> DataFrame:
|
def analyze_ticker(self, ticker_history: List[Dict]) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
Parses the given ticker history and returns a populated DataFrame
|
Parses the given ticker history and returns a populated DataFrame
|
||||||
|
@ -125,17 +125,9 @@ class FreqtradeBot(object):
|
|||||||
Constants.DYNAMIC_WHITELIST
|
Constants.DYNAMIC_WHITELIST
|
||||||
)
|
)
|
||||||
|
|
||||||
interval = int(
|
|
||||||
self.config.get(
|
|
||||||
'ticker_interval',
|
|
||||||
Constants.TICKER_INTERVAL
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self._throttle(func=self._process,
|
self._throttle(func=self._process,
|
||||||
min_secs=min_secs,
|
min_secs=min_secs,
|
||||||
nb_assets=nb_assets,
|
nb_assets=nb_assets)
|
||||||
interval=interval)
|
|
||||||
return new_state
|
return new_state
|
||||||
|
|
||||||
def _throttle(self, func: Callable[..., Any], min_secs: float, *args, **kwargs) -> Any:
|
def _throttle(self, func: Callable[..., Any], min_secs: float, *args, **kwargs) -> Any:
|
||||||
@ -154,7 +146,7 @@ class FreqtradeBot(object):
|
|||||||
time.sleep(duration)
|
time.sleep(duration)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _process(self, interval: int, nb_assets: Optional[int] = 0) -> bool:
|
def _process(self, nb_assets: Optional[int] = 0) -> bool:
|
||||||
"""
|
"""
|
||||||
Queries the persistence layer for open trades and handles them,
|
Queries the persistence layer for open trades and handles them,
|
||||||
otherwise a new trade is created.
|
otherwise a new trade is created.
|
||||||
@ -179,11 +171,11 @@ class FreqtradeBot(object):
|
|||||||
|
|
||||||
# First process current opened trades
|
# First process current opened trades
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
state_changed |= self.process_maybe_execute_sell(trade, interval)
|
state_changed |= self.process_maybe_execute_sell(trade)
|
||||||
|
|
||||||
# Then looking for buy opportunities
|
# Then looking for buy opportunities
|
||||||
if len(trades) < self.config['max_open_trades']:
|
if len(trades) < self.config['max_open_trades']:
|
||||||
state_changed = self.process_maybe_execute_buy(interval)
|
state_changed = self.process_maybe_execute_buy()
|
||||||
|
|
||||||
if 'unfilledtimeout' in self.config:
|
if 'unfilledtimeout' in self.config:
|
||||||
# Check and handle any timed out open orders
|
# Check and handle any timed out open orders
|
||||||
@ -263,9 +255,7 @@ class FreqtradeBot(object):
|
|||||||
balance = self.config['bid_strategy']['ask_last_balance']
|
balance = self.config['bid_strategy']['ask_last_balance']
|
||||||
return ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
return ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
||||||
|
|
||||||
# TODO: Remove the two parameters and use the value already in conf['stake_amount'] and
|
def create_trade(self) -> bool:
|
||||||
# int(conf['ticker_interval'])
|
|
||||||
def create_trade(self, stake_amount: float, interval: int) -> bool:
|
|
||||||
"""
|
"""
|
||||||
Checks the implemented trading indicator(s) for a randomly picked pair,
|
Checks the implemented trading indicator(s) for a randomly picked pair,
|
||||||
if one pair triggers the buy_signal a new trade record gets created
|
if one pair triggers the buy_signal a new trade record gets created
|
||||||
@ -273,6 +263,9 @@ class FreqtradeBot(object):
|
|||||||
:param interval: Ticker interval used for Analyze
|
:param interval: Ticker interval used for Analyze
|
||||||
:return: True if a trade object has been created and persisted, False otherwise
|
:return: True if a trade object has been created and persisted, False otherwise
|
||||||
"""
|
"""
|
||||||
|
stake_amount = self.config['stake_amount']
|
||||||
|
interval = self.analyze.get_ticker_interval()
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'Checking buy signals to create a new trade with stake_amount: %f ...',
|
'Checking buy signals to create a new trade with stake_amount: %f ...',
|
||||||
stake_amount
|
stake_amount
|
||||||
@ -343,14 +336,14 @@ class FreqtradeBot(object):
|
|||||||
Trade.session.flush()
|
Trade.session.flush()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def process_maybe_execute_buy(self, interval: int) -> bool:
|
def process_maybe_execute_buy(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Tries to execute a buy trade in a safe way
|
Tries to execute a buy trade in a safe way
|
||||||
:return: True if executed
|
:return: True if executed
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Create entity and execute trade
|
# Create entity and execute trade
|
||||||
if self.create_trade(float(self.config['stake_amount']), interval):
|
if self.create_trade():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
self.logger.info('Found no buy signals for whitelisted currencies. Trying again..')
|
self.logger.info('Found no buy signals for whitelisted currencies. Trying again..')
|
||||||
@ -359,7 +352,7 @@ class FreqtradeBot(object):
|
|||||||
self.logger.warning('Unable to create trade: %s', exception)
|
self.logger.warning('Unable to create trade: %s', exception)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def process_maybe_execute_sell(self, trade: Trade, interval: int) -> bool:
|
def process_maybe_execute_sell(self, trade: Trade) -> bool:
|
||||||
"""
|
"""
|
||||||
Tries to execute a sell trade
|
Tries to execute a sell trade
|
||||||
:return: True if executed
|
:return: True if executed
|
||||||
@ -372,10 +365,10 @@ class FreqtradeBot(object):
|
|||||||
|
|
||||||
if trade.is_open and trade.open_order_id is None:
|
if trade.is_open and trade.open_order_id is None:
|
||||||
# Check if we can sell our current pair
|
# Check if we can sell our current pair
|
||||||
return self.handle_trade(trade, interval)
|
return self.handle_trade(trade)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def handle_trade(self, trade: Trade, interval: int) -> bool:
|
def handle_trade(self, trade: Trade) -> bool:
|
||||||
"""
|
"""
|
||||||
Sells the current pair if the threshold is reached and updates the trade record.
|
Sells the current pair if the threshold is reached and updates the trade record.
|
||||||
:return: True if trade has been sold, False otherwise
|
:return: True if trade has been sold, False otherwise
|
||||||
@ -389,7 +382,7 @@ class FreqtradeBot(object):
|
|||||||
(buy, sell) = (False, False)
|
(buy, sell) = (False, False)
|
||||||
|
|
||||||
if self.config.get('experimental', {}).get('use_sell_signal'):
|
if self.config.get('experimental', {}).get('use_sell_signal'):
|
||||||
(buy, sell) = self.analyze.get_signal(trade.pair, interval)
|
(buy, sell) = self.analyze.get_signal(trade.pair, self.analyze.get_ticker_interval())
|
||||||
|
|
||||||
if self.analyze.should_sell(trade, current_rate, datetime.utcnow(), buy, sell):
|
if self.analyze.should_sell(trade, current_rate, datetime.utcnow(), buy, sell):
|
||||||
self.execute_sell(trade, current_rate)
|
self.execute_sell(trade, current_rate)
|
||||||
|
@ -64,7 +64,7 @@ class Strategy(object):
|
|||||||
# Optimal stoploss designed for the strategy
|
# Optimal stoploss designed for the strategy
|
||||||
self.stoploss = float(self.custom_strategy.stoploss)
|
self.stoploss = float(self.custom_strategy.stoploss)
|
||||||
|
|
||||||
self.ticker_interval = self.custom_strategy.ticker_interval
|
self.ticker_interval = int(self.custom_strategy.ticker_interval)
|
||||||
|
|
||||||
def _load_strategy(self, strategy_name: str) -> None:
|
def _load_strategy(self, strategy_name: str) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -51,7 +51,7 @@ def test_rpc_trade_status(default_conf, ticker, mocker) -> None:
|
|||||||
assert error
|
assert error
|
||||||
assert 'no active trade' in result
|
assert 'no active trade' in result
|
||||||
|
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
(error, result) = rpc.rpc_trade_status()
|
(error, result) = rpc.rpc_trade_status()
|
||||||
assert not error
|
assert not error
|
||||||
trade = result[0]
|
trade = result[0]
|
||||||
@ -99,7 +99,7 @@ def test_rpc_status_table(default_conf, ticker, mocker) -> None:
|
|||||||
assert error
|
assert error
|
||||||
assert '*Status:* `no active order`' in result
|
assert '*Status:* `no active order`' in result
|
||||||
|
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
(error, result) = rpc.rpc_status_table()
|
(error, result) = rpc.rpc_status_table()
|
||||||
assert 'just now' in result['Since'].all()
|
assert 'just now' in result['Since'].all()
|
||||||
assert 'BTC_ETH' in result['Pair'].all()
|
assert 'BTC_ETH' in result['Pair'].all()
|
||||||
@ -127,7 +127,7 @@ def test_rpc_daily_profit(default_conf, update, ticker, limit_buy_order, limit_s
|
|||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ def test_rpc_trade_statistics(
|
|||||||
assert stats.find('no closed trade') >= 0
|
assert stats.find('no closed trade') >= 0
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
# Simulate fulfilled LIMIT_BUY order for trade
|
# Simulate fulfilled LIMIT_BUY order for trade
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
@ -247,7 +247,7 @@ def test_rpc_trade_statistics_closed(mocker, default_conf, ticker, ticker_sell_u
|
|||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
# Simulate fulfilled LIMIT_BUY order for trade
|
# Simulate fulfilled LIMIT_BUY order for trade
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
@ -427,7 +427,7 @@ def test_rpc_forcesell(default_conf, ticker, mocker) -> None:
|
|||||||
assert not error
|
assert not error
|
||||||
assert res == ''
|
assert res == ''
|
||||||
|
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
(error, res) = rpc.rpc_forcesell('all')
|
(error, res) = rpc.rpc_forcesell('all')
|
||||||
assert not error
|
assert not error
|
||||||
assert res == ''
|
assert res == ''
|
||||||
@ -462,7 +462,7 @@ def test_rpc_forcesell(default_conf, ticker, mocker) -> None:
|
|||||||
assert res == ''
|
assert res == ''
|
||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 1
|
||||||
|
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
# make an limit-sell open trade
|
# make an limit-sell open trade
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
'freqtrade.freqtradebot.exchange.get_order',
|
'freqtrade.freqtradebot.exchange.get_order',
|
||||||
@ -497,7 +497,7 @@ def test_performance_handle(default_conf, ticker, limit_buy_order,
|
|||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ def test_rpc_count(mocker, default_conf, ticker) -> None:
|
|||||||
assert nb_trades == 0
|
assert nb_trades == 0
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
(error, trades) = rpc.rpc_count()
|
(error, trades) = rpc.rpc_count()
|
||||||
nb_trades = len(trades)
|
nb_trades = len(trades)
|
||||||
assert not error
|
assert not error
|
||||||
|
@ -266,7 +266,7 @@ def test_status(default_conf, update, mocker, ticker) -> None:
|
|||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
freqtradebot.create_trade(0.001, 5)
|
freqtradebot.create_trade()
|
||||||
|
|
||||||
telegram._status(bot=MagicMock(), update=update)
|
telegram._status(bot=MagicMock(), update=update)
|
||||||
assert msg_mock.call_count == 3
|
assert msg_mock.call_count == 3
|
||||||
@ -314,7 +314,7 @@ def test_status_handle(default_conf, update, ticker, mocker) -> None:
|
|||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
# Trigger status while we have a fulfilled order for the open trade
|
# Trigger status while we have a fulfilled order for the open trade
|
||||||
telegram._status(bot=MagicMock(), update=update)
|
telegram._status(bot=MagicMock(), update=update)
|
||||||
|
|
||||||
@ -342,7 +342,9 @@ def test_status_table_handle(default_conf, update, ticker, mocker) -> None:
|
|||||||
)
|
)
|
||||||
mocker.patch('freqtrade.freqtradebot.RPCManager', MagicMock())
|
mocker.patch('freqtrade.freqtradebot.RPCManager', MagicMock())
|
||||||
|
|
||||||
freqtradebot = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
conf = deepcopy(default_conf)
|
||||||
|
conf['stake_amount'] = 15.0
|
||||||
|
freqtradebot = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
telegram = Telegram(freqtradebot)
|
telegram = Telegram(freqtradebot)
|
||||||
|
|
||||||
freqtradebot.update_state(State.STOPPED)
|
freqtradebot.update_state(State.STOPPED)
|
||||||
@ -358,7 +360,7 @@ def test_status_table_handle(default_conf, update, ticker, mocker) -> None:
|
|||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(15.0, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
|
|
||||||
telegram._status_table(bot=MagicMock(), update=update)
|
telegram._status_table(bot=MagicMock(), update=update)
|
||||||
|
|
||||||
@ -399,7 +401,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order,
|
|||||||
telegram = Telegram(freqtradebot)
|
telegram = Telegram(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
|
|
||||||
@ -426,8 +428,8 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order,
|
|||||||
# Reset msg_mock
|
# Reset msg_mock
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
# Add two other trades
|
# Add two other trades
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
|
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
@ -512,7 +514,7 @@ def test_profit_handle(default_conf, update, ticker, ticker_sell_up,
|
|||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
|
|
||||||
# Simulate fulfilled LIMIT_BUY order for trade
|
# Simulate fulfilled LIMIT_BUY order for trade
|
||||||
@ -764,7 +766,7 @@ def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker)
|
|||||||
telegram = Telegram(freqtradebot)
|
telegram = Telegram(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -803,7 +805,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, ticker_sell_down, m
|
|||||||
telegram = Telegram(freqtradebot)
|
telegram = Telegram(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
|
|
||||||
# Decrease the price and sell it
|
# Decrease the price and sell it
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
@ -847,7 +849,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, mocker) -> None:
|
|||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
for _ in range(4):
|
for _ in range(4):
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
rpc_mock.reset_mock()
|
rpc_mock.reset_mock()
|
||||||
|
|
||||||
update.message.text = '/forcesell all'
|
update.message.text = '/forcesell all'
|
||||||
@ -925,7 +927,7 @@ def test_performance_handle(default_conf, update, ticker, limit_buy_order,
|
|||||||
telegram = Telegram(freqtradebot)
|
telegram = Telegram(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
|
|
||||||
@ -995,7 +997,7 @@ def test_count_handle(default_conf, update, ticker, mocker) -> None:
|
|||||||
freqtradebot.update_state(State.RUNNING)
|
freqtradebot.update_state(State.RUNNING)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtradebot.create_trade()
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
telegram._count(bot=MagicMock(), update=update)
|
telegram._count(bot=MagicMock(), update=update)
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ def test_create_trade(default_conf, ticker, limit_buy_order, mocker) -> None:
|
|||||||
# Save state of current whitelist
|
# Save state of current whitelist
|
||||||
whitelist = deepcopy(default_conf['exchange']['pair_whitelist'])
|
whitelist = deepcopy(default_conf['exchange']['pair_whitelist'])
|
||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade is not None
|
assert trade is not None
|
||||||
@ -287,12 +287,14 @@ def test_create_trade_minimal_amount(default_conf, ticker, mocker) -> None:
|
|||||||
get_ticker=ticker,
|
get_ticker=ticker,
|
||||||
buy=buy_mock
|
buy=buy_mock
|
||||||
)
|
)
|
||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
|
||||||
|
|
||||||
min_stake_amount = 0.0005
|
conf = deepcopy(default_conf)
|
||||||
freqtrade.create_trade(min_stake_amount, int(default_conf['ticker_interval']))
|
conf['stake_amount'] = 0.0005
|
||||||
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
|
freqtrade.create_trade()
|
||||||
rate, amount = buy_mock.call_args[0][1], buy_mock.call_args[0][2]
|
rate, amount = buy_mock.call_args[0][1], buy_mock.call_args[0][2]
|
||||||
assert rate * amount >= min_stake_amount
|
assert rate * amount >= conf['stake_amount']
|
||||||
|
|
||||||
|
|
||||||
def test_create_trade_no_stake_amount(default_conf, ticker, mocker) -> None:
|
def test_create_trade_no_stake_amount(default_conf, ticker, mocker) -> None:
|
||||||
@ -312,7 +314,7 @@ def test_create_trade_no_stake_amount(default_conf, ticker, mocker) -> None:
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
with pytest.raises(DependencyException, match=r'.*stake amount.*'):
|
with pytest.raises(DependencyException, match=r'.*stake amount.*'):
|
||||||
freqtrade.create_trade(default_conf['stake_amount'], int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
|
|
||||||
def test_create_trade_no_pairs(default_conf, ticker, mocker) -> None:
|
def test_create_trade_no_pairs(default_conf, ticker, mocker) -> None:
|
||||||
@ -334,10 +336,10 @@ def test_create_trade_no_pairs(default_conf, ticker, mocker) -> None:
|
|||||||
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
|
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
|
with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
|
||||||
freqtrade.create_trade(default_conf['stake_amount'], int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
|
|
||||||
def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker) -> None:
|
def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker) -> None:
|
||||||
@ -359,10 +361,10 @@ def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker) ->
|
|||||||
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
|
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
|
with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
|
||||||
freqtrade.create_trade(conf['stake_amount'], int(conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
|
|
||||||
def test_create_trade_no_signal(default_conf, mocker) -> None:
|
def test_create_trade_no_signal(default_conf, mocker) -> None:
|
||||||
@ -381,12 +383,14 @@ def test_create_trade_no_signal(default_conf, mocker) -> None:
|
|||||||
get_ticker_history=MagicMock(return_value=20),
|
get_ticker_history=MagicMock(return_value=20),
|
||||||
get_balance=MagicMock(return_value=20)
|
get_balance=MagicMock(return_value=20)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
conf = deepcopy(default_conf)
|
||||||
|
conf['stake_amount'] = 10
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
stake_amount = 10
|
|
||||||
Trade.query = MagicMock()
|
Trade.query = MagicMock()
|
||||||
Trade.query.filter = MagicMock()
|
Trade.query.filter = MagicMock()
|
||||||
assert not freqtrade.create_trade(stake_amount, int(conf['ticker_interval']))
|
assert not freqtrade.create_trade()
|
||||||
|
|
||||||
|
|
||||||
def test_process_trade_creation(default_conf, ticker, limit_buy_order,
|
def test_process_trade_creation(default_conf, ticker, limit_buy_order,
|
||||||
@ -410,7 +414,7 @@ def test_process_trade_creation(default_conf, ticker, limit_buy_order,
|
|||||||
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
||||||
assert not trades
|
assert not trades
|
||||||
|
|
||||||
result = freqtrade._process(interval=int(default_conf['ticker_interval']))
|
result = freqtrade._process()
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|
||||||
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
||||||
@ -447,7 +451,7 @@ def test_process_exchange_failures(default_conf, ticker, health, mocker) -> None
|
|||||||
sleep_mock = mocker.patch('time.sleep', side_effect=lambda _: None)
|
sleep_mock = mocker.patch('time.sleep', side_effect=lambda _: None)
|
||||||
|
|
||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
result = freqtrade._process(interval=int(default_conf['ticker_interval']))
|
result = freqtrade._process()
|
||||||
assert result is False
|
assert result is False
|
||||||
assert sleep_mock.has_calls()
|
assert sleep_mock.has_calls()
|
||||||
|
|
||||||
@ -469,7 +473,7 @@ def test_process_operational_exception(default_conf, ticker, health, mocker) ->
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
assert freqtrade.get_state() == State.RUNNING
|
assert freqtrade.get_state() == State.RUNNING
|
||||||
|
|
||||||
result = freqtrade._process(interval=int(default_conf['ticker_interval']))
|
result = freqtrade._process()
|
||||||
assert result is False
|
assert result is False
|
||||||
assert freqtrade.get_state() == State.STOPPED
|
assert freqtrade.get_state() == State.STOPPED
|
||||||
assert 'OperationalException' in msg_mock.call_args_list[-1][0][0]
|
assert 'OperationalException' in msg_mock.call_args_list[-1][0][0]
|
||||||
@ -494,12 +498,12 @@ def test_process_trade_handling(default_conf, ticker, limit_buy_order, health, m
|
|||||||
|
|
||||||
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
||||||
assert not trades
|
assert not trades
|
||||||
result = freqtrade._process(interval=int(default_conf['ticker_interval']))
|
result = freqtrade._process()
|
||||||
assert result is True
|
assert result is True
|
||||||
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
||||||
assert len(trades) == 1
|
assert len(trades) == 1
|
||||||
|
|
||||||
result = freqtrade._process(interval=int(default_conf['ticker_interval']))
|
result = freqtrade._process()
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|
||||||
|
|
||||||
@ -537,10 +541,10 @@ def test_process_maybe_execute_buy(mocker, default_conf) -> None:
|
|||||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
|
||||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade', MagicMock(return_value=True))
|
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade', MagicMock(return_value=True))
|
||||||
assert freqtrade.process_maybe_execute_buy(int(default_conf['ticker_interval']))
|
assert freqtrade.process_maybe_execute_buy()
|
||||||
|
|
||||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade', MagicMock(return_value=False))
|
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade', MagicMock(return_value=False))
|
||||||
assert not freqtrade.process_maybe_execute_buy(int(default_conf['ticker_interval']))
|
assert not freqtrade.process_maybe_execute_buy()
|
||||||
|
|
||||||
|
|
||||||
def test_process_maybe_execute_buy_exception(mocker, default_conf, caplog) -> None:
|
def test_process_maybe_execute_buy_exception(mocker, default_conf, caplog) -> None:
|
||||||
@ -553,7 +557,7 @@ def test_process_maybe_execute_buy_exception(mocker, default_conf, caplog) -> No
|
|||||||
'freqtrade.freqtradebot.FreqtradeBot.create_trade',
|
'freqtrade.freqtradebot.FreqtradeBot.create_trade',
|
||||||
MagicMock(side_effect=DependencyException)
|
MagicMock(side_effect=DependencyException)
|
||||||
)
|
)
|
||||||
freqtrade.process_maybe_execute_buy(int(default_conf['ticker_interval']))
|
freqtrade.process_maybe_execute_buy()
|
||||||
log_has('Unable to create trade:', caplog.record_tuples)
|
log_has('Unable to create trade:', caplog.record_tuples)
|
||||||
|
|
||||||
|
|
||||||
@ -568,11 +572,11 @@ def test_process_maybe_execute_sell(mocker, default_conf) -> None:
|
|||||||
|
|
||||||
trade = MagicMock()
|
trade = MagicMock()
|
||||||
trade.open_order_id = '123'
|
trade.open_order_id = '123'
|
||||||
assert not freqtrade.process_maybe_execute_sell(trade, int(default_conf['ticker_interval']))
|
assert not freqtrade.process_maybe_execute_sell(trade)
|
||||||
trade.is_open = True
|
trade.is_open = True
|
||||||
trade.open_order_id = None
|
trade.open_order_id = None
|
||||||
# Assert we call handle_trade() if trade is feasible for execution
|
# Assert we call handle_trade() if trade is feasible for execution
|
||||||
assert freqtrade.process_maybe_execute_sell(trade, int(default_conf['ticker_interval']))
|
assert freqtrade.process_maybe_execute_sell(trade)
|
||||||
|
|
||||||
|
|
||||||
def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, mocker) -> None:
|
def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, mocker) -> None:
|
||||||
@ -597,7 +601,7 @@ def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, mocker) -
|
|||||||
|
|
||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -606,7 +610,7 @@ def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, mocker) -
|
|||||||
assert trade.is_open is True
|
assert trade.is_open is True
|
||||||
|
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, int(default_conf['ticker_interval'])) is True
|
assert freqtrade.handle_trade(trade) is True
|
||||||
assert trade.open_order_id == 'mocked_limit_sell'
|
assert trade.open_order_id == 'mocked_limit_sell'
|
||||||
|
|
||||||
# Simulate fulfilled LIMIT_SELL order for trade
|
# Simulate fulfilled LIMIT_SELL order for trade
|
||||||
@ -638,7 +642,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, mocker) -> None:
|
|||||||
|
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
# Buy and Sell triggering, so doing nothing ...
|
# Buy and Sell triggering, so doing nothing ...
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
@ -647,7 +651,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, mocker) -> None:
|
|||||||
|
|
||||||
# Buy is triggering, so buying ...
|
# Buy is triggering, so buying ...
|
||||||
patch_get_signal(mocker, value=(True, False))
|
patch_get_signal(mocker, value=(True, False))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
nb_trades = len(trades)
|
nb_trades = len(trades)
|
||||||
assert nb_trades == 1
|
assert nb_trades == 1
|
||||||
@ -655,7 +659,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, mocker) -> None:
|
|||||||
|
|
||||||
# Buy and Sell are not triggering, so doing nothing ...
|
# Buy and Sell are not triggering, so doing nothing ...
|
||||||
patch_get_signal(mocker, value=(False, False))
|
patch_get_signal(mocker, value=(False, False))
|
||||||
assert freqtrade.handle_trade(trades[0], int(default_conf['ticker_interval'])) is False
|
assert freqtrade.handle_trade(trades[0]) is False
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
nb_trades = len(trades)
|
nb_trades = len(trades)
|
||||||
assert nb_trades == 1
|
assert nb_trades == 1
|
||||||
@ -663,7 +667,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, mocker) -> None:
|
|||||||
|
|
||||||
# Buy and Sell are triggering, so doing nothing ...
|
# Buy and Sell are triggering, so doing nothing ...
|
||||||
patch_get_signal(mocker, value=(True, True))
|
patch_get_signal(mocker, value=(True, True))
|
||||||
assert freqtrade.handle_trade(trades[0], int(default_conf['ticker_interval'])) is False
|
assert freqtrade.handle_trade(trades[0]) is False
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
nb_trades = len(trades)
|
nb_trades = len(trades)
|
||||||
assert nb_trades == 1
|
assert nb_trades == 1
|
||||||
@ -672,7 +676,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, mocker) -> None:
|
|||||||
# Sell is triggering, guess what : we are Selling!
|
# Sell is triggering, guess what : we are Selling!
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
assert freqtrade.handle_trade(trades[0], int(default_conf['ticker_interval'])) is True
|
assert freqtrade.handle_trade(trades[0]) is True
|
||||||
|
|
||||||
|
|
||||||
def test_handle_trade_roi(default_conf, ticker, mocker, caplog) -> None:
|
def test_handle_trade_roi(default_conf, ticker, mocker, caplog) -> None:
|
||||||
@ -695,7 +699,7 @@ def test_handle_trade_roi(default_conf, ticker, mocker, caplog) -> None:
|
|||||||
|
|
||||||
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=True)
|
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=True)
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.is_open = True
|
trade.is_open = True
|
||||||
@ -706,7 +710,7 @@ def test_handle_trade_roi(default_conf, ticker, mocker, caplog) -> None:
|
|||||||
# executing
|
# executing
|
||||||
# if ROI is reached we must sell
|
# if ROI is reached we must sell
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, interval=int(default_conf['ticker_interval']))
|
assert freqtrade.handle_trade(trade)
|
||||||
assert log_has('Required profit reached. Selling..', caplog.record_tuples)
|
assert log_has('Required profit reached. Selling..', caplog.record_tuples)
|
||||||
|
|
||||||
|
|
||||||
@ -730,16 +734,16 @@ def test_handle_trade_experimental(default_conf, ticker, mocker, caplog) -> None
|
|||||||
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
|
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
|
||||||
|
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.is_open = True
|
trade.is_open = True
|
||||||
|
|
||||||
patch_get_signal(mocker, value=(False, False))
|
patch_get_signal(mocker, value=(False, False))
|
||||||
assert not freqtrade.handle_trade(trade, int(default_conf['ticker_interval']))
|
assert not freqtrade.handle_trade(trade)
|
||||||
|
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, int(default_conf['ticker_interval']))
|
assert freqtrade.handle_trade(trade)
|
||||||
assert log_has('Sell signal received. Selling..', caplog.record_tuples)
|
assert log_has('Sell signal received. Selling..', caplog.record_tuples)
|
||||||
|
|
||||||
|
|
||||||
@ -759,7 +763,7 @@ def test_close_trade(default_conf, ticker, limit_buy_order, limit_sell_order, mo
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
# Create trade and sell it
|
# Create trade and sell it
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -769,7 +773,7 @@ def test_close_trade(default_conf, ticker, limit_buy_order, limit_sell_order, mo
|
|||||||
assert trade.is_open is False
|
assert trade.is_open is False
|
||||||
|
|
||||||
with pytest.raises(ValueError, match=r'.*closed trade.*'):
|
with pytest.raises(ValueError, match=r'.*closed trade.*'):
|
||||||
freqtrade.handle_trade(trade, int(default_conf['ticker_interval']))
|
freqtrade.handle_trade(trade)
|
||||||
|
|
||||||
|
|
||||||
def test_check_handle_timedout_buy(default_conf, ticker, limit_buy_order_old, mocker) -> None:
|
def test_check_handle_timedout_buy(default_conf, ticker, limit_buy_order_old, mocker) -> None:
|
||||||
@ -1004,7 +1008,7 @@ def test_execute_sell_up(default_conf, ticker, ticker_sell_up, mocker) -> None:
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -1044,7 +1048,7 @@ def test_execute_sell_down(default_conf, ticker, ticker_sell_down, mocker) -> No
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -1082,7 +1086,7 @@ def test_execute_sell_without_conf_sell_up(default_conf, ticker, ticker_sell_up,
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -1122,7 +1126,7 @@ def test_execute_sell_without_conf_sell_down(default_conf, ticker,
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
assert trade
|
assert trade
|
||||||
@ -1168,12 +1172,12 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order, mocker) -
|
|||||||
'sell_profit_only': True,
|
'sell_profit_only': True,
|
||||||
}
|
}
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, int(default_conf['ticker_interval'])) is True
|
assert freqtrade.handle_trade(trade) is True
|
||||||
|
|
||||||
|
|
||||||
def test_sell_profit_only_disable_profit(default_conf, limit_buy_order, mocker) -> None:
|
def test_sell_profit_only_disable_profit(default_conf, limit_buy_order, mocker) -> None:
|
||||||
@ -1200,12 +1204,12 @@ def test_sell_profit_only_disable_profit(default_conf, limit_buy_order, mocker)
|
|||||||
'sell_profit_only': False,
|
'sell_profit_only': False,
|
||||||
}
|
}
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, int(default_conf['ticker_interval'])) is True
|
assert freqtrade.handle_trade(trade) is True
|
||||||
|
|
||||||
|
|
||||||
def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, mocker) -> None:
|
def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, mocker) -> None:
|
||||||
@ -1232,12 +1236,12 @@ def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, mocker) ->
|
|||||||
'sell_profit_only': True,
|
'sell_profit_only': True,
|
||||||
}
|
}
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, int(default_conf['ticker_interval'])) is False
|
assert freqtrade.handle_trade(trade) is False
|
||||||
|
|
||||||
|
|
||||||
def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, mocker) -> None:
|
def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, mocker) -> None:
|
||||||
@ -1266,9 +1270,9 @@ def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, mocker) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||||
freqtrade.create_trade(0.001, int(default_conf['ticker_interval']))
|
freqtrade.create_trade()
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
patch_get_signal(mocker, value=(False, True))
|
patch_get_signal(mocker, value=(False, True))
|
||||||
assert freqtrade.handle_trade(trade, int(default_conf['ticker_interval'])) is True
|
assert freqtrade.handle_trade(trade) is True
|
||||||
|
Loading…
Reference in New Issue
Block a user