Skip to content

Commit 1118032

Browse files
committed
feat: add /profit_all endpoint
1 parent 277828b commit 1118032

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

freqtrade/rpc/api_server/api_schemas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class Profit(BaseModel):
173173
bot_start_date: str
174174

175175

176+
class ProfitAll(BaseModel):
177+
all: Profit
178+
long: Profit | None = None
179+
short: Profit | None = None
180+
181+
176182
class SellReason(BaseModel):
177183
wins: int
178184
losses: int

freqtrade/rpc/api_server/api_v1.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
Ping,
4444
PlotConfig,
4545
Profit,
46+
ProfitAll,
4647
ResultMsg,
4748
ShowConfig,
4849
Stats,
@@ -89,7 +90,8 @@
8990
# 2.40: Add hyperopt-loss endpoint
9091
# 2.41: Add download-data endpoint
9192
# 2.42: Add /pair_history endpoint with live data
92-
API_VERSION = 2.42
93+
# 2.43: Add /profit_all endpoint
94+
API_VERSION = 2.43
9395

9496
# Public API, requires no auth.
9597
router_public = APIRouter()
@@ -148,6 +150,24 @@ def profit(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
148150
return rpc._rpc_trade_statistics(config["stake_currency"], config.get("fiat_display_currency"))
149151

150152

153+
@router.get("/profit_all", response_model=ProfitAll, tags=["info"])
154+
def profit_all(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
155+
response = {
156+
"all": rpc._rpc_trade_statistics(
157+
config["stake_currency"], config.get("fiat_display_currency")
158+
),
159+
}
160+
if config.get("trading_mode", TradingMode.SPOT) != TradingMode.SPOT:
161+
response["long"] = rpc._rpc_trade_statistics(
162+
config["stake_currency"], config.get("fiat_display_currency"), direction="long"
163+
)
164+
response["short"] = rpc._rpc_trade_statistics(
165+
config["stake_currency"], config.get("fiat_display_currency"), direction="short"
166+
)
167+
168+
return response
169+
170+
151171
@router.get("/stats", response_model=Stats, tags=["info"])
152172
def stats(rpc: RPC = Depends(get_rpc)):
153173
return rpc._rpc_stats()

0 commit comments

Comments
 (0)