Merge branch 'develop' into safe_sell_amount
This commit is contained in:
@@ -77,7 +77,7 @@ def get_patched_exchange(mocker, config, api_mock=None, id='bittrex',
|
||||
patch_exchange(mocker, api_mock, id, mock_markets)
|
||||
config["exchange"]["name"] = id
|
||||
try:
|
||||
exchange = ExchangeResolver(id, config).exchange
|
||||
exchange = ExchangeResolver.load_exchange(id, config)
|
||||
except ImportError:
|
||||
exchange = Exchange(config)
|
||||
return exchange
|
||||
|
@@ -124,19 +124,19 @@ def test_exchange_resolver(default_conf, mocker, caplog):
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_async_markets', MagicMock())
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_pairs', MagicMock())
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
exchange = ExchangeResolver('Bittrex', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('Bittrex', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert log_has_re(r"No .* specific subclass found. Using the generic class instead.", caplog)
|
||||
caplog.clear()
|
||||
|
||||
exchange = ExchangeResolver('kraken', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('kraken', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Kraken)
|
||||
assert not isinstance(exchange, Binance)
|
||||
assert not log_has_re(r"No .* specific subclass found. Using the generic class instead.",
|
||||
caplog)
|
||||
|
||||
exchange = ExchangeResolver('binance', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('binance', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Binance)
|
||||
assert not isinstance(exchange, Kraken)
|
||||
@@ -145,7 +145,7 @@ def test_exchange_resolver(default_conf, mocker, caplog):
|
||||
caplog)
|
||||
|
||||
# Test mapping
|
||||
exchange = ExchangeResolver('binanceus', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('binanceus', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Binance)
|
||||
assert not isinstance(exchange, Kraken)
|
||||
@@ -363,8 +363,9 @@ def test_validate_pairs_exception(default_conf, mocker, caplog):
|
||||
def test_validate_pairs_restricted(default_conf, mocker, caplog):
|
||||
api_mock = MagicMock()
|
||||
type(api_mock).markets = PropertyMock(return_value={
|
||||
'ETH/BTC': {}, 'LTC/BTC': {}, 'NEO/BTC': {},
|
||||
'XRP/BTC': {'info': {'IsRestricted': True}}
|
||||
'ETH/BTC': {}, 'LTC/BTC': {},
|
||||
'XRP/BTC': {'info': {'IsRestricted': True}},
|
||||
'NEO/BTC': {'info': 'TestString'}, # info can also be a string ...
|
||||
})
|
||||
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
@@ -977,7 +978,7 @@ def test_get_tickers(default_conf, mocker, exchange_name):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||
def test_get_ticker(default_conf, mocker, exchange_name):
|
||||
def test_fetch_ticker(default_conf, mocker, exchange_name):
|
||||
api_mock = MagicMock()
|
||||
tick = {
|
||||
'symbol': 'ETH/BTC',
|
||||
@@ -989,7 +990,7 @@ def test_get_ticker(default_conf, mocker, exchange_name):
|
||||
api_mock.markets = {'ETH/BTC': {'active': True}}
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||
# retrieve original ticker
|
||||
ticker = exchange.get_ticker(pair='ETH/BTC')
|
||||
ticker = exchange.fetch_ticker(pair='ETH/BTC')
|
||||
|
||||
assert ticker['bid'] == 0.00001098
|
||||
assert ticker['ask'] == 0.00001099
|
||||
@@ -1006,7 +1007,7 @@ def test_get_ticker(default_conf, mocker, exchange_name):
|
||||
|
||||
# if not caching the result we should get the same ticker
|
||||
# if not fetching a new result we should get the cached ticker
|
||||
ticker = exchange.get_ticker(pair='ETH/BTC')
|
||||
ticker = exchange.fetch_ticker(pair='ETH/BTC')
|
||||
|
||||
assert api_mock.fetch_ticker.call_count == 1
|
||||
assert ticker['bid'] == 0.5
|
||||
@@ -1018,19 +1019,19 @@ def test_get_ticker(default_conf, mocker, exchange_name):
|
||||
|
||||
# Test caching
|
||||
api_mock.fetch_ticker = MagicMock()
|
||||
exchange.get_ticker(pair='ETH/BTC', refresh=False)
|
||||
exchange.fetch_ticker(pair='ETH/BTC', refresh=False)
|
||||
assert api_mock.fetch_ticker.call_count == 0
|
||||
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock, exchange_name,
|
||||
"get_ticker", "fetch_ticker",
|
||||
"fetch_ticker", "fetch_ticker",
|
||||
pair='ETH/BTC', refresh=True)
|
||||
|
||||
api_mock.fetch_ticker = MagicMock(return_value={})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||
exchange.get_ticker(pair='ETH/BTC', refresh=True)
|
||||
exchange.fetch_ticker(pair='ETH/BTC', refresh=True)
|
||||
|
||||
with pytest.raises(DependencyException, match=r'Pair XRP/ETH not available'):
|
||||
exchange.get_ticker(pair='XRP/ETH', refresh=True)
|
||||
exchange.fetch_ticker(pair='XRP/ETH', refresh=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||
|
@@ -394,8 +394,8 @@ def test_generate_text_table_sell_reason(default_conf, mocker):
|
||||
results = pd.DataFrame(
|
||||
{
|
||||
'pair': ['ETH/BTC', 'ETH/BTC', 'ETH/BTC'],
|
||||
'profit_percent': [0.1, 0.2, 0.3],
|
||||
'profit_abs': [0.2, 0.4, 0.5],
|
||||
'profit_percent': [0.1, 0.2, -0.3],
|
||||
'profit_abs': [0.2, 0.4, -0.5],
|
||||
'trade_duration': [10, 30, 10],
|
||||
'profit': [2, 0, 0],
|
||||
'loss': [0, 0, 1],
|
||||
@@ -404,10 +404,10 @@ def test_generate_text_table_sell_reason(default_conf, mocker):
|
||||
)
|
||||
|
||||
result_str = (
|
||||
'| Sell Reason | Count |\n'
|
||||
'|:--------------|--------:|\n'
|
||||
'| roi | 2 |\n'
|
||||
'| stop_loss | 1 |'
|
||||
'| Sell Reason | Count | Profit | Loss |\n'
|
||||
'|:--------------|--------:|---------:|-------:|\n'
|
||||
'| roi | 2 | 2 | 0 |\n'
|
||||
'| stop_loss | 1 | 0 | 1 |'
|
||||
)
|
||||
assert backtesting._generate_text_table_sell_reason(
|
||||
data={'ETH/BTC': {}}, results=results) == result_str
|
||||
|
@@ -163,7 +163,7 @@ def test_hyperoptresolver(mocker, default_conf, caplog) -> None:
|
||||
MagicMock(return_value=hyperopt(default_conf))
|
||||
)
|
||||
default_conf.update({'hyperopt': 'DefaultHyperOpt'})
|
||||
x = HyperOptResolver(default_conf).hyperopt
|
||||
x = HyperOptResolver.load_hyperopt(default_conf)
|
||||
assert not hasattr(x, 'populate_indicators')
|
||||
assert not hasattr(x, 'populate_buy_trend')
|
||||
assert not hasattr(x, 'populate_sell_trend')
|
||||
@@ -180,7 +180,7 @@ def test_hyperoptresolver_wrongname(mocker, default_conf, caplog) -> None:
|
||||
default_conf.update({'hyperopt': "NonExistingHyperoptClass"})
|
||||
|
||||
with pytest.raises(OperationalException, match=r'Impossible to load Hyperopt.*'):
|
||||
HyperOptResolver(default_conf).hyperopt
|
||||
HyperOptResolver.load_hyperopt(default_conf)
|
||||
|
||||
|
||||
def test_hyperoptresolver_noname(default_conf):
|
||||
@@ -188,7 +188,7 @@ def test_hyperoptresolver_noname(default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match="No Hyperopt set. Please use `--hyperopt` to specify "
|
||||
"the Hyperopt class to use."):
|
||||
HyperOptResolver(default_conf)
|
||||
HyperOptResolver.load_hyperopt(default_conf)
|
||||
|
||||
|
||||
def test_hyperoptlossresolver(mocker, default_conf, caplog) -> None:
|
||||
@@ -198,7 +198,7 @@ def test_hyperoptlossresolver(mocker, default_conf, caplog) -> None:
|
||||
'freqtrade.resolvers.hyperopt_resolver.HyperOptLossResolver._load_hyperoptloss',
|
||||
MagicMock(return_value=hl)
|
||||
)
|
||||
x = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
x = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
assert hasattr(x, "hyperopt_loss_function")
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ def test_hyperoptlossresolver_wrongname(mocker, default_conf, caplog) -> None:
|
||||
default_conf.update({'hyperopt_loss': "NonExistingLossClass"})
|
||||
|
||||
with pytest.raises(OperationalException, match=r'Impossible to load HyperoptLoss.*'):
|
||||
HyperOptLossResolver(default_conf).hyperopt
|
||||
HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
|
||||
|
||||
def test_start_not_installed(mocker, default_conf, caplog, import_fails) -> None:
|
||||
@@ -286,7 +286,7 @@ def test_start_filelock(mocker, default_conf, caplog) -> None:
|
||||
|
||||
|
||||
def test_loss_calculation_prefer_correct_trade_count(default_conf, hyperopt_results) -> None:
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, 600)
|
||||
over = hl.hyperopt_loss_function(hyperopt_results, 600 + 100)
|
||||
under = hl.hyperopt_loss_function(hyperopt_results, 600 - 100)
|
||||
@@ -298,7 +298,7 @@ def test_loss_calculation_prefer_shorter_trades(default_conf, hyperopt_results)
|
||||
resultsb = hyperopt_results.copy()
|
||||
resultsb.loc[1, 'trade_duration'] = 20
|
||||
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
longer = hl.hyperopt_loss_function(hyperopt_results, 100)
|
||||
shorter = hl.hyperopt_loss_function(resultsb, 100)
|
||||
assert shorter < longer
|
||||
@@ -310,7 +310,7 @@ def test_loss_calculation_has_limited_profit(default_conf, hyperopt_results) ->
|
||||
results_under = hyperopt_results.copy()
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, 600)
|
||||
over = hl.hyperopt_loss_function(results_over, 600)
|
||||
under = hl.hyperopt_loss_function(results_under, 600)
|
||||
@@ -325,7 +325,7 @@ def test_sharpe_loss_prefers_higher_profits(default_conf, hyperopt_results) -> N
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
|
||||
default_conf.update({'hyperopt_loss': 'SharpeHyperOptLoss'})
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, len(hyperopt_results),
|
||||
datetime(2019, 1, 1), datetime(2019, 5, 1))
|
||||
over = hl.hyperopt_loss_function(results_over, len(hyperopt_results),
|
||||
@@ -343,7 +343,7 @@ def test_onlyprofit_loss_prefers_higher_profits(default_conf, hyperopt_results)
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
|
||||
default_conf.update({'hyperopt_loss': 'OnlyProfitHyperOptLoss'})
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, len(hyperopt_results),
|
||||
datetime(2019, 1, 1), datetime(2019, 5, 1))
|
||||
over = hl.hyperopt_loss_function(results_over, len(hyperopt_results),
|
||||
|
@@ -53,7 +53,8 @@ def test_load_pairlist_noexist(mocker, markets, default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Impossible to load Pairlist 'NonexistingPairList'. "
|
||||
r"This class does not exist or contains Python code errors."):
|
||||
PairListResolver('NonexistingPairList', bot.exchange, plm, default_conf, {}, 1)
|
||||
PairListResolver.load_pairlist('NonexistingPairList', bot.exchange, plm,
|
||||
default_conf, {}, 1)
|
||||
|
||||
|
||||
def test_refresh_market_pair_not_in_whitelist(mocker, markets, static_pl_conf):
|
||||
|
@@ -29,7 +29,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -65,7 +65,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
||||
'open_order': '(limit buy rem=0.00000000)'
|
||||
} == results[0]
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(side_effect=DependencyException(f"Pair 'ETH/BTC' not available")))
|
||||
# invalidate ticker cache
|
||||
rpc._freqtrade.exchange._cached_ticker = {}
|
||||
@@ -104,7 +104,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -134,7 +134,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
||||
assert 'ETH/BTC' == result[0][1]
|
||||
assert '-0.59% (-0.09)' == result[0][3]
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(side_effect=DependencyException(f"Pair 'ETH/BTC' not available")))
|
||||
# invalidate ticker cache
|
||||
rpc._freqtrade.exchange._cached_ticker = {}
|
||||
@@ -149,7 +149,7 @@ def test_rpc_daily_profit(default_conf, update, ticker, fee,
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
@@ -201,7 +201,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -225,7 +225,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
||||
# Update the ticker with a market going up
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_up
|
||||
fetch_ticker=ticker_sell_up
|
||||
)
|
||||
trade.update(limit_sell_order)
|
||||
trade.close_date = datetime.utcnow()
|
||||
@@ -239,7 +239,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
||||
# Update the ticker with a market going up
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_up
|
||||
fetch_ticker=ticker_sell_up
|
||||
)
|
||||
trade.update(limit_sell_order)
|
||||
trade.close_date = datetime.utcnow()
|
||||
@@ -260,7 +260,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
||||
assert prec_satoshi(stats['best_rate'], 6.2)
|
||||
|
||||
# Test non-available pair
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(side_effect=DependencyException(f"Pair 'ETH/BTC' not available")))
|
||||
# invalidate ticker cache
|
||||
rpc._freqtrade.exchange._cached_ticker = {}
|
||||
@@ -287,7 +287,7 @@ def test_rpc_trade_statistics_closed(mocker, default_conf, ticker, fee,
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -306,7 +306,7 @@ def test_rpc_trade_statistics_closed(mocker, default_conf, ticker, fee,
|
||||
# Update the ticker with a market going up
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_up,
|
||||
fetch_ticker=ticker_sell_up,
|
||||
get_fee=fee
|
||||
)
|
||||
trade.update(limit_sell_order)
|
||||
@@ -439,7 +439,7 @@ def test_rpc_start(mocker, default_conf) -> None:
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock()
|
||||
fetch_ticker=MagicMock()
|
||||
)
|
||||
|
||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||
@@ -460,7 +460,7 @@ def test_rpc_stop(mocker, default_conf) -> None:
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock()
|
||||
fetch_ticker=MagicMock()
|
||||
)
|
||||
|
||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||
@@ -482,7 +482,7 @@ def test_rpc_stopbuy(mocker, default_conf) -> None:
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock()
|
||||
fetch_ticker=MagicMock()
|
||||
)
|
||||
|
||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||
@@ -502,7 +502,7 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
||||
cancel_order_mock = MagicMock()
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
cancel_order=cancel_order_mock,
|
||||
get_order=MagicMock(
|
||||
return_value={
|
||||
@@ -604,7 +604,7 @@ def test_performance_handle(default_conf, ticker, limit_buy_order, fee,
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -637,7 +637,7 @@ def test_rpc_count(mocker, default_conf, ticker, fee) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -661,7 +661,7 @@ def test_rpcforcebuy(mocker, default_conf, ticker, fee, limit_buy_order) -> None
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
buy=buy_mm
|
||||
)
|
||||
|
@@ -256,7 +256,7 @@ def test_api_count(botclient, mocker, ticker, fee, markets):
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
@@ -292,7 +292,7 @@ def test_api_daily(botclient, mocker, ticker, fee, markets):
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
@@ -308,7 +308,7 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
@@ -323,7 +323,7 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, limit_buy_order, li
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
@@ -413,7 +413,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets):
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
@@ -541,7 +541,7 @@ def test_api_forcesell(botclient, mocker, ticker, fee, markets):
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_balances=MagicMock(return_value=ticker),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
|
@@ -150,7 +150,7 @@ def test_status(default_conf, update, mocker, fee, ticker,) -> None:
|
||||
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
msg_mock = MagicMock()
|
||||
@@ -204,7 +204,7 @@ def test_status(default_conf, update, mocker, fee, ticker,) -> None:
|
||||
def test_status_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
msg_mock = MagicMock()
|
||||
@@ -254,7 +254,7 @@ def test_status_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
def test_status_table_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': 'mocked_order_id'}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -307,7 +307,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order, fee,
|
||||
)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
msg_mock = MagicMock()
|
||||
@@ -373,7 +373,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order, fee,
|
||||
def test_daily_wrong_input(default_conf, update, ticker, mocker) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker
|
||||
fetch_ticker=ticker
|
||||
)
|
||||
msg_mock = MagicMock()
|
||||
mocker.patch.multiple(
|
||||
@@ -411,7 +411,7 @@ def test_profit_handle(default_conf, update, ticker, ticker_sell_up, fee,
|
||||
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
msg_mock = MagicMock()
|
||||
@@ -443,7 +443,7 @@ def test_profit_handle(default_conf, update, ticker, ticker_sell_up, fee,
|
||||
msg_mock.reset_mock()
|
||||
|
||||
# Update the ticker with a market going up
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker', ticker_sell_up)
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', ticker_sell_up)
|
||||
trade.update(limit_sell_order)
|
||||
|
||||
trade.close_date = datetime.utcnow()
|
||||
@@ -534,7 +534,7 @@ def test_balance_handle_empty_response_dry(default_conf, update, mocker) -> None
|
||||
telegram._balance(update=update, context=MagicMock())
|
||||
result = msg_mock.call_args_list[0][0][0]
|
||||
assert msg_mock.call_count == 1
|
||||
assert "*Warning:*Simulated balances in Dry Mode." in result
|
||||
assert "*Warning:* Simulated balances in Dry Mode." in result
|
||||
assert "Starting capital: `1000` BTC" in result
|
||||
|
||||
|
||||
@@ -700,7 +700,7 @@ def test_forcesell_handle(default_conf, update, ticker, fee,
|
||||
patch_whitelist(mocker, default_conf)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -715,7 +715,7 @@ def test_forcesell_handle(default_conf, update, ticker, fee,
|
||||
assert trade
|
||||
|
||||
# Increase the price and sell it
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker', ticker_sell_up)
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', ticker_sell_up)
|
||||
|
||||
# /forcesell 1
|
||||
context = MagicMock()
|
||||
@@ -755,7 +755,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, fee,
|
||||
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
@@ -769,7 +769,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, fee,
|
||||
# Decrease the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_down
|
||||
fetch_ticker=ticker_sell_down
|
||||
)
|
||||
|
||||
trade = Trade.query.first()
|
||||
@@ -812,7 +812,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, fee, mocker) -> None
|
||||
patch_whitelist(mocker, default_conf)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
default_conf['max_open_trades'] = 4
|
||||
@@ -963,7 +963,7 @@ def test_performance_handle(default_conf, update, ticker, fee,
|
||||
)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||
@@ -998,7 +998,7 @@ def test_count_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': 'mocked_order_id'}),
|
||||
get_fee=fee,
|
||||
)
|
||||
|
@@ -302,6 +302,19 @@ def test_is_pair_locked(default_conf):
|
||||
# ETH/BTC locked for 4 minutes
|
||||
assert strategy.is_pair_locked(pair)
|
||||
|
||||
# Test lock does not change
|
||||
lock = strategy._pair_locked_until[pair]
|
||||
strategy.lock_pair(pair, arrow.utcnow().shift(minutes=2).datetime)
|
||||
assert lock == strategy._pair_locked_until[pair]
|
||||
|
||||
# XRP/BTC should not be locked now
|
||||
pair = 'XRP/BTC'
|
||||
assert not strategy.is_pair_locked(pair)
|
||||
|
||||
# Unlocking a pair that's not locked should not raise an error
|
||||
strategy.unlock_pair(pair)
|
||||
|
||||
# Unlock original pair
|
||||
pair = 'ETH/BTC'
|
||||
strategy.unlock_pair(pair)
|
||||
assert not strategy.is_pair_locked(pair)
|
||||
|
@@ -39,8 +39,8 @@ def test_load_strategy(default_conf, result):
|
||||
default_conf.update({'strategy': 'SampleStrategy',
|
||||
'strategy_path': str(Path(__file__).parents[2] / 'freqtrade/templates')
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
|
||||
|
||||
def test_load_strategy_base64(result, caplog, default_conf):
|
||||
@@ -48,8 +48,8 @@ def test_load_strategy_base64(result, caplog, default_conf):
|
||||
encoded_string = urlsafe_b64encode(file.read()).decode("utf-8")
|
||||
default_conf.update({'strategy': 'SampleStrategy:{}'.format(encoded_string)})
|
||||
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
# Make sure strategy was loaded from base64 (using temp directory)!!
|
||||
assert log_has_re(r"Using resolved strategy SampleStrategy from '"
|
||||
r".*(/|\\).*(/|\\)SampleStrategy\.py'\.\.\.", caplog)
|
||||
@@ -57,13 +57,13 @@ def test_load_strategy_base64(result, caplog, default_conf):
|
||||
|
||||
def test_load_strategy_invalid_directory(result, caplog, default_conf):
|
||||
default_conf['strategy'] = 'DefaultStrategy'
|
||||
resolver = StrategyResolver(default_conf)
|
||||
extra_dir = Path.cwd() / 'some/path'
|
||||
resolver._load_strategy('DefaultStrategy', config=default_conf, extra_dir=extra_dir)
|
||||
strategy = StrategyResolver._load_strategy('DefaultStrategy', config=default_conf,
|
||||
extra_dir=extra_dir)
|
||||
|
||||
assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog)
|
||||
|
||||
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
|
||||
|
||||
def test_load_not_found_strategy(default_conf):
|
||||
@@ -71,7 +71,7 @@ def test_load_not_found_strategy(default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Impossible to load Strategy 'NotFoundStrategy'. "
|
||||
r"This class does not exist or contains Python code errors."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_load_strategy_noname(default_conf):
|
||||
@@ -79,30 +79,30 @@ def test_load_strategy_noname(default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match="No strategy set. Please use `--strategy` to specify "
|
||||
"the strategy class to use."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_strategy(result, default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
assert resolver.strategy.minimal_roi[0] == 0.04
|
||||
assert strategy.minimal_roi[0] == 0.04
|
||||
assert default_conf["minimal_roi"]['0'] == 0.04
|
||||
|
||||
assert resolver.strategy.stoploss == -0.10
|
||||
assert strategy.stoploss == -0.10
|
||||
assert default_conf['stoploss'] == -0.10
|
||||
|
||||
assert resolver.strategy.ticker_interval == '5m'
|
||||
assert strategy.ticker_interval == '5m'
|
||||
assert default_conf['ticker_interval'] == '5m'
|
||||
|
||||
df_indicators = resolver.strategy.advise_indicators(result, metadata=metadata)
|
||||
df_indicators = strategy.advise_indicators(result, metadata=metadata)
|
||||
assert 'adx' in df_indicators
|
||||
|
||||
dataframe = resolver.strategy.advise_buy(df_indicators, metadata=metadata)
|
||||
dataframe = strategy.advise_buy(df_indicators, metadata=metadata)
|
||||
assert 'buy' in dataframe.columns
|
||||
|
||||
dataframe = resolver.strategy.advise_sell(df_indicators, metadata=metadata)
|
||||
dataframe = strategy.advise_sell(df_indicators, metadata=metadata)
|
||||
assert 'sell' in dataframe.columns
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ def test_strategy_override_minimal_roi(caplog, default_conf):
|
||||
"0": 0.5
|
||||
}
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.minimal_roi[0] == 0.5
|
||||
assert strategy.minimal_roi[0] == 0.5
|
||||
assert log_has("Override strategy 'minimal_roi' with value in config file: {'0': 0.5}.", caplog)
|
||||
|
||||
|
||||
@@ -126,9 +126,9 @@ def test_strategy_override_stoploss(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'stoploss': -0.5
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.stoploss == -0.5
|
||||
assert strategy.stoploss == -0.5
|
||||
assert log_has("Override strategy 'stoploss' with value in config file: -0.5.", caplog)
|
||||
|
||||
|
||||
@@ -138,10 +138,10 @@ def test_strategy_override_trailing_stop(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'trailing_stop': True
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.trailing_stop
|
||||
assert isinstance(resolver.strategy.trailing_stop, bool)
|
||||
assert strategy.trailing_stop
|
||||
assert isinstance(strategy.trailing_stop, bool)
|
||||
assert log_has("Override strategy 'trailing_stop' with value in config file: True.", caplog)
|
||||
|
||||
|
||||
@@ -153,13 +153,13 @@ def test_strategy_override_trailing_stop_positive(caplog, default_conf):
|
||||
'trailing_stop_positive_offset': -0.2
|
||||
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.trailing_stop_positive == -0.1
|
||||
assert strategy.trailing_stop_positive == -0.1
|
||||
assert log_has("Override strategy 'trailing_stop_positive' with value in config file: -0.1.",
|
||||
caplog)
|
||||
|
||||
assert resolver.strategy.trailing_stop_positive_offset == -0.2
|
||||
assert strategy.trailing_stop_positive_offset == -0.2
|
||||
assert log_has("Override strategy 'trailing_stop_positive' with value in config file: -0.1.",
|
||||
caplog)
|
||||
|
||||
@@ -172,10 +172,10 @@ def test_strategy_override_ticker_interval(caplog, default_conf):
|
||||
'ticker_interval': 60,
|
||||
'stake_currency': 'ETH'
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.ticker_interval == 60
|
||||
assert resolver.strategy.stake_currency == 'ETH'
|
||||
assert strategy.ticker_interval == 60
|
||||
assert strategy.stake_currency == 'ETH'
|
||||
assert log_has("Override strategy 'ticker_interval' with value in config file: 60.",
|
||||
caplog)
|
||||
|
||||
@@ -187,9 +187,9 @@ def test_strategy_override_process_only_new_candles(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'process_only_new_candles': True
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.process_only_new_candles
|
||||
assert strategy.process_only_new_candles
|
||||
assert log_has("Override strategy 'process_only_new_candles' with value in config file: True.",
|
||||
caplog)
|
||||
|
||||
@@ -207,11 +207,11 @@ def test_strategy_override_order_types(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'order_types': order_types
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.order_types
|
||||
assert strategy.order_types
|
||||
for method in ['buy', 'sell', 'stoploss', 'stoploss_on_exchange']:
|
||||
assert resolver.strategy.order_types[method] == order_types[method]
|
||||
assert strategy.order_types[method] == order_types[method]
|
||||
|
||||
assert log_has("Override strategy 'order_types' with value in config file:"
|
||||
" {'buy': 'market', 'sell': 'limit', 'stoploss': 'limit',"
|
||||
@@ -225,7 +225,7 @@ def test_strategy_override_order_types(caplog, default_conf):
|
||||
with pytest.raises(ImportError,
|
||||
match=r"Impossible to load Strategy 'DefaultStrategy'. "
|
||||
r"Order-types mapping is incomplete."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_strategy_override_order_tif(caplog, default_conf):
|
||||
@@ -240,11 +240,11 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'order_time_in_force': order_time_in_force
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.order_time_in_force
|
||||
assert strategy.order_time_in_force
|
||||
for method in ['buy', 'sell']:
|
||||
assert resolver.strategy.order_time_in_force[method] == order_time_in_force[method]
|
||||
assert strategy.order_time_in_force[method] == order_time_in_force[method]
|
||||
|
||||
assert log_has("Override strategy 'order_time_in_force' with value in config file:"
|
||||
" {'buy': 'fok', 'sell': 'gtc'}.", caplog)
|
||||
@@ -257,7 +257,7 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
with pytest.raises(ImportError,
|
||||
match=r"Impossible to load Strategy 'DefaultStrategy'. "
|
||||
r"Order-time-in-force mapping is incomplete."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
@@ -265,9 +265,9 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert resolver.strategy.use_sell_signal
|
||||
assert isinstance(resolver.strategy.use_sell_signal, bool)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert strategy.use_sell_signal
|
||||
assert isinstance(strategy.use_sell_signal, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'use_sell_signal' in default_conf['ask_strategy']
|
||||
assert default_conf['ask_strategy']['use_sell_signal']
|
||||
@@ -278,10 +278,10 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
'use_sell_signal': False,
|
||||
},
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert not resolver.strategy.use_sell_signal
|
||||
assert isinstance(resolver.strategy.use_sell_signal, bool)
|
||||
assert not strategy.use_sell_signal
|
||||
assert isinstance(strategy.use_sell_signal, bool)
|
||||
assert log_has("Override strategy 'use_sell_signal' with value in config file: False.", caplog)
|
||||
|
||||
|
||||
@@ -290,9 +290,9 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert not resolver.strategy.sell_profit_only
|
||||
assert isinstance(resolver.strategy.sell_profit_only, bool)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert not strategy.sell_profit_only
|
||||
assert isinstance(strategy.sell_profit_only, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'sell_profit_only' in default_conf['ask_strategy']
|
||||
assert not default_conf['ask_strategy']['sell_profit_only']
|
||||
@@ -303,10 +303,10 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
'sell_profit_only': True,
|
||||
},
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.sell_profit_only
|
||||
assert isinstance(resolver.strategy.sell_profit_only, bool)
|
||||
assert strategy.sell_profit_only
|
||||
assert isinstance(strategy.sell_profit_only, bool)
|
||||
assert log_has("Override strategy 'sell_profit_only' with value in config file: True.", caplog)
|
||||
|
||||
|
||||
@@ -315,11 +315,11 @@ def test_deprecate_populate_indicators(result, default_conf):
|
||||
default_location = path.join(path.dirname(path.realpath(__file__)))
|
||||
default_conf.update({'strategy': 'TestStrategyLegacy',
|
||||
'strategy_path': default_location})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Cause all warnings to always be triggered.
|
||||
warnings.simplefilter("always")
|
||||
indicators = resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
indicators = strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
assert len(w) == 1
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated - check out the Sample strategy to see the current function headers!" \
|
||||
@@ -328,7 +328,7 @@ def test_deprecate_populate_indicators(result, default_conf):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Cause all warnings to always be triggered.
|
||||
warnings.simplefilter("always")
|
||||
resolver.strategy.advise_buy(indicators, {'pair': 'ETH/BTC'})
|
||||
strategy.advise_buy(indicators, {'pair': 'ETH/BTC'})
|
||||
assert len(w) == 1
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated - check out the Sample strategy to see the current function headers!" \
|
||||
@@ -337,7 +337,7 @@ def test_deprecate_populate_indicators(result, default_conf):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Cause all warnings to always be triggered.
|
||||
warnings.simplefilter("always")
|
||||
resolver.strategy.advise_sell(indicators, {'pair': 'ETH_BTC'})
|
||||
strategy.advise_sell(indicators, {'pair': 'ETH_BTC'})
|
||||
assert len(w) == 1
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated - check out the Sample strategy to see the current function headers!" \
|
||||
@@ -349,47 +349,47 @@ def test_call_deprecated_function(result, monkeypatch, default_conf):
|
||||
default_location = path.join(path.dirname(path.realpath(__file__)))
|
||||
default_conf.update({'strategy': 'TestStrategyLegacy',
|
||||
'strategy_path': default_location})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
|
||||
# Make sure we are using a legacy function
|
||||
assert resolver.strategy._populate_fun_len == 2
|
||||
assert resolver.strategy._buy_fun_len == 2
|
||||
assert resolver.strategy._sell_fun_len == 2
|
||||
assert resolver.strategy.INTERFACE_VERSION == 1
|
||||
assert strategy._populate_fun_len == 2
|
||||
assert strategy._buy_fun_len == 2
|
||||
assert strategy._sell_fun_len == 2
|
||||
assert strategy.INTERFACE_VERSION == 1
|
||||
|
||||
indicator_df = resolver.strategy.advise_indicators(result, metadata=metadata)
|
||||
indicator_df = strategy.advise_indicators(result, metadata=metadata)
|
||||
assert isinstance(indicator_df, DataFrame)
|
||||
assert 'adx' in indicator_df.columns
|
||||
|
||||
buydf = resolver.strategy.advise_buy(result, metadata=metadata)
|
||||
buydf = strategy.advise_buy(result, metadata=metadata)
|
||||
assert isinstance(buydf, DataFrame)
|
||||
assert 'buy' in buydf.columns
|
||||
|
||||
selldf = resolver.strategy.advise_sell(result, metadata=metadata)
|
||||
selldf = strategy.advise_sell(result, metadata=metadata)
|
||||
assert isinstance(selldf, DataFrame)
|
||||
assert 'sell' in selldf
|
||||
|
||||
|
||||
def test_strategy_interface_versioning(result, monkeypatch, default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
|
||||
# Make sure we are using a legacy function
|
||||
assert resolver.strategy._populate_fun_len == 3
|
||||
assert resolver.strategy._buy_fun_len == 3
|
||||
assert resolver.strategy._sell_fun_len == 3
|
||||
assert resolver.strategy.INTERFACE_VERSION == 2
|
||||
assert strategy._populate_fun_len == 3
|
||||
assert strategy._buy_fun_len == 3
|
||||
assert strategy._sell_fun_len == 3
|
||||
assert strategy.INTERFACE_VERSION == 2
|
||||
|
||||
indicator_df = resolver.strategy.advise_indicators(result, metadata=metadata)
|
||||
indicator_df = strategy.advise_indicators(result, metadata=metadata)
|
||||
assert isinstance(indicator_df, DataFrame)
|
||||
assert 'adx' in indicator_df.columns
|
||||
|
||||
buydf = resolver.strategy.advise_buy(result, metadata=metadata)
|
||||
buydf = strategy.advise_buy(result, metadata=metadata)
|
||||
assert isinstance(buydf, DataFrame)
|
||||
assert 'buy' in buydf.columns
|
||||
|
||||
selldf = resolver.strategy.advise_sell(result, metadata=metadata)
|
||||
selldf = strategy.advise_sell(result, metadata=metadata)
|
||||
assert isinstance(selldf, DataFrame)
|
||||
assert 'sell' in selldf
|
||||
|
@@ -977,7 +977,7 @@ def test_pairlist_resolving_fallback(mocker):
|
||||
|
||||
assert config['pairs'] == ['ETH/BTC', 'XRP/BTC']
|
||||
assert config['exchange']['name'] == 'binance'
|
||||
assert config['datadir'] == str(Path.cwd() / "user_data/data/binance")
|
||||
assert config['datadir'] == Path.cwd() / "user_data/data/binance"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("setting", [
|
||||
|
@@ -157,7 +157,7 @@ def test_get_trade_stake_amount_unlimited_amount(default_conf, ticker,
|
||||
patch_wallet(mocker, free=default_conf['stake_amount'])
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee
|
||||
)
|
||||
@@ -232,7 +232,7 @@ def test_edge_overrides_stoploss(limit_buy_order, fee, caplog, mocker, edge_conf
|
||||
buy_price = limit_buy_order['price']
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': buy_price * 0.79,
|
||||
'ask': buy_price * 0.79,
|
||||
'last': buy_price * 0.79
|
||||
@@ -272,7 +272,7 @@ def test_edge_should_ignore_strategy_stoploss(limit_buy_order, fee,
|
||||
buy_price = limit_buy_order['price']
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': buy_price * 0.85,
|
||||
'ask': buy_price * 0.85,
|
||||
'last': buy_price * 0.85
|
||||
@@ -304,7 +304,7 @@ def test_total_open_trades_stakes(mocker, default_conf, ticker,
|
||||
default_conf['max_open_trades'] = 2
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -467,7 +467,7 @@ def test_create_trades(default_conf, ticker, limit_buy_order, fee, mocker) -> No
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -501,7 +501,7 @@ def test_create_trades_no_stake_amount(default_conf, ticker, limit_buy_order,
|
||||
patch_wallet(mocker, free=default_conf['stake_amount'] * 0.5)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -519,7 +519,7 @@ def test_create_trades_minimal_amount(default_conf, ticker, limit_buy_order,
|
||||
buy_mock = MagicMock(return_value={'id': limit_buy_order['id']})
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=buy_mock,
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -539,7 +539,7 @@ def test_create_trades_too_small_stake_amount(default_conf, ticker, limit_buy_or
|
||||
buy_mock = MagicMock(return_value={'id': limit_buy_order['id']})
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=buy_mock,
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -558,7 +558,7 @@ def test_create_trades_limit_reached(default_conf, ticker, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_balance=MagicMock(return_value=default_conf['stake_amount']),
|
||||
get_fee=fee,
|
||||
@@ -579,7 +579,7 @@ def test_create_trades_no_pairs_let(default_conf, ticker, limit_buy_order, fee,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -600,7 +600,7 @@ def test_create_trades_no_pairs_in_whitelist(default_conf, ticker, limit_buy_ord
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -639,7 +639,7 @@ def test_create_trades_multiple_trades(default_conf, ticker,
|
||||
default_conf['max_open_trades'] = max_open
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': "12355555"}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -658,7 +658,7 @@ def test_create_trades_preopen(default_conf, ticker, fee, mocker) -> None:
|
||||
default_conf['max_open_trades'] = 4
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': "12355555"}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -684,7 +684,7 @@ def test_process_trade_creation(default_conf, ticker, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_order=MagicMock(return_value=limit_buy_order),
|
||||
get_fee=fee,
|
||||
@@ -718,7 +718,7 @@ def test_process_exchange_failures(default_conf, ticker, mocker) -> None:
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(side_effect=TemporaryError)
|
||||
)
|
||||
sleep_mock = mocker.patch('time.sleep', side_effect=lambda _: None)
|
||||
@@ -735,7 +735,7 @@ def test_process_operational_exception(default_conf, ticker, mocker) -> None:
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(side_effect=OperationalException)
|
||||
)
|
||||
worker = Worker(args=None, config=default_conf)
|
||||
@@ -753,7 +753,7 @@ def test_process_trade_handling(default_conf, ticker, limit_buy_order, fee, mock
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_order=MagicMock(return_value=limit_buy_order),
|
||||
get_fee=fee,
|
||||
@@ -780,7 +780,7 @@ def test_process_trade_no_whitelist_pair(default_conf, ticker, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_order=MagicMock(return_value=limit_buy_order),
|
||||
get_fee=fee,
|
||||
@@ -830,7 +830,7 @@ def test_process_informative_pairs_added(default_conf, ticker, mocker) -> None:
|
||||
refresh_mock = MagicMock()
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(side_effect=TemporaryError),
|
||||
refresh_latest_ohlcv=refresh_mock,
|
||||
)
|
||||
@@ -853,7 +853,7 @@ def test_process_informative_pairs_added(default_conf, ticker, mocker) -> None:
|
||||
def test_balance_fully_ask_side(mocker, default_conf) -> None:
|
||||
default_conf['bid_strategy']['ask_last_balance'] = 0.0
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={'ask': 20, 'last': 10}))
|
||||
|
||||
assert freqtrade.get_target_bid('ETH/BTC') == 20
|
||||
@@ -862,7 +862,7 @@ def test_balance_fully_ask_side(mocker, default_conf) -> None:
|
||||
def test_balance_fully_last_side(mocker, default_conf) -> None:
|
||||
default_conf['bid_strategy']['ask_last_balance'] = 1.0
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={'ask': 20, 'last': 10}))
|
||||
|
||||
assert freqtrade.get_target_bid('ETH/BTC') == 10
|
||||
@@ -871,7 +871,7 @@ def test_balance_fully_last_side(mocker, default_conf) -> None:
|
||||
def test_balance_bigger_last_ask(mocker, default_conf) -> None:
|
||||
default_conf['bid_strategy']['ask_last_balance'] = 1.0
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={'ask': 5, 'last': 10}))
|
||||
assert freqtrade.get_target_bid('ETH/BTC') == 5
|
||||
|
||||
@@ -891,7 +891,7 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order) -> None:
|
||||
buy_mm = MagicMock(return_value={'id': limit_buy_order['id']})
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1000,7 +1000,7 @@ def test_handle_stoploss_on_exchange(mocker, default_conf, fee, caplog,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1100,7 +1100,7 @@ def test_handle_sle_cancel_cant_recreate(mocker, default_conf, fee, caplog,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1134,7 +1134,7 @@ def test_create_stoploss_order_invalid_order(mocker, default_conf, caplog, fee,
|
||||
sell_mock = MagicMock(return_value={'id': limit_sell_order['id']})
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1177,7 +1177,7 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee, caplog,
|
||||
patch_RPCManager(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1231,7 +1231,7 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee, caplog,
|
||||
assert freqtrade.handle_stoploss_on_exchange(trade) is False
|
||||
|
||||
# price jumped 2x
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker', MagicMock(return_value={
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', MagicMock(return_value={
|
||||
'bid': 0.00002344,
|
||||
'ask': 0.00002346,
|
||||
'last': 0.00002344
|
||||
@@ -1271,7 +1271,7 @@ def test_handle_stoploss_on_exchange_trailing_error(mocker, default_conf, fee, c
|
||||
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1342,7 +1342,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, caplog,
|
||||
edge_conf['dry_run_wallet'] = 999.9
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1406,7 +1406,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, caplog,
|
||||
mocker.patch('freqtrade.exchange.Exchange.stoploss_limit', stoploss_order_mock)
|
||||
|
||||
# price goes down 5%
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker', MagicMock(return_value={
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', MagicMock(return_value={
|
||||
'bid': 0.00001172 * 0.95,
|
||||
'ask': 0.00001173 * 0.95,
|
||||
'last': 0.00001172 * 0.95
|
||||
@@ -1422,7 +1422,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, caplog,
|
||||
cancel_order_mock.assert_not_called()
|
||||
|
||||
# price jumped 2x
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker', MagicMock(return_value={
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', MagicMock(return_value={
|
||||
'bid': 0.00002344,
|
||||
'ask': 0.00002346,
|
||||
'last': 0.00002344
|
||||
@@ -1662,7 +1662,7 @@ def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, fee, mock
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -1702,7 +1702,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, limit_buy_order, fee,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -1755,7 +1755,7 @@ def test_handle_trade_roi(default_conf, ticker, limit_buy_order,
|
||||
patch_RPCManager(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -1787,7 +1787,7 @@ def test_handle_trade_use_sell_signal(
|
||||
patch_RPCManager(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -1815,7 +1815,7 @@ def test_close_trade(default_conf, ticker, limit_buy_order, limit_sell_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -1843,7 +1843,7 @@ def test_check_handle_timedout_buy(default_conf, ticker, limit_buy_order_old, op
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_buy_order_old),
|
||||
cancel_order=cancel_order_mock,
|
||||
get_fee=fee
|
||||
@@ -1870,7 +1870,7 @@ def test_check_handle_cancelled_buy(default_conf, ticker, limit_buy_order_old, o
|
||||
limit_buy_order_old.update({"status": "canceled"})
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_buy_order_old),
|
||||
cancel_order=cancel_order_mock,
|
||||
get_fee=fee
|
||||
@@ -1897,7 +1897,7 @@ def test_check_handle_timedout_buy_exception(default_conf, ticker, limit_buy_ord
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
validate_pairs=MagicMock(),
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(side_effect=DependencyException),
|
||||
cancel_order=cancel_order_mock,
|
||||
get_fee=fee
|
||||
@@ -1922,7 +1922,7 @@ def test_check_handle_timedout_sell(default_conf, ticker, limit_sell_order_old,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_sell_order_old),
|
||||
cancel_order=cancel_order_mock
|
||||
)
|
||||
@@ -1950,7 +1950,7 @@ def test_check_handle_cancelled_sell(default_conf, ticker, limit_sell_order_old,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_sell_order_old),
|
||||
cancel_order=cancel_order_mock
|
||||
)
|
||||
@@ -1977,7 +1977,7 @@ def test_check_handle_timedout_partial(default_conf, ticker, limit_buy_order_old
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_buy_order_old_partial),
|
||||
cancel_order=cancel_order_mock
|
||||
)
|
||||
@@ -2004,7 +2004,7 @@ def test_check_handle_timedout_partial_fee(default_conf, ticker, open_trade, cap
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_buy_order_old_partial),
|
||||
cancel_order=cancel_order_mock,
|
||||
get_trades_for_order=MagicMock(return_value=trades_for_order),
|
||||
@@ -2041,7 +2041,7 @@ def test_check_handle_timedout_partial_except(default_conf, ticker, open_trade,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(return_value=limit_buy_order_old_partial),
|
||||
cancel_order=cancel_order_mock,
|
||||
get_trades_for_order=MagicMock(return_value=trades_for_order),
|
||||
@@ -2085,7 +2085,7 @@ def test_check_handle_timedout_exception(default_conf, ticker, open_trade, mocke
|
||||
)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_order=MagicMock(side_effect=requests.exceptions.RequestException('Oh snap')),
|
||||
cancel_order=cancel_order_mock
|
||||
)
|
||||
@@ -2175,7 +2175,7 @@ def test_execute_sell_up(default_conf, ticker, fee, ticker_sell_up, mocker) -> N
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
patch_whitelist(mocker, default_conf)
|
||||
@@ -2191,7 +2191,7 @@ def test_execute_sell_up(default_conf, ticker, fee, ticker_sell_up, mocker) -> N
|
||||
# Increase the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_up
|
||||
fetch_ticker=ticker_sell_up
|
||||
)
|
||||
|
||||
freqtrade.execute_sell(trade=trade, limit=ticker_sell_up()['bid'], sell_reason=SellType.ROI)
|
||||
@@ -2223,7 +2223,7 @@ def test_execute_sell_down(default_conf, ticker, fee, ticker_sell_down, mocker)
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
patch_whitelist(mocker, default_conf)
|
||||
@@ -2239,7 +2239,7 @@ def test_execute_sell_down(default_conf, ticker, fee, ticker_sell_down, mocker)
|
||||
# Decrease the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_down
|
||||
fetch_ticker=ticker_sell_down
|
||||
)
|
||||
|
||||
freqtrade.execute_sell(trade=trade, limit=ticker_sell_down()['bid'],
|
||||
@@ -2273,7 +2273,7 @@ def test_execute_sell_down_stoploss_on_exchange_dry_run(default_conf, ticker, fe
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
patch_whitelist(mocker, default_conf)
|
||||
@@ -2289,7 +2289,7 @@ def test_execute_sell_down_stoploss_on_exchange_dry_run(default_conf, ticker, fe
|
||||
# Decrease the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_down
|
||||
fetch_ticker=ticker_sell_down
|
||||
)
|
||||
|
||||
default_conf['dry_run'] = True
|
||||
@@ -2332,7 +2332,7 @@ def test_execute_sell_sloe_cancel_exception(mocker, default_conf, ticker, fee, c
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
sell=sellmock
|
||||
)
|
||||
@@ -2369,7 +2369,7 @@ def test_execute_sell_with_stoploss_on_exchange(default_conf, ticker, fee, ticke
|
||||
cancel_order = MagicMock(return_value=True)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
symbol_amount_prec=lambda s, x, y: y,
|
||||
symbol_price_prec=lambda s, x, y: y,
|
||||
@@ -2393,7 +2393,7 @@ def test_execute_sell_with_stoploss_on_exchange(default_conf, ticker, fee, ticke
|
||||
# Increase the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_up
|
||||
fetch_ticker=ticker_sell_up
|
||||
)
|
||||
|
||||
freqtrade.execute_sell(trade=trade, limit=ticker_sell_up()['bid'],
|
||||
@@ -2412,7 +2412,7 @@ def test_may_execute_sell_after_stoploss_on_exchange_hit(default_conf, ticker, f
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
symbol_amount_prec=lambda s, x, y: y,
|
||||
symbol_price_prec=lambda s, x, y: y,
|
||||
@@ -2476,7 +2476,7 @@ def test_execute_sell_market_order(default_conf, ticker, fee,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
patch_whitelist(mocker, default_conf)
|
||||
@@ -2492,7 +2492,7 @@ def test_execute_sell_market_order(default_conf, ticker, fee,
|
||||
# Increase the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_up
|
||||
fetch_ticker=ticker_sell_up
|
||||
)
|
||||
freqtrade.config['order_types']['sell'] = 'market'
|
||||
|
||||
@@ -2530,7 +2530,7 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00002172,
|
||||
'ask': 0.00002173,
|
||||
'last': 0.00002172
|
||||
@@ -2562,7 +2562,7 @@ def test_sell_profit_only_disable_profit(default_conf, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00002172,
|
||||
'ask': 0.00002173,
|
||||
'last': 0.00002172
|
||||
@@ -2592,7 +2592,7 @@ def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, fee, mocker
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00000172,
|
||||
'ask': 0.00000173,
|
||||
'last': 0.00000172
|
||||
@@ -2621,7 +2621,7 @@ def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, fee, mocke
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.0000172,
|
||||
'ask': 0.0000173,
|
||||
'last': 0.0000172
|
||||
@@ -2654,7 +2654,7 @@ def test_sell_not_enough_balance(default_conf, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00002172,
|
||||
'ask': 0.00002173,
|
||||
'last': 0.00002172
|
||||
@@ -2728,7 +2728,7 @@ def test_locked_pairs(default_conf, ticker, fee, ticker_sell_down, mocker, caplo
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
)
|
||||
freqtrade = FreqtradeBot(default_conf)
|
||||
@@ -2743,7 +2743,7 @@ def test_locked_pairs(default_conf, ticker, fee, ticker_sell_down, mocker, caplo
|
||||
# Decrease the price and sell it
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker_sell_down
|
||||
fetch_ticker=ticker_sell_down
|
||||
)
|
||||
|
||||
freqtrade.execute_sell(trade=trade, limit=ticker_sell_down()['bid'],
|
||||
@@ -2764,7 +2764,7 @@ def test_ignore_roi_if_buy_signal(default_conf, limit_buy_order, fee, mocker) ->
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.0000172,
|
||||
'ask': 0.0000173,
|
||||
'last': 0.0000172
|
||||
@@ -2798,7 +2798,7 @@ def test_trailing_stop_loss(default_conf, limit_buy_order, fee, caplog, mocker)
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001099,
|
||||
'ask': 0.00001099,
|
||||
'last': 0.00001099
|
||||
@@ -2817,7 +2817,7 @@ def test_trailing_stop_loss(default_conf, limit_buy_order, fee, caplog, mocker)
|
||||
assert freqtrade.handle_trade(trade) is False
|
||||
|
||||
# Raise ticker above buy price
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': 0.00001099 * 1.5,
|
||||
'ask': 0.00001099 * 1.5,
|
||||
@@ -2828,7 +2828,7 @@ def test_trailing_stop_loss(default_conf, limit_buy_order, fee, caplog, mocker)
|
||||
assert freqtrade.handle_trade(trade) is False
|
||||
|
||||
# Price fell
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': 0.00001099 * 1.1,
|
||||
'ask': 0.00001099 * 1.1,
|
||||
@@ -2852,7 +2852,7 @@ def test_trailing_stop_loss_positive(default_conf, limit_buy_order, fee,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': buy_price - 0.000001,
|
||||
'ask': buy_price - 0.000001,
|
||||
'last': buy_price - 0.000001
|
||||
@@ -2876,7 +2876,7 @@ def test_trailing_stop_loss_positive(default_conf, limit_buy_order, fee,
|
||||
assert freqtrade.handle_trade(trade) is False
|
||||
|
||||
# Raise ticker above buy price
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': buy_price + 0.000003,
|
||||
'ask': buy_price + 0.000003,
|
||||
@@ -2888,7 +2888,7 @@ def test_trailing_stop_loss_positive(default_conf, limit_buy_order, fee,
|
||||
assert log_has(f"ETH/BTC - Adjusting stoploss...", caplog)
|
||||
assert trade.stop_loss == 0.0000138501
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': buy_price + 0.000002,
|
||||
'ask': buy_price + 0.000002,
|
||||
@@ -2909,7 +2909,7 @@ def test_trailing_stop_loss_offset(default_conf, limit_buy_order, fee,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': buy_price - 0.000001,
|
||||
'ask': buy_price - 0.000001,
|
||||
'last': buy_price - 0.000001
|
||||
@@ -2933,7 +2933,7 @@ def test_trailing_stop_loss_offset(default_conf, limit_buy_order, fee,
|
||||
assert freqtrade.handle_trade(trade) is False
|
||||
|
||||
# Raise ticker above buy price
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': buy_price + 0.000003,
|
||||
'ask': buy_price + 0.000003,
|
||||
@@ -2946,7 +2946,7 @@ def test_trailing_stop_loss_offset(default_conf, limit_buy_order, fee,
|
||||
assert log_has(f"ETH/BTC - Adjusting stoploss...", caplog)
|
||||
assert trade.stop_loss == 0.0000138501
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': buy_price + 0.000002,
|
||||
'ask': buy_price + 0.000002,
|
||||
@@ -2970,7 +2970,7 @@ def test_tsl_only_offset_reached(default_conf, limit_buy_order, fee,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': buy_price,
|
||||
'ask': buy_price,
|
||||
'last': buy_price
|
||||
@@ -2997,7 +2997,7 @@ def test_tsl_only_offset_reached(default_conf, limit_buy_order, fee,
|
||||
assert trade.stop_loss == 0.0000098910
|
||||
|
||||
# Raise ticker above buy price
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': buy_price + 0.0000004,
|
||||
'ask': buy_price + 0.0000004,
|
||||
@@ -3011,7 +3011,7 @@ def test_tsl_only_offset_reached(default_conf, limit_buy_order, fee,
|
||||
assert trade.stop_loss == 0.0000098910
|
||||
|
||||
# price rises above the offset (rises 12% when the offset is 5.5%)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker',
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
MagicMock(return_value={
|
||||
'bid': buy_price + 0.0000014,
|
||||
'ask': buy_price + 0.0000014,
|
||||
@@ -3031,7 +3031,7 @@ def test_disable_ignore_roi_if_buy_signal(default_conf, limit_buy_order,
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00000172,
|
||||
'ask': 0.00000173,
|
||||
'last': 0.00000172
|
||||
@@ -3368,7 +3368,7 @@ def test_order_book_depth_of_market(default_conf, ticker, limit_buy_order, fee,
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_order_book', order_book_l2)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -3405,7 +3405,7 @@ def test_order_book_depth_of_market_high_delta(default_conf, ticker, limit_buy_o
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_order_book', order_book_l2)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
@@ -3428,7 +3428,7 @@ def test_order_book_bid_strategy1(mocker, default_conf, order_book_l2) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_order_book=order_book_l2,
|
||||
get_ticker=ticker_mock,
|
||||
fetch_ticker=ticker_mock,
|
||||
|
||||
)
|
||||
default_conf['exchange']['name'] = 'binance'
|
||||
@@ -3452,7 +3452,7 @@ def test_order_book_bid_strategy2(mocker, default_conf, order_book_l2) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_order_book=order_book_l2,
|
||||
get_ticker=ticker_mock,
|
||||
fetch_ticker=ticker_mock,
|
||||
|
||||
)
|
||||
default_conf['exchange']['name'] = 'binance'
|
||||
@@ -3502,7 +3502,7 @@ def test_order_book_ask_strategy(default_conf, limit_buy_order, limit_sell_order
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=MagicMock(return_value={
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
@@ -3533,7 +3533,7 @@ def test_get_sell_rate(default_conf, mocker, ticker, order_book_l2) -> None:
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_order_book=order_book_l2,
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
)
|
||||
pair = "ETH/BTC"
|
||||
|
||||
@@ -3612,7 +3612,7 @@ def test_sync_wallet_dry_run(mocker, default_conf, ticker, fee, limit_buy_order)
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
|
@@ -55,7 +55,7 @@ def test_may_execute_sell_stoploss_on_exchange_multi(default_conf, ticker, fee,
|
||||
mocker.patch('freqtrade.exchange.Binance.stoploss_limit', stoploss_limit)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
symbol_amount_prec=lambda s, x, y: y,
|
||||
symbol_price_prec=lambda s, x, y: y,
|
||||
@@ -118,15 +118,13 @@ def test_forcebuy_last_unlimited(default_conf, ticker, fee, limit_buy_order, moc
|
||||
default_conf['max_open_trades'] = 5
|
||||
default_conf['forcebuy_enable'] = True
|
||||
default_conf['stake_amount'] = 'unlimited'
|
||||
default_conf['dry_run_wallet'] = 1000
|
||||
default_conf['exchange']['name'] = 'binance'
|
||||
default_conf['telegram']['enabled'] = True
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch('freqtrade.wallets.Wallets.get_free', MagicMock(
|
||||
side_effect=[1000, 800, 600, 400, 200]
|
||||
))
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
fetch_ticker=ticker,
|
||||
get_fee=fee,
|
||||
symbol_amount_prec=lambda s, x, y: y,
|
||||
symbol_price_prec=lambda s, x, y: y,
|
||||
@@ -138,6 +136,14 @@ def test_forcebuy_last_unlimited(default_conf, ticker, fee, limit_buy_order, moc
|
||||
update_trade_state=MagicMock(),
|
||||
_notify_sell=MagicMock(),
|
||||
)
|
||||
should_sell_mock = MagicMock(side_effect=[
|
||||
SellCheckTuple(sell_flag=False, sell_type=SellType.NONE),
|
||||
SellCheckTuple(sell_flag=True, sell_type=SellType.SELL_SIGNAL),
|
||||
SellCheckTuple(sell_flag=False, sell_type=SellType.NONE),
|
||||
SellCheckTuple(sell_flag=False, sell_type=SellType.NONE),
|
||||
SellCheckTuple(sell_flag=None, sell_type=SellType.NONE)]
|
||||
)
|
||||
mocker.patch("freqtrade.strategy.interface.IStrategy.should_sell", should_sell_mock)
|
||||
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
rpc = RPC(freqtrade)
|
||||
@@ -158,3 +164,20 @@ def test_forcebuy_last_unlimited(default_conf, ticker, fee, limit_buy_order, moc
|
||||
|
||||
for trade in trades:
|
||||
assert trade.stake_amount == 200
|
||||
# Reset trade open order id's
|
||||
trade.open_order_id = None
|
||||
trades = Trade.get_open_trades()
|
||||
assert len(trades) == 5
|
||||
bals = freqtrade.wallets.get_all_balances()
|
||||
|
||||
freqtrade.process_maybe_execute_sells(trades)
|
||||
trades = Trade.get_open_trades()
|
||||
# One trade sold
|
||||
assert len(trades) == 4
|
||||
# Validate that balance of sold trade is not in dry-run balances anymore.
|
||||
bals2 = freqtrade.wallets.get_all_balances()
|
||||
assert bals != bals2
|
||||
assert len(bals) == 6
|
||||
assert len(bals2) == 5
|
||||
assert 'LTC' in bals
|
||||
assert 'LTC' not in bals2
|
||||
|
@@ -100,7 +100,7 @@ def test_init_dryrun_db(default_conf, mocker):
|
||||
|
||||
init(default_conf['db_url'], default_conf['dry_run'])
|
||||
assert create_engine_mock.call_count == 1
|
||||
assert create_engine_mock.mock_calls[0][1][0] == 'sqlite://'
|
||||
assert create_engine_mock.mock_calls[0][1][0] == 'sqlite:///tradesv3.dryrun.sqlite'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
|
Reference in New Issue
Block a user