Use passed in config object to allow this to work in webserver mode
This commit is contained in:
parent
bf0e75e2a5
commit
f227f6a755
@ -1,3 +1,4 @@
|
|||||||
|
from copy import deepcopy
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
@ -538,14 +539,19 @@ class ApiServer(RPC):
|
|||||||
parameters:
|
parameters:
|
||||||
- pair: Pair
|
- pair: Pair
|
||||||
- timeframe: Timeframe to get data for (should be aligned to strategy.timeframe)
|
- 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))
|
- timerange: timerange in the format YYYYMMDD-YYYYMMDD (YYYYMMDD- or (-YYYYMMDD))
|
||||||
are als possible. If omitted uses all available data.
|
are als possible. If omitted uses all available data.
|
||||||
"""
|
"""
|
||||||
pair = request.args.get("pair")
|
pair = request.args.get("pair")
|
||||||
timeframe = request.args.get("timeframe")
|
timeframe = request.args.get("timeframe")
|
||||||
timerange = request.args.get("timerange")
|
timerange = request.args.get("timerange")
|
||||||
|
strategy = request.args.get("strategy")
|
||||||
results = self._rpc_analysed_history_full(pair, timeframe, timerange)
|
config = deepcopy(self._config)
|
||||||
|
config.update({
|
||||||
|
'strategy': strategy,
|
||||||
|
})
|
||||||
|
results = self._rpc_analysed_history_full(config, pair, timeframe, timerange)
|
||||||
return self.rest_dump(results)
|
return self.rest_dump(results)
|
||||||
|
|
||||||
@require_login
|
@require_login
|
||||||
|
@ -689,19 +689,19 @@ class RPC:
|
|||||||
_data = _data.iloc[-limit:].copy()
|
_data = _data.iloc[-limit:].copy()
|
||||||
return self._convert_dataframe_to_dict(pair, _data, last_analyzed)
|
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: str) -> Dict[str, Any]:
|
||||||
timerange = TimeRange.parse_timerange(timerange)
|
timerange = TimeRange.parse_timerange(timerange)
|
||||||
|
|
||||||
_data = load_data(
|
_data = load_data(
|
||||||
datadir=self._freqtrade.config.get("datadir"),
|
datadir=config.get("datadir"),
|
||||||
pairs=[pair],
|
pairs=[pair],
|
||||||
timeframe=self._freqtrade.config.get('timeframe', '5m'),
|
timeframe=timeframe,
|
||||||
timerange=timerange,
|
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
|
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})
|
df_analyzed = strategy.analyze_ticker(_data[pair], {'pair': pair})
|
||||||
|
|
||||||
return self._convert_dataframe_to_dict(pair, df_analyzed, arrow.Arrow.utcnow().datetime)
|
return self._convert_dataframe_to_dict(pair, df_analyzed, arrow.Arrow.utcnow().datetime)
|
||||||
|
Loading…
Reference in New Issue
Block a user