Merge pull request #1692 from freqtrade/feat/scripts_flake_mypy

run flake8 and mypy against scripts folder as well.
This commit is contained in:
Misagh 2019-03-24 17:08:52 +01:00 committed by GitHub
commit 71d3a7de40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 19 deletions

View File

@ -39,9 +39,9 @@ jobs:
- cp config.json.example config.json
- python freqtrade --datadir freqtrade/tests/testdata hyperopt -e 5
name: hyperopt
- script: flake8 freqtrade
- script: flake8 freqtrade scripts
name: flake8
- script: mypy freqtrade
- script: mypy freqtrade scripts
name: mypy
- stage: docker

View File

@ -84,5 +84,5 @@ The `-p` pair argument, can be used to plot a single pair
Example
```
python3 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 LTC/BTC
```

View File

@ -51,7 +51,6 @@ try:
id = sys.argv[1] # get exchange id from command line arguments
# check if the exchange is supported by ccxt
exchange_found = id in ccxt.exchanges
@ -90,4 +89,3 @@ except Exception as e:
dump('[' + type(e).__name__ + ']', str(e))
dump("Usage: python " + sys.argv[0], green('id'))
print_supported_exchanges()

View File

@ -24,24 +24,22 @@ Example of usage:
> python3 scripts/plot_dataframe.py --pairs BTC/EUR,XRP/BTC -d user_data/data/
--indicators1 sma,ema3 --indicators2 fastk,fastd
"""
import json
import logging
import sys
from argparse import Namespace
from pathlib import Path
from typing import Dict, List, Any
from typing import Any, Dict, List
import pandas as pd
import plotly.graph_objs as go
import pytz
from plotly import tools
from plotly.offline import plot
from freqtrade import persistence
from freqtrade.arguments import Arguments, TimeRange
from freqtrade.data import history
from freqtrade.data.btanalysis import load_backtest_data, BT_DATA_COLUMNS
from freqtrade.data.btanalysis import BT_DATA_COLUMNS, load_backtest_data
from freqtrade.exchange import Exchange
from freqtrade.optimize.backtesting import setup_configuration
from freqtrade.persistence import Trade
@ -148,7 +146,7 @@ def get_tickers_data(strategy, exchange, pairs: List[str], args):
tickers[pair] = exchange.klines((pair, tick_interval))
else:
tickers = history.load_data(
datadir=Path(_CONF.get("datadir")),
datadir=Path(str(_CONF.get("datadir"))),
pairs=pairs,
ticker_interval=tick_interval,
refresh_pairs=_CONF.get('refresh_pairs', False),

View File

@ -12,26 +12,24 @@ Optional Cli parameters
--timerange: specify what timerange of data to use
--export-filename: Specify where the backtest export is located.
"""
import json
import logging
import sys
import json
from argparse import Namespace
from pathlib import Path
from typing import List, Optional
import numpy as np
import numpy as np
import plotly.graph_objs as go
from plotly import tools
from plotly.offline import plot
import plotly.graph_objs as go
from freqtrade import constants, misc
from freqtrade.arguments import Arguments
from freqtrade.configuration import Configuration
from freqtrade import constants
from freqtrade.data import history
from freqtrade.resolvers import StrategyResolver
from freqtrade.state import RunMode
import freqtrade.misc as misc
logger = logging.getLogger(__name__)
@ -39,7 +37,7 @@ logger = logging.getLogger(__name__)
# data:: [ pair, profit-%, enter, exit, time, duration]
# data:: ["ETH/BTC", 0.0023975, "1515598200", "1515602100", "2018-01-10 07:30:00+00:00", 65]
def make_profit_array(data: List, px: int, min_date: int,
interval: int,
interval: str,
filter_pairs: Optional[List] = None) -> np.ndarray:
pg = np.zeros(px)
filter_pairs = filter_pairs or []
@ -122,7 +120,7 @@ def plot_profit(args: Namespace) -> None:
logger.info('Filter, keep pairs %s' % pairs)
tickers = history.load_data(
datadir=Path(config.get('datadir')),
datadir=Path(str(config.get('datadir'))),
pairs=pairs,
ticker_interval=tick_interval,
refresh_pairs=False,
@ -180,7 +178,7 @@ def plot_profit(args: Namespace) -> None:
fig.append_trace(profit, 2, 1)
for pair in pairs:
pg = make_profit_array(data, num_iterations, min_date, tick_interval, pair)
pg = make_profit_array(data, num_iterations, min_date, tick_interval, [pair])
pair_profit = go.Scattergl(
x=dates,
y=pg,