func (m *MarketClient) GetIndexCandlestick(pair, interval string, limit int32, startTime, endTime int64) (interface{}, error) {
	var err error
	if pair == "" {
		err = errors.New(PairEmpty)
		return nil, err
	}
	if interval == "" {
		err = errors.New(IntervalEmpty)
		return nil, err
	}
	params := fmt.Sprintf("pair=%s&interval=%s", pair, interval)
	if limit > 1500 {
		limit = 1500
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	if startTime > 0 {
		params += fmt.Sprintf("&startTime=%d", startTime)
	}
	if endTime > 0 {
		params += fmt.Sprintf("&endTime=%d", endTime)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/indexPriceKlines", params)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := IndexCandlestickResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
GetIndexCandlestick Kline/candlestick bars for the index price of a pair. Kline are uniquely identified by their open time.
package futuresclient
import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/dirname/binance"
	logger "github.com/dirname/binance/logging"
	"github.com/dirname/binance/model"
	"net/http"
)
type MarketClient struct {
	Builder *binance.PublicUrlBuilder
	AppKey  string
}
func NewMarketClient(host, appKey string) *MarketClient {
	return &MarketClient{
		Builder: binance.NewPublicUrlBuilder(host),
		AppKey:  appKey,
	}
}
func (m *MarketClient) GetExchangeInfo() (interface{}, error) {
	var err error
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/exchangeInfo", "")
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := ExchangeInfoResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
func (m *MarketClient) GetOrderBook(symbol string, limit int32) (interface{}, error) {
	var err error
	if symbol == "" {
		err = errors.New(SymbolEmpty)
		return nil, err
	}
	params := fmt.Sprintf("symbol=%s", symbol)
	if limit > 1000 {
		limit = 1000
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/depth", params)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := OrderBookResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
func (m *MarketClient) GetRecentTrades(symbol string, limit int32) (interface{}, error) {
	var err error
	if symbol == "" {
		err = errors.New(SymbolEmpty)
		return nil, err
	}
	params := fmt.Sprintf("symbol=%s", symbol)
	if limit > 1000 {
		limit = 1000
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/trades", params)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := RecentTradesListResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
func (m *MarketClient) GetOldTradeLookUp(symbol string, limit int32, formID, startTime, endTime int64) (interface{}, error) {
	var err error
	if symbol == "" {
		err = errors.New(SymbolEmpty)
		return nil, err
	}
	params := fmt.Sprintf("symbol=%s", symbol)
	if limit > 1000 {
		limit = 1000
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	if formID > 0 {
		params += fmt.Sprintf("&formId=%d", formID)
	}
	if startTime > 0 {
		params += fmt.Sprintf("&startTime=%d", startTime)
	}
	if endTime > 0 {
		params += fmt.Sprintf("&endTime=%d", endTime)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/historicalTrades", params)
	req.Header.Set("X-MBX-APIKEY", m.AppKey)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := OlderTradeLookUpResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
func (m *MarketClient) GetAggregateTrades(symbol string, limit int32, formID, startTime, endTime int64) (interface{}, error) {
	var err error
	if symbol == "" {
		err = errors.New(SymbolEmpty)
		return nil, err
	}
	params := fmt.Sprintf("symbol=%s", symbol)
	if limit > 1000 {
		limit = 1000
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	if formID > 0 {
		params += fmt.Sprintf("&formId=%d", formID)
	}
	if startTime > 0 {
		params += fmt.Sprintf("&startTime=%d", startTime)
	}
	if endTime > 0 {
		params += fmt.Sprintf("&endTime=%d", endTime)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/aggTrades", params)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := AggregateTradeResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
func (m *MarketClient) GetCandlestick(symbol, interval string, limit int32, startTime, endTime int64) (interface{}, error) {
	var err error
	if symbol == "" {
		err = errors.New(SymbolEmpty)
		return nil, err
	}
	if interval == "" {
		err = errors.New(IntervalEmpty)
		return nil, err
	}
	params := fmt.Sprintf("symbol=%s&interval=%s", symbol, interval)
	if limit > 1500 {
		limit = 1500
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	if startTime > 0 {
		params += fmt.Sprintf("&startTime=%d", startTime)
	}
	if endTime > 0 {
		params += fmt.Sprintf("&endTime=%d", endTime)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/klines", params)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := CandlestickResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}
func (m *MarketClient) GetContractCandlestick(pair, contractType, interval string, limit int32, startTime, endTime int64) (interface{}, error) {
	var err error
	if pair == "" {
		err = errors.New(PairEmpty)
		return nil, err
	}
	if interval == "" {
		err = errors.New(IntervalEmpty)
		return nil, err
	}
	if contractType == "" {
		err = errors.New(ContractEmpty)
		return nil, err
	}
	params := fmt.Sprintf("pair=%s&interval=%s&contractType=%s", pair, interval, contractType)
	if limit > 1500 {
		limit = 1500
	}
	if limit > 0 {
		params += fmt.Sprintf("&limit=%d", limit)
	}
	if startTime > 0 {
		params += fmt.Sprintf("&startTime=%d", startTime)
	}
	if endTime > 0 {
		params += fmt.Sprintf("&endTime=%d", endTime)
	}
	req, err := m.Builder.Build(http.MethodGet, "/fapi/v1/continuousKlines", params)
	if err != nil {
		logger.Error("Failed to build url: %s", err.Error())
	}
	res, err := binance.HttpRequest(req)
	var parser map[string]interface{}
	err = json.Unmarshal(res, &parser)
	if _, ok := parser["code"]; ok {
		result := model.APIErrorResponse{}
		err = json.Unmarshal(res, &result)
		return result, err
	}
	result := ContractCandlestickResponse{}
	err = json.Unmarshal(res, &result)
	return result, err
}