feat: Add cross-sectional strategy support
- Add cross-sectional strategy type (single vs cross-sectional) - Support multi-symbol portfolio management with automatic ranking - Add portfolio size, long ratio, and rebalance frequency configuration - Implement parallel order execution for cross-sectional strategies - Add frontend UI for strategy type selection and configuration - Add i18n support (Chinese and English) for cross-sectional features - Fix decimal precision issues in exchange order quantities - Add last_rebalance_at field to database schema - Add comprehensive documentation and examples Database migration required: Add last_rebalance_at column to qd_strategies_trading table
This commit is contained in:
@@ -427,6 +427,11 @@ def get_positions():
|
||||
pct = _calc_pnl_percent(entry, size, pnl)
|
||||
|
||||
rr = dict(r)
|
||||
# 确保 entry_price 有值(如果数据库中是 NULL,使用计算出的 entry 值)
|
||||
if not rr.get("entry_price") or float(rr.get("entry_price") or 0.0) <= 0:
|
||||
rr["entry_price"] = float(entry or 0.0)
|
||||
else:
|
||||
rr["entry_price"] = float(rr.get("entry_price") or 0.0)
|
||||
rr["current_price"] = float(cp or 0.0)
|
||||
rr["unrealized_pnl"] = float(pnl)
|
||||
rr["pnl_percent"] = float(pct)
|
||||
|
||||
Reference in New Issue
Block a user