diff --git a/backend_api_python/app/services/pending_order_worker.py b/backend_api_python/app/services/pending_order_worker.py
index 00acfb5..f9d3d14 100644
--- a/backend_api_python/app/services/pending_order_worker.py
+++ b/backend_api_python/app/services/pending_order_worker.py
@@ -529,10 +529,19 @@ class PendingOrderWorker:
(float(u["size"]), float(u["entry_price"]), int(u["id"]))
)
for ins in to_insert:
+ # Get user_id from strategy
+ ins_user_id = 1
+ try:
+ cur.execute("SELECT user_id FROM qd_strategies_trading WHERE id = %s", (int(ins["strategy_id"]),))
+ strategy_row = cur.fetchone()
+ if strategy_row and strategy_row.get("user_id"):
+ ins_user_id = int(strategy_row["user_id"])
+ except Exception:
+ pass
cur.execute(
"""INSERT INTO qd_strategy_positions (user_id, strategy_id, symbol, side, size, entry_price, updated_at)
VALUES (%s, %s, %s, %s, %s, %s, NOW())""",
- (1, int(ins["strategy_id"]), str(ins["symbol"]), str(ins["side"]), float(ins["size"]), float(ins["entry_price"]))
+ (ins_user_id, int(ins["strategy_id"]), str(ins["symbol"]), str(ins["side"]), float(ins["size"]), float(ins["entry_price"]))
)
db.commit()
cur.close()
diff --git a/quantdinger_vue/src/views/dashboard/index.vue b/quantdinger_vue/src/views/dashboard/index.vue
index fa05ddf..0fd5d16 100644
--- a/quantdinger_vue/src/views/dashboard/index.vue
+++ b/quantdinger_vue/src/views/dashboard/index.vue
@@ -132,13 +132,10 @@
{{ $t('dashboard.runningStrategies') || '运行中策略' }}
- {{ summary.indicator_strategy_count + summary.ai_strategy_count }}
+ {{ summary.indicator_strategy_count }}
{{ $t('dashboard.unit.strategies') }}
- {{ summary.ai_strategy_count }}
- AI
- ·
{{ summary.indicator_strategy_count }}
{{ $t('dashboard.label.indicator') }}
@@ -1044,14 +1041,30 @@ export default {
if (!chartDom) return
this.pieChart = echarts.init(chartDom)
+ // Use strategy_stats for pie chart data (shows all strategies, not just those with positions)
+ const stats = Array.isArray(this.summary.strategy_stats) ? this.summary.strategy_stats : []
const raw = Array.isArray(this.summary.strategy_pnl_chart) ? this.summary.strategy_pnl_chart : []
- const data = raw
- .map(it => {
- const name = (it && it.name) ? String(it.name) : '-'
- const val = Number(it && it.value ? it.value : 0)
- return { name, value: Math.abs(val), signedValue: val }
- })
- .filter(it => it.value > 0)
+
+ // Prefer strategy_stats if available, fallback to strategy_pnl_chart
+ let data = []
+ if (stats.length > 0) {
+ data = stats.map(it => {
+ const name = (it && it.strategy_name) ? String(it.strategy_name) : '-'
+ const val = Number(it && it.total_pnl ? it.total_pnl : 0)
+ const trades = Number(it && it.total_trades ? it.total_trades : 0)
+ // Use trades count as value if no PnL, so at least we show the distribution
+ const displayVal = val !== 0 ? Math.abs(val) : trades
+ return { name, value: displayVal, signedValue: val, trades }
+ }).filter(it => it.value > 0)
+ } else {
+ data = raw
+ .map(it => {
+ const name = (it && it.name) ? String(it.name) : '-'
+ const val = Number(it && it.value ? it.value : 0)
+ return { name, value: Math.abs(val), signedValue: val }
+ })
+ .filter(it => it.value > 0)
+ }
const isDark = this.isDarkTheme
const textColor = isDark ? '#9ca3af' : '#6b7280'