Use passed in config object to allow this to work in webserver mode

This commit is contained in:
Matthias 2020-07-26 20:31:11 +02:00
parent bf0e75e2a5
commit f227f6a755
2 changed files with 13 additions and 7 deletions

View File

@ -1,3 +1,4 @@
from copy import deepcopy
import logging
import threading
from datetime import date, datetime
@ -538,14 +539,19 @@ class ApiServer(RPC):
parameters:
- pair: Pair
- timeframe: Timeframe to get data for (should be aligned to strategy.timeframe)
- strategy: Strategy to use - Must exist in configured strategy-path!
- timerange: timerange in the format YYYYMMDD-YYYYMMDD (YYYYMMDD- or (-YYYYMMDD))
are als possible. If omitted uses all available data.
"""
pair = request.args.get("pair")
timeframe = request.args.get("timeframe")
timerange = request.args.get("timerange")
results = self._rpc_analysed_history_full(pair, timeframe, timerange)
strategy = request.args.get("strategy")
config = deepcopy(self._config)
config.update({
'strategy': strategy,
})
results = self._rpc_analysed_history_full(config, pair, timeframe, timerange)
return self.rest_dump(results)
@require_login

View File

@ -689,19 +689,19 @@ class RPC:
_data = _data.iloc[-limit:].copy()
return self._convert_dataframe_to_dict(pair, _data, last_analyzed)
def _rpc_analysed_history_full(self, pair: str, timeframe: str,
def _rpc_analysed_history_full(self, config: Dict[str, any], pair: str, timeframe: str,
timerange: str) -> Dict[str, Any]:
timerange = TimeRange.parse_timerange(timerange)
_data = load_data(
datadir=self._freqtrade.config.get("datadir"),
datadir=config.get("datadir"),
pairs=[pair],
timeframe=self._freqtrade.config.get('timeframe', '5m'),
timeframe=timeframe,
timerange=timerange,
data_format=self._freqtrade.config.get('dataformat_ohlcv', 'json'),
data_format=config.get('dataformat_ohlcv', 'json'),
)
from freqtrade.resolvers.strategy_resolver import StrategyResolver
strategy = StrategyResolver.load_strategy(self._freqtrade.config)
strategy = StrategyResolver.load_strategy(config)
df_analyzed = strategy.analyze_ticker(_data[pair], {'pair': pair})
return self._convert_dataframe_to_dict(pair, df_analyzed, arrow.Arrow.utcnow().datetime)