@@ -20,7 +20,7 @@ const (
2020 getSwapContractInfoApiPath = "/swap-ex/v1/swap_contract_info"
2121 tickerApiPath = "/swap-ex/market/detail/merged"
2222 marketApiPath = "/swap-ex/market/depth"
23- klineApiPath = "/swap-api /market/history/kline"
23+ klineApiPath = "/swap-ex /market/history/kline"
2424 accountApiPath = "/swap-api/v1/swap_account_info"
2525 placeOrderApiPath = "/swap-api/v1/swap_order"
2626 getPositionApiPath = "/swap-api/v1/swap_position_info"
@@ -476,7 +476,50 @@ func (swap *HbdmSwap) GetContractValue(currencyPair CurrencyPair) (float64, erro
476476}
477477
478478func (swap * HbdmSwap ) GetKlineRecords (contractType string , currency CurrencyPair , period KlinePeriod , size int , opt ... OptionalParameter ) ([]FutureKline , error ) {
479- panic ("not implement" )
479+ klineType := AdaptKlinePeriodForOKEx (int (period ))
480+ contractCode := currency .ToSymbol ("-" )
481+ apiUrl := fmt .Sprintf ("%s%s?contract_code=%s&period=%s&size=%d" , swap .c .Endpoint , klineApiPath , contractCode , klineType , size )
482+ responseBody , err := HttpGet5 (swap .base .config .HttpClient , apiUrl , map [string ]string {})
483+ if err != nil {
484+ return nil , err
485+ }
486+ logger .Debugf ("response body: %s" , string (responseBody ))
487+
488+ var ret struct {
489+ BaseResponse
490+ Data []struct {
491+ Id int64 `json:"id"`
492+ Amount float64 `json:"amount"`
493+ Close float64 `json:"close"`
494+ High float64 `json:"high"`
495+ Low float64 `json:"low"`
496+ Open float64 `json:"open"`
497+ Vol float64 `json:"vol"`
498+ } `json:"data"`
499+ }
500+
501+ err = json .Unmarshal (responseBody , & ret )
502+ if err != nil {
503+ logger .Errorf ("[hbdm-swap] err=%s" , err .Error ())
504+ return nil , err
505+ }
506+
507+ var lines []FutureKline
508+ for i := len (ret .Data ) - 1 ; i >= 0 ; i -- {
509+ d := ret .Data [i ]
510+ lines = append (lines , FutureKline {
511+ Kline : & Kline {
512+ Pair : currency ,
513+ Vol : d .Vol ,
514+ Open : d .Open ,
515+ Close : d .Close ,
516+ High : d .High ,
517+ Low : d .Low ,
518+ Timestamp : d .Id },
519+ Vol2 : d .Vol })
520+ }
521+
522+ return lines , err
480523}
481524
482525func (swap * HbdmSwap ) GetTrades (contractType string , currencyPair CurrencyPair , since int64 ) ([]Trade , error ) {
0 commit comments