Merge branch 'develop' into feat/short
This commit is contained in:
@@ -605,16 +605,33 @@ def test_get_ui_download_url(mocker):
|
||||
def test_get_ui_download_url_direct(mocker):
|
||||
response = MagicMock()
|
||||
response.json = MagicMock(
|
||||
side_effect=[[{
|
||||
'assets_url': 'http://whatever.json',
|
||||
'name': '0.0.1',
|
||||
'assets': [{'browser_download_url': 'http://download11.zip'}]}]])
|
||||
return_value=[
|
||||
{
|
||||
'assets_url': 'http://whatever.json',
|
||||
'name': '0.0.2',
|
||||
'assets': [{'browser_download_url': 'http://download22.zip'}]
|
||||
},
|
||||
{
|
||||
'assets_url': 'http://whatever.json',
|
||||
'name': '0.0.1',
|
||||
'assets': [{'browser_download_url': 'http://download1.zip'}]
|
||||
},
|
||||
])
|
||||
get_mock = mocker.patch("freqtrade.commands.deploy_commands.requests.get",
|
||||
return_value=response)
|
||||
x, last_version = get_ui_download_url()
|
||||
assert get_mock.call_count == 1
|
||||
assert last_version == '0.0.2'
|
||||
assert x == 'http://download22.zip'
|
||||
get_mock.reset_mock()
|
||||
response.json.reset_mock()
|
||||
|
||||
x, last_version = get_ui_download_url('0.0.1')
|
||||
assert last_version == '0.0.1'
|
||||
assert x == 'http://download11.zip'
|
||||
assert x == 'http://download1.zip'
|
||||
|
||||
with pytest.raises(ValueError, match="UI-Version not found."):
|
||||
x, last_version = get_ui_download_url('0.0.3')
|
||||
|
||||
|
||||
def test_download_data_keyboardInterrupt(mocker, caplog, markets):
|
||||
|
@@ -277,6 +277,7 @@ def test_amount_to_precision(default_conf, mocker, amount, precision_mode, preci
|
||||
(234.43, 4, 0.5, 234.5),
|
||||
(234.53, 4, 0.5, 235.0),
|
||||
(0.891534, 4, 0.0001, 0.8916),
|
||||
(64968.89, 4, 0.01, 64968.89),
|
||||
|
||||
])
|
||||
def test_price_to_precision(default_conf, mocker, price, precision_mode, precision, expected):
|
||||
@@ -295,7 +296,7 @@ def test_price_to_precision(default_conf, mocker, price, precision_mode, precisi
|
||||
PropertyMock(return_value=precision_mode))
|
||||
|
||||
pair = 'ETH/BTC'
|
||||
assert pytest.approx(exchange.price_to_precision(pair, price)) == expected
|
||||
assert exchange.price_to_precision(pair, price) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("price,precision_mode,precision,expected", [
|
||||
@@ -1895,6 +1896,7 @@ def test_fetch_l2_order_book_exception(default_conf, mocker, exchange_name):
|
||||
('ask', 20, 19, 10, 0.3, 17), # Between ask and last
|
||||
('ask', 5, 6, 10, 1.0, 5), # last bigger than ask
|
||||
('ask', 5, 6, 10, 0.5, 5), # last bigger than ask
|
||||
('ask', 20, 19, 10, None, 20), # ask_last_balance missing
|
||||
('ask', 10, 20, None, 0.5, 10), # last not available - uses ask
|
||||
('ask', 4, 5, None, 0.5, 4), # last not available - uses ask
|
||||
('ask', 4, 5, None, 1, 4), # last not available - uses ask
|
||||
@@ -1905,6 +1907,7 @@ def test_fetch_l2_order_book_exception(default_conf, mocker, exchange_name):
|
||||
('bid', 21, 20, 10, 0.7, 13), # Between bid and last
|
||||
('bid', 21, 20, 10, 0.3, 17), # Between bid and last
|
||||
('bid', 6, 5, 10, 1.0, 5), # last bigger than bid
|
||||
('bid', 21, 20, 10, None, 20), # ask_last_balance missing
|
||||
('bid', 6, 5, 10, 0.5, 5), # last bigger than bid
|
||||
('bid', 21, 20, None, 0.5, 20), # last not available - uses bid
|
||||
('bid', 6, 5, None, 0.5, 5), # last not available - uses bid
|
||||
@@ -1914,7 +1917,10 @@ def test_fetch_l2_order_book_exception(default_conf, mocker, exchange_name):
|
||||
def test_get_buy_rate(mocker, default_conf, caplog, side, ask, bid,
|
||||
last, last_ab, expected) -> None:
|
||||
caplog.set_level(logging.DEBUG)
|
||||
default_conf['bid_strategy']['ask_last_balance'] = last_ab
|
||||
if last_ab is None:
|
||||
del default_conf['bid_strategy']['ask_last_balance']
|
||||
else:
|
||||
default_conf['bid_strategy']['ask_last_balance'] = last_ab
|
||||
default_conf['bid_strategy']['price_side'] = side
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
@@ -1939,6 +1945,7 @@ def test_get_buy_rate(mocker, default_conf, caplog, side, ask, bid,
|
||||
('bid', 12.0, 11.2, 10.5, 1.0, 11.2), # Last smaller than bid - uses bid
|
||||
('bid', 12.0, 11.2, 10.5, 0.5, 11.2), # Last smaller than bid - uses bid
|
||||
('bid', 0.003, 0.002, 0.005, 0.0, 0.002),
|
||||
('bid', 0.003, 0.002, 0.005, None, 0.002),
|
||||
('ask', 12.0, 11.0, 12.5, 0.0, 12.0), # full ask side
|
||||
('ask', 12.0, 11.0, 12.5, 1.0, 12.5), # full last side
|
||||
('ask', 12.0, 11.0, 12.5, 0.5, 12.25), # between bid and lat
|
||||
@@ -1949,13 +1956,15 @@ def test_get_buy_rate(mocker, default_conf, caplog, side, ask, bid,
|
||||
('ask', 10.11, 11.2, 11.0, 0.0, 10.11),
|
||||
('ask', 0.001, 0.002, 11.0, 0.0, 0.001),
|
||||
('ask', 0.006, 1.0, 11.0, 0.0, 0.006),
|
||||
('ask', 0.006, 1.0, 11.0, None, 0.006),
|
||||
])
|
||||
def test_get_sell_rate(default_conf, mocker, caplog, side, bid, ask,
|
||||
last, last_ab, expected) -> None:
|
||||
caplog.set_level(logging.DEBUG)
|
||||
|
||||
default_conf['ask_strategy']['price_side'] = side
|
||||
default_conf['ask_strategy']['bid_last_balance'] = last_ab
|
||||
if last_ab is not None:
|
||||
default_conf['ask_strategy']['bid_last_balance'] = last_ab
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||
return_value={'ask': ask, 'bid': bid, 'last': last})
|
||||
pair = "ETH/BTC"
|
||||
|
28
tests/exchange/test_gateio.py
Normal file
28
tests/exchange/test_gateio.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.exchange import Gateio
|
||||
from freqtrade.resolvers.exchange_resolver import ExchangeResolver
|
||||
|
||||
|
||||
def test_validate_order_types_gateio(default_conf, mocker):
|
||||
default_conf['exchange']['name'] = 'gateio'
|
||||
mocker.patch('freqtrade.exchange.Exchange._init_ccxt')
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_markets', return_value={})
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_pairs')
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
|
||||
mocker.patch('freqtrade.exchange.Exchange.name', 'Bittrex')
|
||||
exch = ExchangeResolver.load_exchange('gateio', default_conf, True)
|
||||
assert isinstance(exch, Gateio)
|
||||
|
||||
default_conf['order_types'] = {
|
||||
'buy': 'market',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
with pytest.raises(OperationalException,
|
||||
match=r'Exchange .* does not support market orders.'):
|
||||
ExchangeResolver.load_exchange('gateio', default_conf, True)
|
@@ -84,13 +84,14 @@ def test_loss_calculation_has_limited_profit(hyperopt_conf, hyperopt_results) ->
|
||||
"SortinoHyperOptLossDaily",
|
||||
"SharpeHyperOptLoss",
|
||||
"SharpeHyperOptLossDaily",
|
||||
"MaxDrawDownHyperOptLoss",
|
||||
])
|
||||
def test_loss_functions_better_profits(default_conf, hyperopt_results, lossfunction) -> None:
|
||||
results_over = hyperopt_results.copy()
|
||||
results_over['profit_abs'] = hyperopt_results['profit_abs'] * 2
|
||||
results_over['profit_abs'] = hyperopt_results['profit_abs'] * 2 + 0.2
|
||||
results_over['profit_ratio'] = hyperopt_results['profit_ratio'] * 2
|
||||
results_under = hyperopt_results.copy()
|
||||
results_under['profit_abs'] = hyperopt_results['profit_abs'] / 2
|
||||
results_under['profit_abs'] = hyperopt_results['profit_abs'] / 2 - 0.2
|
||||
results_under['profit_ratio'] = hyperopt_results['profit_ratio'] / 2
|
||||
|
||||
default_conf.update({'hyperopt_loss': lossfunction})
|
||||
|
@@ -1272,6 +1272,16 @@ def test_list_available_pairs(botclient):
|
||||
assert len(rc.json()['pair_interval']) == 1
|
||||
|
||||
|
||||
def test_sysinfo(botclient):
|
||||
ftbot, client = botclient
|
||||
|
||||
rc = client_get(client, f"{BASE_URI}/sysinfo")
|
||||
assert_response(rc)
|
||||
result = rc.json()
|
||||
assert 'cpu_pct' in result
|
||||
assert 'ram_pct' in result
|
||||
|
||||
|
||||
def test_api_backtesting(botclient, mocker, fee, caplog):
|
||||
ftbot, client = botclient
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
|
||||
|
Reference in New Issue
Block a user