mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
feat: add /profit_all endpoint
This commit is contained in:
@@ -173,6 +173,12 @@ class Profit(BaseModel):
|
||||
bot_start_date: str
|
||||
|
||||
|
||||
class ProfitAll(BaseModel):
|
||||
all: Profit
|
||||
long: Profit | None = None
|
||||
short: Profit | None = None
|
||||
|
||||
|
||||
class SellReason(BaseModel):
|
||||
wins: int
|
||||
losses: int
|
||||
|
||||
@@ -43,6 +43,7 @@ from freqtrade.rpc.api_server.api_schemas import (
|
||||
Ping,
|
||||
PlotConfig,
|
||||
Profit,
|
||||
ProfitAll,
|
||||
ResultMsg,
|
||||
ShowConfig,
|
||||
Stats,
|
||||
@@ -89,7 +90,8 @@ logger = logging.getLogger(__name__)
|
||||
# 2.40: Add hyperopt-loss endpoint
|
||||
# 2.41: Add download-data endpoint
|
||||
# 2.42: Add /pair_history endpoint with live data
|
||||
API_VERSION = 2.42
|
||||
# 2.43: Add /profit_all endpoint
|
||||
API_VERSION = 2.43
|
||||
|
||||
# Public API, requires no auth.
|
||||
router_public = APIRouter()
|
||||
@@ -148,6 +150,24 @@ def profit(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
||||
return rpc._rpc_trade_statistics(config["stake_currency"], config.get("fiat_display_currency"))
|
||||
|
||||
|
||||
@router.get("/profit_all", response_model=ProfitAll, tags=["info"])
|
||||
def profit_all(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
||||
response = {
|
||||
"all": rpc._rpc_trade_statistics(
|
||||
config["stake_currency"], config.get("fiat_display_currency")
|
||||
),
|
||||
}
|
||||
if config.get("trading_mode", TradingMode.SPOT) != TradingMode.SPOT:
|
||||
response["long"] = rpc._rpc_trade_statistics(
|
||||
config["stake_currency"], config.get("fiat_display_currency"), direction="long"
|
||||
)
|
||||
response["short"] = rpc._rpc_trade_statistics(
|
||||
config["stake_currency"], config.get("fiat_display_currency"), direction="short"
|
||||
)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@router.get("/stats", response_model=Stats, tags=["info"])
|
||||
def stats(rpc: RPC = Depends(get_rpc)):
|
||||
return rpc._rpc_stats()
|
||||
|
||||
Reference in New Issue
Block a user