package trade import ( "encoding/json" "github.com/adshao/go-binance/v2/futures" ) // 技术指标结果 type TechnicalsIndex struct { NewPrice float64 `json:"new_price"` Rsi float64 `json:"rsi"` PriceRate []float64 `json:"price_rate"` Today *TodayIndex `json:"today"` Ema *EmaIndex `json:"ema"` Boll *BollBandsIndex `json:"boll"` TopBottom *TopBottomIndex `json:"top_bottom"` Timeseq int64 `json:"timeseq"` KLines []*futures.Kline `json:"k_lines"` } type TodayIndex struct { Open float64 `json:"open"` High float64 `json:"high"` Low float64 `json:"low"` Rate float64 `json:"rate"` Status string `json:"status"` } type EmaIndex struct { Max float64 `json:"max"` Top float64 `json:"top"` Avg float64 `json:"avg"` End float64 `json:"end"` Min float64 `json:"min"` } type TopBottomIndex struct { High float64 `json:"high"` Low float64 `json:"low"` } type BollBandsIndex struct { Mid float64 `json:"mid"` Upper float64 `json:"upper"` Lower float64 `json:"lower"` } func NewTechnicalsIndex(from string) (*TechnicalsIndex, error) { var ret TechnicalsIndex err := json.Unmarshal([]byte(from), &ret) return &ret, err } func (t *TechnicalsIndex) String() string { if t == nil { return "" } res, _ := json.Marshal(t) return string(res) } func (t *TechnicalsIndex) KLineString() string { if t.KLines == nil { return "" } res, _ := json.Marshal(t.KLines) return string(res) }