feat:新增投顾agent和nl2sqlagent

This commit is contained in:
2026-09-13 16:19:24 +08:00
parent c80c6acac0
commit 163192bf55
122 changed files with 7488 additions and 362 deletions
+39
View File
@@ -0,0 +1,39 @@
"""现有业务 ORM 到投顾意图输入的适配。"""
from __future__ import annotations
from decimal import Decimal
def _number(value):
return float(value) if isinstance(value, Decimal) else value
def to_fund_performance_row(row) -> dict:
return {
"period": getattr(row, "period", None),
"return_rate": _number(getattr(row, "return_rate", None)),
"annual_volatility": _number(getattr(row, "annual_volatility", None)),
"max_drawdown": _number(getattr(row, "max_drawdown", None)),
"sharpe": _number(getattr(row, "sharpe", None)),
}
def to_holding_input(holding, product) -> dict:
return {
"product_id": holding.product_id,
"product_code": product.product_code,
"asset_class": product.product_type,
"market_value": holding.current_value or Decimal("0"),
}
def to_product_candidate(product) -> dict:
expected_return = product.expected_return or Decimal("0")
return {
"product_id": product.id,
"product_code": product.product_code,
"product_name": product.product_name,
"asset_class": product.product_type,
"risk_level": product.risk_level,
"performance_score": float(expected_return),
}