set output depending on backtest/backslap type
This commit is contained in:
parent
224f238ebe
commit
6eb70cf75b
@ -6,7 +6,7 @@ from typing import Dict, Any
|
||||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.optimize.optimize import IOptimize, BacktestResult, setup_configuration
|
||||
from freqtrade.optimize.optimize import IOptimize, BacktestResult, OptimizeType, setup_configuration
|
||||
from freqtrade.strategy import IStrategy
|
||||
from freqtrade.strategy.interface import SellType
|
||||
from freqtrade.strategy.resolver import StrategyResolver
|
||||
@ -24,6 +24,7 @@ class Backslapping(IOptimize):
|
||||
constructor
|
||||
"""
|
||||
super().__init__(config)
|
||||
self._optimizetype = OptimizeType.BACKTEST
|
||||
|
||||
self.fee = self.exchange.get_fee()
|
||||
|
||||
|
@ -9,7 +9,7 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.optimize.optimize import IOptimize, BacktestResult, setup_configuration
|
||||
from freqtrade.optimize.optimize import IOptimize, BacktestResult, OptimizeType, setup_configuration
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.strategy.interface import SellType
|
||||
|
||||
@ -27,6 +27,7 @@ class Backtesting(IOptimize):
|
||||
|
||||
def __init__(self, config: Dict[str, Any]) -> None:
|
||||
super().__init__(config)
|
||||
self._optimizetype = OptimizeType.BACKTEST
|
||||
|
||||
def _get_sell_trade_entry(
|
||||
self, pair: str, buy_row: DataFrame,
|
||||
|
@ -24,6 +24,7 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
from freqtrade.arguments import Arguments
|
||||
from freqtrade.configuration import Configuration
|
||||
from freqtrade.optimize import load_data
|
||||
from freqtrade.optimize.optimize import OptimizeType
|
||||
from freqtrade.optimize.backtesting import Backtesting
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -42,6 +43,7 @@ class Hyperopt(Backtesting):
|
||||
"""
|
||||
def __init__(self, config: Dict[str, Any]) -> None:
|
||||
super().__init__(config)
|
||||
self._optimizetype = OptimizeType.HYPEROPT
|
||||
# set TARGET_TRADES to suit your number concurrent trades so its realistic
|
||||
# to the number of days
|
||||
self.target_trades = 600
|
||||
|
@ -11,6 +11,7 @@ from copy import deepcopy
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
|
||||
from enum import Enum
|
||||
|
||||
import arrow
|
||||
from pandas import DataFrame
|
||||
@ -46,6 +47,12 @@ class BacktestResult(NamedTuple):
|
||||
sell_reason: SellType
|
||||
|
||||
|
||||
class OptimizeType(Enum):
|
||||
BACKTEST = "backtest"
|
||||
BACKSLAP = "backslap"
|
||||
HYPEROPT = "hyperopt"
|
||||
|
||||
|
||||
class IOptimize(ABC):
|
||||
"""
|
||||
Backtesting Abstract class, this class contains all the logic to run a backtest
|
||||
@ -269,7 +276,7 @@ class IOptimize(ABC):
|
||||
strategy if len(self.strategylist) > 1 else None)
|
||||
|
||||
print(f"Result for strategy {strategy}")
|
||||
print(' BACKTESTING REPORT '.center(119, '='))
|
||||
print(f' {self._optimizetype.value.upper()} REPORT '.center(119, '='))
|
||||
print(self._generate_text_table(data, results))
|
||||
|
||||
print(' SELL REASON STATS '.center(119, '='))
|
||||
|
Loading…
Reference in New Issue
Block a user