Enable plot_config to work in webserver mode
(requires strategy argument)
This commit is contained in:
parent
da0992f859
commit
3216a05a9e
@ -248,8 +248,18 @@ def pair_history(pair: str, timeframe: str, timerange: str, strategy: str,
|
|||||||
|
|
||||||
|
|
||||||
@router.get('/plot_config', response_model=PlotConfig, tags=['candle data'])
|
@router.get('/plot_config', response_model=PlotConfig, tags=['candle data'])
|
||||||
def plot_config(rpc: RPC = Depends(get_rpc)):
|
def plot_config(strategy: Optional[str] = None, config=Depends(get_config),
|
||||||
return PlotConfig.parse_obj(rpc._rpc_plot_config())
|
rpc: Optional[RPC] = Depends(get_rpc_optional)):
|
||||||
|
if not strategy:
|
||||||
|
if not rpc:
|
||||||
|
raise RPCException("Strategy is mandatory in webserver mode.")
|
||||||
|
return PlotConfig.parse_obj(rpc._rpc_plot_config())
|
||||||
|
else:
|
||||||
|
config1 = deepcopy(config)
|
||||||
|
config1.update({
|
||||||
|
'strategy': strategy
|
||||||
|
})
|
||||||
|
return PlotConfig.parse_obj(RPC._rpc_plot_config_with_strategy(config1))
|
||||||
|
|
||||||
|
|
||||||
@router.get('/strategies', response_model=StrategyListResponse, tags=['strategy'])
|
@router.get('/strategies', response_model=StrategyListResponse, tags=['strategy'])
|
||||||
|
@ -1157,6 +1157,16 @@ class RPC:
|
|||||||
self._freqtrade.strategy.plot_config['subplots'] = {}
|
self._freqtrade.strategy.plot_config['subplots'] = {}
|
||||||
return self._freqtrade.strategy.plot_config
|
return self._freqtrade.strategy.plot_config
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _rpc_plot_config_with_strategy(config: Config) -> Dict[str, Any]:
|
||||||
|
|
||||||
|
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||||
|
strategy = StrategyResolver.load_strategy(config)
|
||||||
|
|
||||||
|
if (strategy.plot_config and 'subplots' not in strategy.plot_config):
|
||||||
|
strategy.plot_config['subplots'] = {}
|
||||||
|
return strategy.plot_config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _rpc_sysinfo() -> Dict[str, Any]:
|
def _rpc_sysinfo() -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user