38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List
|
|
|
|
_TEMPLATES: Dict[str, Dict[str, Any]] = {
|
|
"analysis_default": {
|
|
"name": "analysis_default",
|
|
"description": "General market analysis prompt with technicals and news context",
|
|
"variables": ["symbol", "timeframe", "recent_news", "technicals"],
|
|
"body": (
|
|
"You are a trading assistant. Analyze {{symbol}} on {{timeframe}} timeframe.\n"
|
|
"Consider technical signals: {{technicals}} and relevant news: {{recent_news}}.\n"
|
|
"Provide a concise recommendation (BUY/SELL/HOLD) with reasoning and risk notes."
|
|
),
|
|
},
|
|
"risk_control_default": {
|
|
"name": "risk_control_default",
|
|
"description": "Risk control instructions for planning",
|
|
"variables": ["max_position_fraction", "min_rr_ratio"],
|
|
"body": (
|
|
"Adhere to risk rules: position <= {{max_position_fraction}} of equity,"
|
|
" risk-reward ratio >= {{min_rr_ratio}} whenever applicable."
|
|
),
|
|
},
|
|
}
|
|
|
|
|
|
def list_templates() -> List[Dict[str, Any]]:
|
|
return [
|
|
{"name": t["name"], "description": t["description"], "variables": t["variables"]}
|
|
for t in _TEMPLATES.values()
|
|
]
|
|
|
|
|
|
def get_template(name: str) -> Dict[str, Any]:
|
|
if name not in _TEMPLATES:
|
|
raise KeyError("Template not found")
|
|
return _TEMPLATES[name] |