Fix conflicts

This commit is contained in:
Anton
2018-05-03 11:16:29 +03:00
43 changed files with 1113 additions and 694 deletions

View File

@@ -183,11 +183,11 @@ def load_cached_data_for_updating(filename: str,
return (data, since_ms)
# FIX: 20180110, suggest rename interval to tick_interval
def download_backtesting_testdata(datadir: str,
pair: str,
tick_interval: str = '5m',
timerange: Optional[Tuple[Tuple, int, int]] = None) -> bool:
timerange: Optional[Tuple[Tuple, int, int]] = None) -> None:
"""
Download the latest ticker intervals from the exchange for the pairs passed in parameters
The data is downloaded starting from the last correct ticker interval data that
@@ -198,7 +198,8 @@ def download_backtesting_testdata(datadir: str,
:param pairs: list of pairs to download
:param tick_interval: ticker interval
:param timerange: range of time to download
:return: bool
:return: None
"""
path = make_testdata_path(datadir)
@@ -223,5 +224,3 @@ def download_backtesting_testdata(datadir: str,
logger.debug("New End: %s", misc.format_ms_time(data[-1][0]))
misc.file_dump_json(filename, data)
return True

View File

@@ -4,11 +4,12 @@
This module contains the backtesting logic
"""
import logging
import operator
from argparse import Namespace
from typing import Dict, Tuple, Any, List, Optional
import arrow
from pandas import DataFrame, Series
from pandas import DataFrame
from tabulate import tabulate
import freqtrade.optimize as optimize
@@ -19,7 +20,6 @@ from freqtrade.configuration import Configuration
from freqtrade.misc import file_dump_json
from freqtrade.persistence import Trade
logger = logging.getLogger(__name__)
@@ -66,11 +66,12 @@ class Backtesting(object):
:param data: dictionary with preprocessed backtesting data
:return: tuple containing min_date, max_date
"""
all_dates = Series([])
for pair_data in data.values():
all_dates = all_dates.append(pair_data['date'])
all_dates.sort_values(inplace=True)
return arrow.get(all_dates.iloc[0]), arrow.get(all_dates.iloc[-1])
timeframe = [
(arrow.get(min(frame.date)), arrow.get(max(frame.date)))
for frame in data.values()
]
return min(timeframe, key=operator.itemgetter(0))[0], \
max(timeframe, key=operator.itemgetter(1))[1]
def _generate_text_table(self, data: Dict[str, Dict], results: DataFrame) -> str:
"""
@@ -113,12 +114,14 @@ class Backtesting(object):
stake_amount = args['stake_amount']
max_open_trades = args.get('max_open_trades', 0)
fee = exchange.get_fee()
trade = Trade(
open_rate=buy_row.close,
open_date=buy_row.date,
stake_amount=stake_amount,
amount=stake_amount / buy_row.open,
fee=exchange.get_fee()
fee_open=fee,
fee_close=fee
)
# calculate win/lose forwards from buy point
@@ -199,9 +202,9 @@ class Backtesting(object):
# record a tuple of pair, current_profit_percent,
# entry-date, duration
records.append((pair, trade_entry[1],
row.date.timestamp(),
row2.date.timestamp(),
row.date, trade_entry[3]))
row.date.strftime('%s'),
row2.date.strftime('%s'),
index, trade_entry[3]))
# For now export inside backtest(), maybe change so that backtest()
# returns a tuple like: (dataframe, records, logs, etc)
if record and record.find('trades') >= 0:
@@ -302,12 +305,9 @@ def start(args: Namespace) -> None:
:param args: Cli args from Arguments()
:return: None
"""
# Initialize logger
logger.info('Starting freqtrade in Backtesting mode')
# Initialize configuration
config = setup_configuration(args)
logger.info('Starting freqtrade in Backtesting mode')
# Initialize backtesting object
backtesting = Backtesting(config)

View File

@@ -29,7 +29,6 @@ from freqtrade.optimize import load_data
from freqtrade.optimize.backtesting import Backtesting
from user_data.hyperopt_conf import hyperopt_optimize_conf
logger = logging.getLogger(__name__)
@@ -591,11 +590,11 @@ def start(args: Namespace) -> None:
logging.getLogger('hyperopt.mongoexp').setLevel(logging.WARNING)
logging.getLogger('hyperopt.tpe').setLevel(logging.WARNING)
logger.info('Starting freqtrade in Hyperopt mode')
# Initialize configuration
# Monkey patch the configuration with hyperopt_conf.py
configuration = Configuration(args)
logger.info('Starting freqtrade in Hyperopt mode')
optimize_config = hyperopt_optimize_conf()
config = configuration._load_common_config(optimize_config)
config = configuration._load_backtesting_config(config)