手动打分页改为按品种选择,日期限定主力合约范围,结果自动滚动到视图
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,13 +6,14 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
type runRequest struct {
|
||||
TsCode string `json:"ts_code,omitempty"`
|
||||
Symbol string `json:"symbol,omitempty"`
|
||||
TradeDate string `json:"trade_date,omitempty"`
|
||||
TsCode string `json:"ts_code,omitempty"`
|
||||
Symbol string `json:"symbol,omitempty"`
|
||||
TradeDate string `json:"trade_date,omitempty"`
|
||||
}
|
||||
|
||||
func (d *Deps) RunPipeline(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -40,3 +41,24 @@ func (d *Deps) RunPipeline(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
_, _ = io.Copy(w, resp.Body)
|
||||
}
|
||||
|
||||
func (d *Deps) GetActiveContract(w http.ResponseWriter, r *http.Request) {
|
||||
symbol := r.URL.Query().Get("symbol")
|
||||
if symbol == "" {
|
||||
writeErr(w, http.StatusBadRequest, "symbol is required")
|
||||
return
|
||||
}
|
||||
|
||||
target := fmt.Sprintf("%s/api/v1/contracts/active?symbol=%s", d.TushareURL, url.QueryEscape(symbol))
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
resp, err := client.Get(target)
|
||||
if err != nil {
|
||||
writeErr(w, http.StatusBadGateway, fmt.Sprintf("tushare service unavailable: %v", err))
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
_, _ = io.Copy(w, resp.Body)
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ func New(d *handlers.Deps, mgr *auth.Manager, authStore *store.AuthStore, dist f
|
||||
r.Get("/scores", d.ListScores)
|
||||
r.Get("/scores/{id}", d.GetScore)
|
||||
r.Get("/contracts", d.ListContracts)
|
||||
r.Get("/contracts/active", d.GetActiveContract)
|
||||
r.Get("/candles", d.ListCandles)
|
||||
r.Post("/run", d.RunPipeline)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user