Don't require RPC for strategy
This commit is contained in:
parent
e6176d43f3
commit
ca0bb7bbb8
@ -1,5 +1,5 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, TypeVar, Union
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
@ -180,6 +180,9 @@ class TradeResponse(BaseModel):
|
|||||||
trades_count: int
|
trades_count: int
|
||||||
|
|
||||||
|
|
||||||
|
ForceBuyResponse = TypeVar('ForceBuyResponse', TradeSchema, StatusMsg)
|
||||||
|
|
||||||
|
|
||||||
class LockModel(BaseModel):
|
class LockModel(BaseModel):
|
||||||
active: bool
|
active: bool
|
||||||
lock_end_time: str
|
lock_end_time: str
|
||||||
@ -234,11 +237,14 @@ class DeleteTrade(BaseModel):
|
|||||||
trade_id: int
|
trade_id: int
|
||||||
|
|
||||||
|
|
||||||
class PlotConfig(BaseModel):
|
class PlotConfig_(BaseModel):
|
||||||
main_plot: Dict[str, Any]
|
main_plot: Dict[str, Any]
|
||||||
subplots: Optional[Dict[str, Any]]
|
subplots: Optional[Dict[str, Any]]
|
||||||
|
|
||||||
|
|
||||||
|
PlotConfig = TypeVar('PlotConfig', PlotConfig_, Dict)
|
||||||
|
|
||||||
|
|
||||||
class StrategyListResponse(BaseModel):
|
class StrategyListResponse(BaseModel):
|
||||||
strategies: List[str]
|
strategies: List[str]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import List, Optional
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
@ -12,12 +12,12 @@ from freqtrade.exceptions import OperationalException
|
|||||||
from freqtrade.rpc import RPC
|
from freqtrade.rpc import RPC
|
||||||
from freqtrade.rpc.api_server.api_schemas import (AvailablePairs, Balances, BlacklistPayload,
|
from freqtrade.rpc.api_server.api_schemas import (AvailablePairs, Balances, BlacklistPayload,
|
||||||
BlacklistResponse, Count, Daily, DeleteTrade,
|
BlacklistResponse, Count, Daily, DeleteTrade,
|
||||||
ForceBuyPayload, ForceSellPayload, Locks, Logs,
|
ForceBuyPayload, ForceBuyResponse,
|
||||||
OpenTradeSchema, PairHistory, PerformanceEntry,
|
ForceSellPayload, Locks, Logs, OpenTradeSchema,
|
||||||
Ping, PlotConfig, Profit, ResultMsg, Stats,
|
PairHistory, PerformanceEntry, Ping, PlotConfig,
|
||||||
StatusMsg, StrategyListResponse, StrategyResponse,
|
Profit, ResultMsg, Stats, StatusMsg,
|
||||||
TradeResponse, TradeSchema, Version,
|
StrategyListResponse, StrategyResponse,
|
||||||
WhitelistResponse)
|
TradeResponse, Version, WhitelistResponse)
|
||||||
from freqtrade.rpc.api_server.deps import get_config, get_rpc, get_rpc_optional
|
from freqtrade.rpc.api_server.deps import get_config, get_rpc, get_rpc_optional
|
||||||
from freqtrade.rpc.rpc import RPCException
|
from freqtrade.rpc.rpc import RPCException
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ def show_config(rpc: Optional[RPC] = Depends(get_rpc_optional), config=Depends(g
|
|||||||
return RPC._rpc_show_config(config, state)
|
return RPC._rpc_show_config(config, state)
|
||||||
|
|
||||||
|
|
||||||
@router.post('/forcebuy', response_model=Union[TradeSchema, StatusMsg], tags=['trading'])
|
@router.post('/forcebuy', response_model=ForceBuyResponse, tags=['trading'])
|
||||||
def forcebuy(payload: ForceBuyPayload, rpc: RPC = Depends(get_rpc)):
|
def forcebuy(payload: ForceBuyPayload, rpc: RPC = Depends(get_rpc)):
|
||||||
trade = rpc._rpc_forcebuy(payload.pair, payload.price)
|
trade = rpc._rpc_forcebuy(payload.pair, payload.price)
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ def pair_history(pair: str, timeframe: str, timerange: str, strategy: str,
|
|||||||
return RPC._rpc_analysed_history_full(config, pair, timeframe, timerange)
|
return RPC._rpc_analysed_history_full(config, pair, timeframe, timerange)
|
||||||
|
|
||||||
|
|
||||||
@router.get('/plot_config', response_model=Union[PlotConfig, Dict], tags=['candle data'])
|
@router.get('/plot_config', response_model=PlotConfig, tags=['candle data'])
|
||||||
def plot_config(rpc: RPC = Depends(get_rpc)):
|
def plot_config(rpc: RPC = Depends(get_rpc)):
|
||||||
return rpc._rpc_plot_config()
|
return rpc._rpc_plot_config()
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ def list_strategies(config=Depends(get_config)):
|
|||||||
|
|
||||||
|
|
||||||
@router.get('/strategy/{strategy}', response_model=StrategyResponse, tags=['strategy'])
|
@router.get('/strategy/{strategy}', response_model=StrategyResponse, tags=['strategy'])
|
||||||
def get_strategy(strategy: str, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
def get_strategy(strategy: str, config=Depends(get_config)):
|
||||||
|
|
||||||
config = deepcopy(config)
|
config = deepcopy(config)
|
||||||
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||||
|
@ -25,6 +25,7 @@ class ApiServer(RPCHandler):
|
|||||||
self._server = None
|
self._server = None
|
||||||
|
|
||||||
ApiServer._rpc = rpc
|
ApiServer._rpc = rpc
|
||||||
|
ApiServer._has_rpc = True
|
||||||
ApiServer._config = config
|
ApiServer._config = config
|
||||||
api_config = self._config['api_server']
|
api_config = self._config['api_server']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user