chore(stock): 调试接口增加涨跌边界样本
This commit is contained in:
@@ -156,18 +156,20 @@ func (h *StockHandler) TriggerSync(c *gin.Context) {
|
||||
}
|
||||
|
||||
type debugStatsResponse struct {
|
||||
TradeDate string `json:"trade_date"`
|
||||
Total int64 `json:"total"`
|
||||
IndexCount int64 `json:"index_count"`
|
||||
SuspendedCount int64 `json:"suspended_count"`
|
||||
UpByPrice int64 `json:"up_by_price"`
|
||||
DownByPrice int64 `json:"down_by_price"`
|
||||
FlatByPrice int64 `json:"flat_by_price"`
|
||||
UpByPct int64 `json:"up_by_pct"`
|
||||
DownByPct int64 `json:"down_by_pct"`
|
||||
FlatByPct int64 `json:"flat_by_pct"`
|
||||
FlatSamples []stockRow `json:"flat_samples"`
|
||||
BoundarySamples []stockRow `json:"boundary_samples"`
|
||||
TradeDate string `json:"trade_date"`
|
||||
Total int64 `json:"total"`
|
||||
IndexCount int64 `json:"index_count"`
|
||||
SuspendedCount int64 `json:"suspended_count"`
|
||||
UpByPrice int64 `json:"up_by_price"`
|
||||
DownByPrice int64 `json:"down_by_price"`
|
||||
FlatByPrice int64 `json:"flat_by_price"`
|
||||
UpByPct int64 `json:"up_by_pct"`
|
||||
DownByPct int64 `json:"down_by_pct"`
|
||||
FlatByPct int64 `json:"flat_by_pct"`
|
||||
FlatSamples []stockRow `json:"flat_samples"`
|
||||
BoundarySamples []stockRow `json:"boundary_samples"`
|
||||
UpBoundarySamples []stockRow `json:"up_boundary_samples"`
|
||||
DownBoundarySamples []stockRow `json:"down_boundary_samples"`
|
||||
}
|
||||
|
||||
// DebugStats 返回最新交易日的详细统计与边界样本,便于对齐第三方口径。
|
||||
@@ -230,6 +232,24 @@ func (h *StockHandler) DebugStats(c *gin.Context) {
|
||||
Scan(&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})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user