diff --git a/v2/futures/asset_index_service.go b/v2/futures/asset_index_service.go index 553e7706..02aac9ed 100644 --- a/v2/futures/asset_index_service.go +++ b/v2/futures/asset_index_service.go @@ -33,7 +33,7 @@ func (s *AssetIndexService) Symbol(symbol string) *AssetIndexService { func (s *AssetIndexService) Do(ctx context.Context, opts ...RequestOption) (res []*AssetIndex, err error) { r := &request{ method: http.MethodGet, - endpoint: "/futures/v1/assetIndex", + endpoint: "/fapi/v1/assetIndex", } if s.symbol != nil { r.setParam("symbol", *s.symbol) diff --git a/v2/futures/client.go b/v2/futures/client.go index ab7fe423..47ba1312 100644 --- a/v2/futures/client.go +++ b/v2/futures/client.go @@ -556,11 +556,6 @@ func (c *Client) NewFundingRateService() *FundingRateService { return &FundingRateService{c: c} } -// NewFundingRateHistoryService init funding rate history service -func (c *Client) NewFundingRateHistoryService() *FundingRateHistoryService { - return &FundingRateHistoryService{c: c} -} - // NewFundingRateInfoService init funding rate info service func (c *Client) NewFundingRateInfoService() *FundingRateInfoService { return &FundingRateInfoService{c: c} diff --git a/v2/futures/constituents_service.go b/v2/futures/constituents_service.go index 734eb99e..5eb5e6c5 100644 --- a/v2/futures/constituents_service.go +++ b/v2/futures/constituents_service.go @@ -30,7 +30,7 @@ func (s *ConstituentsService) Symbol(symbol string) *ConstituentsService { func (s *ConstituentsService) Do(ctx context.Context, opts ...RequestOption) (res *ConstituentsServiceRsp, err error) { r := &request{ method: http.MethodGet, - endpoint: "/futures/v1/assetIndex", + endpoint: "/fapi/v1/constituents", } r.setParam("symbol", s.symbol) diff --git a/v2/futures/data_service.go b/v2/futures/data_service.go index f430a2e2..d006e779 100644 --- a/v2/futures/data_service.go +++ b/v2/futures/data_service.go @@ -12,8 +12,8 @@ type DeliveryPriceService struct { } type DeliveryPrice struct { - DeliveryTime uint64 `json:"DeliveryTime"` // deliveryTime - DeliveryPrice float64 `json:"DeliveryPrice"` // deliveryPrice + DeliveryTime uint64 `json:"deliveryTime"` // deliveryTime + DeliveryPrice float64 `json:"deliveryPrice"` // deliveryPrice } func (s *DeliveryPriceService) Pair(pair string) *DeliveryPriceService { diff --git a/v2/futures/funding_rate_history.go b/v2/futures/funding_rate_history.go deleted file mode 100644 index ab0b5f24..00000000 --- a/v2/futures/funding_rate_history.go +++ /dev/null @@ -1,82 +0,0 @@ -package futures - -import ( - "context" - "encoding/json" - "net/http" - - "github.com/adshao/go-binance/v2/common" -) - -// FundingRateHistoryService gets funding rate history -type FundingRateHistoryService struct { - c *Client - symbol *string - startTime *int64 - endTime *int64 - limit *int -} - -// Symbol set symbol -func (s *FundingRateHistoryService) Symbol(symbol string) *FundingRateHistoryService { - s.symbol = &symbol - return s -} - -// StartTime set startTime -func (s *FundingRateHistoryService) StartTime(startTime int64) *FundingRateHistoryService { - s.startTime = &startTime - return s -} - -// EndTime set startTime -func (s *FundingRateHistoryService) EndTime(endTime int64) *FundingRateHistoryService { - s.endTime = &endTime - return s -} - -// Limit set limit -func (s *FundingRateHistoryService) Limit(limit int) *FundingRateHistoryService { - s.limit = &limit - return s -} - -// Do send request -func (s *FundingRateHistoryService) Do(ctx context.Context, opts ...RequestOption) (res []*FundingRateHistory, err error) { - r := &request{ - method: http.MethodGet, - endpoint: "/fapi/v1/fundingRate", - secType: secTypeNone, - } - if s.symbol != nil { - r.setParam("symbol", *s.symbol) - } - if s.startTime != nil { - r.setParam("startTime", *s.startTime) - } - if s.endTime != nil { - r.setParam("endTime", *s.endTime) - } - if s.limit != nil { - r.setParam("limit", *s.limit) - } - data, _, err := s.c.callAPI(ctx, r, opts...) - data = common.ToJSONList(data) - if err != nil { - return []*FundingRateHistory{}, err - } - res = make([]*FundingRateHistory, 0) - err = json.Unmarshal(data, &res) - if err != nil { - return []*FundingRateHistory{}, err - } - return res, nil -} - -// FundingRateHistory defines funding rate history data -type FundingRateHistory struct { - Symbol string `json:"symbol"` - FundingTime int64 `json:"fundingTime"` - FundingRate string `json:"fundingRate"` - MarkPrice string `json:"markPrice"` -} diff --git a/v2/futures/funding_rate_history_test.go b/v2/futures/funding_rate_history_test.go deleted file mode 100644 index 39ee476d..00000000 --- a/v2/futures/funding_rate_history_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package futures - -import ( - "github.com/stretchr/testify/suite" - "testing" -) - -type fundingRateHistoryServiceTestSuite struct { - baseTestSuite -} - -func TestFundingRateHistoryService(t *testing.T) { - suite.Run(t, new(fundingRateHistoryServiceTestSuite)) -} - -func (s *fundingRateHistoryServiceTestSuite) TestGetFundingRateHistory() { - data := []byte(`[{ - "symbol": "BTCUSDT", - "fundingTime": 1698768000000, - "fundingRate": "0.00010000", - "markPrice": "34287.54619963" - }]`) - s.mockDo(data, nil) - defer s.assertDo() - - symbol := "BTCUSDT" - startTime := int64(1576566020000) - endTime := int64(1676566020000) - limit := 10 - s.assertReq(func(r *request) { - e := newRequest().setParams(params{ - "symbol": symbol, - "startTime": startTime, - "endTime": endTime, - "limit": limit, - }) - s.assertRequestEqual(e, r) - }) - - res, err := s.client.NewFundingRateHistoryService().Symbol(symbol).StartTime(startTime).EndTime(endTime).Limit(limit).Do(newContext()) - s.r().NoError(err) - e := []*FundingRateHistory{ - { - Symbol: symbol, - FundingTime: 1698768000000, - FundingRate: "0.00010000", - MarkPrice: "34287.54619963", - }, - } - s.assertFundingRateHistoryEqual(e, res) -} - -func (s *fundingRateHistoryServiceTestSuite) assertFundingRateHistoryEqual(e, a []*FundingRateHistory) { - r := s.r() - r.Equal(e[0].Symbol, a[0].Symbol, "Symbol") - r.Equal(e[0].FundingRate, a[0].FundingRate, "FundingRate") - r.Equal(e[0].FundingTime, a[0].FundingTime, "FundingTime") - r.Equal(e[0].MarkPrice, a[0].MarkPrice, "MarkPrice") -}