cleanups
This commit is contained in:
parent
ae0a1436e2
commit
7b0beb0afa
@ -4,11 +4,9 @@ import logging
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Optional, List, Dict
|
from typing import Optional, List, Dict
|
||||||
|
from pandas import DataFrame
|
||||||
from freqtrade.exchange import get_ticker_history
|
from freqtrade.exchange import get_ticker_history
|
||||||
from freqtrade.optimize.hyperopt_conf import hyperopt_optimize_conf
|
from freqtrade.optimize.hyperopt_conf import hyperopt_optimize_conf
|
||||||
|
|
||||||
from pandas import DataFrame
|
|
||||||
|
|
||||||
from freqtrade.analyze import populate_indicators, parse_ticker_dataframe
|
from freqtrade.analyze import populate_indicators, parse_ticker_dataframe
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -50,10 +48,8 @@ def load_data(ticker_interval: int = 5, pairs: Optional[List[str]] = None,
|
|||||||
|
|
||||||
def preprocess(tickerdata: Dict[str, List]) -> Dict[str, DataFrame]:
|
def preprocess(tickerdata: Dict[str, List]) -> Dict[str, DataFrame]:
|
||||||
"""Creates a dataframe and populates indicators for given ticker data"""
|
"""Creates a dataframe and populates indicators for given ticker data"""
|
||||||
processed = {}
|
return {pair: populate_indicators(parse_ticker_dataframe(pair_data))
|
||||||
for pair, pair_data in tickerdata.items():
|
for pair, pair_data in tickerdata.items()}
|
||||||
processed[pair] = populate_indicators(parse_ticker_dataframe(pair_data))
|
|
||||||
return processed
|
|
||||||
|
|
||||||
|
|
||||||
def testdata_path() -> str:
|
def testdata_path() -> str:
|
||||||
|
@ -111,14 +111,14 @@ def backtest(stake_amount: float, processed: Dict[str, DataFrame],
|
|||||||
|
|
||||||
if min_roi_reached(trade, row2.close, row2.date) or row2.sell == 1:
|
if min_roi_reached(trade, row2.close, row2.date) or row2.sell == 1:
|
||||||
current_profit_percent = trade.calc_profit_percent(rate=row2.close)
|
current_profit_percent = trade.calc_profit_percent(rate=row2.close)
|
||||||
current_profit_BTC = trade.calc_profit(rate=row2.close)
|
current_profit_btc = trade.calc_profit(rate=row2.close)
|
||||||
lock_pair_until = row2.Index
|
lock_pair_until = row2.Index
|
||||||
|
|
||||||
trades.append(
|
trades.append(
|
||||||
(
|
(
|
||||||
pair,
|
pair,
|
||||||
current_profit_percent,
|
current_profit_percent,
|
||||||
current_profit_BTC,
|
current_profit_btc,
|
||||||
row2.Index - row.Index
|
row2.Index - row.Index
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -118,8 +118,7 @@ def optimizer(params):
|
|||||||
backtesting.populate_buy_trend = buy_strategy_generator(params)
|
backtesting.populate_buy_trend = buy_strategy_generator(params)
|
||||||
|
|
||||||
results = backtest(OPTIMIZE_CONFIG['stake_amount'], PROCESSED)
|
results = backtest(OPTIMIZE_CONFIG['stake_amount'], PROCESSED)
|
||||||
|
result_explanation = format_results(results)
|
||||||
result = format_results(results)
|
|
||||||
|
|
||||||
total_profit = results.profit_percent.sum()
|
total_profit = results.profit_percent.sum()
|
||||||
trade_count = len(results.index)
|
trade_count = len(results.index)
|
||||||
@ -135,20 +134,17 @@ def optimizer(params):
|
|||||||
loss = trade_loss + profit_loss
|
loss = trade_loss + profit_loss
|
||||||
_CURRENT_TRIES += 1
|
_CURRENT_TRIES += 1
|
||||||
|
|
||||||
result_data = {
|
log_results({
|
||||||
'loss': loss,
|
'loss': loss,
|
||||||
'current_tries': _CURRENT_TRIES,
|
'current_tries': _CURRENT_TRIES,
|
||||||
'total_tries': TOTAL_TRIES,
|
'total_tries': TOTAL_TRIES,
|
||||||
'result': result,
|
'result': result_explanation,
|
||||||
}
|
})
|
||||||
log_results(result_data)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'loss': loss,
|
'loss': loss,
|
||||||
'status': STATUS_OK,
|
'status': STATUS_OK,
|
||||||
'result': result,
|
'result': result_explanation,
|
||||||
'total_profit': total_profit,
|
|
||||||
'avg_profit': results.profit_percent.mean() * 100.0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user