github.com/frankrap/okex-api@v1.0.4/index_api.go (about) 1 package okex 2 3 import ( 4 "time" 5 ) 6 7 type Constituent struct { 8 Symbol string `json:"symbol"` 9 OriginalPrice float64 `json:"original_price,string"` 10 Weight float64 `json:"weight,string"` 11 UsdPrice float64 `json:"usd_price,string"` 12 Exchange string `json:"exchange"` 13 } 14 15 type IndexConstituents struct { 16 Last string `json:"last"` 17 Constituents []Constituent `json:"constituents"` 18 InstrumentID string `json:"instrument_id"` 19 Timestamp time.Time `json:"timestamp"` 20 } 21 22 type IndexConstituentsResult struct { 23 Code int `json:"code"` 24 Data IndexConstituents `json:"data"` 25 DetailMsg string `json:"detailMsg"` 26 Msg string `json:"msg"` 27 } 28 29 // GetIndexConstituents 公共-获取指数成分 30 func (client *Client) GetIndexConstituents(instrumentID string) (IndexConstituentsResult, error) { 31 baseURI := GetInstrumentIdUri(INDEX_CONSTITUENTS, instrumentID) 32 var result IndexConstituentsResult 33 _, _, err := client.Request(GET, baseURI, nil, &result) 34 // if err != nil { 35 // return result, err 36 // } 37 // body, _ := ioutil.ReadAll(resp.Body) 38 // log.Printf("%v", string(body)) 39 return result, err 40 }