feat: api /pair_history - make Strategy optional

This commit is contained in:
Matthias
2025-02-01 17:39:28 +01:00
parent 6fb74fa166
commit ae42f8d512
2 changed files with 16 additions and 8 deletions

View File

@@ -526,7 +526,7 @@ class PairCandlesRequest(BaseModel):
class PairHistoryRequest(PairCandlesRequest, ExchangeModePayloadMixin):
timerange: str
strategy: str
strategy: str | None = None
freqaimodel: str | None = None
live_mode: bool = False

View File

@@ -1449,8 +1449,11 @@ class RPC:
from freqtrade.data.dataprovider import DataProvider
from freqtrade.resolvers.strategy_resolver import StrategyResolver
strategy_name = ""
if config.get("strategy"):
strategy = StrategyResolver.load_strategy(config)
startup_candles = strategy.startup_candle_count
strategy_name = strategy.get_strategy_name()
if live:
data = exchange.get_historic_ohlcv(
@@ -1477,14 +1480,19 @@ class RPC:
)
data = _data[pair]
if config.get("strategy"):
strategy.dp = DataProvider(config, exchange=exchange, pairlists=None)
strategy.ft_bot_start()
df_analyzed = strategy.analyze_ticker(data, {"pair": pair})
df_analyzed = trim_dataframe(df_analyzed, timerange_parsed, startup_candles=startup_candles)
df_analyzed = trim_dataframe(
df_analyzed, timerange_parsed, startup_candles=startup_candles
)
else:
df_analyzed = data
return RPC._convert_dataframe_to_dict(
strategy.get_strategy_name(),
strategy_name,
pair,
timeframe,
df_analyzed.copy(),