mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
feat: api /pair_history - make Strategy optional
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user