Skip to content

Commit 3a6ade3

Browse files
committed
Merge branch 'v1.0'
2 parents ef579dc + f7af6eb commit 3a6ade3

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

huobi/Hbdm_Swap.go

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

478478
func (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

482525
func (swap *HbdmSwap) GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error) {

okex/v5/OKExV5.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ func (ok *OKExV5) CreateOrder(param *CreateOrderParam) (*OrderSummaryV5, error)
289289
reqBody["reduceOnly"] = param.ReduceOnly
290290
}
291291

292+
reqBody["tag"] = "86d4a3bf87bcBCDE"
293+
292294
type OrderResponse struct {
293295
Code int `json:"code,string"`
294296
Msg string `json:"msg"`

0 commit comments

Comments
 (0)