Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/valuecell/server/api/schemas/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,14 @@ class StrategyPerformanceData(BaseModel):
strategy_type: Optional[StrategyType] = Field(
None, description="Strategy type (PromptBasedStrategy/GridStrategy)"
)
trading_mode: Optional[Literal["live", "virtual"]] = Field(
None, description="Trading mode: live or virtual"
)
max_leverage: Optional[float] = Field(None, description="Maximum leverage")
symbols: Optional[List[str]] = Field(None, description="Symbols universe")
prompt_name: Optional[str] = Field(
None, description="Prompt template name used by the strategy"
)
prompt: Optional[str] = Field(
None, description="Final resolved prompt text used by the strategy"
)
Expand Down
8 changes: 8 additions & 0 deletions python/valuecell/server/services/strategy_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ async def get_strategy_performance(
if trading_mode_raw.startswith("tradingmode."):
trading_mode_raw = trading_mode_raw.split(".", 1)[1]
is_live_mode = trading_mode_raw == "live"
trading_mode: Optional[str] = (
trading_mode_raw if trading_mode_raw in ("live", "virtual") else None
)

if is_live_mode:
# Fast path: read from metadata set on first LIVE snapshot
Expand All @@ -240,14 +243,17 @@ async def get_strategy_performance(
tr.get("template_id") if tr.get("template_id") is not None else None
)
final_prompt: Optional[str] = None
prompt_name: Optional[str] = None
if template_id:
try:
prompt_item = repo.get_prompt_by_id(template_id)
if prompt_item and getattr(prompt_item, "content", None):
final_prompt = prompt_item.content
prompt_name = getattr(prompt_item, "name", None)
except Exception:
# Strict mode: do not fallback; leave final_prompt as None
final_prompt = None
prompt_name = None

total_value = (
_to_optional_float(getattr(snapshot, "total_value", None))
Expand All @@ -272,8 +278,10 @@ async def get_strategy_performance(
llm_model_id=llm_model_id,
exchange_id=exchange_id,
strategy_type=strategy_type,
trading_mode=trading_mode,
max_leverage=max_leverage,
symbols=symbols,
prompt_name=prompt_name,
prompt=final_prompt,
)

Expand Down