Skip to content

Commit c5b9cc7

Browse files
authored
fix: fix return_rate_pct (ValueCell-ai#460)
## 📝 Pull Request Template ### 1. Related Issue Closes # (issue number) ### 2. Type of Change (select one) Type of Change: Bug Fix ### 3. Description Please describe the changes made and why they are necessary. ### 4. Testing - [x] I have tested this locally. - [x] I have updated or added relevant tests. ### 5. Checklist - [x] I have read the [Code of Conduct](./CODE_OF_CONDUCT.md) - [x] I have followed the [Contributing Guidelines](./CONTRIBUTING.md) - [x] My changes follow the project's coding style
1 parent b5f0dc7 commit c5b9cc7

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

python/valuecell/server/api/routers/strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def normalize_strategy_type(
204204
response_model=StrategyPerformanceResponse,
205205
summary="Get strategy performance and configuration overview",
206206
description=(
207-
"Return ROI, model/provider, and final prompt strictly from templates (no fallback)."
207+
"Return ROI strictly from portfolio view equity (total_value) relative to initial_capital; model/provider; and final prompt strictly from templates (no fallback)."
208208
),
209209
)
210210
async def get_strategy_performance(

python/valuecell/server/services/strategy_service.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,13 @@ async def get_strategy_performance(
219219
if snapshot
220220
else None
221221
)
222-
pnl_value = (
223-
StrategyService._combine_realized_unrealized(snapshot) if snapshot else None
224-
)
225222

226223
return_rate_pct: Optional[float] = None
227224
try:
228-
if initial_capital and initial_capital > 0:
229-
if total_value is not None:
230-
return_rate_pct = (
231-
(total_value - initial_capital) / initial_capital
232-
) * 100.0
233-
elif pnl_value is not None:
234-
return_rate_pct = (pnl_value / initial_capital) * 100.0
225+
if initial_capital and initial_capital > 0 and total_value is not None:
226+
return_rate_pct = (
227+
(total_value - initial_capital) / initial_capital
228+
) * 100.0
235229
except Exception:
236230
return_rate_pct = None
237231

0 commit comments

Comments
 (0)