mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33: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):
|
class PairHistoryRequest(PairCandlesRequest, ExchangeModePayloadMixin):
|
||||||
timerange: str
|
timerange: str
|
||||||
strategy: str
|
strategy: str | None = None
|
||||||
freqaimodel: str | None = None
|
freqaimodel: str | None = None
|
||||||
live_mode: bool = False
|
live_mode: bool = False
|
||||||
|
|
||||||
|
|||||||
@@ -1449,8 +1449,11 @@ class RPC:
|
|||||||
from freqtrade.data.dataprovider import DataProvider
|
from freqtrade.data.dataprovider import DataProvider
|
||||||
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||||
|
|
||||||
|
strategy_name = ""
|
||||||
|
if config.get("strategy"):
|
||||||
strategy = StrategyResolver.load_strategy(config)
|
strategy = StrategyResolver.load_strategy(config)
|
||||||
startup_candles = strategy.startup_candle_count
|
startup_candles = strategy.startup_candle_count
|
||||||
|
strategy_name = strategy.get_strategy_name()
|
||||||
|
|
||||||
if live:
|
if live:
|
||||||
data = exchange.get_historic_ohlcv(
|
data = exchange.get_historic_ohlcv(
|
||||||
@@ -1477,14 +1480,19 @@ class RPC:
|
|||||||
)
|
)
|
||||||
data = _data[pair]
|
data = _data[pair]
|
||||||
|
|
||||||
|
if config.get("strategy"):
|
||||||
strategy.dp = DataProvider(config, exchange=exchange, pairlists=None)
|
strategy.dp = DataProvider(config, exchange=exchange, pairlists=None)
|
||||||
strategy.ft_bot_start()
|
strategy.ft_bot_start()
|
||||||
|
|
||||||
df_analyzed = strategy.analyze_ticker(data, {"pair": pair})
|
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(
|
return RPC._convert_dataframe_to_dict(
|
||||||
strategy.get_strategy_name(),
|
strategy_name,
|
||||||
pair,
|
pair,
|
||||||
timeframe,
|
timeframe,
|
||||||
df_analyzed.copy(),
|
df_analyzed.copy(),
|
||||||
|
|||||||
Reference in New Issue
Block a user