fix some testcase
This commit is contained in:
parent
d31d38a85f
commit
ed30c023cd
@ -197,6 +197,7 @@ class Backtesting:
|
|||||||
if not pair_data.empty:
|
if not pair_data.empty:
|
||||||
pair_data.loc[:, 'buy'] = 0 # cleanup if buy_signal is exist
|
pair_data.loc[:, 'buy'] = 0 # cleanup if buy_signal is exist
|
||||||
pair_data.loc[:, 'sell'] = 0 # cleanup if sell_signal is exist
|
pair_data.loc[:, 'sell'] = 0 # cleanup if sell_signal is exist
|
||||||
|
pair_data.loc[:, 'buy_signal_name'] = '' # cleanup if buy_signal_name is exist
|
||||||
|
|
||||||
df_analyzed = self.strategy.advise_sell(
|
df_analyzed = self.strategy.advise_sell(
|
||||||
self.strategy.advise_buy(pair_data, {'pair': pair}), {'pair': pair})[headers].copy()
|
self.strategy.advise_buy(pair_data, {'pair': pair}), {'pair': pair})[headers].copy()
|
||||||
@ -205,6 +206,7 @@ class Backtesting:
|
|||||||
# from the previous candle
|
# from the previous candle
|
||||||
df_analyzed.loc[:, 'buy'] = df_analyzed.loc[:, 'buy'].shift(1)
|
df_analyzed.loc[:, 'buy'] = df_analyzed.loc[:, 'buy'].shift(1)
|
||||||
df_analyzed.loc[:, 'sell'] = df_analyzed.loc[:, 'sell'].shift(1)
|
df_analyzed.loc[:, 'sell'] = df_analyzed.loc[:, 'sell'].shift(1)
|
||||||
|
df_analyzed.loc[:, 'buy_signal_name'] = df_analyzed.loc[:, 'buy_signal_name'].shift(1)
|
||||||
|
|
||||||
df_analyzed.drop(df_analyzed.head(1).index, inplace=True)
|
df_analyzed.drop(df_analyzed.head(1).index, inplace=True)
|
||||||
|
|
||||||
|
@ -404,6 +404,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
logger.debug("Skipping TA Analysis for already analyzed candle")
|
logger.debug("Skipping TA Analysis for already analyzed candle")
|
||||||
dataframe['buy'] = 0
|
dataframe['buy'] = 0
|
||||||
dataframe['sell'] = 0
|
dataframe['sell'] = 0
|
||||||
|
dataframe['buy_signal_name'] = ''
|
||||||
|
|
||||||
# Other Defs in strategy that want to be called every loop here
|
# Other Defs in strategy that want to be called every loop here
|
||||||
# twitter_sell = self.watch_twitter_feed(dataframe, metadata)
|
# twitter_sell = self.watch_twitter_feed(dataframe, metadata)
|
||||||
|
@ -482,6 +482,7 @@ def test_backtest__enter_trade(default_conf, fee, mocker) -> None:
|
|||||||
0, # Sell
|
0, # Sell
|
||||||
0.00099, # Low
|
0.00099, # Low
|
||||||
0.0012, # High
|
0.0012, # High
|
||||||
|
'', # Buy Signal Name
|
||||||
]
|
]
|
||||||
trade = backtesting._enter_trade(pair, row=row)
|
trade = backtesting._enter_trade(pair, row=row)
|
||||||
assert isinstance(trade, LocalTrade)
|
assert isinstance(trade, LocalTrade)
|
||||||
|
@ -769,20 +769,20 @@ def test_spreadfilter_invalid_data(mocker, default_conf, markets, tickers, caplo
|
|||||||
get_tickers=tickers
|
get_tickers=tickers
|
||||||
)
|
)
|
||||||
|
|
||||||
ftbot = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
ftbot.pairlists.refresh_pairlist()
|
freqtrade.pairlists.refresh_pairlist()
|
||||||
|
|
||||||
assert len(ftbot.pairlists.whitelist) == 5
|
assert len(freqtrade.pairlists.whitelist) == 5
|
||||||
|
|
||||||
tickers.return_value['ETH/BTC']['ask'] = 0.0
|
tickers.return_value['ETH/BTC']['ask'] = 0.0
|
||||||
del tickers.return_value['TKN/BTC']
|
del tickers.return_value['TKN/BTC']
|
||||||
del tickers.return_value['LTC/BTC']
|
del tickers.return_value['LTC/BTC']
|
||||||
mocker.patch.multiple('freqtrade.exchange.Exchange', get_tickers=tickers)
|
mocker.patch.multiple('freqtrade.exchange.Exchange', get_tickers=tickers)
|
||||||
|
|
||||||
ftbot.pairlists.refresh_pairlist()
|
freqtrade.pairlists.refresh_pairlist()
|
||||||
assert log_has_re(r'Removed .* invalid ticker data.*', caplog)
|
assert log_has_re(r'Removed .* invalid ticker data.*', caplog)
|
||||||
|
|
||||||
assert len(ftbot.pairlists.whitelist) == 2
|
assert len(freqtrade.pairlists.whitelist) == 2
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("pairlistconfig,desc_expected,exception_expected", [
|
@pytest.mark.parametrize("pairlistconfig,desc_expected,exception_expected", [
|
||||||
|
@ -35,7 +35,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
freqtradebot.state = State.RUNNING
|
freqtradebot.state = State.RUNNING
|
||||||
@ -69,6 +69,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'min_rate': ANY,
|
'min_rate': ANY,
|
||||||
'max_rate': ANY,
|
'max_rate': ANY,
|
||||||
'strategy': ANY,
|
'strategy': ANY,
|
||||||
|
'buy_signal_name': ANY,
|
||||||
'timeframe': 5,
|
'timeframe': 5,
|
||||||
'open_order_id': ANY,
|
'open_order_id': ANY,
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
@ -135,6 +136,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'min_rate': ANY,
|
'min_rate': ANY,
|
||||||
'max_rate': ANY,
|
'max_rate': ANY,
|
||||||
'strategy': ANY,
|
'strategy': ANY,
|
||||||
|
'buy_signal_name': ANY,
|
||||||
'timeframe': ANY,
|
'timeframe': ANY,
|
||||||
'open_order_id': ANY,
|
'open_order_id': ANY,
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
@ -190,7 +192,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
|||||||
)
|
)
|
||||||
del default_conf['fiat_display_currency']
|
del default_conf['fiat_display_currency']
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
freqtradebot.state = State.RUNNING
|
freqtradebot.state = State.RUNNING
|
||||||
@ -237,7 +239,7 @@ def test_rpc_daily_profit(default_conf, update, ticker, fee,
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
stake_currency = default_conf['stake_currency']
|
stake_currency = default_conf['stake_currency']
|
||||||
fiat_display_currency = default_conf['fiat_display_currency']
|
fiat_display_currency = default_conf['fiat_display_currency']
|
||||||
|
|
||||||
@ -369,7 +371,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
stake_currency = default_conf['stake_currency']
|
stake_currency = default_conf['stake_currency']
|
||||||
fiat_display_currency = default_conf['fiat_display_currency']
|
fiat_display_currency = default_conf['fiat_display_currency']
|
||||||
|
|
||||||
@ -457,7 +459,7 @@ def test_rpc_trade_statistics_closed(mocker, default_conf, ticker, fee,
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
stake_currency = default_conf['stake_currency']
|
stake_currency = default_conf['stake_currency']
|
||||||
fiat_display_currency = default_conf['fiat_display_currency']
|
fiat_display_currency = default_conf['fiat_display_currency']
|
||||||
|
|
||||||
@ -524,7 +526,7 @@ def test_rpc_balance_handle_error(default_conf, mocker):
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
rpc._fiat_converter = CryptoToFiatConverter()
|
rpc._fiat_converter = CryptoToFiatConverter()
|
||||||
with pytest.raises(RPCException, match="Error getting current tickers."):
|
with pytest.raises(RPCException, match="Error getting current tickers."):
|
||||||
@ -565,7 +567,7 @@ def test_rpc_balance_handle(default_conf, mocker, tickers):
|
|||||||
)
|
)
|
||||||
default_conf['dry_run'] = False
|
default_conf['dry_run'] = False
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
rpc._fiat_converter = CryptoToFiatConverter()
|
rpc._fiat_converter = CryptoToFiatConverter()
|
||||||
|
|
||||||
@ -610,7 +612,7 @@ def test_rpc_start(mocker, default_conf) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
freqtradebot.state = State.STOPPED
|
freqtradebot.state = State.STOPPED
|
||||||
|
|
||||||
@ -631,7 +633,7 @@ def test_rpc_stop(mocker, default_conf) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
freqtradebot.state = State.RUNNING
|
freqtradebot.state = State.RUNNING
|
||||||
|
|
||||||
@ -653,7 +655,7 @@ def test_rpc_stopbuy(mocker, default_conf) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
freqtradebot.state = State.RUNNING
|
freqtradebot.state = State.RUNNING
|
||||||
|
|
||||||
@ -685,7 +687,7 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
|||||||
mocker.patch('freqtrade.wallets.Wallets.get_free', return_value=1000)
|
mocker.patch('freqtrade.wallets.Wallets.get_free', return_value=1000)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
freqtradebot.state = State.STOPPED
|
freqtradebot.state = State.STOPPED
|
||||||
@ -803,7 +805,7 @@ def test_performance_handle(default_conf, ticker, limit_buy_order, fee,
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
@ -836,7 +838,7 @@ def test_rpc_count(mocker, default_conf, ticker, fee) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
|
|
||||||
counts = rpc._rpc_count()
|
counts = rpc._rpc_count()
|
||||||
@ -861,7 +863,7 @@ def test_rpcforcebuy(mocker, default_conf, ticker, fee, limit_buy_order_open) ->
|
|||||||
)
|
)
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
pair = 'ETH/BTC'
|
pair = 'ETH/BTC'
|
||||||
trade = rpc._rpc_forcebuy(pair, None)
|
trade = rpc._rpc_forcebuy(pair, None)
|
||||||
@ -887,7 +889,7 @@ def test_rpcforcebuy(mocker, default_conf, ticker, fee, limit_buy_order_open) ->
|
|||||||
# Test not buying
|
# Test not buying
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
freqtradebot.config['stake_amount'] = 0.0000001
|
freqtradebot.config['stake_amount'] = 0.0000001
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
pair = 'TKN/BTC'
|
pair = 'TKN/BTC'
|
||||||
trade = rpc._rpc_forcebuy(pair, None)
|
trade = rpc._rpc_forcebuy(pair, None)
|
||||||
@ -900,7 +902,7 @@ def test_rpcforcebuy_stopped(mocker, default_conf) -> None:
|
|||||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
pair = 'ETH/BTC'
|
pair = 'ETH/BTC'
|
||||||
with pytest.raises(RPCException, match=r'trader is not running'):
|
with pytest.raises(RPCException, match=r'trader is not running'):
|
||||||
@ -911,7 +913,7 @@ def test_rpcforcebuy_disabled(mocker, default_conf) -> None:
|
|||||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
pair = 'ETH/BTC'
|
pair = 'ETH/BTC'
|
||||||
with pytest.raises(RPCException, match=r'Forcebuy not enabled.'):
|
with pytest.raises(RPCException, match=r'Forcebuy not enabled.'):
|
||||||
|
@ -45,11 +45,11 @@ def botclient(default_conf, mocker):
|
|||||||
"password": _TEST_PASS,
|
"password": _TEST_PASS,
|
||||||
}})
|
}})
|
||||||
|
|
||||||
ftbot = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
rpc = RPC(ftbot)
|
rpc = RPC(freqtrade)
|
||||||
mocker.patch('freqtrade.rpc.api_server.ApiServer.start_api', MagicMock())
|
mocker.patch('freqtrade.rpc.api_server.ApiServer.start_api', MagicMock())
|
||||||
apiserver = ApiServer(rpc, default_conf)
|
apiserver = ApiServer(rpc, default_conf)
|
||||||
yield ftbot, TestClient(apiserver.app)
|
yield freqtrade, TestClient(apiserver.app)
|
||||||
# Cleanup ... ?
|
# Cleanup ... ?
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ def assert_response(response, expected_code=200, needs_cors=True):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_not_found(botclient):
|
def test_api_not_found(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/invalid_url")
|
rc = client_get(client, f"{BASE_URI}/invalid_url")
|
||||||
assert_response(rc, 404)
|
assert_response(rc, 404)
|
||||||
@ -91,7 +91,7 @@ def test_api_not_found(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_ui_fallback(botclient):
|
def test_api_ui_fallback(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, "/favicon.ico")
|
rc = client_get(client, "/favicon.ico")
|
||||||
assert rc.status_code == 200
|
assert rc.status_code == 200
|
||||||
@ -126,7 +126,7 @@ def test_api_auth():
|
|||||||
|
|
||||||
|
|
||||||
def test_api_unauthorized(botclient):
|
def test_api_unauthorized(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
rc = client.get(f"{BASE_URI}/ping")
|
rc = client.get(f"{BASE_URI}/ping")
|
||||||
assert_response(rc, needs_cors=False)
|
assert_response(rc, needs_cors=False)
|
||||||
assert rc.json() == {'status': 'pong'}
|
assert rc.json() == {'status': 'pong'}
|
||||||
@ -137,20 +137,20 @@ def test_api_unauthorized(botclient):
|
|||||||
assert rc.json() == {'detail': 'Unauthorized'}
|
assert rc.json() == {'detail': 'Unauthorized'}
|
||||||
|
|
||||||
# Change only username
|
# Change only username
|
||||||
ftbot.config['api_server']['username'] = 'Ftrader'
|
freqtrade.config['api_server']['username'] = 'Ftrader'
|
||||||
rc = client_get(client, f"{BASE_URI}/version")
|
rc = client_get(client, f"{BASE_URI}/version")
|
||||||
assert_response(rc, 401)
|
assert_response(rc, 401)
|
||||||
assert rc.json() == {'detail': 'Unauthorized'}
|
assert rc.json() == {'detail': 'Unauthorized'}
|
||||||
|
|
||||||
# Change only password
|
# Change only password
|
||||||
ftbot.config['api_server']['username'] = _TEST_USER
|
freqtrade.config['api_server']['username'] = _TEST_USER
|
||||||
ftbot.config['api_server']['password'] = 'WrongPassword'
|
freqtrade.config['api_server']['password'] = 'WrongPassword'
|
||||||
rc = client_get(client, f"{BASE_URI}/version")
|
rc = client_get(client, f"{BASE_URI}/version")
|
||||||
assert_response(rc, 401)
|
assert_response(rc, 401)
|
||||||
assert rc.json() == {'detail': 'Unauthorized'}
|
assert rc.json() == {'detail': 'Unauthorized'}
|
||||||
|
|
||||||
ftbot.config['api_server']['username'] = 'Ftrader'
|
freqtrade.config['api_server']['username'] = 'Ftrader'
|
||||||
ftbot.config['api_server']['password'] = 'WrongPassword'
|
freqtrade.config['api_server']['password'] = 'WrongPassword'
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/version")
|
rc = client_get(client, f"{BASE_URI}/version")
|
||||||
assert_response(rc, 401)
|
assert_response(rc, 401)
|
||||||
@ -158,7 +158,7 @@ def test_api_unauthorized(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_token_login(botclient):
|
def test_api_token_login(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
rc = client.post(f"{BASE_URI}/token/login",
|
rc = client.post(f"{BASE_URI}/token/login",
|
||||||
data=None,
|
data=None,
|
||||||
headers={'Authorization': _basic_auth_str('WRONG_USER', 'WRONG_PASS'),
|
headers={'Authorization': _basic_auth_str('WRONG_USER', 'WRONG_PASS'),
|
||||||
@ -177,7 +177,7 @@ def test_api_token_login(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_token_refresh(botclient):
|
def test_api_token_refresh(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
rc = client_post(client, f"{BASE_URI}/token/login")
|
rc = client_post(client, f"{BASE_URI}/token/login")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
rc = client.post(f"{BASE_URI}/token/refresh",
|
rc = client.post(f"{BASE_URI}/token/refresh",
|
||||||
@ -190,12 +190,12 @@ def test_api_token_refresh(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_stop_workflow(botclient):
|
def test_api_stop_workflow(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
assert ftbot.state == State.RUNNING
|
assert freqtrade.state == State.RUNNING
|
||||||
rc = client_post(client, f"{BASE_URI}/stop")
|
rc = client_post(client, f"{BASE_URI}/stop")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json() == {'status': 'stopping trader ...'}
|
assert rc.json() == {'status': 'stopping trader ...'}
|
||||||
assert ftbot.state == State.STOPPED
|
assert freqtrade.state == State.STOPPED
|
||||||
|
|
||||||
# Stop bot again
|
# Stop bot again
|
||||||
rc = client_post(client, f"{BASE_URI}/stop")
|
rc = client_post(client, f"{BASE_URI}/stop")
|
||||||
@ -206,7 +206,7 @@ def test_api_stop_workflow(botclient):
|
|||||||
rc = client_post(client, f"{BASE_URI}/start")
|
rc = client_post(client, f"{BASE_URI}/start")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json() == {'status': 'starting trader ...'}
|
assert rc.json() == {'status': 'starting trader ...'}
|
||||||
assert ftbot.state == State.RUNNING
|
assert freqtrade.state == State.RUNNING
|
||||||
|
|
||||||
# Call start again
|
# Call start again
|
||||||
rc = client_post(client, f"{BASE_URI}/start")
|
rc = client_post(client, f"{BASE_URI}/start")
|
||||||
@ -358,32 +358,32 @@ def test_api_cleanup(default_conf, mocker, caplog):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_reloadconf(botclient):
|
def test_api_reloadconf(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_post(client, f"{BASE_URI}/reload_config")
|
rc = client_post(client, f"{BASE_URI}/reload_config")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json() == {'status': 'Reloading config ...'}
|
assert rc.json() == {'status': 'Reloading config ...'}
|
||||||
assert ftbot.state == State.RELOAD_CONFIG
|
assert freqtrade.state == State.RELOAD_CONFIG
|
||||||
|
|
||||||
|
|
||||||
def test_api_stopbuy(botclient):
|
def test_api_stopbuy(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
assert ftbot.config['max_open_trades'] != 0
|
assert freqtrade.config['max_open_trades'] != 0
|
||||||
|
|
||||||
rc = client_post(client, f"{BASE_URI}/stopbuy")
|
rc = client_post(client, f"{BASE_URI}/stopbuy")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json() == {'status': 'No more buy will occur from now. Run /reload_config to reset.'}
|
assert rc.json() == {'status': 'No more buy will occur from now. Run /reload_config to reset.'}
|
||||||
assert ftbot.config['max_open_trades'] == 0
|
assert freqtrade.config['max_open_trades'] == 0
|
||||||
|
|
||||||
|
|
||||||
def test_api_balance(botclient, mocker, rpc_balance):
|
def test_api_balance(botclient, mocker, rpc_balance):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
ftbot.config['dry_run'] = False
|
freqtrade.config['dry_run'] = False
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value=rpc_balance)
|
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value=rpc_balance)
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_valid_pair_combination',
|
mocker.patch('freqtrade.exchange.Exchange.get_valid_pair_combination',
|
||||||
side_effect=lambda a, b: f"{a}/{b}")
|
side_effect=lambda a, b: f"{a}/{b}")
|
||||||
ftbot.wallets.update()
|
freqtrade.wallets.update()
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/balance")
|
rc = client_get(client, f"{BASE_URI}/balance")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
@ -400,8 +400,8 @@ def test_api_balance(botclient, mocker, rpc_balance):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_count(botclient, mocker, ticker, fee, markets):
|
def test_api_count(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -422,13 +422,13 @@ def test_api_count(botclient, mocker, ticker, fee, markets):
|
|||||||
assert rc.json()["current"] == 4
|
assert rc.json()["current"] == 4
|
||||||
assert rc.json()["max"] == 1
|
assert rc.json()["max"] == 1
|
||||||
|
|
||||||
ftbot.config['max_open_trades'] = float('inf')
|
freqtrade.config['max_open_trades'] = float('inf')
|
||||||
rc = client_get(client, f"{BASE_URI}/count")
|
rc = client_get(client, f"{BASE_URI}/count")
|
||||||
assert rc.json()["max"] == -1
|
assert rc.json()["max"] == -1
|
||||||
|
|
||||||
|
|
||||||
def test_api_locks(botclient):
|
def test_api_locks(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/locks")
|
rc = client_get(client, f"{BASE_URI}/locks")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
@ -462,8 +462,8 @@ def test_api_locks(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_show_config(botclient, mocker):
|
def test_api_show_config(botclient, mocker):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/show_config")
|
rc = client_get(client, f"{BASE_URI}/show_config")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
@ -480,8 +480,8 @@ def test_api_show_config(botclient, mocker):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_daily(botclient, mocker, ticker, fee, markets):
|
def test_api_daily(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -498,8 +498,8 @@ def test_api_daily(botclient, mocker, ticker, fee, markets):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_trades(botclient, mocker, fee, markets):
|
def test_api_trades(botclient, mocker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
markets=PropertyMock(return_value=markets)
|
markets=PropertyMock(return_value=markets)
|
||||||
@ -526,8 +526,8 @@ def test_api_trades(botclient, mocker, fee, markets):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_trade_single(botclient, mocker, fee, ticker, markets):
|
def test_api_trade_single(botclient, mocker, fee, ticker, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
markets=PropertyMock(return_value=markets),
|
markets=PropertyMock(return_value=markets),
|
||||||
@ -546,8 +546,8 @@ def test_api_trade_single(botclient, mocker, fee, ticker, markets):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_delete_trade(botclient, mocker, fee, markets):
|
def test_api_delete_trade(botclient, mocker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
stoploss_mock = MagicMock()
|
stoploss_mock = MagicMock()
|
||||||
cancel_mock = MagicMock()
|
cancel_mock = MagicMock()
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
@ -562,7 +562,7 @@ def test_api_delete_trade(botclient, mocker, fee, markets):
|
|||||||
|
|
||||||
create_mock_trades(fee)
|
create_mock_trades(fee)
|
||||||
Trade.query.session.flush()
|
Trade.query.session.flush()
|
||||||
ftbot.strategy.order_types['stoploss_on_exchange'] = True
|
freqtrade.strategy.order_types['stoploss_on_exchange'] = True
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
trades[1].stoploss_order_id = '1234'
|
trades[1].stoploss_order_id = '1234'
|
||||||
assert len(trades) > 2
|
assert len(trades) > 2
|
||||||
@ -588,7 +588,7 @@ def test_api_delete_trade(botclient, mocker, fee, markets):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_logs(botclient):
|
def test_api_logs(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
rc = client_get(client, f"{BASE_URI}/logs")
|
rc = client_get(client, f"{BASE_URI}/logs")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert len(rc.json()) == 2
|
assert len(rc.json()) == 2
|
||||||
@ -620,8 +620,8 @@ def test_api_logs(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -636,8 +636,8 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
def test_api_profit(botclient, mocker, ticker, fee, markets):
|
def test_api_profit(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -683,8 +683,8 @@ def test_api_profit(botclient, mocker, ticker, fee, markets):
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
def test_api_stats(botclient, mocker, ticker, fee, markets,):
|
def test_api_stats(botclient, mocker, ticker, fee, markets,):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -711,8 +711,8 @@ def test_api_stats(botclient, mocker, ticker, fee, markets,):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_performance(botclient, fee):
|
def test_api_performance(botclient, fee):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
|
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='LTC/ETH',
|
pair='LTC/ETH',
|
||||||
@ -757,8 +757,8 @@ def test_api_performance(botclient, fee):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_status(botclient, mocker, ticker, fee, markets):
|
def test_api_status(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -845,7 +845,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_version(botclient):
|
def test_api_version(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/version")
|
rc = client_get(client, f"{BASE_URI}/version")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
@ -853,7 +853,7 @@ def test_api_version(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_blacklist(botclient, mocker):
|
def test_api_blacklist(botclient, mocker):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/blacklist")
|
rc = client_get(client, f"{BASE_URI}/blacklist")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
@ -888,7 +888,7 @@ def test_api_blacklist(botclient, mocker):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_whitelist(botclient):
|
def test_api_whitelist(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/whitelist")
|
rc = client_get(client, f"{BASE_URI}/whitelist")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
@ -900,7 +900,7 @@ def test_api_whitelist(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_forcebuy(botclient, mocker, fee):
|
def test_api_forcebuy(botclient, mocker, fee):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_post(client, f"{BASE_URI}/forcebuy",
|
rc = client_post(client, f"{BASE_URI}/forcebuy",
|
||||||
data='{"pair": "ETH/BTC"}')
|
data='{"pair": "ETH/BTC"}')
|
||||||
@ -908,7 +908,7 @@ def test_api_forcebuy(botclient, mocker, fee):
|
|||||||
assert rc.json() == {"error": "Error querying /api/v1/forcebuy: Forcebuy not enabled."}
|
assert rc.json() == {"error": "Error querying /api/v1/forcebuy: Forcebuy not enabled."}
|
||||||
|
|
||||||
# enable forcebuy
|
# enable forcebuy
|
||||||
ftbot.config['forcebuy_enable'] = True
|
freqtrade.config['forcebuy_enable'] = True
|
||||||
|
|
||||||
fbuy_mock = MagicMock(return_value=None)
|
fbuy_mock = MagicMock(return_value=None)
|
||||||
mocker.patch("freqtrade.rpc.RPC._rpc_forcebuy", fbuy_mock)
|
mocker.patch("freqtrade.rpc.RPC._rpc_forcebuy", fbuy_mock)
|
||||||
@ -990,7 +990,7 @@ def test_api_forcebuy(botclient, mocker, fee):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_forcesell(botclient, mocker, ticker, fee, markets):
|
def test_api_forcesell(botclient, mocker, ticker, fee, markets):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balances=MagicMock(return_value=ticker),
|
get_balances=MagicMock(return_value=ticker),
|
||||||
@ -999,14 +999,14 @@ def test_api_forcesell(botclient, mocker, ticker, fee, markets):
|
|||||||
markets=PropertyMock(return_value=markets),
|
markets=PropertyMock(return_value=markets),
|
||||||
_is_dry_limit_order_filled=MagicMock(return_value=False),
|
_is_dry_limit_order_filled=MagicMock(return_value=False),
|
||||||
)
|
)
|
||||||
patch_get_signal(ftbot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
|
|
||||||
rc = client_post(client, f"{BASE_URI}/forcesell",
|
rc = client_post(client, f"{BASE_URI}/forcesell",
|
||||||
data='{"tradeid": "1"}')
|
data='{"tradeid": "1"}')
|
||||||
assert_response(rc, 502)
|
assert_response(rc, 502)
|
||||||
assert rc.json() == {"error": "Error querying /api/v1/forcesell: invalid argument"}
|
assert rc.json() == {"error": "Error querying /api/v1/forcesell: invalid argument"}
|
||||||
|
|
||||||
ftbot.enter_positions()
|
freqtrade.enter_positions()
|
||||||
|
|
||||||
rc = client_post(client, f"{BASE_URI}/forcesell",
|
rc = client_post(client, f"{BASE_URI}/forcesell",
|
||||||
data='{"tradeid": "1"}')
|
data='{"tradeid": "1"}')
|
||||||
@ -1015,7 +1015,7 @@ def test_api_forcesell(botclient, mocker, ticker, fee, markets):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_pair_candles(botclient, ohlcv_history):
|
def test_api_pair_candles(botclient, ohlcv_history):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
timeframe = '5m'
|
timeframe = '5m'
|
||||||
amount = 3
|
amount = 3
|
||||||
|
|
||||||
@ -1043,7 +1043,7 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
|||||||
ohlcv_history.loc[1, 'buy'] = 1
|
ohlcv_history.loc[1, 'buy'] = 1
|
||||||
ohlcv_history['sell'] = 0
|
ohlcv_history['sell'] = 0
|
||||||
|
|
||||||
ftbot.dataprovider._set_cached_df("XRP/BTC", timeframe, ohlcv_history)
|
freqtrade.dataprovider._set_cached_df("XRP/BTC", timeframe, ohlcv_history)
|
||||||
|
|
||||||
rc = client_get(client,
|
rc = client_get(client,
|
||||||
f"{BASE_URI}/pair_candles?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}")
|
f"{BASE_URI}/pair_candles?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}")
|
||||||
@ -1081,7 +1081,7 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_pair_history(botclient, ohlcv_history):
|
def test_api_pair_history(botclient, ohlcv_history):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
timeframe = '5m'
|
timeframe = '5m'
|
||||||
|
|
||||||
# No pair
|
# No pair
|
||||||
@ -1134,21 +1134,21 @@ def test_api_pair_history(botclient, ohlcv_history):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_plot_config(botclient):
|
def test_api_plot_config(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/plot_config")
|
rc = client_get(client, f"{BASE_URI}/plot_config")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json() == {}
|
assert rc.json() == {}
|
||||||
|
|
||||||
ftbot.strategy.plot_config = {'main_plot': {'sma': {}},
|
freqtrade.strategy.plot_config = {'main_plot': {'sma': {}},
|
||||||
'subplots': {'RSI': {'rsi': {'color': 'red'}}}}
|
'subplots': {'RSI': {'rsi': {'color': 'red'}}}}
|
||||||
rc = client_get(client, f"{BASE_URI}/plot_config")
|
rc = client_get(client, f"{BASE_URI}/plot_config")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json() == ftbot.strategy.plot_config
|
assert rc.json() == freqtrade.strategy.plot_config
|
||||||
assert isinstance(rc.json()['main_plot'], dict)
|
assert isinstance(rc.json()['main_plot'], dict)
|
||||||
assert isinstance(rc.json()['subplots'], dict)
|
assert isinstance(rc.json()['subplots'], dict)
|
||||||
|
|
||||||
ftbot.strategy.plot_config = {'main_plot': {'sma': {}}}
|
freqtrade.strategy.plot_config = {'main_plot': {'sma': {}}}
|
||||||
rc = client_get(client, f"{BASE_URI}/plot_config")
|
rc = client_get(client, f"{BASE_URI}/plot_config")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
|
|
||||||
@ -1157,7 +1157,7 @@ def test_api_plot_config(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_strategies(botclient):
|
def test_api_strategies(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/strategies")
|
rc = client_get(client, f"{BASE_URI}/strategies")
|
||||||
|
|
||||||
@ -1170,7 +1170,7 @@ def test_api_strategies(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_api_strategy(botclient):
|
def test_api_strategy(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/strategy/DefaultStrategy")
|
rc = client_get(client, f"{BASE_URI}/strategy/DefaultStrategy")
|
||||||
|
|
||||||
@ -1185,7 +1185,7 @@ def test_api_strategy(botclient):
|
|||||||
|
|
||||||
|
|
||||||
def test_list_available_pairs(botclient):
|
def test_list_available_pairs(botclient):
|
||||||
ftbot, client = botclient
|
freqtrade, client = botclient
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/available_pairs")
|
rc = client_get(client, f"{BASE_URI}/available_pairs")
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class DummyCls(Telegram):
|
|||||||
raise Exception('test')
|
raise Exception('test')
|
||||||
|
|
||||||
|
|
||||||
def get_telegram_testobject(mocker, default_conf, mock=True, ftbot=None):
|
def get_telegram_testobject(mocker, default_conf, mock=True, freqtrade=None):
|
||||||
msg_mock = MagicMock()
|
msg_mock = MagicMock()
|
||||||
if mock:
|
if mock:
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
@ -63,12 +63,12 @@ def get_telegram_testobject(mocker, default_conf, mock=True, ftbot=None):
|
|||||||
_init=MagicMock(),
|
_init=MagicMock(),
|
||||||
_send_msg=msg_mock
|
_send_msg=msg_mock
|
||||||
)
|
)
|
||||||
if not ftbot:
|
if not freqtrade:
|
||||||
ftbot = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
rpc = RPC(ftbot)
|
rpc = RPC(freqtrade)
|
||||||
telegram = Telegram(rpc, default_conf)
|
telegram = Telegram(rpc, default_conf)
|
||||||
|
|
||||||
return telegram, ftbot, msg_mock
|
return telegram, freqtrade, msg_mock
|
||||||
|
|
||||||
|
|
||||||
def test_telegram__init__(default_conf, mocker) -> None:
|
def test_telegram__init__(default_conf, mocker) -> None:
|
||||||
@ -115,11 +115,11 @@ def test_authorized_only(default_conf, mocker, caplog, update) -> None:
|
|||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
caplog.set_level(logging.DEBUG)
|
caplog.set_level(logging.DEBUG)
|
||||||
default_conf['telegram']['enabled'] = False
|
default_conf['telegram']['enabled'] = False
|
||||||
bot = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(default_conf)
|
||||||
rpc = RPC(bot)
|
rpc = RPC(freqtrade)
|
||||||
dummy = DummyCls(rpc, default_conf)
|
dummy = DummyCls(rpc, default_conf)
|
||||||
|
|
||||||
patch_get_signal(bot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
dummy.dummy_handler(update=update, context=MagicMock())
|
dummy.dummy_handler(update=update, context=MagicMock())
|
||||||
assert dummy.state['called'] is True
|
assert dummy.state['called'] is True
|
||||||
assert log_has('Executing handler: dummy_handler for chat_id: 0', caplog)
|
assert log_has('Executing handler: dummy_handler for chat_id: 0', caplog)
|
||||||
@ -135,11 +135,11 @@ def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> None:
|
|||||||
update.message = Message(randint(1, 100), datetime.utcnow(), chat)
|
update.message = Message(randint(1, 100), datetime.utcnow(), chat)
|
||||||
|
|
||||||
default_conf['telegram']['enabled'] = False
|
default_conf['telegram']['enabled'] = False
|
||||||
bot = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(default_conf)
|
||||||
rpc = RPC(bot)
|
rpc = RPC(freqtrade)
|
||||||
dummy = DummyCls(rpc, default_conf)
|
dummy = DummyCls(rpc, default_conf)
|
||||||
|
|
||||||
patch_get_signal(bot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
dummy.dummy_handler(update=update, context=MagicMock())
|
dummy.dummy_handler(update=update, context=MagicMock())
|
||||||
assert dummy.state['called'] is False
|
assert dummy.state['called'] is False
|
||||||
assert not log_has('Executing handler: dummy_handler for chat_id: 3735928559', caplog)
|
assert not log_has('Executing handler: dummy_handler for chat_id: 3735928559', caplog)
|
||||||
@ -152,10 +152,10 @@ def test_authorized_only_exception(default_conf, mocker, caplog, update) -> None
|
|||||||
|
|
||||||
default_conf['telegram']['enabled'] = False
|
default_conf['telegram']['enabled'] = False
|
||||||
|
|
||||||
bot = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(default_conf)
|
||||||
rpc = RPC(bot)
|
rpc = RPC(freqtrade)
|
||||||
dummy = DummyCls(rpc, default_conf)
|
dummy = DummyCls(rpc, default_conf)
|
||||||
patch_get_signal(bot, (True, False))
|
patch_get_signal(freqtrade, (True, False, ''))
|
||||||
|
|
||||||
dummy.dummy_exception(update=update, context=MagicMock())
|
dummy.dummy_exception(update=update, context=MagicMock())
|
||||||
assert dummy.state['called'] is False
|
assert dummy.state['called'] is False
|
||||||
@ -228,7 +228,7 @@ def test_status_handle(default_conf, update, ticker, fee, mocker) -> None:
|
|||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
|
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
freqtradebot.state = State.STOPPED
|
freqtradebot.state = State.STOPPED
|
||||||
# Status is also enabled when stopped
|
# Status is also enabled when stopped
|
||||||
@ -285,7 +285,7 @@ def test_status_table_handle(default_conf, update, ticker, fee, mocker) -> None:
|
|||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
|
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
freqtradebot.state = State.STOPPED
|
freqtradebot.state = State.STOPPED
|
||||||
# Status table is also enabled when stopped
|
# Status table is also enabled when stopped
|
||||||
@ -329,7 +329,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order, fee,
|
|||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
|
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.enter_positions()
|
freqtradebot.enter_positions()
|
||||||
@ -400,7 +400,7 @@ def test_daily_wrong_input(default_conf, update, ticker, mocker) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Try invalid data
|
# Try invalid data
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
@ -432,7 +432,7 @@ def test_profit_handle(default_conf, update, ticker, ticker_sell_up, fee,
|
|||||||
)
|
)
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
telegram._profit(update=update, context=MagicMock())
|
telegram._profit(update=update, context=MagicMock())
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
@ -486,7 +486,7 @@ def test_telegram_stats(default_conf, update, ticker, ticker_sell_up, fee,
|
|||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
telegram._stats(update=update, context=MagicMock())
|
telegram._stats(update=update, context=MagicMock())
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
@ -512,7 +512,7 @@ def test_telegram_balance_handle(default_conf, update, mocker, rpc_balance, tick
|
|||||||
side_effect=lambda a, b: f"{a}/{b}")
|
side_effect=lambda a, b: f"{a}/{b}")
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
telegram._balance(update=update, context=MagicMock())
|
telegram._balance(update=update, context=MagicMock())
|
||||||
result = msg_mock.call_args_list[0][0][0]
|
result = msg_mock.call_args_list[0][0][0]
|
||||||
@ -532,7 +532,7 @@ def test_balance_handle_empty_response(default_conf, update, mocker) -> None:
|
|||||||
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value={})
|
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value={})
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
freqtradebot.config['dry_run'] = False
|
freqtradebot.config['dry_run'] = False
|
||||||
telegram._balance(update=update, context=MagicMock())
|
telegram._balance(update=update, context=MagicMock())
|
||||||
@ -545,7 +545,7 @@ def test_balance_handle_empty_response_dry(default_conf, update, mocker) -> None
|
|||||||
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value={})
|
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value={})
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
telegram._balance(update=update, context=MagicMock())
|
telegram._balance(update=update, context=MagicMock())
|
||||||
result = msg_mock.call_args_list[0][0][0]
|
result = msg_mock.call_args_list[0][0][0]
|
||||||
@ -574,7 +574,7 @@ def test_balance_handle_too_large_response(default_conf, update, mocker) -> None
|
|||||||
})
|
})
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
telegram._balance(update=update, context=MagicMock())
|
telegram._balance(update=update, context=MagicMock())
|
||||||
assert msg_mock.call_count > 1
|
assert msg_mock.call_count > 1
|
||||||
@ -673,7 +673,7 @@ def test_telegram_forcesell_handle(default_conf, update, ticker, fee,
|
|||||||
freqtradebot = FreqtradeBot(default_conf)
|
freqtradebot = FreqtradeBot(default_conf)
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
telegram = Telegram(rpc, default_conf)
|
telegram = Telegram(rpc, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.enter_positions()
|
freqtradebot.enter_positions()
|
||||||
@ -732,7 +732,7 @@ def test_telegram_forcesell_down_handle(default_conf, update, ticker, fee,
|
|||||||
freqtradebot = FreqtradeBot(default_conf)
|
freqtradebot = FreqtradeBot(default_conf)
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
telegram = Telegram(rpc, default_conf)
|
telegram = Telegram(rpc, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.enter_positions()
|
freqtradebot.enter_positions()
|
||||||
@ -793,7 +793,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, fee, mocker) -> None
|
|||||||
freqtradebot = FreqtradeBot(default_conf)
|
freqtradebot = FreqtradeBot(default_conf)
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
telegram = Telegram(rpc, default_conf)
|
telegram = Telegram(rpc, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.enter_positions()
|
freqtradebot.enter_positions()
|
||||||
@ -834,7 +834,7 @@ def test_forcesell_handle_invalid(default_conf, update, mocker) -> None:
|
|||||||
return_value=15000.0)
|
return_value=15000.0)
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Trader is not running
|
# Trader is not running
|
||||||
freqtradebot.state = State.STOPPED
|
freqtradebot.state = State.STOPPED
|
||||||
@ -872,7 +872,7 @@ def test_forcebuy_handle(default_conf, update, mocker) -> None:
|
|||||||
mocker.patch('freqtrade.rpc.RPC._rpc_forcebuy', fbuy_mock)
|
mocker.patch('freqtrade.rpc.RPC._rpc_forcebuy', fbuy_mock)
|
||||||
|
|
||||||
telegram, freqtradebot, _ = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, _ = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# /forcebuy ETH/BTC
|
# /forcebuy ETH/BTC
|
||||||
context = MagicMock()
|
context = MagicMock()
|
||||||
@ -901,7 +901,7 @@ def test_forcebuy_handle_exception(default_conf, update, mocker) -> None:
|
|||||||
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0)
|
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0)
|
||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
update.message.text = '/forcebuy ETH/Nonepair'
|
update.message.text = '/forcebuy ETH/Nonepair'
|
||||||
telegram._forcebuy(update=update, context=MagicMock())
|
telegram._forcebuy(update=update, context=MagicMock())
|
||||||
@ -918,7 +918,7 @@ def test_forcebuy_no_pair(default_conf, update, mocker) -> None:
|
|||||||
|
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
|
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
context = MagicMock()
|
context = MagicMock()
|
||||||
context.args = []
|
context.args = []
|
||||||
@ -946,7 +946,7 @@ def test_performance_handle(default_conf, update, ticker, fee,
|
|||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtradebot.enter_positions()
|
freqtradebot.enter_positions()
|
||||||
@ -974,7 +974,7 @@ def test_count_handle(default_conf, update, ticker, fee, mocker) -> None:
|
|||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
|
|
||||||
freqtradebot.state = State.STOPPED
|
freqtradebot.state = State.STOPPED
|
||||||
telegram._count(update=update, context=MagicMock())
|
telegram._count(update=update, context=MagicMock())
|
||||||
@ -1003,7 +1003,7 @@ def test_telegram_lock_handle(default_conf, update, ticker, fee, mocker) -> None
|
|||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
patch_get_signal(freqtradebot, (True, False))
|
patch_get_signal(freqtradebot, (True, False, ''))
|
||||||
telegram._locks(update=update, context=MagicMock())
|
telegram._locks(update=update, context=MagicMock())
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert 'No active locks.' in msg_mock.call_args_list[0][0][0]
|
assert 'No active locks.' in msg_mock.call_args_list[0][0][0]
|
||||||
|
@ -1972,16 +1972,16 @@ def test_close_trade(default_conf, ticker, limit_buy_order, limit_buy_order_open
|
|||||||
|
|
||||||
|
|
||||||
def test_bot_loop_start_called_once(mocker, default_conf, caplog):
|
def test_bot_loop_start_called_once(mocker, default_conf, caplog):
|
||||||
ftbot = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade')
|
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.create_trade')
|
||||||
patch_get_signal(ftbot)
|
patch_get_signal(freqtrade)
|
||||||
ftbot.strategy.bot_loop_start = MagicMock(side_effect=ValueError)
|
freqtrade.strategy.bot_loop_start = MagicMock(side_effect=ValueError)
|
||||||
ftbot.strategy.analyze = MagicMock()
|
freqtrade.strategy.analyze = MagicMock()
|
||||||
|
|
||||||
ftbot.process()
|
freqtrade.process()
|
||||||
assert log_has_re(r'Strategy caused the following exception.*', caplog)
|
assert log_has_re(r'Strategy caused the following exception.*', caplog)
|
||||||
assert ftbot.strategy.bot_loop_start.call_count == 1
|
assert freqtrade.strategy.bot_loop_start.call_count == 1
|
||||||
assert ftbot.strategy.analyze.call_count == 1
|
assert freqtrade.strategy.analyze.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
def test_check_handle_timedout_buy_usercustom(default_conf, ticker, limit_buy_order_old, open_trade,
|
def test_check_handle_timedout_buy_usercustom(default_conf, ticker, limit_buy_order_old, open_trade,
|
||||||
@ -4044,14 +4044,14 @@ def test_startup_trade_reinit(default_conf, edge_conf, mocker):
|
|||||||
reinit_mock = MagicMock()
|
reinit_mock = MagicMock()
|
||||||
mocker.patch('freqtrade.persistence.Trade.stoploss_reinitialization', reinit_mock)
|
mocker.patch('freqtrade.persistence.Trade.stoploss_reinitialization', reinit_mock)
|
||||||
|
|
||||||
ftbot = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
ftbot.startup()
|
freqtrade.startup()
|
||||||
assert reinit_mock.call_count == 1
|
assert reinit_mock.call_count == 1
|
||||||
|
|
||||||
reinit_mock.reset_mock()
|
reinit_mock.reset_mock()
|
||||||
|
|
||||||
ftbot = get_patched_freqtradebot(mocker, edge_conf)
|
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
||||||
ftbot.startup()
|
freqtrade.startup()
|
||||||
assert reinit_mock.call_count == 0
|
assert reinit_mock.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
@ -4070,17 +4070,17 @@ def test_sync_wallet_dry_run(mocker, default_conf, ticker, fee, limit_buy_order_
|
|||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
|
|
||||||
bot = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
patch_get_signal(bot)
|
patch_get_signal(freqtrade)
|
||||||
assert bot.wallets.get_free('BTC') == 0.002
|
assert freqtrade.wallets.get_free('BTC') == 0.002
|
||||||
|
|
||||||
n = bot.enter_positions()
|
n = freqtrade.enter_positions()
|
||||||
assert n == 2
|
assert n == 2
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
assert len(trades) == 2
|
assert len(trades) == 2
|
||||||
|
|
||||||
bot.config['max_open_trades'] = 3
|
freqtrade.config['max_open_trades'] = 3
|
||||||
n = bot.enter_positions()
|
n = freqtrade.enter_positions()
|
||||||
assert n == 0
|
assert n == 0
|
||||||
assert log_has_re(r"Unable to create trade for XRP/BTC: "
|
assert log_has_re(r"Unable to create trade for XRP/BTC: "
|
||||||
r"Available balance \(0.0 BTC\) is lower than stake amount \(0.001 BTC\)",
|
r"Available balance \(0.0 BTC\) is lower than stake amount \(0.001 BTC\)",
|
||||||
|
Loading…
Reference in New Issue
Block a user