Merge pull request #3815 from freqtrade/isort_config

Introduce isort to have clear way to sort imports
This commit is contained in:
Matthias 2020-09-29 06:27:23 +02:00 committed by GitHub
commit d2111c088b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
112 changed files with 305 additions and 283 deletions

View File

@ -94,6 +94,10 @@ jobs:
run: | run: |
flake8 flake8
- name: Sort imports (isort)
run: |
isort --check .
- name: Mypy - name: Mypy
run: | run: |
mypy freqtrade scripts mypy freqtrade scripts

View File

@ -65,6 +65,14 @@ Guide for installing them is [here](http://flake8.pycqa.org/en/latest/user/using
mypy freqtrade mypy freqtrade
``` ```
### 4. Ensure all imports are correct
#### Run isort
``` bash
isort .
```
## (Core)-Committer Guide ## (Core)-Committer Guide
### Process: Pull Requests ### Process: Pull Requests

View File

@ -8,5 +8,6 @@ To launch Freqtrade as a module
from freqtrade import main from freqtrade import main
if __name__ == '__main__': if __name__ == '__main__':
main.main() main.main()

View File

@ -8,23 +8,15 @@ Note: Be careful with file-scoped imports in these subfiles.
""" """
from freqtrade.commands.arguments import Arguments from freqtrade.commands.arguments import Arguments
from freqtrade.commands.build_config_commands import start_new_config from freqtrade.commands.build_config_commands import start_new_config
from freqtrade.commands.data_commands import (start_convert_data, from freqtrade.commands.data_commands import (start_convert_data, start_download_data,
start_download_data,
start_list_data) start_list_data)
from freqtrade.commands.deploy_commands import (start_create_userdir, from freqtrade.commands.deploy_commands import (start_create_userdir, start_new_hyperopt,
start_new_hyperopt,
start_new_strategy) start_new_strategy)
from freqtrade.commands.hyperopt_commands import (start_hyperopt_list, from freqtrade.commands.hyperopt_commands import start_hyperopt_list, start_hyperopt_show
start_hyperopt_show) from freqtrade.commands.list_commands import (start_list_exchanges, start_list_hyperopts,
from freqtrade.commands.list_commands import (start_list_exchanges, start_list_markets, start_list_strategies,
start_list_hyperopts, start_list_timeframes, start_show_trades)
start_list_markets, from freqtrade.commands.optimize_commands import start_backtesting, start_edge, start_hyperopt
start_list_strategies,
start_list_timeframes,
start_show_trades)
from freqtrade.commands.optimize_commands import (start_backtesting,
start_edge, start_hyperopt)
from freqtrade.commands.pairlist_commands import start_test_pairlist from freqtrade.commands.pairlist_commands import start_test_pairlist
from freqtrade.commands.plot_commands import (start_plot_dataframe, from freqtrade.commands.plot_commands import start_plot_dataframe, start_plot_profit
start_plot_profit)
from freqtrade.commands.trade_commands import start_trading from freqtrade.commands.trade_commands import start_trading

View File

@ -9,6 +9,7 @@ from typing import Any, Dict, List, Optional
from freqtrade.commands.cli_options import AVAILABLE_CLI_OPTIONS from freqtrade.commands.cli_options import AVAILABLE_CLI_OPTIONS
from freqtrade.constants import DEFAULT_CONFIG from freqtrade.constants import DEFAULT_CONFIG
ARGS_COMMON = ["verbosity", "logfile", "version", "config", "datadir", "user_data_dir"] ARGS_COMMON = ["verbosity", "logfile", "version", "config", "datadir", "user_data_dir"]
ARGS_STRATEGY = ["strategy", "strategy_path"] ARGS_STRATEGY = ["strategy", "strategy_path"]
@ -161,16 +162,14 @@ class Arguments:
self.parser = argparse.ArgumentParser(description='Free, open source crypto trading bot') self.parser = argparse.ArgumentParser(description='Free, open source crypto trading bot')
self._build_args(optionlist=['version'], parser=self.parser) self._build_args(optionlist=['version'], parser=self.parser)
from freqtrade.commands import (start_create_userdir, start_convert_data, from freqtrade.commands import (start_backtesting, start_convert_data, start_create_userdir,
start_download_data, start_list_data, start_download_data, start_edge, start_hyperopt,
start_hyperopt_list, start_hyperopt_show, start_hyperopt_list, start_hyperopt_show, start_list_data,
start_list_exchanges, start_list_hyperopts, start_list_exchanges, start_list_hyperopts,
start_list_markets, start_list_strategies, start_list_markets, start_list_strategies,
start_list_timeframes, start_new_config, start_list_timeframes, start_new_config, start_new_hyperopt,
start_new_hyperopt, start_new_strategy, start_new_strategy, start_plot_dataframe, start_plot_profit,
start_plot_dataframe, start_plot_profit, start_show_trades, start_show_trades, start_test_pairlist, start_trading)
start_backtesting, start_hyperopt, start_edge,
start_test_pairlist, start_trading)
subparsers = self.parser.add_subparsers(dest='command', subparsers = self.parser.add_subparsers(dest='command',
# Use custom message when no subhandler is added # Use custom message when no subhandler is added

View File

@ -5,9 +5,11 @@ from typing import Any, Dict
from questionary import Separator, prompt from questionary import Separator, prompt
from freqtrade.constants import UNLIMITED_STAKE_AMOUNT from freqtrade.constants import UNLIMITED_STAKE_AMOUNT
from freqtrade.exchange import available_exchanges, MAP_EXCHANGE_CHILDCLASS
from freqtrade.misc import render_template
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import MAP_EXCHANGE_CHILDCLASS, available_exchanges
from freqtrade.misc import render_template
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -6,16 +6,15 @@ from typing import Any, Dict, List
import arrow import arrow
from freqtrade.configuration import TimeRange, setup_utils_configuration from freqtrade.configuration import TimeRange, setup_utils_configuration
from freqtrade.data.converter import (convert_ohlcv_format, from freqtrade.data.converter import convert_ohlcv_format, convert_trades_format
convert_trades_format) from freqtrade.data.history import (convert_trades_to_ohlcv, refresh_backtest_ohlcv_data,
from freqtrade.data.history import (convert_trades_to_ohlcv,
refresh_backtest_ohlcv_data,
refresh_backtest_trades_data) refresh_backtest_trades_data)
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes
from freqtrade.resolvers import ExchangeResolver from freqtrade.resolvers import ExchangeResolver
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -105,8 +104,9 @@ def start_list_data(args: Dict[str, Any]) -> None:
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
from freqtrade.data.history.idatahandler import get_datahandler
from tabulate import tabulate from tabulate import tabulate
from freqtrade.data.history.idatahandler import get_datahandler
dhc = get_datahandler(config['datadir'], config['dataformat_ohlcv']) dhc = get_datahandler(config['datadir'], config['dataformat_ohlcv'])
paircombs = dhc.ohlcv_get_available_data(config['datadir']) paircombs = dhc.ohlcv_get_available_data(config['datadir'])

View File

@ -4,13 +4,13 @@ from pathlib import Path
from typing import Any, Dict from typing import Any, Dict
from freqtrade.configuration import setup_utils_configuration from freqtrade.configuration import setup_utils_configuration
from freqtrade.configuration.directory_operations import (copy_sample_files, from freqtrade.configuration.directory_operations import copy_sample_files, create_userdata_dir
create_userdata_dir)
from freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES from freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.misc import render_template, render_template_with_fallback from freqtrade.misc import render_template, render_template_with_fallback
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -5,9 +5,10 @@ from typing import Any, Dict, List
from colorama import init as colorama_init from colorama import init as colorama_init
from freqtrade.configuration import setup_utils_configuration from freqtrade.configuration import setup_utils_configuration
from freqtrade.data.btanalysis import get_latest_hyperopt_file
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.state import RunMode from freqtrade.state import RunMode
from freqtrade.data.btanalysis import get_latest_hyperopt_file
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -5,20 +5,20 @@ from collections import OrderedDict
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List from typing import Any, Dict, List
from colorama import init as colorama_init
from colorama import Fore, Style
import rapidjson import rapidjson
from colorama import Fore, Style
from colorama import init as colorama_init
from tabulate import tabulate from tabulate import tabulate
from freqtrade.configuration import setup_utils_configuration from freqtrade.configuration import setup_utils_configuration
from freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES from freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import (available_exchanges, ccxt_exchanges, from freqtrade.exchange import available_exchanges, ccxt_exchanges, market_is_active
market_is_active)
from freqtrade.misc import plural from freqtrade.misc import plural
from freqtrade.resolvers import ExchangeResolver, StrategyResolver from freqtrade.resolvers import ExchangeResolver, StrategyResolver
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -203,8 +203,9 @@ def start_show_trades(args: Dict[str, Any]) -> None:
""" """
Show trades Show trades
""" """
from freqtrade.persistence import init, Trade
import json import json
from freqtrade.persistence import Trade, init
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
if 'db_url' not in config: if 'db_url' not in config:

View File

@ -6,6 +6,7 @@ from freqtrade.configuration import setup_utils_configuration
from freqtrade.exceptions import DependencyException, OperationalException from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -58,6 +59,7 @@ def start_hyperopt(args: Dict[str, Any]) -> None:
# Import here to avoid loading hyperopt module when it's not used # Import here to avoid loading hyperopt module when it's not used
try: try:
from filelock import FileLock, Timeout from filelock import FileLock, Timeout
from freqtrade.optimize.hyperopt import Hyperopt from freqtrade.optimize.hyperopt import Hyperopt
except ImportError as e: except ImportError as e:
raise OperationalException( raise OperationalException(
@ -98,6 +100,7 @@ def start_edge(args: Dict[str, Any]) -> None:
:return: None :return: None
""" """
from freqtrade.optimize.edge_cli import EdgeCli from freqtrade.optimize.edge_cli import EdgeCli
# Initialize configuration # Initialize configuration
config = setup_optimize_configuration(args, RunMode.EDGE) config = setup_optimize_configuration(args, RunMode.EDGE)
logger.info('Starting freqtrade in Edge mode') logger.info('Starting freqtrade in Edge mode')

View File

@ -7,6 +7,7 @@ from freqtrade.configuration import setup_utils_configuration
from freqtrade.resolvers import ExchangeResolver from freqtrade.resolvers import ExchangeResolver
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,5 +1,4 @@
import logging import logging
from typing import Any, Dict from typing import Any, Dict

View File

@ -1,7 +1,7 @@
# flake8: noqa: F401 # flake8: noqa: F401
from freqtrade.configuration.config_setup import setup_utils_configuration
from freqtrade.configuration.check_exchange import check_exchange, remove_credentials from freqtrade.configuration.check_exchange import check_exchange, remove_credentials
from freqtrade.configuration.timerange import TimeRange from freqtrade.configuration.config_setup import setup_utils_configuration
from freqtrade.configuration.configuration import Configuration
from freqtrade.configuration.config_validation import validate_config_consistency from freqtrade.configuration.config_validation import validate_config_consistency
from freqtrade.configuration.configuration import Configuration
from freqtrade.configuration.timerange import TimeRange

View File

@ -2,11 +2,11 @@ import logging
from typing import Any, Dict from typing import Any, Dict
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import (available_exchanges, get_exchange_bad_reason, from freqtrade.exchange import (available_exchanges, get_exchange_bad_reason, is_exchange_bad,
is_exchange_bad, is_exchange_known_ccxt, is_exchange_known_ccxt, is_exchange_officially_supported)
is_exchange_officially_supported)
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,10 +1,12 @@
import logging import logging
from typing import Any, Dict from typing import Any, Dict
from freqtrade.state import RunMode
from .check_exchange import remove_credentials
from .config_validation import validate_config_consistency from .config_validation import validate_config_consistency
from .configuration import Configuration from .configuration import Configuration
from .check_exchange import remove_credentials
from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -9,6 +9,7 @@ from freqtrade import constants
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -10,14 +10,14 @@ from typing import Any, Callable, Dict, List, Optional
from freqtrade import constants from freqtrade import constants
from freqtrade.configuration.check_exchange import check_exchange from freqtrade.configuration.check_exchange import check_exchange
from freqtrade.configuration.deprecated_settings import process_temporary_deprecated_settings from freqtrade.configuration.deprecated_settings import process_temporary_deprecated_settings
from freqtrade.configuration.directory_operations import (create_datadir, from freqtrade.configuration.directory_operations import create_datadir, create_userdata_dir
create_userdata_dir)
from freqtrade.configuration.load_config import load_config_file from freqtrade.configuration.load_config import load_config_file
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.loggers import setup_logging from freqtrade.loggers import setup_logging
from freqtrade.misc import deep_merge_dicts, json_load from freqtrade.misc import deep_merge_dicts, json_load
from freqtrade.state import NON_UTIL_MODES, TRADING_MODES, RunMode from freqtrade.state import NON_UTIL_MODES, TRADING_MODES, RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -3,8 +3,9 @@ import shutil
from pathlib import Path from pathlib import Path
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
from freqtrade.exceptions import OperationalException
from freqtrade.constants import USER_DATA_FILES from freqtrade.constants import USER_DATA_FILES
from freqtrade.exceptions import OperationalException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -11,6 +11,7 @@ import rapidjson
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -2,18 +2,19 @@
Helpers when analyzing backtest data Helpers when analyzing backtest data
""" """
import logging import logging
from datetime import timezone
from pathlib import Path from pathlib import Path
from typing import Dict, Union, Tuple, Any, Optional from typing import Any, Dict, Optional, Tuple, Union
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from datetime import timezone
from freqtrade import persistence from freqtrade import persistence
from freqtrade.constants import LAST_BT_RESULT_FN from freqtrade.constants import LAST_BT_RESULT_FN
from freqtrade.misc import json_load from freqtrade.misc import json_load
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# must align with columns in backtest.py # must align with columns in backtest.py

View File

@ -10,8 +10,8 @@ from typing import Any, Dict, List
import pandas as pd import pandas as pd
from pandas import DataFrame, to_datetime from pandas import DataFrame, to_datetime
from freqtrade.constants import (DEFAULT_DATAFRAME_COLUMNS, from freqtrade.constants import DEFAULT_DATAFRAME_COLUMNS, DEFAULT_TRADES_COLUMNS
DEFAULT_TRADES_COLUMNS)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@ from freqtrade.exceptions import ExchangeError, OperationalException
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -5,10 +5,8 @@ Includes:
* load data for a pair (or a list of pairs) from disk * load data for a pair (or a list of pairs) from disk
* download data from exchange and store to disk * download data from exchange and store to disk
""" """
# flake8: noqa: F401
from .history_utils import (convert_trades_to_ohlcv, # noqa: F401 from .history_utils import (convert_trades_to_ohlcv, get_timerange, load_data, load_pair_history,
get_timerange, load_data, load_pair_history, refresh_backtest_ohlcv_data, refresh_backtest_trades_data, refresh_data,
refresh_backtest_ohlcv_data,
refresh_backtest_trades_data, refresh_data,
validate_backtest_data) validate_backtest_data)
from .idatahandler import get_datahandler # noqa: F401 from .idatahandler import get_datahandler

View File

@ -7,12 +7,12 @@ import pandas as pd
from freqtrade import misc from freqtrade import misc
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import (DEFAULT_DATAFRAME_COLUMNS, from freqtrade.constants import (DEFAULT_DATAFRAME_COLUMNS, DEFAULT_TRADES_COLUMNS,
DEFAULT_TRADES_COLUMNS,
ListPairsWithTimeframes) ListPairsWithTimeframes)
from .idatahandler import IDataHandler, TradeList from .idatahandler import IDataHandler, TradeList
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -9,15 +9,14 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import DEFAULT_DATAFRAME_COLUMNS from freqtrade.constants import DEFAULT_DATAFRAME_COLUMNS
from freqtrade.data.converter import (clean_ohlcv_dataframe, from freqtrade.data.converter import (clean_ohlcv_dataframe, ohlcv_to_dataframe,
ohlcv_to_dataframe, trades_remove_duplicates, trades_to_ohlcv)
trades_remove_duplicates,
trades_to_ohlcv)
from freqtrade.data.history.idatahandler import IDataHandler, get_datahandler from freqtrade.data.history.idatahandler import IDataHandler, get_datahandler
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.misc import format_ms_time from freqtrade.misc import format_ms_time
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -14,10 +14,10 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import ListPairsWithTimeframes from freqtrade.constants import ListPairsWithTimeframes
from freqtrade.data.converter import (clean_ohlcv_dataframe, from freqtrade.data.converter import clean_ohlcv_dataframe, trades_remove_duplicates, trim_dataframe
trades_remove_duplicates, trim_dataframe)
from freqtrade.exchange import timeframe_to_seconds from freqtrade.exchange import timeframe_to_seconds
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Type for trades list # Type for trades list

View File

@ -8,12 +8,12 @@ from pandas import DataFrame, read_json, to_datetime
from freqtrade import misc from freqtrade import misc
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import (DEFAULT_DATAFRAME_COLUMNS, from freqtrade.constants import DEFAULT_DATAFRAME_COLUMNS, ListPairsWithTimeframes
ListPairsWithTimeframes)
from freqtrade.data.converter import trades_dict_to_list from freqtrade.data.converter import trades_dict_to_list
from .idatahandler import IDataHandler, TradeList from .idatahandler import IDataHandler, TradeList
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -9,11 +9,12 @@ import utils_find_1st as utf1st
from pandas import DataFrame from pandas import DataFrame
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import UNLIMITED_STAKE_AMOUNT, DATETIME_PRINT_FORMAT from freqtrade.constants import DATETIME_PRINT_FORMAT, UNLIMITED_STAKE_AMOUNT
from freqtrade.exceptions import OperationalException
from freqtrade.data.history import get_timerange, load_data, refresh_data from freqtrade.data.history import get_timerange, load_data, refresh_data
from freqtrade.exceptions import OperationalException
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,19 +1,15 @@
# flake8: noqa: F401 # flake8: noqa: F401
# isort: off
from freqtrade.exchange.common import MAP_EXCHANGE_CHILDCLASS from freqtrade.exchange.common import MAP_EXCHANGE_CHILDCLASS
from freqtrade.exchange.exchange import Exchange from freqtrade.exchange.exchange import Exchange
from freqtrade.exchange.exchange import (get_exchange_bad_reason, # isort: on
is_exchange_bad,
is_exchange_known_ccxt,
is_exchange_officially_supported,
ccxt_exchanges,
available_exchanges)
from freqtrade.exchange.exchange import (timeframe_to_seconds,
timeframe_to_minutes,
timeframe_to_msecs,
timeframe_to_next_date,
timeframe_to_prev_date)
from freqtrade.exchange.exchange import (market_is_active)
from freqtrade.exchange.kraken import Kraken
from freqtrade.exchange.binance import Binance
from freqtrade.exchange.bibox import Bibox from freqtrade.exchange.bibox import Bibox
from freqtrade.exchange.binance import Binance
from freqtrade.exchange.exchange import (available_exchanges, ccxt_exchanges,
get_exchange_bad_reason, is_exchange_bad,
is_exchange_known_ccxt, is_exchange_officially_supported,
market_is_active, timeframe_to_minutes, timeframe_to_msecs,
timeframe_to_next_date, timeframe_to_prev_date,
timeframe_to_seconds)
from freqtrade.exchange.ftx import Ftx from freqtrade.exchange.ftx import Ftx
from freqtrade.exchange.kraken import Kraken

View File

@ -4,6 +4,7 @@ from typing import Dict
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -4,12 +4,12 @@ from typing import Dict
import ccxt import ccxt
from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException,
InvalidOrderException, OperationalException, OperationalException, TemporaryError)
TemporaryError)
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.exchange.common import retrier from freqtrade.exchange.common import retrier
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -3,8 +3,8 @@ import logging
import time import time
from functools import wraps from functools import wraps
from freqtrade.exceptions import (DDosProtection, RetryableOrderError, from freqtrade.exceptions import DDosProtection, RetryableOrderError, TemporaryError
TemporaryError)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -13,20 +13,20 @@ from typing import Any, Dict, List, Optional, Tuple
import arrow import arrow
import ccxt import ccxt
import ccxt.async_support as ccxt_async import ccxt.async_support as ccxt_async
from ccxt.base.decimal_to_precision import (ROUND_DOWN, ROUND_UP, TICK_SIZE, from ccxt.base.decimal_to_precision import (ROUND_DOWN, ROUND_UP, TICK_SIZE, TRUNCATE,
TRUNCATE, decimal_to_precision) decimal_to_precision)
from pandas import DataFrame from pandas import DataFrame
from freqtrade.constants import ListPairsWithTimeframes from freqtrade.constants import ListPairsWithTimeframes
from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list
from freqtrade.exceptions import (DDosProtection, ExchangeError, from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError,
InsufficientFundsError, InvalidOrderException, OperationalException, RetryableOrderError,
InvalidOrderException, OperationalException, TemporaryError)
RetryableOrderError, TemporaryError) from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, BAD_EXCHANGES, retrier,
from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, retrier_async)
BAD_EXCHANGES, retrier, retrier_async)
from freqtrade.misc import deep_merge_dicts, safe_value_fallback2 from freqtrade.misc import deep_merge_dicts, safe_value_fallback2
CcxtModuleType = Any CcxtModuleType = Any

View File

@ -4,12 +4,12 @@ from typing import Any, Dict
import ccxt import ccxt
from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException,
InvalidOrderException, OperationalException, OperationalException, TemporaryError)
TemporaryError)
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.exchange.common import API_FETCH_ORDER_RETRY_COUNT, retrier from freqtrade.exchange.common import API_FETCH_ORDER_RETRY_COUNT, retrier
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -4,12 +4,12 @@ from typing import Any, Dict
import ccxt import ccxt
from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException,
InvalidOrderException, OperationalException, OperationalException, TemporaryError)
TemporaryError)
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.exchange.common import retrier from freqtrade.exchange.common import retrier
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -30,6 +30,7 @@ from freqtrade.strategy.interface import IStrategy, SellType
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
from freqtrade.wallets import Wallets from freqtrade.wallets import Wallets
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,12 +1,12 @@
import logging import logging
import sys import sys
from logging import Formatter from logging import Formatter
from logging.handlers import (BufferingHandler, RotatingFileHandler, from logging.handlers import BufferingHandler, RotatingFileHandler, SysLogHandler
SysLogHandler)
from typing import Any, Dict from typing import Any, Dict
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
LOGFORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' LOGFORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

View File

@ -7,6 +7,7 @@ import logging
import sys import sys
from typing import Any, List from typing import Any, List
# check min. python version # check min. python version
if sys.version_info < (3, 6): if sys.version_info < (3, 6):
sys.exit("Freqtrade requires Python version >= 3.6") sys.exit("Freqtrade requires Python version >= 3.6")

View File

@ -12,6 +12,7 @@ from typing.io import IO
import numpy as np import numpy as np
import rapidjson import rapidjson
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -11,22 +11,21 @@ from typing import Any, Dict, List, NamedTuple, Optional, Tuple
import arrow import arrow
from pandas import DataFrame from pandas import DataFrame
from freqtrade.configuration import (TimeRange, remove_credentials, from freqtrade.configuration import TimeRange, remove_credentials, validate_config_consistency
validate_config_consistency)
from freqtrade.constants import DATETIME_PRINT_FORMAT from freqtrade.constants import DATETIME_PRINT_FORMAT
from freqtrade.data import history from freqtrade.data import history
from freqtrade.data.converter import trim_dataframe from freqtrade.data.converter import trim_dataframe
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds
from freqtrade.optimize.optimize_reports import (generate_backtest_stats, from freqtrade.optimize.optimize_reports import (generate_backtest_stats, show_backtest_results,
show_backtest_results,
store_backtest_stats) store_backtest_stats)
from freqtrade.pairlist.pairlistmanager import PairListManager from freqtrade.pairlist.pairlistmanager import PairListManager
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.resolvers import ExchangeResolver, StrategyResolver from freqtrade.resolvers import ExchangeResolver, StrategyResolver
from freqtrade.strategy.interface import IStrategy, SellCheckTuple, SellType from freqtrade.strategy.interface import IStrategy, SellCheckTuple, SellType
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -7,12 +7,12 @@ import logging
from typing import Any, Dict from typing import Any, Dict
from freqtrade import constants from freqtrade import constants
from freqtrade.configuration import (TimeRange, remove_credentials, from freqtrade.configuration import TimeRange, remove_credentials, validate_config_consistency
validate_config_consistency)
from freqtrade.edge import Edge from freqtrade.edge import Edge
from freqtrade.optimize.optimize_reports import generate_edge_table from freqtrade.optimize.optimize_reports import generate_edge_table
from freqtrade.resolvers import ExchangeResolver, StrategyResolver from freqtrade.resolvers import ExchangeResolver, StrategyResolver
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -22,8 +22,7 @@ import rapidjson
import tabulate import tabulate
from colorama import Fore, Style from colorama import Fore, Style
from colorama import init as colorama_init from colorama import init as colorama_init
from joblib import (Parallel, cpu_count, delayed, dump, load, from joblib import Parallel, cpu_count, delayed, dump, load, wrap_non_picklable_objects
wrap_non_picklable_objects)
from pandas import DataFrame, isna, json_normalize from pandas import DataFrame, isna, json_normalize
from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN
@ -35,10 +34,10 @@ from freqtrade.optimize.backtesting import Backtesting
# Import IHyperOpt and IHyperOptLoss to allow unpickling classes from these modules # Import IHyperOpt and IHyperOptLoss to allow unpickling classes from these modules
from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F401 from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F401
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F401 from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F401
from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver, from freqtrade.resolvers.hyperopt_resolver import HyperOptLossResolver, HyperOptResolver
HyperOptResolver)
from freqtrade.strategy import IStrategy from freqtrade.strategy import IStrategy
# Suppress scikit-learn FutureWarnings from skopt # Suppress scikit-learn FutureWarnings from skopt
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning) warnings.filterwarnings("ignore", category=FutureWarning)

View File

@ -13,6 +13,7 @@ from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes
from freqtrade.misc import round_dict from freqtrade.misc import round_dict
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -6,8 +6,8 @@ Hyperoptimization.
""" """
from datetime import datetime from datetime import datetime
from pandas import DataFrame
import numpy as np import numpy as np
from pandas import DataFrame
from freqtrade.optimize.hyperopt import IHyperOptLoss from freqtrade.optimize.hyperopt import IHyperOptLoss

View File

@ -6,8 +6,8 @@ Hyperoptimization.
""" """
from datetime import datetime from datetime import datetime
from pandas import DataFrame
import numpy as np import numpy as np
from pandas import DataFrame
from freqtrade.optimize.hyperopt import IHyperOptLoss from freqtrade.optimize.hyperopt import IHyperOptLoss

View File

@ -4,14 +4,15 @@ from pathlib import Path
from typing import Any, Dict, List, Union from typing import Any, Dict, List, Union
from arrow import Arrow from arrow import Arrow
from pandas import DataFrame
from numpy import int64 from numpy import int64
from pandas import DataFrame
from tabulate import tabulate from tabulate import tabulate
from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN
from freqtrade.data.btanalysis import calculate_max_drawdown, calculate_market_change from freqtrade.data.btanalysis import calculate_market_change, calculate_max_drawdown
from freqtrade.misc import file_dump_json from freqtrade.misc import file_dump_json
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -2,9 +2,10 @@
Minimum age (days listed) pair list filter Minimum age (days listed) pair list filter
""" """
import logging import logging
import arrow
from typing import Any, Dict from typing import Any, Dict
import arrow
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.misc import plural from freqtrade.misc import plural
from freqtrade.pairlist.IPairList import IPairList from freqtrade.pairlist.IPairList import IPairList

View File

@ -4,8 +4,9 @@ Precision pair list filter
import logging import logging
from typing import Any, Dict from typing import Any, Dict
from freqtrade.pairlist.IPairList import IPairList
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.pairlist.IPairList import IPairList
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -7,10 +7,10 @@ from typing import Dict, List
from cachetools import TTLCache, cached from cachetools import TTLCache, cached
from freqtrade.constants import ListPairsWithTimeframes
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.pairlist.IPairList import IPairList from freqtrade.pairlist.IPairList import IPairList
from freqtrade.resolvers import PairListResolver from freqtrade.resolvers import PairListResolver
from freqtrade.constants import ListPairsWithTimeframes
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,4 +1,3 @@
# flake8: noqa: F401 # flake8: noqa: F401
from freqtrade.persistence.models import (Order, Trade, clean_dry_run_db, from freqtrade.persistence.models import Order, Trade, clean_dry_run_db, cleanup, init
cleanup, init)

View File

@ -3,6 +3,7 @@ from typing import List
from sqlalchemy import inspect from sqlalchemy import inspect
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -7,8 +7,8 @@ from decimal import Decimal
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
import arrow import arrow
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Integer, from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Integer, String,
String, create_engine, desc, func, inspect) create_engine, desc, func, inspect)
from sqlalchemy.exc import NoSuchModuleError from sqlalchemy.exc import NoSuchModuleError
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Query, relationship from sqlalchemy.orm import Query, relationship
@ -21,6 +21,7 @@ from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.misc import safe_value_fallback from freqtrade.misc import safe_value_fallback
from freqtrade.persistence.migrations import check_migrate from freqtrade.persistence.migrations import check_migrate
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -5,11 +5,8 @@ from typing import Any, Dict, List
import pandas as pd import pandas as pd
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.data.btanalysis import (calculate_max_drawdown, from freqtrade.data.btanalysis import (calculate_max_drawdown, combine_dataframes_with_mean,
combine_dataframes_with_mean, create_cum_profit, extract_trades_of_period, load_trades)
create_cum_profit,
extract_trades_of_period,
load_trades)
from freqtrade.data.converter import trim_dataframe from freqtrade.data.converter import trim_dataframe
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.data.history import load_data from freqtrade.data.history import load_data
@ -19,13 +16,14 @@ from freqtrade.misc import pair_to_filename
from freqtrade.resolvers import ExchangeResolver, StrategyResolver from freqtrade.resolvers import ExchangeResolver, StrategyResolver
from freqtrade.strategy import IStrategy from freqtrade.strategy import IStrategy
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
try: try:
from plotly.subplots import make_subplots
from plotly.offline import plot
import plotly.graph_objects as go import plotly.graph_objects as go
from plotly.offline import plot
from plotly.subplots import make_subplots
except ImportError: except ImportError:
logger.exception("Module plotly not found \n Please install using `pip3 install plotly`") logger.exception("Module plotly not found \n Please install using `pip3 install plotly`")
exit(1) exit(1)

View File

@ -1,6 +1,12 @@
from freqtrade.resolvers.iresolver import IResolver # noqa: F401 # flake8: noqa: F401
from freqtrade.resolvers.exchange_resolver import ExchangeResolver # noqa: F401 # isort: off
from freqtrade.resolvers.iresolver import IResolver
from freqtrade.resolvers.exchange_resolver import ExchangeResolver
# isort: on
# Don't import HyperoptResolver to avoid loading the whole Optimize tree # Don't import HyperoptResolver to avoid loading the whole Optimize tree
# from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver # noqa: F401 # from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver
from freqtrade.resolvers.pairlist_resolver import PairListResolver # noqa: F401 from freqtrade.resolvers.pairlist_resolver import PairListResolver
from freqtrade.resolvers.strategy_resolver import StrategyResolver # noqa: F401 from freqtrade.resolvers.strategy_resolver import StrategyResolver

View File

@ -3,10 +3,11 @@ This module loads custom exchanges
""" """
import logging import logging
from freqtrade.exchange import Exchange, MAP_EXCHANGE_CHILDCLASS
import freqtrade.exchange as exchanges import freqtrade.exchange as exchanges
from freqtrade.exchange import MAP_EXCHANGE_CHILDCLASS, Exchange
from freqtrade.resolvers import IResolver from freqtrade.resolvers import IResolver
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -13,6 +13,7 @@ from freqtrade.optimize.hyperopt_interface import IHyperOpt
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss
from freqtrade.resolvers import IResolver from freqtrade.resolvers import IResolver
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -11,6 +11,7 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -9,6 +9,7 @@ from pathlib import Path
from freqtrade.pairlist.IPairList import IPairList from freqtrade.pairlist.IPairList import IPairList
from freqtrade.resolvers import IResolver from freqtrade.resolvers import IResolver
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -11,12 +11,12 @@ from inspect import getfullargspec
from pathlib import Path from pathlib import Path
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
from freqtrade.constants import (REQUIRED_ORDERTIF, REQUIRED_ORDERTYPES, from freqtrade.constants import REQUIRED_ORDERTIF, REQUIRED_ORDERTYPES, USERPATH_STRATEGIES
USERPATH_STRATEGIES)
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.resolvers import IResolver from freqtrade.resolvers import IResolver
from freqtrade.strategy.interface import IStrategy from freqtrade.strategy.interface import IStrategy
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,2 +1,3 @@
from .rpc import RPC, RPCMessageType, RPCException # noqa # flake8: noqa: F401
from .rpc_manager import RPCManager # noqa from .rpc import RPC, RPCException, RPCMessageType
from .rpc_manager import RPCManager

View File

@ -8,9 +8,8 @@ from arrow import Arrow
from flask import Flask, jsonify, request from flask import Flask, jsonify, request
from flask.json import JSONEncoder from flask.json import JSONEncoder
from flask_cors import CORS from flask_cors import CORS
from flask_jwt_extended import (JWTManager, create_access_token, from flask_jwt_extended import (JWTManager, create_access_token, create_refresh_token,
create_refresh_token, get_jwt_identity, get_jwt_identity, jwt_refresh_token_required,
jwt_refresh_token_required,
verify_jwt_in_request_optional) verify_jwt_in_request_optional)
from werkzeug.security import safe_str_cmp from werkzeug.security import safe_str_cmp
from werkzeug.serving import make_server from werkzeug.serving import make_server
@ -21,6 +20,7 @@ from freqtrade.persistence import Trade
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
from freqtrade.rpc.rpc import RPC, RPCException from freqtrade.rpc.rpc import RPC, RPCException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
BASE_URI = "/api/v1" BASE_URI = "/api/v1"

View File

@ -21,6 +21,7 @@ from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
from freqtrade.state import State from freqtrade.state import State
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -6,6 +6,7 @@ from typing import Any, Dict, List
from freqtrade.rpc import RPC, RPCMessageType from freqtrade.rpc import RPC, RPCMessageType
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -5,9 +5,9 @@ This module manage Telegram communication
""" """
import json import json
import logging import logging
import arrow
from typing import Any, Callable, Dict from typing import Any, Callable, Dict
import arrow
from tabulate import tabulate from tabulate import tabulate
from telegram import ParseMode, ReplyKeyboardMarkup, Update from telegram import ParseMode, ReplyKeyboardMarkup, Update
from telegram.error import NetworkError, TelegramError from telegram.error import NetworkError, TelegramError
@ -18,6 +18,7 @@ from freqtrade.__init__ import __version__
from freqtrade.rpc import RPC, RPCException, RPCMessageType from freqtrade.rpc import RPC, RPCException, RPCMessageType
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.debug('Included module rpc.telegram ...') logger.debug('Included module rpc.telegram ...')

View File

@ -2,9 +2,9 @@
This module manages webhook communication This module manages webhook communication
""" """
import logging import logging
from typing import Any, Dict from typing import Any, Dict
from requests import post, RequestException from requests import RequestException, post
from freqtrade.rpc import RPC, RPCMessageType from freqtrade.rpc import RPC, RPCMessageType

View File

@ -1,5 +1,5 @@
# flake8: noqa: F401 # flake8: noqa: F401
from freqtrade.exchange import (timeframe_to_minutes, timeframe_to_prev_date, from freqtrade.exchange import (timeframe_to_minutes, timeframe_to_msecs, timeframe_to_next_date,
timeframe_to_seconds, timeframe_to_next_date, timeframe_to_msecs) timeframe_to_prev_date, timeframe_to_seconds)
from freqtrade.strategy.interface import IStrategy from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy.strategy_helper import merge_informative_pair from freqtrade.strategy.strategy_helper import merge_informative_pair

View File

@ -21,6 +21,7 @@ from freqtrade.persistence import Trade
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
from freqtrade.wallets import Wallets from freqtrade.wallets import Wallets
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,4 +1,5 @@
import pandas as pd import pandas as pd
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes

View File

@ -2,6 +2,7 @@ import logging
from freqtrade.exceptions import StrategyError from freqtrade.exceptions import StrategyError
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,4 +1,5 @@
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# isort: skip_file
# --- Do not remove these libs --- # --- Do not remove these libs ---
from functools import reduce from functools import reduce

View File

@ -1,5 +1,5 @@
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# isort: skip_file
# --- Do not remove these libs --- # --- Do not remove these libs ---
from functools import reduce from functools import reduce
from typing import Any, Callable, Dict, List from typing import Any, Callable, Dict, List

View File

@ -1,10 +1,11 @@
from math import exp
from datetime import datetime from datetime import datetime
from math import exp
from pandas import DataFrame from pandas import DataFrame
from freqtrade.optimize.hyperopt import IHyperOptLoss from freqtrade.optimize.hyperopt import IHyperOptLoss
# Define some constants: # Define some constants:
# set TARGET_TRADES to suit your number concurrent trades so its realistic # set TARGET_TRADES to suit your number concurrent trades so its realistic

View File

@ -1,5 +1,5 @@
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# isort: skip_file
# --- Do not remove these libs --- # --- Do not remove these libs ---
import numpy as np # noqa import numpy as np # noqa
import pandas as pd # noqa import pandas as pd # noqa

View File

@ -19,14 +19,15 @@
# limitations under the License. # limitations under the License.
# #
import warnings
import sys import sys
import warnings
from datetime import datetime, timedelta from datetime import datetime, timedelta
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from pandas.core.base import PandasObject from pandas.core.base import PandasObject
# ============================================= # =============================================
# check min, python version # check min, python version
if sys.version_info < (3, 4): if sys.version_info < (3, 4):

View File

@ -10,6 +10,7 @@ import arrow
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -15,6 +15,7 @@ from freqtrade.exceptions import OperationalException, TemporaryError
from freqtrade.freqtradebot import FreqtradeBot from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.state import State from freqtrade.state import State
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -13,6 +13,7 @@ pytest-asyncio==0.14.0
pytest-cov==2.10.1 pytest-cov==2.10.1
pytest-mock==3.3.1 pytest-mock==3.3.1
pytest-random-order==1.0.4 pytest-random-order==1.0.4
isort==5.5.3
# Convert jupyter notebooks to markdown documents # Convert jupyter notebooks to markdown documents
nbconvert==6.0.6 nbconvert==6.0.6

View File

@ -10,8 +10,8 @@ so it can be used as a standalone script.
import argparse import argparse
import inspect import inspect
import json import json
import re
import logging import logging
import re
import sys import sys
from pathlib import Path from pathlib import Path
from urllib.parse import urlencode, urlparse, urlunparse from urllib.parse import urlencode, urlparse, urlunparse
@ -20,6 +20,7 @@ import rapidjson
import requests import requests
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
logging.basicConfig( logging.basicConfig(
level=logging.INFO, level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',

View File

@ -8,6 +8,11 @@ exclude =
.eggs, .eggs,
user_data, user_data,
[isort]
line_length=100
multi_line_output=0
lines_after_imports=2
[mypy] [mypy]
ignore_missing_imports = True ignore_missing_imports = True

View File

@ -1,12 +1,15 @@
from sys import version_info from sys import version_info
from setuptools import setup from setuptools import setup
if version_info.major == 3 and version_info.minor < 6 or \ if version_info.major == 3 and version_info.minor < 6 or \
version_info.major < 3: version_info.major < 3:
print('Your Python interpreter must be 3.6 or greater!') print('Your Python interpreter must be 3.6 or greater!')
exit(1) exit(1)
from pathlib import Path # noqa: E402 from pathlib import Path # noqa: E402
from freqtrade import __version__ # noqa: E402 from freqtrade import __version__ # noqa: E402
@ -108,6 +111,7 @@ setup(name='freqtrade',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Operating System :: MacOS', 'Operating System :: MacOS',
'Operating System :: Unix', 'Operating System :: Unix',
'Topic :: Office/Business :: Financial :: Investment', 'Topic :: Office/Business :: Financial :: Investment',

View File

@ -4,10 +4,8 @@ from unittest.mock import MagicMock
import pytest import pytest
import rapidjson import rapidjson
from freqtrade.commands.build_config_commands import (ask_user_config, from freqtrade.commands.build_config_commands import (ask_user_config, ask_user_overwrite,
ask_user_overwrite, start_new_config, validate_is_float,
start_new_config,
validate_is_float,
validate_is_int) validate_is_int)
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from tests.conftest import get_args, log_has_re from tests.conftest import get_args, log_has_re

View File

@ -5,19 +5,16 @@ from unittest.mock import MagicMock, PropertyMock
import arrow import arrow
import pytest import pytest
from freqtrade.commands import (start_convert_data, start_create_userdir, from freqtrade.commands import (start_convert_data, start_create_userdir, start_download_data,
start_download_data, start_hyperopt_list, start_hyperopt_list, start_hyperopt_show, start_list_data,
start_hyperopt_show, start_list_data, start_list_exchanges, start_list_hyperopts, start_list_markets,
start_list_exchanges, start_list_hyperopts, start_list_strategies, start_list_timeframes, start_new_hyperopt,
start_list_markets, start_list_strategies, start_new_strategy, start_show_trades, start_test_pairlist,
start_list_timeframes, start_new_hyperopt, start_trading)
start_new_strategy, start_show_trades,
start_test_pairlist, start_trading)
from freqtrade.configuration import setup_utils_configuration from freqtrade.configuration import setup_utils_configuration
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.state import RunMode from freqtrade.state import RunMode
from tests.conftest import (create_mock_trades, get_args, log_has, log_has_re, from tests.conftest import (create_mock_trades, get_args, log_has, log_has_re, patch_exchange,
patch_exchange,
patched_configuration_load_config_file) patched_configuration_load_config_file)
from tests.conftest_trades import MOCK_TRADE_COUNT from tests.conftest_trades import MOCK_TRADE_COUNT

View File

@ -22,8 +22,9 @@ from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.resolvers import ExchangeResolver from freqtrade.resolvers import ExchangeResolver
from freqtrade.worker import Worker from freqtrade.worker import Worker
from tests.conftest_trades import (mock_trade_1, mock_trade_2, mock_trade_3, from tests.conftest_trades import (mock_trade_1, mock_trade_2, mock_trade_3, mock_trade_4,
mock_trade_4, mock_trade_5, mock_trade_6) mock_trade_5, mock_trade_6)
logging.getLogger('').setLevel(logging.INFO) logging.getLogger('').setLevel(logging.INFO)

View File

@ -7,16 +7,11 @@ from pandas import DataFrame, DateOffset, Timestamp, to_datetime
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import LAST_BT_RESULT_FN from freqtrade.constants import LAST_BT_RESULT_FN
from freqtrade.data.btanalysis import (BT_DATA_COLUMNS, from freqtrade.data.btanalysis import (BT_DATA_COLUMNS, analyze_trade_parallelism,
analyze_trade_parallelism, calculate_market_change, calculate_max_drawdown,
calculate_market_change, combine_dataframes_with_mean, create_cum_profit,
calculate_max_drawdown, extract_trades_of_period, get_latest_backtest_filename,
combine_dataframes_with_mean, get_latest_hyperopt_file, load_backtest_data, load_trades,
create_cum_profit,
extract_trades_of_period,
get_latest_backtest_filename,
get_latest_hyperopt_file,
load_backtest_data, load_trades,
load_trades_from_db) load_trades_from_db)
from freqtrade.data.history import load_data, load_pair_history from freqtrade.data.history import load_data, load_pair_history
from freqtrade.optimize.backtesting import BacktestResult from freqtrade.optimize.backtesting import BacktestResult

View File

@ -2,13 +2,11 @@
import logging import logging
from freqtrade.configuration.timerange import TimeRange from freqtrade.configuration.timerange import TimeRange
from freqtrade.data.converter import (convert_ohlcv_format, from freqtrade.data.converter import (convert_ohlcv_format, convert_trades_format,
convert_trades_format, ohlcv_fill_up_missing_data, ohlcv_to_dataframe,
ohlcv_fill_up_missing_data, trades_dict_to_list, trades_remove_duplicates, trim_dataframe)
ohlcv_to_dataframe, trades_dict_to_list, from freqtrade.data.history import (get_timerange, load_data, load_pair_history,
trades_remove_duplicates, trim_dataframe) validate_backtest_data)
from freqtrade.data.history import (get_timerange, load_data,
load_pair_history, validate_backtest_data)
from tests.conftest import log_has from tests.conftest import log_has
from tests.data.test_history import _backup_file, _clean_test_file from tests.data.test_history import _backup_file, _clean_test_file

View File

@ -15,20 +15,19 @@ from freqtrade.configuration import TimeRange
from freqtrade.constants import AVAILABLE_DATAHANDLERS from freqtrade.constants import AVAILABLE_DATAHANDLERS
from freqtrade.data.converter import ohlcv_to_dataframe from freqtrade.data.converter import ohlcv_to_dataframe
from freqtrade.data.history.hdf5datahandler import HDF5DataHandler from freqtrade.data.history.hdf5datahandler import HDF5DataHandler
from freqtrade.data.history.history_utils import ( from freqtrade.data.history.history_utils import (_download_pair_history, _download_trades_history,
_download_pair_history, _download_trades_history, _load_cached_data_for_updating,
_load_cached_data_for_updating, convert_trades_to_ohlcv, get_timerange, convert_trades_to_ohlcv, get_timerange, load_data,
load_data, load_pair_history, refresh_backtest_ohlcv_data, load_pair_history, refresh_backtest_ohlcv_data,
refresh_backtest_trades_data, refresh_data, validate_backtest_data) refresh_backtest_trades_data, refresh_data,
from freqtrade.data.history.idatahandler import (IDataHandler, get_datahandler, validate_backtest_data)
get_datahandlerclass) from freqtrade.data.history.idatahandler import IDataHandler, get_datahandler, get_datahandlerclass
from freqtrade.data.history.jsondatahandler import (JsonDataHandler, from freqtrade.data.history.jsondatahandler import JsonDataHandler, JsonGzDataHandler
JsonGzDataHandler)
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes
from freqtrade.misc import file_dump_json from freqtrade.misc import file_dump_json
from freqtrade.resolvers import StrategyResolver from freqtrade.resolvers import StrategyResolver
from tests.conftest import (get_patched_exchange, log_has, log_has_re, from tests.conftest import get_patched_exchange, log_has, log_has_re, patch_exchange
patch_exchange)
# Change this if modifying UNITTEST/BTC testdatafile # Change this if modifying UNITTEST/BTC testdatafile
_BTC_UNITTEST_LENGTH = 13681 _BTC_UNITTEST_LENGTH = 13681

View File

@ -10,14 +10,15 @@ import numpy as np
import pytest import pytest
from pandas import DataFrame, to_datetime from pandas import DataFrame, to_datetime
from freqtrade.exceptions import OperationalException
from freqtrade.data.converter import ohlcv_to_dataframe from freqtrade.data.converter import ohlcv_to_dataframe
from freqtrade.edge import Edge, PairInfo from freqtrade.edge import Edge, PairInfo
from freqtrade.exceptions import OperationalException
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
from tests.conftest import get_patched_freqtradebot, log_has from tests.conftest import get_patched_freqtradebot, log_has
from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe, from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe,
_get_frame_time_from_offset) _get_frame_time_from_offset)
# Cases to be tested: # Cases to be tested:
# 1) Open trade should be removed from the end # 1) Open trade should be removed from the end
# 2) Two complete trades within dataframe (with sell hit for all) # 2) Two complete trades within dataframe (with sell hit for all)

View File

@ -4,8 +4,7 @@ from unittest.mock import MagicMock
import ccxt import ccxt
import pytest import pytest
from freqtrade.exceptions import (DependencyException, InvalidOrderException, from freqtrade.exceptions import DependencyException, InvalidOrderException, OperationalException
OperationalException)
from tests.conftest import get_patched_exchange from tests.conftest import get_patched_exchange
from tests.exchange.test_exchange import ccxt_exceptionhandlers from tests.exchange.test_exchange import ccxt_exceptionhandlers

View File

@ -9,21 +9,18 @@ import ccxt
import pytest import pytest
from pandas import DataFrame from pandas import DataFrame
from freqtrade.exceptions import (DDosProtection, DependencyException, from freqtrade.exceptions import (DDosProtection, DependencyException, InvalidOrderException,
InvalidOrderException, OperationalException, OperationalException, TemporaryError)
TemporaryError)
from freqtrade.exchange import Binance, Exchange, Kraken from freqtrade.exchange import Binance, Exchange, Kraken
from freqtrade.exchange.common import (API_RETRY_COUNT, API_FETCH_ORDER_RETRY_COUNT, from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, API_RETRY_COUNT,
calculate_backoff) calculate_backoff)
from freqtrade.exchange.exchange import (market_is_active, from freqtrade.exchange.exchange import (market_is_active, timeframe_to_minutes, timeframe_to_msecs,
timeframe_to_minutes, timeframe_to_next_date, timeframe_to_prev_date,
timeframe_to_msecs,
timeframe_to_next_date,
timeframe_to_prev_date,
timeframe_to_seconds) timeframe_to_seconds)
from freqtrade.resolvers.exchange_resolver import ExchangeResolver from freqtrade.resolvers.exchange_resolver import ExchangeResolver
from tests.conftest import get_patched_exchange, log_has, log_has_re from tests.conftest import get_patched_exchange, log_has, log_has_re
# Make sure to always keep one exchange here which is NOT subclassed!! # Make sure to always keep one exchange here which is NOT subclassed!!
EXCHANGES = ['bittrex', 'binance', 'kraken', 'ftx'] EXCHANGES = ['bittrex', 'binance', 'kraken', 'ftx']

View File

@ -10,6 +10,7 @@ from tests.conftest import get_patched_exchange
from .test_exchange import ccxt_exceptionhandlers from .test_exchange import ccxt_exceptionhandlers
STOPLOSS_ORDERTYPE = 'stop' STOPLOSS_ORDERTYPE = 'stop'

View File

@ -8,6 +8,7 @@ from freqtrade.exceptions import DependencyException, InvalidOrderException
from tests.conftest import get_patched_exchange from tests.conftest import get_patched_exchange
from tests.exchange.test_exchange import ccxt_exceptionhandlers from tests.exchange.test_exchange import ccxt_exceptionhandlers
STOPLOSS_ORDERTYPE = 'stop-loss' STOPLOSS_ORDERTYPE = 'stop-loss'

View File

@ -6,6 +6,7 @@ from pandas import DataFrame
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
tests_start_time = arrow.get(2018, 10, 3) tests_start_time = arrow.get(2018, 10, 3)
tests_timeframe = '1h' tests_timeframe = '1h'

View File

@ -11,6 +11,7 @@ from tests.conftest import patch_exchange
from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe, from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe,
_get_frame_time_from_offset, tests_timeframe) _get_frame_time_from_offset, tests_timeframe)
# Test 0: Sell with signal sell in candle 3 # Test 0: Sell with signal sell in candle 3
# Test with Stop-loss at 1% # Test with Stop-loss at 1%
tc0 = BTContainer(data=[ tc0 = BTContainer(data=[

View File

@ -10,8 +10,7 @@ import pytest
from arrow import Arrow from arrow import Arrow
from freqtrade import constants from freqtrade import constants
from freqtrade.commands.optimize_commands import (setup_optimize_configuration, from freqtrade.commands.optimize_commands import setup_optimize_configuration, start_backtesting
start_backtesting)
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.data import history from freqtrade.data import history
from freqtrade.data.btanalysis import BT_DATA_COLUMNS, evaluate_result_multi from freqtrade.data.btanalysis import BT_DATA_COLUMNS, evaluate_result_multi
@ -26,6 +25,7 @@ from freqtrade.strategy.interface import SellType
from tests.conftest import (get_args, log_has, log_has_re, patch_exchange, from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patched_configuration_load_config_file) patched_configuration_load_config_file)
ORDER_TYPES = [ ORDER_TYPES = [
{ {
'buy': 'limit', 'buy': 'limit',

View File

@ -1,9 +1,9 @@
# pragma pylint: disable=missing-docstring,W0212,C0103 # pragma pylint: disable=missing-docstring,W0212,C0103
import locale import locale
import logging import logging
from copy import deepcopy
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from copy import deepcopy
from typing import Dict, List from typing import Dict, List
from unittest.mock import MagicMock from unittest.mock import MagicMock
@ -13,14 +13,12 @@ from arrow import Arrow
from filelock import Timeout from filelock import Timeout
from freqtrade import constants from freqtrade import constants
from freqtrade.commands.optimize_commands import (setup_optimize_configuration, from freqtrade.commands.optimize_commands import setup_optimize_configuration, start_hyperopt
start_hyperopt)
from freqtrade.data.history import load_data from freqtrade.data.history import load_data
from freqtrade.exceptions import DependencyException, OperationalException from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.optimize.default_hyperopt_loss import DefaultHyperOptLoss from freqtrade.optimize.default_hyperopt_loss import DefaultHyperOptLoss
from freqtrade.optimize.hyperopt import Hyperopt from freqtrade.optimize.hyperopt import Hyperopt
from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver, from freqtrade.resolvers.hyperopt_resolver import HyperOptLossResolver, HyperOptResolver
HyperOptResolver)
from freqtrade.state import RunMode from freqtrade.state import RunMode
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
from tests.conftest import (get_args, log_has, log_has_re, patch_exchange, from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,

View File

@ -5,21 +5,17 @@ from pathlib import Path
import pandas as pd import pandas as pd
import pytest import pytest
from arrow import Arrow from arrow import Arrow
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.constants import LAST_BT_RESULT_FN from freqtrade.constants import LAST_BT_RESULT_FN
from freqtrade.data import history from freqtrade.data import history
from freqtrade.data.btanalysis import (get_latest_backtest_filename, from freqtrade.data.btanalysis import get_latest_backtest_filename, load_backtest_data
load_backtest_data)
from freqtrade.edge import PairInfo from freqtrade.edge import PairInfo
from freqtrade.optimize.optimize_reports import (generate_backtest_stats, from freqtrade.optimize.optimize_reports import (generate_backtest_stats, generate_daily_stats,
generate_daily_stats, generate_edge_table, generate_pair_metrics,
generate_edge_table,
generate_pair_metrics,
generate_sell_reason_stats, generate_sell_reason_stats,
generate_strategy_metrics, generate_strategy_metrics, store_backtest_stats,
store_backtest_stats, text_table_bt_results, text_table_sell_reason,
text_table_bt_results,
text_table_sell_reason,
text_table_strategy) text_table_strategy)
from freqtrade.resolvers.strategy_resolver import StrategyResolver from freqtrade.resolvers.strategy_resolver import StrategyResolver
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType

View File

@ -13,8 +13,7 @@ from freqtrade.persistence import Trade
from freqtrade.rpc import RPC, RPCException from freqtrade.rpc import RPC, RPCException
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
from freqtrade.state import State from freqtrade.state import State
from tests.conftest import (create_mock_trades, get_patched_freqtradebot, from tests.conftest import create_mock_trades, get_patched_freqtradebot, patch_get_signal
patch_get_signal)
# Functions for recurrent object patching # Functions for recurrent object patching

View File

@ -14,8 +14,8 @@ from freqtrade.loggers import setup_logging, setup_logging_pre
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.rpc.api_server import BASE_URI, ApiServer from freqtrade.rpc.api_server import BASE_URI, ApiServer
from freqtrade.state import State from freqtrade.state import State
from tests.conftest import (create_mock_trades, get_patched_freqtradebot, from tests.conftest import create_mock_trades, get_patched_freqtradebot, log_has, patch_get_signal
log_has, patch_get_signal)
_TEST_USER = "FreqTrader" _TEST_USER = "FreqTrader"
_TEST_PASS = "SuperSecurePassword1!" _TEST_PASS = "SuperSecurePassword1!"

View File

@ -1,10 +1,10 @@
# pragma pylint: disable=missing-docstring, C0103 # pragma pylint: disable=missing-docstring, C0103
import time
import logging import logging
import time
from unittest.mock import MagicMock from unittest.mock import MagicMock
from freqtrade.rpc import RPCMessageType, RPCManager from freqtrade.rpc import RPCManager, RPCMessageType
from tests.conftest import log_has, get_patched_freqtradebot from tests.conftest import get_patched_freqtradebot, log_has
def test__init__(mocker, default_conf) -> None: def test__init__(mocker, default_conf) -> None:

Some files were not shown because too many files have changed in this diff Show More