Replace more occurances of ticker_interval with timeframe
This commit is contained in:
parent
18913db992
commit
cadc50ce9b
@ -25,7 +25,7 @@ def start_test_pairlist(args: Dict[str, Any]) -> None:
|
||||
results = {}
|
||||
for curr in quote_currencies:
|
||||
config['stake_currency'] = curr
|
||||
# Do not use ticker_interval set in the config
|
||||
# Do not use timeframe set in the config
|
||||
pairlists = PairListManager(exchange, config)
|
||||
pairlists.refresh_pairlist()
|
||||
results[curr] = pairlists.whitelist
|
||||
|
@ -236,12 +236,12 @@ def convert_ohlcv_format(config: Dict[str, Any], convert_from: str, convert_to:
|
||||
from freqtrade.data.history.idatahandler import get_datahandler
|
||||
src = get_datahandler(config['datadir'], convert_from)
|
||||
trg = get_datahandler(config['datadir'], convert_to)
|
||||
timeframes = config.get('timeframes', [config.get('ticker_interval')])
|
||||
timeframes = config.get('timeframes', [config.get('timeframe')])
|
||||
logger.info(f"Converting candle (OHLCV) for timeframe {timeframes}")
|
||||
|
||||
if 'pairs' not in config:
|
||||
config['pairs'] = []
|
||||
# Check timeframes or fall back to ticker_interval.
|
||||
# Check timeframes or fall back to timeframe.
|
||||
for timeframe in timeframes:
|
||||
config['pairs'].extend(src.ohlcv_get_pairs(config['datadir'],
|
||||
timeframe))
|
||||
|
@ -55,7 +55,7 @@ class DataProvider:
|
||||
Use False only for read-only operations (where the dataframe is not modified)
|
||||
"""
|
||||
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
|
||||
return self._exchange.klines((pair, timeframe or self._config['ticker_interval']),
|
||||
return self._exchange.klines((pair, timeframe or self._config['timeframe']),
|
||||
copy=copy)
|
||||
else:
|
||||
return DataFrame()
|
||||
@ -67,7 +67,7 @@ class DataProvider:
|
||||
:param timeframe: timeframe to get data for
|
||||
"""
|
||||
return load_pair_history(pair=pair,
|
||||
timeframe=timeframe or self._config['ticker_interval'],
|
||||
timeframe=timeframe or self._config['timeframe'],
|
||||
datadir=self._config['datadir']
|
||||
)
|
||||
|
||||
|
@ -547,7 +547,7 @@ class FreqtradeBot:
|
||||
exchange=self.exchange.id,
|
||||
open_order_id=order_id,
|
||||
strategy=self.strategy.get_strategy_name(),
|
||||
ticker_interval=timeframe_to_minutes(self.config['ticker_interval'])
|
||||
ticker_interval=timeframe_to_minutes(self.config['timeframe'])
|
||||
)
|
||||
|
||||
# Update fees if order is closed
|
||||
@ -780,7 +780,7 @@ class FreqtradeBot:
|
||||
self.update_trade_state(trade, stoploss_order, sl_order=True)
|
||||
# Lock pair for one candle to prevent immediate rebuys
|
||||
self.strategy.lock_pair(trade.pair,
|
||||
timeframe_to_next_date(self.config['ticker_interval']))
|
||||
timeframe_to_next_date(self.config['timeframe']))
|
||||
self._notify_sell(trade, "stoploss")
|
||||
return True
|
||||
|
||||
@ -1090,7 +1090,7 @@ class FreqtradeBot:
|
||||
Trade.session.flush()
|
||||
|
||||
# Lock pair for one candle to prevent immediate rebuys
|
||||
self.strategy.lock_pair(trade.pair, timeframe_to_next_date(self.config['ticker_interval']))
|
||||
self.strategy.lock_pair(trade.pair, timeframe_to_next_date(self.config['timeframe']))
|
||||
|
||||
self._notify_sell(trade, order_type)
|
||||
|
||||
|
@ -94,10 +94,10 @@ class Backtesting:
|
||||
self.strategylist.append(StrategyResolver.load_strategy(self.config))
|
||||
validate_config_consistency(self.config)
|
||||
|
||||
if "ticker_interval" not in self.config:
|
||||
if "timeframe" not in self.config:
|
||||
raise OperationalException("Timeframe (ticker interval) needs to be set in either "
|
||||
"configuration or as cli argument `--ticker-interval 5m`")
|
||||
self.timeframe = str(self.config.get('ticker_interval'))
|
||||
"configuration or as cli argument `--timeframe 5m`")
|
||||
self.timeframe = str(self.config.get('timeframe'))
|
||||
self.timeframe_min = timeframe_to_minutes(self.timeframe)
|
||||
|
||||
# Get maximum required startup period
|
||||
|
@ -37,7 +37,8 @@ class IHyperOpt(ABC):
|
||||
self.config = config
|
||||
|
||||
# Assign ticker_interval to be used in hyperopt
|
||||
IHyperOpt.ticker_interval = str(config['ticker_interval'])
|
||||
IHyperOpt.ticker_interval = str(config['timeframe']) # DEPRECTED
|
||||
IHyperOpt.timeframe = str(config['timeframe'])
|
||||
|
||||
@staticmethod
|
||||
def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||
@ -218,9 +219,10 @@ class IHyperOpt(ABC):
|
||||
# Why do I still need such shamanic mantras in modern python?
|
||||
def __getstate__(self):
|
||||
state = self.__dict__.copy()
|
||||
state['ticker_interval'] = self.ticker_interval
|
||||
state['timeframe'] = self.timeframe
|
||||
return state
|
||||
|
||||
def __setstate__(self, state):
|
||||
self.__dict__.update(state)
|
||||
IHyperOpt.ticker_interval = state['ticker_interval']
|
||||
IHyperOpt.ticker_interval = state['timeframe']
|
||||
IHyperOpt.timeframe = state['timeframe']
|
||||
|
@ -131,6 +131,6 @@ class PairListManager():
|
||||
|
||||
def create_pair_list(self, pairs: List[str], timeframe: str = None) -> ListPairsWithTimeframes:
|
||||
"""
|
||||
Create list of pair tuples with (pair, ticker_interval)
|
||||
Create list of pair tuples with (pair, timeframe)
|
||||
"""
|
||||
return [(pair, timeframe or self._config['ticker_interval']) for pair in pairs]
|
||||
return [(pair, timeframe or self._config['timeframe']) for pair in pairs]
|
||||
|
@ -45,7 +45,7 @@ def init_plotscript(config):
|
||||
data = load_data(
|
||||
datadir=config.get("datadir"),
|
||||
pairs=pairs,
|
||||
timeframe=config.get('ticker_interval', '5m'),
|
||||
timeframe=config.get('timeframe', '5m'),
|
||||
timerange=timerange,
|
||||
data_format=config.get('dataformat_ohlcv', 'json'),
|
||||
)
|
||||
@ -487,7 +487,7 @@ def load_and_plot_trades(config: Dict[str, Any]):
|
||||
plot_config=strategy.plot_config if hasattr(strategy, 'plot_config') else {}
|
||||
)
|
||||
|
||||
store_plot_file(fig, filename=generate_plot_filename(pair, config['ticker_interval']),
|
||||
store_plot_file(fig, filename=generate_plot_filename(pair, config['timeframe']),
|
||||
directory=config['user_data_dir'] / "plot")
|
||||
|
||||
logger.info('End of plotting process. %s plots generated', pair_counter)
|
||||
@ -515,6 +515,6 @@ def plot_profit(config: Dict[str, Any]) -> None:
|
||||
# Create an average close price of all the pairs that were involved.
|
||||
# this could be useful to gauge the overall market trend
|
||||
fig = generate_profit_graph(plot_elements["pairs"], plot_elements["ohlcv"],
|
||||
trades, config.get('ticker_interval', '5m'))
|
||||
trades, config.get('timeframe', '5m'))
|
||||
store_plot_file(fig, filename='freqtrade-profit-plot.html',
|
||||
directory=config['user_data_dir'] / "plot", auto_open=True)
|
||||
|
@ -77,8 +77,9 @@ class HyperOptLossResolver(IResolver):
|
||||
config, kwargs={},
|
||||
extra_dir=config.get('hyperopt_path'))
|
||||
|
||||
# Assign ticker_interval to be used in hyperopt
|
||||
hyperoptloss.__class__.ticker_interval = str(config['ticker_interval'])
|
||||
# Assign timeframe to be used in hyperopt
|
||||
hyperoptloss.__class__.ticker_interval = str(config['timeframe'])
|
||||
hyperoptloss.__class__.timeframe = str(config['timeframe'])
|
||||
|
||||
if not hasattr(hyperoptloss, 'hyperopt_loss_function'):
|
||||
raise OperationalException(
|
||||
|
@ -54,7 +54,7 @@ class StrategyResolver(IResolver):
|
||||
# Check if we need to override configuration
|
||||
# (Attribute name, default, subkey)
|
||||
attributes = [("minimal_roi", {"0": 10.0}, None),
|
||||
("ticker_interval", None, None),
|
||||
("timeframe", None, None),
|
||||
("stoploss", None, None),
|
||||
("trailing_stop", None, None),
|
||||
("trailing_stop_positive", None, None),
|
||||
|
@ -62,7 +62,7 @@ class IStrategy(ABC):
|
||||
Attributes you can use:
|
||||
minimal_roi -> Dict: Minimal ROI designed for the strategy
|
||||
stoploss -> float: optimal stoploss designed for the strategy
|
||||
ticker_interval -> str: value of the timeframe (ticker interval) to use with the strategy
|
||||
timeframe -> str: value of the timeframe (ticker interval) to use with the strategy
|
||||
"""
|
||||
# Strategy interface version
|
||||
# Default to version 2
|
||||
|
@ -51,8 +51,8 @@ class {{ strategy }}(IStrategy):
|
||||
# trailing_stop_positive = 0.01
|
||||
# trailing_stop_positive_offset = 0.0 # Disabled / not configured
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
ticker_interval = '5m'
|
||||
# Optimal timeframe for the strategy.
|
||||
timeframe = '5m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
@ -186,7 +186,7 @@ def test_strategy_override_timeframe(caplog, default_conf):
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert strategy.ticker_interval == 60
|
||||
assert strategy.timeframe == 60
|
||||
assert strategy.stake_currency == 'ETH'
|
||||
assert log_has("Override strategy 'timeframe' with value in config file: 60.",
|
||||
caplog)
|
||||
|
Loading…
Reference in New Issue
Block a user