replace pymarketcap with coinmarketcap (#562)

* replace pymarketcap with coinmarketcap

* fix tests to use coinmarketcap instead of pymarketcap

* use arraypos 0

* update setup.py from pymarketcap to coinmarketcap

* Add test to check for unsupported Crypto currency
This commit is contained in:
Matthias 2018-03-18 00:42:24 +01:00 committed by gcarq
parent 94caf82ab2
commit b67257db35
9 changed files with 97 additions and 89 deletions

View File

@ -5,7 +5,7 @@ e.g BTC to USD
import logging
import time
from pymarketcap import Pymarketcap
from coinmarketcap import Market
logger = logging.getLogger(__name__)
@ -72,11 +72,17 @@ class CryptoToFiatConverter(object):
"RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR", "USD"
]
CRYPTOMAP = {
'BTC': 'bitcoin',
'ETH': 'ethereum',
'USDT': 'thether'
}
def __new__(cls):
if CryptoToFiatConverter.__instance is None:
CryptoToFiatConverter.__instance = object.__new__(cls)
try:
CryptoToFiatConverter._coinmarketcap = Pymarketcap()
CryptoToFiatConverter._coinmarketcap = Market()
except BaseException:
CryptoToFiatConverter._coinmarketcap = None
return CryptoToFiatConverter.__instance
@ -171,12 +177,16 @@ class CryptoToFiatConverter(object):
# Check if the fiat convertion you want is supported
if not self._is_supported_fiat(fiat=fiat_symbol):
raise ValueError('The fiat {} is not supported.'.format(fiat_symbol))
if crypto_symbol not in self.CRYPTOMAP:
raise ValueError(
'The crypto symbol {} is not supported.'.format(crypto_symbol))
try:
return float(
self._coinmarketcap.ticker(
currency=crypto_symbol,
currency=self.CRYPTOMAP[crypto_symbol],
convert=fiat_symbol
)['price_' + fiat_symbol.lower()]
)[0]['price_' + fiat_symbol.lower()]
)
except BaseException:
return 0.0

View File

@ -33,7 +33,7 @@ def get_patched_freqtradebot(mocker, config) -> FreqtradeBot:
:param config: Config to pass to the bot
:return: None
"""
mocker.patch('freqtrade.fiat_convert.Pymarketcap', {'price_usd': 12345.0})
mocker.patch('freqtrade.fiat_convert.Market', {'price_usd': 12345.0})
mocker.patch('freqtrade.freqtradebot.Analyze', MagicMock())
mocker.patch('freqtrade.freqtradebot.RPCManager', MagicMock())
mocker.patch('freqtrade.freqtradebot.persistence.init', MagicMock())

View File

@ -13,7 +13,7 @@ from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.persistence import Trade
from freqtrade.rpc.rpc import RPC
from freqtrade.state import State
from freqtrade.tests.test_freqtradebot import patch_get_signal, patch_pymarketcap
from freqtrade.tests.test_freqtradebot import patch_get_signal, patch_coinmarketcap
# Functions for recurrent object patching
@ -30,7 +30,7 @@ def test_rpc_trade_status(default_conf, ticker, mocker) -> None:
Test rpc_trade_status() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -78,7 +78,7 @@ def test_rpc_status_table(default_conf, ticker, mocker) -> None:
Test rpc_status_table() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -112,7 +112,7 @@ def test_rpc_daily_profit(default_conf, update, ticker, limit_buy_order, limit_s
Test rpc_daily_profit() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -165,9 +165,8 @@ def test_rpc_trade_statistics(
"""
patch_get_signal(mocker, (True, False))
mocker.patch.multiple(
'freqtrade.fiat_convert.Pymarketcap',
'freqtrade.fiat_convert.Market',
ticker=MagicMock(return_value={'price_usd': 15000.0}),
_cache_symbols=MagicMock(return_value={'BTC': 1})
)
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
@ -228,9 +227,8 @@ def test_rpc_trade_statistics_closed(mocker, default_conf, ticker, ticker_sell_u
"""
patch_get_signal(mocker, (True, False))
mocker.patch.multiple(
'freqtrade.fiat_convert.Pymarketcap',
'freqtrade.fiat_convert.Market',
ticker=MagicMock(return_value={'price_usd': 15000.0}),
_cache_symbols=MagicMock(return_value={'BTC': 1})
)
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
@ -303,9 +301,8 @@ def test_rpc_balance_handle(default_conf, mocker):
patch_get_signal(mocker, (True, False))
mocker.patch.multiple(
'freqtrade.fiat_convert.Pymarketcap',
'freqtrade.fiat_convert.Market',
ticker=MagicMock(return_value={'price_usd': 15000.0}),
_cache_symbols=MagicMock(return_value={'BTC': 1})
)
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
@ -337,7 +334,7 @@ def test_rpc_start(mocker, default_conf) -> None:
Test rpc_start() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -365,7 +362,7 @@ def test_rpc_stop(mocker, default_conf) -> None:
Test rpc_stop() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -393,7 +390,7 @@ def test_rpc_forcesell(default_conf, ticker, mocker) -> None:
Test rpc_forcesell() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
cancel_order_mock = MagicMock()
@ -484,7 +481,7 @@ def test_performance_handle(default_conf, ticker, limit_buy_order,
Test rpc_performance() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -522,7 +519,7 @@ def test_rpc_count(mocker, default_conf, ticker) -> None:
Test rpc_count() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.rpc.rpc_manager.Telegram', MagicMock())
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',

View File

@ -21,7 +21,7 @@ from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.rpc.telegram import Telegram
from freqtrade.persistence import Trade
from freqtrade.state import State
from freqtrade.tests.test_freqtradebot import patch_get_signal, patch_pymarketcap
from freqtrade.tests.test_freqtradebot import patch_get_signal, patch_coinmarketcap
from freqtrade.tests.conftest import get_patched_freqtradebot, log_has
@ -147,7 +147,7 @@ def test_authorized_only(default_conf, mocker, caplog) -> None:
Test authorized_only() method when we are authorized
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
chat = Chat(0, 0)
@ -178,7 +178,7 @@ def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> None:
Test authorized_only() method when we are unauthorized
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
chat = Chat(0xdeadbeef, 0)
@ -209,7 +209,7 @@ def test_authorized_only_exception(default_conf, mocker, caplog) -> None:
Test authorized_only() method when an exception is thrown
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
update = Update(randint(1, 100))
@ -244,7 +244,7 @@ def test_status(default_conf, update, mocker, ticker) -> None:
conf['telegram']['chat_id'] = 123
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -282,7 +282,7 @@ def test_status_handle(default_conf, update, ticker, mocker) -> None:
Test _status() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -327,7 +327,7 @@ def test_status_table_handle(default_conf, update, ticker, mocker) -> None:
Test _status_table() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -379,7 +379,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order,
Test _daily() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch(
'freqtrade.fiat_convert.CryptoToFiatConverter._find_price',
return_value=15000.0
@ -451,7 +451,7 @@ def test_daily_wrong_input(default_conf, update, ticker, mocker) -> None:
Test _daily() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -490,7 +490,7 @@ def test_profit_handle(default_conf, update, ticker, ticker_sell_up,
Test _profit() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -597,7 +597,7 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None:
}
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
mocker.patch('freqtrade.freqtradebot.exchange.get_balances', return_value=mock_balance)
mocker.patch('freqtrade.freqtradebot.exchange.get_ticker', side_effect=mock_ticker)
@ -628,7 +628,7 @@ def test_zero_balance_handle(default_conf, update, mocker) -> None:
Test _balance() method when the Exchange platform returns nothing
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
mocker.patch('freqtrade.freqtradebot.exchange.get_balances', return_value=[])
@ -652,7 +652,7 @@ def test_start_handle(default_conf, update, mocker) -> None:
"""
Test _start() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
msg_mock = MagicMock()
mocker.patch.multiple(
@ -676,7 +676,7 @@ def test_start_handle_already_running(default_conf, update, mocker) -> None:
"""
Test _start() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
msg_mock = MagicMock()
mocker.patch.multiple(
@ -701,7 +701,7 @@ def test_stop_handle(default_conf, update, mocker) -> None:
"""
Test _stop() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
msg_mock = MagicMock()
mocker.patch.multiple(
@ -726,7 +726,7 @@ def test_stop_handle_already_stopped(default_conf, update, mocker) -> None:
"""
Test _stop() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
msg_mock = MagicMock()
mocker.patch.multiple(
@ -752,7 +752,7 @@ def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker)
Test _forcesell() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock())
mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock())
@ -791,7 +791,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, ticker_sell_down, m
Test _forcesell() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock())
mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock())
@ -834,7 +834,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, mocker) -> None:
Test _forcesell() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock())
mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock())
@ -867,7 +867,7 @@ def test_forcesell_handle_invalid(default_conf, update, mocker) -> None:
Test _forcesell() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
msg_mock = MagicMock()
mocker.patch.multiple(
@ -910,7 +910,7 @@ def test_performance_handle(default_conf, update, ticker, limit_buy_order,
Test _performance() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
msg_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.rpc.telegram.Telegram',
@ -950,7 +950,7 @@ def test_performance_handle_invalid(default_conf, update, mocker) -> None:
Test _performance() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
msg_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.rpc.telegram.Telegram',
@ -973,7 +973,7 @@ def test_count_handle(default_conf, update, ticker, mocker) -> None:
Test _count() method
"""
patch_get_signal(mocker, (True, False))
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
msg_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.rpc.telegram.Telegram',
@ -1011,7 +1011,7 @@ def test_help_handle(default_conf, update, mocker) -> None:
"""
Test _help() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
msg_mock = MagicMock()
mocker.patch.multiple(
@ -1031,7 +1031,7 @@ def test_version_handle(default_conf, update, mocker) -> None:
"""
Test _version() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
msg_mock = MagicMock()
mocker.patch.multiple(
@ -1051,7 +1051,7 @@ def test_send_msg(default_conf, mocker) -> None:
"""
Test send_msg() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock())
conf = deepcopy(default_conf)
@ -1073,7 +1073,7 @@ def test_send_msg_network_error(default_conf, mocker, caplog) -> None:
"""
Test send_msg() method
"""
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock())
conf = deepcopy(default_conf)

View File

@ -71,12 +71,15 @@ def test_fiat_convert_find_price(mocker):
'price_usd': 12345.0,
'price_eur': 13000.2
})
mocker.patch('freqtrade.fiat_convert.Pymarketcap.ticker', api_mock)
mocker.patch('freqtrade.fiat_convert.Market.ticker', api_mock)
fiat_convert = CryptoToFiatConverter()
with pytest.raises(ValueError, match=r'The fiat ABC is not supported.'):
fiat_convert._find_price(crypto_symbol='BTC', fiat_symbol='ABC')
with pytest.raises(ValueError, match=r'The crypto symbol XRP is not supported.'):
fiat_convert.get_price(crypto_symbol='XRP', fiat_symbol='USD')
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=12345.0)
assert fiat_convert.get_price(crypto_symbol='BTC', fiat_symbol='USD') == 12345.0
assert fiat_convert.get_price(crypto_symbol='btc', fiat_symbol='usd') == 12345.0
@ -90,7 +93,7 @@ def test_fiat_convert_get_price(mocker):
'price_usd': 28000.0,
'price_eur': 15000.0
})
mocker.patch('freqtrade.fiat_convert.Pymarketcap.ticker', api_mock)
mocker.patch('freqtrade.fiat_convert.Market.ticker', api_mock)
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=28000.0)
fiat_convert = CryptoToFiatConverter()

View File

@ -35,7 +35,7 @@ def get_patched_freqtradebot(mocker, config) -> FreqtradeBot:
mocker.patch('freqtrade.freqtradebot.RPCManager', MagicMock())
mocker.patch('freqtrade.freqtradebot.persistence.init', MagicMock())
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
return FreqtradeBot(config, create_engine('sqlite://'))
@ -64,18 +64,18 @@ def patch_RPCManager(mocker) -> MagicMock:
return rpc_mock
def patch_pymarketcap(mocker, value: Optional[Dict[str, float]] = None) -> None:
def patch_coinmarketcap(mocker, value: Optional[Dict[str, float]] = None) -> None:
"""
Mocker to Pymarketcap to speed up tests
:param mocker: mocker to patch Pymarketcap class
Mocker to coinmarketcap to speed up tests
:param mocker: mocker to patch coinmarketcap class
:return: None
"""
pymarketcap = MagicMock()
mock = MagicMock()
if value:
pymarketcap.ticker = {'price_usd': 12345.0}
mock.ticker = {'price_usd': 12345.0}
mocker.patch('freqtrade.fiat_convert.Pymarketcap', pymarketcap)
mocker.patch('freqtrade.fiat_convert.Market', mock)
# Unit tests
@ -244,7 +244,7 @@ def test_create_trade(default_conf, ticker, limit_buy_order, mocker) -> None:
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -279,7 +279,7 @@ def test_create_trade_minimal_amount(default_conf, ticker, mocker) -> None:
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
buy_mock = MagicMock(return_value='mocked_limit_buy')
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -303,7 +303,7 @@ def test_create_trade_no_stake_amount(default_conf, ticker, mocker) -> None:
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -323,7 +323,7 @@ def test_create_trade_no_pairs(default_conf, ticker, mocker) -> None:
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -348,7 +348,7 @@ def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker) ->
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -376,7 +376,7 @@ def test_create_trade_no_signal(default_conf, mocker) -> None:
patch_get_signal(mocker, value=(False, False))
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -400,7 +400,7 @@ def test_process_trade_creation(default_conf, ticker, limit_buy_order,
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker, value={'price_usd': 12345.0})
patch_coinmarketcap(mocker, value={'price_usd': 12345.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -440,7 +440,7 @@ def test_process_exchange_failures(default_conf, ticker, health, mocker) -> None
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker, value={'price_usd': 12345.0})
patch_coinmarketcap(mocker, value={'price_usd': 12345.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -462,7 +462,7 @@ def test_process_operational_exception(default_conf, ticker, health, mocker) ->
"""
patch_get_signal(mocker)
msg_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker, value={'price_usd': 12345.0})
patch_coinmarketcap(mocker, value={'price_usd': 12345.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -485,7 +485,7 @@ def test_process_trade_handling(default_conf, ticker, limit_buy_order, health, m
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker, value={'price_usd': 12345.0})
patch_coinmarketcap(mocker, value={'price_usd': 12345.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -596,8 +596,7 @@ def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, mocker) -
buy=MagicMock(return_value='mocked_limit_buy'),
sell=MagicMock(return_value='mocked_limit_sell')
)
patch_pymarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.fiat_convert.Pymarketcap._cache_symbols', return_value={'BTC': 1})
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
@ -631,7 +630,7 @@ def test_handle_overlpapping_signals(default_conf, ticker, mocker) -> None:
patch_get_signal(mocker, value=(True, True))
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -689,7 +688,7 @@ def test_handle_trade_roi(default_conf, ticker, mocker, caplog) -> None:
patch_get_signal(mocker, value=(True, False))
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -724,7 +723,7 @@ def test_handle_trade_experimental(default_conf, ticker, mocker, caplog) -> None
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -753,7 +752,7 @@ def test_close_trade(default_conf, ticker, limit_buy_order, limit_sell_order, mo
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -782,7 +781,7 @@ def test_check_handle_timedout_buy(default_conf, ticker, limit_buy_order_old, mo
"""
rpc_mock = patch_RPCManager(mocker)
cancel_order_mock = MagicMock()
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -820,7 +819,7 @@ def test_check_handle_timedout_sell(default_conf, ticker, limit_sell_order_old,
Test check_handle_timedout() method
"""
rpc_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
cancel_order_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -859,7 +858,7 @@ def test_check_handle_timedout_partial(default_conf, ticker, limit_buy_order_old
Test check_handle_timedout() method
"""
rpc_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
cancel_order_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -901,7 +900,7 @@ def test_check_handle_timedout_exception(default_conf, ticker, mocker, caplog) -
"""
patch_RPCManager(mocker)
cancel_order_mock = MagicMock()
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.FreqtradeBot',
@ -945,7 +944,7 @@ def test_handle_timedout_limit_buy(mocker, default_conf) -> None:
Test handle_timedout_limit_buy() method
"""
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
cancel_order_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -972,7 +971,7 @@ def test_handle_timedout_limit_sell(mocker, default_conf) -> None:
"""
patch_RPCManager(mocker)
cancel_order_mock = MagicMock()
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -998,7 +997,7 @@ def test_execute_sell_up(default_conf, ticker, ticker_sell_up, mocker) -> None:
"""
patch_get_signal(mocker)
rpc_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -1038,7 +1037,7 @@ def test_execute_sell_down(default_conf, ticker, ticker_sell_down, mocker) -> No
"""
patch_get_signal(mocker)
rpc_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -1077,7 +1076,7 @@ def test_execute_sell_without_conf_sell_up(default_conf, ticker, ticker_sell_up,
"""
patch_get_signal(mocker)
rpc_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker, value={'price_usd': 12345.0})
patch_coinmarketcap(mocker, value={'price_usd': 12345.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -1117,7 +1116,7 @@ def test_execute_sell_without_conf_sell_down(default_conf, ticker,
"""
patch_get_signal(mocker)
rpc_mock = patch_RPCManager(mocker)
patch_pymarketcap(mocker, value={'price_usd': 12345.0})
patch_coinmarketcap(mocker, value={'price_usd': 12345.0})
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
validate_pairs=MagicMock(),
@ -1154,7 +1153,7 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order, mocker) -
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -1186,7 +1185,7 @@ def test_sell_profit_only_disable_profit(default_conf, limit_buy_order, mocker)
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -1218,7 +1217,7 @@ def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, mocker) ->
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',
@ -1250,7 +1249,7 @@ def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, mocker) ->
"""
patch_get_signal(mocker)
patch_RPCManager(mocker)
patch_pymarketcap(mocker)
patch_coinmarketcap(mocker)
mocker.patch('freqtrade.freqtradebot.Analyze.min_roi_reached', return_value=False)
mocker.patch.multiple(
'freqtrade.freqtradebot.exchange',

View File

@ -72,7 +72,6 @@ def test_main(mocker, caplog) -> None:
),
clean=MagicMock(),
)
args = ['-c', 'config.json.example']
# Test Main + the KeyboardInterrupt exception

View File

@ -19,7 +19,7 @@ hyperopt==0.1
# do not upgrade networkx before this is fixed https://github.com/hyperopt/hyperopt/issues/325
networkx==1.11
tabulate==0.8.2
pymarketcap==3.3.158
coinmarketcap==4.2.1
# Required for plotting data
#plotly==2.3.0

View File

@ -35,7 +35,7 @@ setup(name='freqtrade',
'TA-Lib',
'tabulate',
'cachetools',
'pymarketcap',
'coinmarketcap',
],
include_package_data=True,
zip_safe=False,