mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-16 21:01:14 +00:00
Rename class and tests
This commit is contained in:
@@ -20,7 +20,7 @@ from freqtrade.exchange.exchange_utils import (ROUND_DOWN, ROUND_UP, amount_to_c
|
|||||||
timeframe_to_seconds, validate_exchange)
|
timeframe_to_seconds, validate_exchange)
|
||||||
from freqtrade.exchange.gate import Gate
|
from freqtrade.exchange.gate import Gate
|
||||||
from freqtrade.exchange.hitbtc import Hitbtc
|
from freqtrade.exchange.hitbtc import Hitbtc
|
||||||
from freqtrade.exchange.huobi import Huobi
|
from freqtrade.exchange.htx import Htx
|
||||||
from freqtrade.exchange.kraken import Kraken
|
from freqtrade.exchange.kraken import Kraken
|
||||||
from freqtrade.exchange.kucoin import Kucoin
|
from freqtrade.exchange.kucoin import Kucoin
|
||||||
from freqtrade.exchange.okx import Okx
|
from freqtrade.exchange.okx import Okx
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
""" Huobi exchange subclass """
|
""" HTX exchange subclass """
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
@@ -9,9 +9,9 @@ from freqtrade.exchange import Exchange
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Huobi(Exchange):
|
class Htx(Exchange):
|
||||||
"""
|
"""
|
||||||
Huobi exchange class. Contains adjustments needed for Freqtrade to work
|
HTX exchange class. Contains adjustments needed for Freqtrade to work
|
||||||
with this exchange.
|
with this exchange.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ from tests.exchange.test_exchange import ccxt_exceptionhandlers
|
|||||||
(0.99, 220 * 0.99, "sell"),
|
(0.99, 220 * 0.99, "sell"),
|
||||||
(0.98, 220 * 0.98, "sell"),
|
(0.98, 220 * 0.98, "sell"),
|
||||||
])
|
])
|
||||||
def test_create_stoploss_order_huobi(default_conf, mocker, limitratio, expected, side):
|
def test_create_stoploss_order_htx(default_conf, mocker, limitratio, expected, side):
|
||||||
api_mock = MagicMock()
|
api_mock = MagicMock()
|
||||||
order_id = f'test_prod_buy_{randint(0, 10 ** 6)}'
|
order_id = f'test_prod_buy_{randint(0, 10 ** 6)}'
|
||||||
order_type = 'stop-limit'
|
order_type = 'stop-limit'
|
||||||
@@ -29,7 +29,7 @@ def test_create_stoploss_order_huobi(default_conf, mocker, limitratio, expected,
|
|||||||
mocker.patch(f'{EXMS}.amount_to_precision', lambda s, x, y: y)
|
mocker.patch(f'{EXMS}.amount_to_precision', lambda s, x, y: y)
|
||||||
mocker.patch(f'{EXMS}.price_to_precision', lambda s, x, y, **kwargs: y)
|
mocker.patch(f'{EXMS}.price_to_precision', lambda s, x, y, **kwargs: y)
|
||||||
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'huobi')
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'htx')
|
||||||
|
|
||||||
with pytest.raises(InvalidOrderException):
|
with pytest.raises(InvalidOrderException):
|
||||||
order = exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=190,
|
order = exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=190,
|
||||||
@@ -58,7 +58,7 @@ def test_create_stoploss_order_huobi(default_conf, mocker, limitratio, expected,
|
|||||||
# test exception handling
|
# test exception handling
|
||||||
with pytest.raises(DependencyException):
|
with pytest.raises(DependencyException):
|
||||||
api_mock.create_order = MagicMock(side_effect=ccxt.InsufficientFunds("0 balance"))
|
api_mock.create_order = MagicMock(side_effect=ccxt.InsufficientFunds("0 balance"))
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'huobi')
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'htx')
|
||||||
exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=220,
|
exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=220,
|
||||||
order_types={}, side=side, leverage=1.0)
|
order_types={}, side=side, leverage=1.0)
|
||||||
|
|
||||||
@@ -69,20 +69,20 @@ def test_create_stoploss_order_huobi(default_conf, mocker, limitratio, expected,
|
|||||||
exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=220,
|
exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=220,
|
||||||
order_types={}, side=side, leverage=1.0)
|
order_types={}, side=side, leverage=1.0)
|
||||||
|
|
||||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock, "huobi",
|
ccxt_exceptionhandlers(mocker, default_conf, api_mock, "htx",
|
||||||
"create_stoploss", "create_order", retries=1,
|
"create_stoploss", "create_order", retries=1,
|
||||||
pair='ETH/BTC', amount=1, stop_price=220, order_types={},
|
pair='ETH/BTC', amount=1, stop_price=220, order_types={},
|
||||||
side=side, leverage=1.0)
|
side=side, leverage=1.0)
|
||||||
|
|
||||||
|
|
||||||
def test_create_stoploss_order_dry_run_huobi(default_conf, mocker):
|
def test_create_stoploss_order_dry_run_htx(default_conf, mocker):
|
||||||
api_mock = MagicMock()
|
api_mock = MagicMock()
|
||||||
order_type = 'stop-limit'
|
order_type = 'stop-limit'
|
||||||
default_conf['dry_run'] = True
|
default_conf['dry_run'] = True
|
||||||
mocker.patch(f'{EXMS}.amount_to_precision', lambda s, x, y: y)
|
mocker.patch(f'{EXMS}.amount_to_precision', lambda s, x, y: y)
|
||||||
mocker.patch(f'{EXMS}.price_to_precision', lambda s, x, y, **kwargs: y)
|
mocker.patch(f'{EXMS}.price_to_precision', lambda s, x, y, **kwargs: y)
|
||||||
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'huobi')
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'htx')
|
||||||
|
|
||||||
with pytest.raises(InvalidOrderException):
|
with pytest.raises(InvalidOrderException):
|
||||||
order = exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=190,
|
order = exchange.create_stoploss(pair='ETH/BTC', amount=1, stop_price=190,
|
||||||
@@ -103,8 +103,8 @@ def test_create_stoploss_order_dry_run_huobi(default_conf, mocker):
|
|||||||
assert order['amount'] == 1
|
assert order['amount'] == 1
|
||||||
|
|
||||||
|
|
||||||
def test_stoploss_adjust_huobi(mocker, default_conf):
|
def test_stoploss_adjust_htx(mocker, default_conf):
|
||||||
exchange = get_patched_exchange(mocker, default_conf, id='huobi')
|
exchange = get_patched_exchange(mocker, default_conf, id='htx')
|
||||||
order = {
|
order = {
|
||||||
'type': 'stop',
|
'type': 'stop',
|
||||||
'price': 1500,
|
'price': 1500,
|
||||||
Reference in New Issue
Block a user