From 96ad74cd513a71ee79dfc462278cec7af9a4a56e Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 5 Mar 2018 12:55:22 +0100 Subject: [PATCH 01/14] Update python-telegram-bot from 9.0.0 to 10.0.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c79452328..2b5adbe37 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ python-bittrex==0.3.0 SQLAlchemy==1.2.4 -python-telegram-bot==9.0.0 +python-telegram-bot==10.0.1 arrow==0.12.1 cachetools==2.0.1 requests==2.18.4 From d1dbefa3760797f53066797c813a48a4cc34c37e Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 6 Mar 2018 20:50:25 +0100 Subject: [PATCH 02/14] Update sqlalchemy from 1.2.4 to 1.2.5 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0212b91e5..95494320b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ python-bittrex==0.3.0 -SQLAlchemy==1.2.4 +SQLAlchemy==1.2.5 python-telegram-bot==9.0.0 arrow==0.12.1 cachetools==2.0.1 From adf6244eda8ab73f7b5f5a5f291bed26e6ef30fa Mon Sep 17 00:00:00 2001 From: Matthias Voppichler Date: Thu, 8 Mar 2018 19:25:42 +0100 Subject: [PATCH 03/14] Update dockerfile to python:3.6.4-slim-stretch --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a0dafe69a..918552526 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM python:3.6.2 +FROM python:3.6.4-slim-stretch # Install TA-lib -RUN apt-get update && apt-get -y install build-essential && apt-get clean +RUN apt-get update && apt-get -y install curl build-essential && apt-get clean RUN curl -L http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz | \ tar xzvf - && \ cd ta-lib && \ From 4cfa3be69eebd9ee932374cc727a2a1e8145580a Mon Sep 17 00:00:00 2001 From: Matthias Voppichler Date: Fri, 9 Mar 2018 20:51:28 +0100 Subject: [PATCH 04/14] add /etc/localtime to container to syncronize time --- README.md | 2 +- docs/installation.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cac43731d..51d7fc938 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ vi config.json **3. Build your docker image and run it** ```bash docker build -t freqtrade . -docker run --rm -v `pwd`/config.json:/freqtrade/config.json -it freqtrade +docker run --rm -v /etc/localtime:/etc/localtime:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade ``` diff --git a/docs/installation.md b/docs/installation.md index fdd572824..b288fa1a7 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -129,7 +129,7 @@ docker images You can run a one-off container that is immediately deleted upon exiting with the following command (`config.json` must be in the current working directory): ```bash -docker run --rm -v `pwd`/config.json:/freqtrade/config.json -it freqtrade +docker run --rm -v /etc/localtime:/etc/localtime:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade ``` In this example, the database will be created inside the docker instance and will be lost when you will refresh your image. @@ -152,6 +152,7 @@ mv tradesv3.sqlite ~/.freqtrade ```bash docker run -d \ --name freqtrade \ + -v /etc/localtime:/etc/localtime:ro \ -v ~/.freqtrade/config.json:/freqtrade/config.json \ -v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \ freqtrade From 215dea041123ca0ce210842c0f46519898d82b61 Mon Sep 17 00:00:00 2001 From: Matthias Voppichler Date: Sat, 10 Mar 2018 09:53:38 +0100 Subject: [PATCH 05/14] Fix wrong whitespace character --- docs/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index b288fa1a7..a7e61bbe5 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -129,7 +129,7 @@ docker images You can run a one-off container that is immediately deleted upon exiting with the following command (`config.json` must be in the current working directory): ```bash -docker run --rm -v /etc/localtime:/etc/localtime:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade +docker run --rm -v /etc/localtime:/etc/localtime:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade ``` In this example, the database will be created inside the docker instance and will be lost when you will refresh your image. From e172bc134b2bee43cf2fce1bee212a89b71fb6b0 Mon Sep 17 00:00:00 2001 From: Elan Hasson Date: Sun, 11 Mar 2018 16:07:57 -0400 Subject: [PATCH 06/14] Should be Telegram, not Instagram --- docs/pre-requisite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pre-requisite.md b/docs/pre-requisite.md index 931d12d38..79232a89d 100644 --- a/docs/pre-requisite.md +++ b/docs/pre-requisite.md @@ -15,7 +15,7 @@ The only things you need is a working Telegram bot and its API token. Below we explain how to create your Telegram Bot, and how to get your Telegram user id. -### 1. Create your instagram bot +### 1. Create your Telegram bot **1.1. Start a chat with https://telegram.me/BotFather** **1.2. Send the message** `/newbot` *BotFather response:* From 4be75d862feb3c8845be5e2253e3337f80e3473a Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 12 Mar 2018 16:24:35 +0100 Subject: [PATCH 07/14] Update ta-lib from 0.4.16 to 0.4.17 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3ad1c3e38..2cdfbe12e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ scikit-learn==0.19.1 scipy==1.0.0 jsonschema==2.6.0 numpy==1.14.1 -TA-Lib==0.4.16 +TA-Lib==0.4.17 pytest==3.4.2 pytest-mock==1.7.1 pytest-cov==2.5.1 From 5f68a445cfb450b0317e5f4773a68fa3fc28fa07 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 12 Mar 2018 19:53:35 +0100 Subject: [PATCH 08/14] Update numpy from 1.14.1 to 1.14.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2cdfbe12e..b2a2429c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ pandas==0.22.0 scikit-learn==0.19.1 scipy==1.0.0 jsonschema==2.6.0 -numpy==1.14.1 +numpy==1.14.2 TA-Lib==0.4.17 pytest==3.4.2 pytest-mock==1.7.1 From 480d3876b8430ed8e7434f275c710ac24c3fb459 Mon Sep 17 00:00:00 2001 From: Matthias <5024695+xmatthias@users.noreply.github.com> Date: Thu, 15 Mar 2018 23:34:13 +0100 Subject: [PATCH 09/14] Align calling of freqtrade in backtesting and plotting docu (#554) --- docs/backtesting.md | 6 +++--- docs/plotting.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/backtesting.md b/docs/backtesting.md index a704f1cb9..b8da09226 100644 --- a/docs/backtesting.md +++ b/docs/backtesting.md @@ -53,13 +53,13 @@ python3 ./freqtrade/main.py backtesting --datadir freqtrade/tests/testdata-20180 **With a (custom) strategy file** ```bash -python3.6 ./freqtrade/main.py -s currentstrategy backtesting +python3 ./freqtrade/main.py -s currentstrategy backtesting ``` Where `-s currentstrategy` refers to a filename `currentstrategy.py` in `freqtrade/user_data/strategies` **Exporting trades to file** ```bash -freqtrade backtesting --export trades +python3 ./freqtrade/main.py backtesting --export trades ``` **Running backtest with smaller testset** @@ -99,7 +99,7 @@ cd user_data/data-20180113 Possibly edit pairs.json file to include/exclude pairs ```bash -python freqtrade/tests/testdata/download_backtest_data.py -p pairs.json +python3 freqtrade/tests/testdata/download_backtest_data.py -p pairs.json ``` The script will read your pairs.json file, and download ticker data diff --git a/docs/plotting.md b/docs/plotting.md index bbbe0fe16..80ab6866e 100644 --- a/docs/plotting.md +++ b/docs/plotting.md @@ -73,5 +73,5 @@ The `-p` pair argument, can be used to plot a single pair Example ``` -python3.6 scripts/plot_profit.py --datadir ../freqtrade/freqtrade/tests/testdata-20171221/ -p BTC_LTC +python3 scripts/plot_profit.py --datadir ../freqtrade/freqtrade/tests/testdata-20171221/ -p BTC_LTC ``` From e907c48438bd3405a48754f660b560794278bab4 Mon Sep 17 00:00:00 2001 From: Matthias <5024695+xmatthias@users.noreply.github.com> Date: Thu, 15 Mar 2018 23:37:34 +0100 Subject: [PATCH 10/14] Fix test_dataframe when ran standalone (#546) * Fix dataframe test when ran standalone * Fix standalone tests in hyperopt and optimize tests --- freqtrade/tests/optimize/test_hyperopt.py | 9 +++++++-- freqtrade/tests/optimize/test_optimize.py | 2 ++ freqtrade/tests/test_dataframe.py | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/freqtrade/tests/optimize/test_hyperopt.py b/freqtrade/tests/optimize/test_hyperopt.py index 4eb27d026..13b924f1d 100644 --- a/freqtrade/tests/optimize/test_hyperopt.py +++ b/freqtrade/tests/optimize/test_hyperopt.py @@ -7,7 +7,7 @@ import pandas as pd from freqtrade.optimize.hyperopt import calculate_loss, TARGET_TRADES, EXPECTED_MAX_PROFIT, start, \ log_results, save_trials, read_trials, generate_roi_table, has_space - +from freqtrade.strategy.strategy import Strategy import freqtrade.optimize.hyperopt as hyperopt @@ -72,6 +72,7 @@ def test_start_calls_fmin(mocker): args = mocker.Mock(epochs=1, config='config.json.example', mongodb=False, timerange=None, spaces='all') + Strategy().init({'strategy': 'default_strategy'}) start(args) mock_fmin.assert_called_once() @@ -86,6 +87,7 @@ def test_start_uses_mongotrials(mocker): args = mocker.Mock(epochs=1, config='config.json.example', mongodb=True, timerange=None, spaces='all') + Strategy().init({'strategy': 'default_strategy'}) start(args) mock_mongotrials.assert_called_once() @@ -149,6 +151,7 @@ def test_fmin_best_results(mocker, caplog): args = mocker.Mock(epochs=1, config='config.json.example', timerange=None, spaces='all') + Strategy().init({'strategy': 'default_strategy'}) start(args) exists = [ @@ -166,6 +169,7 @@ def test_fmin_best_results(mocker, caplog): def test_fmin_throw_value_error(mocker, caplog): caplog.set_level(logging.INFO) + Strategy().init({'strategy': 'default_strategy'}) mocker.patch('freqtrade.optimize.hyperopt.MongoTrials', return_value=create_trials(mocker)) mocker.patch('freqtrade.optimize.tickerdata_to_dataframe') mocker.patch('freqtrade.optimize.load_data') @@ -173,6 +177,7 @@ def test_fmin_throw_value_error(mocker, caplog): args = mocker.Mock(epochs=1, config='config.json.example', timerange=None, spaces='all') + Strategy().init({'strategy': 'default_strategy'}) start(args) exists = [ @@ -209,7 +214,7 @@ def test_resuming_previous_hyperopt_results_succeeds(mocker): mongodb=False, timerange=None, spaces='all') - + Strategy().init({'strategy': 'default_strategy'}) start(args) mock_read.assert_called_once() diff --git a/freqtrade/tests/optimize/test_optimize.py b/freqtrade/tests/optimize/test_optimize.py index d7a3b1f44..ed43f0f4e 100644 --- a/freqtrade/tests/optimize/test_optimize.py +++ b/freqtrade/tests/optimize/test_optimize.py @@ -10,6 +10,7 @@ from freqtrade.exchange import Bittrex from freqtrade.optimize.__init__ import make_testdata_path, download_pairs,\ download_backtesting_testdata, load_tickerdata_file, trim_tickerlist, file_dump_json from freqtrade.tests.conftest import log_has +from freqtrade.strategy.strategy import Strategy # Change this if modifying BTC_UNITEST testdatafile _BTC_UNITTEST_LENGTH = 13681 @@ -218,6 +219,7 @@ def test_init(default_conf, mocker): def test_tickerdata_to_dataframe(): + Strategy().init({'strategy': 'default_strategy'}) timerange = ((None, 'line'), None, -100) tick = load_tickerdata_file(None, 'BTC_UNITEST', 1, timerange=timerange) tickerlist = {'BTC_UNITEST': tick} diff --git a/freqtrade/tests/test_dataframe.py b/freqtrade/tests/test_dataframe.py index 9af42a30e..44b2a7e8c 100644 --- a/freqtrade/tests/test_dataframe.py +++ b/freqtrade/tests/test_dataframe.py @@ -3,6 +3,7 @@ import pandas import freqtrade.optimize from freqtrade import analyze +from freqtrade.strategy.strategy import Strategy _pairs = ['BTC_ETH'] @@ -17,11 +18,13 @@ def load_dataframe_pair(pairs): def test_dataframe_load(): + Strategy().init({'strategy': 'default_strategy'}) dataframe = load_dataframe_pair(_pairs) assert isinstance(dataframe, pandas.core.frame.DataFrame) def test_dataframe_columns_exists(): + Strategy().init({'strategy': 'default_strategy'}) dataframe = load_dataframe_pair(_pairs) assert 'high' in dataframe.columns assert 'low' in dataframe.columns From fd44c0e59ee94cb19f08e0977030dfb00aecce91 Mon Sep 17 00:00:00 2001 From: Michael Egger Date: Sat, 17 Mar 2018 10:40:50 +0100 Subject: [PATCH 11/14] allow max_open_trades to be zero (#561) --- freqtrade/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/misc.py b/freqtrade/misc.py index b5e8ad070..91498a189 100644 --- a/freqtrade/misc.py +++ b/freqtrade/misc.py @@ -333,7 +333,7 @@ def build_subcommands(parser: argparse.ArgumentParser) -> None: CONF_SCHEMA = { 'type': 'object', 'properties': { - 'max_open_trades': {'type': 'integer', 'minimum': 1}, + 'max_open_trades': {'type': 'integer', 'minimum': 0}, 'ticker_interval': {'type': 'integer', 'enum': [1, 5, 30, 60, 1440]}, 'stake_currency': {'type': 'string', 'enum': ['BTC', 'ETH', 'USDT']}, 'stake_amount': {'type': 'number', 'minimum': 0.0005}, From a99c8c40460011bf3df3f78a03dbef87a07247d5 Mon Sep 17 00:00:00 2001 From: Matthias <5024695+xmatthias@users.noreply.github.com> Date: Sun, 18 Mar 2018 00:42:24 +0100 Subject: [PATCH 12/14] 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 --- freqtrade/fiat_convert.py | 18 ++++++++++++++---- freqtrade/tests/rpc/test_rpc.py | 20 ++++++++------------ freqtrade/tests/rpc/test_rpc_telegram.py | 20 ++++++++------------ freqtrade/tests/test_fiat_convert.py | 7 +++++-- freqtrade/tests/test_main.py | 5 ++--- requirements.txt | 2 +- setup.py | 2 +- 7 files changed, 39 insertions(+), 35 deletions(-) diff --git a/freqtrade/fiat_convert.py b/freqtrade/fiat_convert.py index 6f9d3d3d5..4874247db 100644 --- a/freqtrade/fiat_convert.py +++ b/freqtrade/fiat_convert.py @@ -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 diff --git a/freqtrade/tests/rpc/test_rpc.py b/freqtrade/tests/rpc/test_rpc.py index 06994ce8e..8102e8885 100644 --- a/freqtrade/tests/rpc/test_rpc.py +++ b/freqtrade/tests/rpc/test_rpc.py @@ -189,9 +189,8 @@ def test_rpc_daily_profit(default_conf, update, ticker, limit_buy_order, limit_s mocker.patch.multiple('freqtrade.main.exchange', validate_pairs=MagicMock(), get_ticker=ticker) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0) main.init(default_conf, create_engine('sqlite://')) stake_currency = default_conf['stake_currency'] @@ -242,9 +241,8 @@ def test_rpc_trade_statistics( mocker.patch.multiple('freqtrade.main.exchange', validate_pairs=MagicMock(), get_ticker=ticker) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0) main.init(default_conf, create_engine('sqlite://')) stake_currency = default_conf['stake_currency'] @@ -298,9 +296,8 @@ def test_rpc_trade_statistics_closed( mocker.patch.multiple('freqtrade.main.exchange', validate_pairs=MagicMock(), get_ticker=ticker) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0) main.init(default_conf, create_engine('sqlite://')) stake_currency = default_conf['stake_currency'] @@ -356,9 +353,8 @@ def test_rpc_balance_handle(default_conf, update, mocker): mocker.patch.dict('freqtrade.main._CONF', default_conf) mocker.patch.multiple('freqtrade.main.exchange', get_balances=MagicMock(return_value=mock_balance)) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) (error, res) = rpc.rpc_balance(default_conf['fiat_display_currency']) assert not error diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index 9a1dbcc69..82d6dd865 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -166,9 +166,8 @@ def test_profit_handle( mocker.patch.multiple('freqtrade.main.exchange', validate_pairs=MagicMock(), get_ticker=ticker) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0) init(default_conf, create_engine('sqlite://')) @@ -395,9 +394,8 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order, limit_sell_ mocker.patch.multiple('freqtrade.main.exchange', validate_pairs=MagicMock(), get_ticker=ticker) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0) init(default_conf, create_engine('sqlite://')) @@ -459,9 +457,8 @@ def test_daily_wrong_input(default_conf, update, ticker, mocker): mocker.patch.multiple('freqtrade.main.exchange', validate_pairs=MagicMock(), get_ticker=ticker) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._find_price', return_value=15000.0) init(default_conf, create_engine('sqlite://')) @@ -656,9 +653,8 @@ def test_telegram_balance_handle(default_conf, update, mocker): send_msg=msg_mock) mocker.patch.multiple('freqtrade.main.exchange', get_balances=MagicMock(return_value=mock_balance)) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) mocker.patch('freqtrade.main.exchange.get_ticker', side_effect=mock_ticker) _balance(bot=MagicMock(), update=update) diff --git a/freqtrade/tests/test_fiat_convert.py b/freqtrade/tests/test_fiat_convert.py index 7d0acfc91..49a2adc05 100644 --- a/freqtrade/tests/test_fiat_convert.py +++ b/freqtrade/tests/test_fiat_convert.py @@ -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() diff --git a/freqtrade/tests/test_main.py b/freqtrade/tests/test_main.py index 00b551642..5f490a183 100644 --- a/freqtrade/tests/test_main.py +++ b/freqtrade/tests/test_main.py @@ -284,9 +284,8 @@ 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')) - mocker.patch.multiple('freqtrade.fiat_convert.Pymarketcap', - ticker=MagicMock(return_value={'price_usd': 15000.0}), - _cache_symbols=MagicMock(return_value={'BTC': 1})) + mocker.patch.multiple('freqtrade.fiat_convert.Market', + ticker=MagicMock(return_value={'price_usd': 15000.0})) init(default_conf, create_engine('sqlite://')) create_trade(0.001, int(default_conf['ticker_interval'])) diff --git a/requirements.txt b/requirements.txt index b2a2429c7..29361ecdb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index e53606dea..4b0635efa 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup(name='freqtrade', 'TA-Lib', 'tabulate', 'cachetools', - 'pymarketcap', + 'coinmarketcap', ], include_package_data=True, zip_safe=False, From ebe1d3647f2547243b5a064775d82f0833ca60a6 Mon Sep 17 00:00:00 2001 From: gcarq Date: Sun, 18 Mar 2018 02:03:36 +0100 Subject: [PATCH 13/14] .gitignore: add .pytest_cache/ --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8c7a6e257..c1bb0be68 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,5 @@ target/ .venv .idea .vscode + +.pytest_cache/ From eb8503c547a2479415b140c1221befc4ccbd94a2 Mon Sep 17 00:00:00 2001 From: gcarq Date: Sun, 18 Mar 2018 18:59:13 +0100 Subject: [PATCH 14/14] README: add codeclimate badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 51d7fc938..1caa34a85 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/gcarq/freqtrade.svg?branch=develop)](https://travis-ci.org/gcarq/freqtrade) [![Coverage Status](https://coveralls.io/repos/github/gcarq/freqtrade/badge.svg?branch=develop&service=github)](https://coveralls.io/github/gcarq/freqtrade?branch=develop) +[![Maintainability](https://api.codeclimate.com/v1/badges/5737e6d668200b7518ff/maintainability)](https://codeclimate.com/github/gcarq/freqtrade/maintainability) Simple High frequency trading bot for crypto currencies designed to