chore(stock): 调试接口增加涨跌边界样本

This commit is contained in:
2026-07-04 11:22:01 +08:00
parent 05c38ca8e3
commit 346d3c5555
+32 -12
View File
@@ -156,18 +156,20 @@ func (h *StockHandler) TriggerSync(c *gin.Context) {
} }
type debugStatsResponse struct { type debugStatsResponse struct {
TradeDate string `json:"trade_date"` TradeDate string `json:"trade_date"`
Total int64 `json:"total"` Total int64 `json:"total"`
IndexCount int64 `json:"index_count"` IndexCount int64 `json:"index_count"`
SuspendedCount int64 `json:"suspended_count"` SuspendedCount int64 `json:"suspended_count"`
UpByPrice int64 `json:"up_by_price"` UpByPrice int64 `json:"up_by_price"`
DownByPrice int64 `json:"down_by_price"` DownByPrice int64 `json:"down_by_price"`
FlatByPrice int64 `json:"flat_by_price"` FlatByPrice int64 `json:"flat_by_price"`
UpByPct int64 `json:"up_by_pct"` UpByPct int64 `json:"up_by_pct"`
DownByPct int64 `json:"down_by_pct"` DownByPct int64 `json:"down_by_pct"`
FlatByPct int64 `json:"flat_by_pct"` FlatByPct int64 `json:"flat_by_pct"`
FlatSamples []stockRow `json:"flat_samples"` FlatSamples []stockRow `json:"flat_samples"`
BoundarySamples []stockRow `json:"boundary_samples"` BoundarySamples []stockRow `json:"boundary_samples"`
UpBoundarySamples []stockRow `json:"up_boundary_samples"`
DownBoundarySamples []stockRow `json:"down_boundary_samples"`
} }
// DebugStats 返回最新交易日的详细统计与边界样本,便于对齐第三方口径。 // DebugStats 返回最新交易日的详细统计与边界样本,便于对齐第三方口径。
@@ -230,6 +232,24 @@ func (h *StockHandler) DebugStats(c *gin.Context) {
Scan(&boundarySamples) Scan(&boundarySamples)
stats.BoundarySamples = boundarySamples stats.BoundarySamples = boundarySamples
var upBoundarySamples []stockRow
h.DB.WithContext(ctx).Model(&models.StockDailyQuote{}).
Select("symbol, name, close, prev_close, change_pct").
Where("trade_date = ? AND symbol NOT IN ? AND close > prev_close", latestDate, idxList).
Order("change_pct ASC").
Limit(50).
Scan(&upBoundarySamples)
stats.UpBoundarySamples = upBoundarySamples
var downBoundarySamples []stockRow
h.DB.WithContext(ctx).Model(&models.StockDailyQuote{}).
Select("symbol, name, close, prev_close, change_pct").
Where("trade_date = ? AND symbol NOT IN ? AND close < prev_close", latestDate, idxList).
Order("change_pct DESC").
Limit(50).
Scan(&downBoundarySamples)
stats.DownBoundarySamples = downBoundarySamples
c.JSON(http.StatusOK, gin.H{"success": true, "data": stats}) c.JSON(http.StatusOK, gin.H{"success": true, "data": stats})
} }