commit b9699ebe723ef2c8effac0d630ef9f0c3fd169ea Author: lychiyu Date: Wed Jun 26 00:59:56 2024 +0800 first commit diff --git a/binance/binance.go b/binance/binance.go new file mode 100644 index 0000000..ee923e1 --- /dev/null +++ b/binance/binance.go @@ -0,0 +1,28 @@ +package binance + +import ( + "fmt" + "git.qtrade.icu/coin-quant/exchange" + "git.qtrade.icu/coin-quant/exchange/binance/common" + mfutures "git.qtrade.icu/coin-quant/exchange/binance/features" +) + +func init() { + exchange.RegisterExchange("binance", NewBinance) +} + +func NewBinance(cfg exchange.Config, cltName string) (e exchange.Exchange, err error) { + var eCfg common.BinanceConfig + err = cfg.UnmarshalKey(fmt.Sprintf("exchanges.%s", cltName), &eCfg) + if err != nil { + return + } + clientProxy := cfg.GetString("proxy") + switch eCfg.Kind { + case "futures": + e, err = mfutures.NewBinanceTrader(eCfg, cltName, clientProxy) + default: + err = fmt.Errorf("binance unsupport kind %s", &eCfg.Kind) + } + return +} diff --git a/binance/common/config.go b/binance/common/config.go new file mode 100644 index 0000000..3dbf6fb --- /dev/null +++ b/binance/common/config.go @@ -0,0 +1,11 @@ +package common + +type BinanceConfig struct { + Name string + ApiKey string + SecretKey string + Passphrase string + IsTest bool + Kind string + Currency string +} diff --git a/binance/features/binance.go b/binance/features/binance.go new file mode 100644 index 0000000..2d45d6d --- /dev/null +++ b/binance/features/binance.go @@ -0,0 +1,547 @@ +package features + +import ( + "context" + "fmt" + "git.qtrade.icu/coin-quant/exchange" + bcommon "git.qtrade.icu/coin-quant/exchange/binance/common" + . "git.qtrade.icu/coin-quant/trademodel" + gobinance "github.com/adshao/go-binance/v2" + bfutures "github.com/adshao/go-binance/v2/futures" + "github.com/gorilla/websocket" + log "github.com/sirupsen/logrus" + "net/http" + "net/url" + "sort" + "strconv" + "strings" + "sync" + "time" +) + +var ( + background = context.Background() + newLock sync.Mutex +) + +var _ exchange.Exchange = &BinanceTrade{} + +type BinanceTrade struct { + name string + api *bfutures.Client + + tradeCb exchange.WatchFn + positionCb exchange.WatchFn + balanceCb exchange.WatchFn + closeCh chan bool + + cancelService *bfutures.CancelAllOpenOrdersService + cancelOneService *bfutures.CancelOrderService + timeService *bfutures.ServerTimeService + + klineLimit int + timeout time.Duration + + wsUserListenKey string + + baseCurrency string + symbols map[string]Symbol +} + +func NewBinanceTrader(cfg bcommon.BinanceConfig, cltName, clientProxy string) (b *BinanceTrade, err error) { + b = new(BinanceTrade) + b.name = "binance" + if cltName == "" { + cltName = "binance" + } + b.klineLimit = 1500 + b.baseCurrency = "USDT" + if cfg.Currency != "" { + b.baseCurrency = cfg.Currency + } + + b.timeout = time.Second * 5 + b.closeCh = make(chan bool) + + newLock.Lock() + defer func() { + bfutures.UseTestnet = false + newLock.Unlock() + }() + if cfg.IsTest { + bfutures.UseTestnet = true + log.Warnf("binance trade connecting to testnet") + } + bfutures.WebsocketKeepalive = true + b.api = gobinance.NewFuturesClient(cfg.ApiKey, cfg.SecretKey) + if clientProxy != "" { + var proxyURL *url.URL + proxyURL, err = url.Parse(clientProxy) + if err != nil { + return + } + b.api.HTTPClient = &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} + + websocket.DefaultDialer.Proxy = http.ProxyURL(proxyURL) + websocket.DefaultDialer.HandshakeTimeout = time.Second * 60 + } + b.cancelService = b.api.NewCancelAllOpenOrdersService() + b.cancelOneService = b.api.NewCancelOrderService() + b.timeService = b.api.NewServerTimeService() + _, err = b.Symbols() + if err != nil { + return nil, err + } + // err = b.Start() + return +} + +// fetchBalance different with spot +func (b *BinanceTrade) fetchBalanceAndPosition() (err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + account, err := b.api.NewGetAccountService().Do(ctx) + if err != nil { + return + } + + var balance Balance + balance.Balance = parseFloat(account.TotalWalletBalance) + balance.Available = parseFloat(account.TotalCrossWalletBalance) + // balance.Frozen = + if b.balanceCb != nil { + b.balanceCb(&balance) + } + if b.positionCb != nil { + var amount, profit, initMargin float64 + for _, v := range account.Positions { + amount = parseFloat(v.PositionAmt) + if amount == 0 { + continue + } + var position Position + position.Symbol = v.Symbol + position.Hold = amount + position.Price = parseFloat(v.EntryPrice) + profit = parseFloat(v.UnrealizedProfit) + initMargin = parseFloat(v.PositionInitialMargin) + position.ProfitRatio = profit / initMargin + if position.Hold > 0 { + position.Type = Long + } else { + position.Type = Short + } + b.positionCb(&position) + + } + } + return +} + +func (b *BinanceTrade) Info() (info exchange.ExchangeInfo) { + info = exchange.ExchangeInfo{ + Name: "binance_futures", + Value: "binance_futures", + Desc: "binance futures api", + KLineLimit: exchange.FetchLimit{ + Limit: b.klineLimit, + }, + } + return +} + +func (b *BinanceTrade) Symbols() (symbols []Symbol, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + resp, err := b.api.NewExchangeInfoService().Do(ctx) + if err != nil { + return + } + symbols = make([]Symbol, len(resp.Symbols)) + for i, v := range resp.Symbols { + value := Symbol{ + Name: v.Symbol, + Exchange: "binance", + Symbol: v.Symbol, + Resolutions: "1m,5m,15m,30m,1h,4h,1d,1w", + Precision: v.PricePrecision, + AmountPrecision: v.QuantityPrecision, + PriceStep: 0, + AmountStep: 0, + } + for _, f := range v.Filters { + switch f["filterType"] { + case "PRICE_FILTER": + value.PriceStep = parseFloat(f["tickSize"].(string)) + case "LOT_SIZE": + value.AmountStep = parseFloat(f["stepSize"].(string)) + default: + } + } + symbols[i] = value + } + if len(symbols) > 0 { + symbolMap := make(map[string]Symbol) + for _, v := range symbols { + symbolMap[v.Symbol] = v + } + b.symbols = symbolMap + } + return +} + +func (b *BinanceTrade) Start() (err error) { + err = b.fetchBalanceAndPosition() + if err != nil { + return + } + // watch position and order changed + err = b.startUserWS() + return +} +func (b *BinanceTrade) Stop() (err error) { + close(b.closeCh) + return +} + +// KlineChan get klines +func (b *BinanceTrade) GetKline(symbol, bSize string, start, end time.Time) (data []*Candle, err error) { + var temp *Candle + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + defer func() { + if err != nil && strings.Contains(err.Error(), "Too many requests") { + err = fmt.Errorf("%w, retry: %s", exchange.ErrRetry, err.Error()) + } + }() + // get server time + nTime, err := b.timeService.Do(ctx) + if err != nil { + return + } + nStart := start.Unix() * 1000 + nEnd := end.Unix() * 1000 + + klines, err := b.api.NewKlinesService().Interval(bSize).Symbol(symbol).StartTime(nStart).EndTime(nEnd).Limit(b.klineLimit).Do(ctx) + if err != nil { + return + } + sort.Slice(klines, func(i, j int) bool { + return klines[i].OpenTime < klines[j].OpenTime + }) + if len(klines) == 0 { + log.Warnf("GetKline once, param: [%s]-[%s] no data", start, end) + return + } + log.Infof("GetKline once, param: [%s]-[%s], total: %d, first: %s, last: %s", start, end, len(klines), time.UnixMilli(klines[0].OpenTime), time.UnixMilli(klines[len(klines)-1].OpenTime)) + data = []*Candle{} + for k, v := range klines { + temp = transCandle(v) + if k == len(klines)-1 { + // check if candle is unfinished + if v.CloseTime > nTime { + log.Infof("skip unfinished candle: %##v\n", *v) + break + } + } + data = append(data, temp) + } + return +} + +func (b *BinanceTrade) handleError(typ string, cb func() error) func(error) { + return func(err error) { + log.Errorf("binance %s error:%s, call callback", typ, err.Error()) + if cb != nil { + cb() + } + } +} + +func (b *BinanceTrade) handleAggTradeEvent(fn exchange.WatchFn) func(evt *bfutures.WsAggTradeEvent) { + return func(evt *bfutures.WsAggTradeEvent) { + var err error + var trade Trade + trade.ID = fmt.Sprintf("%d", evt.AggregateTradeID) + trade.Amount, err = strconv.ParseFloat(evt.Quantity, 64) + if err != nil { + log.Errorf("AggTradeEvent parse amount failed: %s", evt.Quantity) + } + trade.Price, err = strconv.ParseFloat(evt.Price, 64) + if err != nil { + log.Errorf("AggTradeEvent parse amount failed: %s", evt.Quantity) + } + trade.Time = time.Unix(evt.Time/1000, (evt.Time%1000)*int64(time.Millisecond)) + if fn != nil { + fn(&trade) + } + } +} + +func (b *BinanceTrade) handleDepth(fn exchange.WatchFn) func(evt *bfutures.WsDepthEvent) { + return func(evt *bfutures.WsDepthEvent) { + var depth Depth + var err error + var price, amount float64 + depth.UpdateTime = time.Unix(evt.TransactionTime/1000, (evt.TransactionTime%1000)*int64(time.Millisecond)) + for _, v := range evt.Asks { + // depth.Sells + price, err = strconv.ParseFloat(v.Price, 64) + if err != nil { + log.Errorf("handleDepth parse price failed: %s", v.Price) + } + amount, err = strconv.ParseFloat(v.Quantity, 64) + if err != nil { + log.Errorf("handleDepth parse amount failed: %s", v.Quantity) + } + depth.Sells = append(depth.Sells, DepthInfo{Price: price, Amount: amount}) + } + for _, v := range evt.Bids { + // depth.Sells + price, err = strconv.ParseFloat(v.Price, 64) + if err != nil { + log.Errorf("handleDepth parse price failed: %s", v.Price) + } + amount, err = strconv.ParseFloat(v.Quantity, 64) + if err != nil { + log.Errorf("handleDepth parse amount failed: %s", v.Quantity) + } + depth.Buys = append(depth.Buys, DepthInfo{Price: price, Amount: amount}) + } + if fn != nil { + fn(&depth) + } + } +} + +func (b *BinanceTrade) retry(param exchange.WatchParam, fn exchange.WatchFn) func() error { + return func() error { + // retry when error cause + select { + case <-b.closeCh: + return nil + default: + } + return b.Watch(param, fn) + } +} + +func (b *BinanceTrade) Watch(param exchange.WatchParam, fn exchange.WatchFn) (err error) { + symbol := param.Param["symbol"] + var stopC chan struct{} + switch param.Type { + case exchange.WatchTypeCandle: + binSize := param.Param["bin"] + if binSize == "" { + binSize = "1m" + } + var doneC chan struct{} + finishC := make(chan struct{}) + doneC, stopC, err = bfutures.WsKlineServe(symbol, binSize, processWsCandle(finishC, fn), b.handleError("watchKline", b.retry(param, fn))) + if err != nil { + log.Error("exchange emitCandle error:", err.Error()) + } + go func() { + <-doneC + close(finishC) + }() + case exchange.WatchTypeDepth: + _, stopC, err = bfutures.WsPartialDepthServeWithRate(symbol, 10, 100*time.Millisecond, b.handleDepth(fn), b.handleError("depth", b.retry(param, fn))) + case exchange.WatchTypeTradeMarket: + _, stopC, err = bfutures.WsAggTradeServe(symbol, b.handleAggTradeEvent(fn), b.handleError("aggTrade", b.retry(param, fn))) + case exchange.WatchTypeTrade: + b.tradeCb = fn + case exchange.WatchTypePosition: + b.positionCb = fn + err = b.fetchBalanceAndPosition() + case exchange.WatchTypeBalance: + b.balanceCb = fn + err = b.fetchBalanceAndPosition() + default: + err = fmt.Errorf("unknown wathc param: %s", param.Type) + } + if err != nil { + return + } + if stopC != nil { + go func() { + <-b.closeCh + close(stopC) + }() + } + return +} + +func (b *BinanceTrade) CancelOrder(old *Order) (order *Order, err error) { + orderID, err := strconv.ParseInt(old.OrderID, 10, 64) + if err != nil { + return + } + resp, err := b.cancelOneService.Symbol(old.Symbol).OrderID(orderID).Do(context.Background()) + if err != nil { + return + } + price, err := strconv.ParseFloat(resp.Price, 64) + if err != nil { + panic(fmt.Sprintf("CancelOrder parse price %s error: %s", resp.Price, err.Error())) + } + amount, err := strconv.ParseFloat(resp.OrigQuantity, 64) + if err != nil { + panic(fmt.Sprintf("CancelOrder parse damount %s error: %s", resp.OrigQuantity, err.Error())) + } + order = &Order{ + OrderID: strconv.FormatInt(resp.OrderID, 10), + Symbol: resp.Symbol, + Currency: resp.Symbol, + Amount: amount, + Price: price, + Status: strings.ToUpper(string(resp.Status)), + Side: strings.ToLower(string(resp.Side)), + Time: time.Unix(resp.UpdateTime/1000, 0), + } + + return +} + +func (b *BinanceTrade) ProcessOrder(act TradeAction) (ret *Order, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + orderType := bfutures.OrderTypeLimit + if act.Action.IsStop() { + orderType = bfutures.OrderTypeStopMarket + } + var side bfutures.SideType + if act.Action.IsLong() { + side = bfutures.SideTypeBuy + } else { + side = bfutures.SideTypeSell + } + symbol, ok := b.symbols[act.Symbol] + if ok { + price := symbol.FixPrice(act.Price) + if price != act.Price { + log.Infof("binance change order price form %f to %f", act.Price, price) + act.Price = price + } + } + + sent := b.api.NewCreateOrderService().Symbol(act.Symbol) + if act.Action.IsStop() { + sent = sent.StopPrice(fmt.Sprintf("%f", act.Price)) + } else { + sent = sent.Price(fmt.Sprintf("%f", act.Price)) + } + if !act.Action.IsOpen() { + sent = sent.ReduceOnly(true) + } + resp, err := sent. + Quantity(fmt.Sprintf("%f", act.Amount)). + TimeInForce(bfutures.TimeInForceTypeGTC). + Type(orderType). + Side(side). + Do(ctx) + if err != nil { + return + } + ret = transCreateOrder(resp) + return +} + +// TODO: cancel stop order +func (b *BinanceTrade) CancelAllOrders() (orders []*Order, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + ret, err := b.api.NewListOrdersService().Do(ctx) + if err != nil { + err = fmt.Errorf("CancelOrder failed with list: %w", err) + return + } + symbolMap := make(map[string]bool) + var st string + var ok bool + for _, v := range ret { + st = string(v.Status) + if st == OrderStatusFilled || st == OrderStatusCanceled { + continue + } + od := transOrder(v) + orders = append(orders, od) + _, ok = symbolMap[od.Symbol] + if ok { + continue + } + symbolMap[od.Symbol] = true + err = b.cancelService.Symbol(od.Symbol).Do(ctx) + if err != nil { + return nil, err + } + } + return +} + +func transOrder(fo *bfutures.Order) (o *Order) { + price, err := strconv.ParseFloat(fo.Price, 64) + if err != nil { + panic(fmt.Sprintf("parse price %s error: %s", fo.Price, err.Error())) + } + amount, err := strconv.ParseFloat(fo.OrigQuantity, 64) + if err != nil { + panic(fmt.Sprintf("parse damount %s error: %s", fo.OrigQuantity, err.Error())) + } + o = &Order{ + OrderID: strconv.FormatInt(fo.OrderID, 10), + Symbol: fo.Symbol, + Currency: fo.Symbol, + Amount: amount, + Price: price, + Status: strings.ToUpper(string(fo.Status)), + Side: strings.ToLower(string(fo.Side)), + Time: time.Unix(fo.Time/1000, 0), + } + return +} + +func transCreateOrder(fo *bfutures.CreateOrderResponse) (o *Order) { + price, err := strconv.ParseFloat(fo.Price, 64) + if err != nil { + panic(fmt.Sprintf("parse price %s error: %s", fo.Price, err.Error())) + } + amount, err := strconv.ParseFloat(fo.OrigQuantity, 64) + if err != nil { + panic(fmt.Sprintf("parse damount %s error: %s", fo.OrigQuantity, err.Error())) + } + o = &Order{ + OrderID: strconv.FormatInt(fo.OrderID, 10), + Symbol: fo.Symbol, + Currency: fo.Symbol, + Amount: amount, + Price: price, + Status: strings.ToUpper(string(fo.Status)), + Side: strings.ToLower(string(fo.Side)), + Time: time.Unix(fo.UpdateTime/1000, 0), + } + return +} + +func transCandle(candle *bfutures.Kline) (ret *Candle) { + ret = &Candle{ + ID: 0, + Start: candle.OpenTime / 1000, + Open: parseFloat(candle.Open), + High: parseFloat(candle.High), + Low: parseFloat(candle.Low), + Close: parseFloat(candle.Close), + Turnover: parseFloat(candle.QuoteAssetVolume), + Volume: parseFloat(candle.Volume), + Trades: candle.TradeNum, + } + return +} + +func parseFloat(str string) float64 { + f, err := strconv.ParseFloat(str, 64) + if err != nil { + panic("binance parseFloat error:" + err.Error()) + } + return f +} diff --git a/binance/features/kline.go b/binance/features/kline.go new file mode 100644 index 0000000..218d49d --- /dev/null +++ b/binance/features/kline.go @@ -0,0 +1,31 @@ +package features + +import ( + "git.qtrade.icu/coin-quant/exchange" + . "git.qtrade.icu/coin-quant/trademodel" + bfutures "github.com/adshao/go-binance/v2/futures" +) + +func processWsCandle(doneC chan struct{}, cb exchange.WatchFn) func(event *bfutures.WsKlineEvent) { + return func(event *bfutures.WsKlineEvent) { + select { + case <-doneC: + return + default: + } + if event.Kline.IsFinal { + candle := Candle{ + ID: 0, + Start: event.Kline.StartTime / 1000, + Open: parseFloat(event.Kline.Open), + High: parseFloat(event.Kline.High), + Low: parseFloat(event.Kline.Low), + Close: parseFloat(event.Kline.Close), + Turnover: parseFloat(event.Kline.QuoteVolume), + Volume: parseFloat(event.Kline.Volume), + Trades: event.Kline.TradeNum, + } + cb(&candle) + } + } +} diff --git a/binance/features/user_ws.go b/binance/features/user_ws.go new file mode 100644 index 0000000..e299aaf --- /dev/null +++ b/binance/features/user_ws.go @@ -0,0 +1,137 @@ +package features + +import ( + "context" + . "git.qtrade.icu/coin-quant/trademodel" + bfutures "github.com/adshao/go-binance/v2/futures" + log "github.com/sirupsen/logrus" + "strconv" + "time" +) + +func (b *BinanceTrade) updateUserListenKey() { + var err error + ticker := time.NewTicker(time.Minute * 30) +Out: + for { + select { + case <-b.closeCh: + break Out + case <-ticker.C: + for i := 0; i < 10; i++ { + ctx, cancel := context.WithTimeout(background, b.timeout) + err = b.api.NewKeepaliveUserStreamService().ListenKey(b.wsUserListenKey).Do(ctx) + cancel() + if err != nil { + log.Error("update listen key failed:", err.Error()) + time.Sleep(time.Minute) + continue + } + break + } + if err != nil { + log.Error("update listen key failed 10 times,just exist::", err.Error()) + break Out + } + } + } +} + +func (b *BinanceTrade) startUserWS() (err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + + listenKey, err := b.api.NewStartUserStreamService().Do(ctx) + if err != nil { + return + } + b.wsUserListenKey = listenKey + + doneC, stopC, err := bfutures.WsUserDataServe(listenKey, b.handleUserData, b.handleUserDataError) + if err != nil { + return + } + go func() { + select { + case <-doneC: + case <-b.closeCh: + } + close(stopC) + }() + go b.updateUserListenKey() + + return +} + +func (b *BinanceTrade) handleUserData(event *bfutures.WsUserDataEvent) { + switch event.Event { + case bfutures.UserDataEventTypeAccountUpdate: + var profit, total float64 + var balance Balance + for _, v := range event.AccountUpdate.Balances { + if v.Asset == b.baseCurrency { + balance.Balance = parseFloat(v.Balance) + balance.Available = parseFloat(v.CrossWalletBalance) + if b.balanceCb != nil { + b.balanceCb(&balance) + } + total = balance.Balance + } + } + var pos Position + for _, v := range event.AccountUpdate.Positions { + pos.Symbol = v.Symbol + profit = parseFloat(v.UnrealizedPnL) + if v.IsolatedWallet != "" { + total = parseFloat(v.IsolatedWallet) + } + if total > 0 { + pos.ProfitRatio = profit / total + } + pos.Price = parseFloat(v.EntryPrice) + pos.Hold = parseFloat(v.Amount) + if pos.Hold > 0 { + pos.Type = Long + } else if pos.Hold < 0 { + pos.Type = Short + } + if b.positionCb != nil { + b.positionCb(&pos) + } + } + case bfutures.UserDataEventTypeOrderTradeUpdate: + var order Order + order.OrderID = strconv.FormatInt(event.OrderTradeUpdate.ID, 10) + order.Symbol = event.OrderTradeUpdate.Symbol + order.Currency = event.OrderTradeUpdate.Symbol + + order.Amount = parseFloat(event.OrderTradeUpdate.OriginalQty) + order.Filled = parseFloat(event.OrderTradeUpdate.AccumulatedFilledQty) + if order.Filled == order.Amount { + order.Price = parseFloat(event.OrderTradeUpdate.AveragePrice) + } else { + order.Price = parseFloat(event.OrderTradeUpdate.OriginalPrice) + } + order.Status = string(event.OrderTradeUpdate.Status) + order.Side = string(event.OrderTradeUpdate.Side) + order.Time = time.UnixMilli(event.OrderTradeUpdate.TradeTime) + if b.tradeCb != nil { + b.tradeCb(&order) + } + } +} + +func (b *BinanceTrade) handleUserDataError(err error) { + log.Errorf("binance userdata error: %s,reconnect", err.Error()) + doneC, stopC, err := bfutures.WsUserDataServe(b.wsUserListenKey, b.handleUserData, b.handleUserDataError) + if err != nil { + return + } + go func() { + select { + case <-doneC: + case <-b.closeCh: + } + close(stopC) + }() +} diff --git a/config.go b/config.go new file mode 100644 index 0000000..a0370dc --- /dev/null +++ b/config.go @@ -0,0 +1,31 @@ +package exchange + +import "github.com/spf13/viper" + +type Config interface { + Get(string) interface{} + GetBool(string) bool + GetInt(string) int + GetString(string) string + UnmarshalKey(string, interface{}) error +} + +type ExchangeConfig struct { + Name string + ApiKey string + SecretKey string + Passphrase string + IsTest bool +} + +func WrapViper(cfg *viper.Viper) Config { + return &ViperCfg{Viper: cfg} +} + +type ViperCfg struct { + *viper.Viper +} + +func (c *ViperCfg) UnmarshalKey(key string, rawVal interface{}) error { + return c.Viper.UnmarshalKey(key, rawVal) +} diff --git a/exchange.go b/exchange.go new file mode 100644 index 0000000..5279f66 --- /dev/null +++ b/exchange.go @@ -0,0 +1,111 @@ +package exchange + +import ( + "errors" + "sort" + "time" + + . "git.qtrade.icu/coin-quant/trademodel" + "github.com/sirupsen/logrus" +) + +const ( + WatchTypeCandle = "candle" + WatchTypeDepth = "depth" + WatchTypeTradeMarket = "trade_market" + WatchTypeTrade = "trade" + WatchTypePosition = "position" + WatchTypeBalance = "balance" +) + +var ( + ErrRetry = errors.New("need retry") +) + +type WatchParam struct { + Type string + Param map[string]string +} + +func WatchCandle(symbol, binSize string) WatchParam { + return WatchParam{ + Type: WatchTypeCandle, + Param: map[string]string{"symbol": symbol, "bin": binSize}, + } +} + +type WatchFn func(interface{}) + +type FetchLimit struct { + Duration string + Limit int +} + +// ExchangeInfo exchange info +type ExchangeInfo struct { + Name string + Value string + Desc string + KLineLimit FetchLimit + OrderLimit FetchLimit +} + +type Exchange interface { + Info() ExchangeInfo + Symbols() ([]Symbol, error) + + Start() error + Stop() error + + // Watch exchange event, call multiple times for different event + Watch(WatchParam, WatchFn) error + + // Kline get klines + GetKline(symbol, bSize string, start, end time.Time) (data []*Candle, err error) + + // for trade + ProcessOrder(act TradeAction) (ret *Order, err error) + CancelAllOrders() (orders []*Order, err error) + CancelOrder(old *Order) (orders *Order, err error) +} + +func KlineChan(e Exchange, symbol, bSize string, start, end time.Time) (dataCh chan *Candle, errCh chan error) { + dataCh = make(chan *Candle, 1024*10) + errCh = make(chan error, 1) + go func() { + defer func() { + close(dataCh) + close(errCh) + }() + tStart := start + tEnd := end + var nPrevStart int64 + for { + klines, err := e.GetKline(symbol, bSize, tStart, tEnd) + if err != nil { + if errors.Is(err, ErrRetry) { + time.Sleep(time.Second * 5) + continue + } + errCh <- err + return + } + sort.Slice(klines, func(i, j int) bool { + return klines[i].Start < klines[j].Start + }) + for _, v := range klines { + if v.Start <= nPrevStart { + continue + } + dataCh <- v + tStart = v.Time() + } + if tStart.Sub(tEnd) >= 0 || tStart.Unix() <= nPrevStart || len(klines) == 0 { + logrus.Info("KlineChan finished: [%s]-[%s], last datatime: %s", start, end, tStart) + break + } + nPrevStart = tStart.Unix() + } + }() + return +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f879e7b --- /dev/null +++ b/go.mod @@ -0,0 +1,42 @@ +module git.qtrade.icu/coin-quant/exchange + +go 1.22.0 + +require ( + git.qtrade.icu/coin-quant/trademodel v0.0.0-20240625151548-cef4b6fc28b9 + github.com/adshao/go-binance/v2 v2.4.5 + github.com/deepmap/oapi-codegen v1.10.1 + github.com/getkin/kin-openapi v0.94.0 + github.com/gorilla/websocket v1.5.0 + github.com/mitchellh/mapstructure v1.5.0 + github.com/sirupsen/logrus v1.9.0 + github.com/spf13/viper v1.11.0 +) + +require ( + github.com/bitly/go-simplejson v0.5.0 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/swag v0.21.1 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/magiconair/properties v1.8.6 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect + github.com/spf13/afero v1.8.2 // indirect + github.com/spf13/cast v1.4.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.2.0 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/text v0.4.0 // indirect + gopkg.in/ini.v1 v1.66.4 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..12ef0ef --- /dev/null +++ b/go.sum @@ -0,0 +1,610 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +git.qtrade.icu/coin-quant/trademodel v0.0.0-20240625151548-cef4b6fc28b9 h1:9T1u+MzfbG9jZU1wzDtmBoOwN1m/fRX0iX7NbLwAHgU= +git.qtrade.icu/coin-quant/trademodel v0.0.0-20240625151548-cef4b6fc28b9/go.mod h1:SZnI+IqcRlKVcDSS++NIgthZX4GG1OU4UG+RDrSOD34= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/adshao/go-binance/v2 v2.4.5 h1:V3KpolmS9a7TLVECSrl2gYm+GGBSxhVk9ILaxvOTOVw= +github.com/adshao/go-binance/v2 v2.4.5/go.mod h1:41Up2dG4NfMXpCldrDPETEtiOq+pHoGsFZ73xGgaumo= +github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= +github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/deepmap/oapi-codegen v1.10.1 h1:xybuJUR6D8l7P+LAuxOm5SD7nTlFKHWvOPl31q+DDVs= +github.com/deepmap/oapi-codegen v1.10.1/go.mod h1:TvVmDQlUkFli9gFij/gtW1o+tFBr4qCHyv2zG+R0YZY= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/getkin/kin-openapi v0.94.0 h1:bAxg2vxgnHHHoeefVdmGbR+oxtJlcv5HsJJa3qmAHuo= +github.com/getkin/kin-openapi v0.94.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= +github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= +github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-playground/validator/v10 v10.10.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/goccy/go-json v0.9.6/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= +github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= +github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ= +github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= +github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= +github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= +github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= +github.com/lestrrat-go/jwx v1.2.23/go.mod h1:sAXjRwzSvCN6soO4RLoWWm1bVPpb8iOuv0IYfH8OWd8= +github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0= +github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= +github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= +github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.11.0 h1:7OX/1FS6n7jHD1zGrZTM7WtY13ZELRyosK4k93oPr44= +github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= +gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/include/all.go b/include/all.go new file mode 100644 index 0000000..3e33b85 --- /dev/null +++ b/include/all.go @@ -0,0 +1,6 @@ +package include + +import ( + _ "git.qtrade.icu/coin-quant/exchange/binance" + _ "git.qtrade.icu/coin-quant/exchange/okex" +) diff --git a/okex/api/account/account.gen.go b/okex/api/account/account.gen.go new file mode 100644 index 0000000..8fb16f2 --- /dev/null +++ b/okex/api/account/account.gen.go @@ -0,0 +1,3324 @@ +// Package account provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.9.0 DO NOT EDIT. +package account + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "path" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + "github.com/getkin/kin-openapi/openapi3" +) + +// GetApiV5AccountAccountPositionRiskParams defines parameters for GetApiV5AccountAccountPositionRisk. +type GetApiV5AccountAccountPositionRiskParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` +} + +// GetApiV5AccountBalanceParams defines parameters for GetApiV5AccountBalance. +type GetApiV5AccountBalanceParams struct { + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` +} + +// GetApiV5AccountBillsParams defines parameters for GetApiV5AccountBills. +type GetApiV5AccountBillsParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` + + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` + + // 仓位类型
`isolated`:逐仓 `cross`:全仓 + MgnMode *string `json:"mgnMode,omitempty"` + + // 合约类型
`linear`:正向合约 `inverse`:反向合约
仅交割/永续有效 + CtType *string `json:"ctType,omitempty"` + + // 账单类型
1:划转 2:交易 3:交割 4:自动换币 5:强平 6:保证金划转 7:扣息 8:资金费 9:自动减仓 10:穿仓补偿 11:系统换币 12:策略划拨 + Type *string `json:"type,omitempty"` + + // 子账单类型
1:买入 2:卖出 3:开多 4:开空 5:平多 6:平空 9:扣息 11:转入 12:转出 160:手动追加保证金 161:手动减少保证金 162:自动追加保证金 114:自动换币买入 115:自动换币卖出 118:系统换币转入 119:系统换币转出 100:强减平多 101:强减平空 102:强减买入 103:强减卖出 104:强平平多 105:强平平空 106:强平买入 107:强平卖出 110:强平换币转入 111:强平换币转出 125:自动减仓平多 126:自动减仓平空 127:自动减仓买入 128:自动减仓卖出 170:到期行权 171:到期被行权 172:到期作废 112:交割平多 113:交割平空 117:交割/期权穿仓补偿 173:资金费支出 174:资金费收入 200:系统转入 201:手动转入 202:系统转出 203:手动转出 + SubType *string `json:"subType,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId` + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId` + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5AccountBillsArchiveParams defines parameters for GetApiV5AccountBillsArchive. +type GetApiV5AccountBillsArchiveParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` + + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` + + // 仓位类型
`isolated`:逐仓 `cross`:全仓 + MgnMode *string `json:"mgnMode,omitempty"` + + // 合约类型
`linear`:正向合约 `inverse`:反向合约
仅交割/永续有效 + CtType *string `json:"ctType,omitempty"` + + // 账单类型
1:划转 2:交易 3:交割 4:自动换币 5:强平 6:保证金划转 7:扣息 8:资金费 9:自动减仓 10:穿仓补偿 11:系统换币 12:策略划拨 + Type *string `json:"type,omitempty"` + + // 子账单类型
1:买入 2:卖出 3:开多 4:开空 5:平多 6:平空 9:扣息 11:转入 12:转出 160:手动追加保证金 161:手动减少保证金 162:自动追加保证金 114:自动换币买入 115:自动换币卖出 118:系统换币转入 119:系统换币转出 100:强减平多 101:强减平空 102:强减买入 103:强减卖出 104:强平平多 105:强平平空 106:强平买入 107:强平卖出 110:强平换币转入 111:强平换币转出 125:自动减仓平多 126:自动减仓平空 127:自动减仓买入 128:自动减仓卖出 170:到期行权 171:到期被行权 172:到期作废 112:交割平多 113:交割平空 117:交割/期权穿仓补偿 173:资金费支出 174:资金费收入 200:系统转入 201:手动转入 202:系统转出 203:手动转出 + SubType *string `json:"subType,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId` + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId` + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5AccountInterestAccruedParams defines parameters for GetApiV5AccountInterestAccrued. +type GetApiV5AccountInterestAccruedParams struct { + // 产品ID,如:`BTC-USDT` + InstId *string `json:"instId,omitempty"` + + // 保证金模式
`isolated`:逐仓 `cross`:全仓 + MgnMode *string `json:"mgnMode,omitempty"` + + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` + + // 查询在此之前的内容,值为时间戳,Unix时间戳为毫秒数格式 + After *string `json:"after,omitempty"` + + // 查询在此之后的内容,值为时间戳,Unix时间戳为毫秒数格式 + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5AccountInterestRateParams defines parameters for GetApiV5AccountInterestRate. +type GetApiV5AccountInterestRateParams struct { + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` +} + +// GetApiV5AccountLeverageInfoParams defines parameters for GetApiV5AccountLeverageInfo. +type GetApiV5AccountLeverageInfoParams struct { + // 产品ID,如:`BTC-USDT-SWAP`
支持多产品ID查询(不超过20个),半角逗号分隔 + InstId string `json:"instId"` + + // 保证金模式
`cross`:全仓 `isolated`:逐仓 + MgnMode string `json:"mgnMode"` +} + +// GetApiV5AccountMaxAvailSizeParams defines parameters for GetApiV5AccountMaxAvailSize. +type GetApiV5AccountMaxAvailSizeParams struct { + // 产品ID,如:`BTC-USDT`
支持多产品ID查询(不超过5个),半角逗号分隔 + InstId string `json:"instId"` + + // 交易模式
`cross`:全仓 `isolated`:逐仓 `cash`:非保证金 + TdMode string `json:"tdMode"` + + // 保证金币种,仅适用于单币种保证金模式下的全仓杠杆订单 + Ccy *string `json:"ccy,omitempty"` + + // 是否为只减仓模式,仅适用于`币币杠杆` + ReduceOnly *bool `json:"reduceOnly,omitempty"` +} + +// GetApiV5AccountMaxLoanParams defines parameters for GetApiV5AccountMaxLoan. +type GetApiV5AccountMaxLoanParams struct { + // 产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 仓位类型
`cross`:全仓 `isolated`:逐仓 + MgnMode string `json:"mgnMode"` + + // 保证金币种,如:`BTC`
币币杠杆单币种全仓情况下必须指定保证金币种 + MgnCcy *string `json:"mgnCcy,omitempty"` +} + +// GetApiV5AccountMaxSizeParams defines parameters for GetApiV5AccountMaxSize. +type GetApiV5AccountMaxSizeParams struct { + // 产品ID,如:`BTC-USDT`
支持多产品ID查询(不超过5个),半角逗号分隔 + InstId string `json:"instId"` + + // 交易模式
`cross`:全仓 `isolated`:逐仓 `cash`:非保证金 + TdMode string `json:"tdMode"` + + // 保证金币种,仅适用于单币种保证金模式下的全仓杠杆订单 + Ccy *string `json:"ccy,omitempty"` + + // 委托价格
当不填委托价时会按当前最新成交价计算
当指定多个`instId`查询时,忽略该参数,按当前最新成交价计算 + Px *string `json:"px,omitempty"` +} + +// GetApiV5AccountMaxWithdrawalParams defines parameters for GetApiV5AccountMaxWithdrawal. +type GetApiV5AccountMaxWithdrawalParams struct { + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` +} + +// PostApiV5AccountPositionMarginBalanceJSONBody defines parameters for PostApiV5AccountPositionMarginBalance. +type PostApiV5AccountPositionMarginBalanceJSONBody struct { + // 必填
增加或减少的保证金数量 + Amt *string `json:"amt,omitempty"` + + // 必填
产品ID,如:`BTC-USDT-SWAP` + InstId string `json:"instId"` + + // 必填
持仓方向,默认值是`net`
`long`:双向持仓多头
`short`:双向持仓空头
`net`:单向持仓 + PosSide string `json:"posSide"` + + // 必填
增加/减少保证金
`add`:增加 `reduce`:减少 + Type string `json:"type"` +} + +// GetApiV5AccountPositionsParams defines parameters for GetApiV5AccountPositions. +type GetApiV5AccountPositionsParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` + + // 产品ID,如:`BTC-USDT`
支持多个instId查询(不超过10个),半角逗号分隔 + InstId *string `json:"instId,omitempty"` + + // 持仓ID,支持多个posId查询(不超过20个),半角逗号分割 + PosId *string `json:"posId,omitempty"` +} + +// PostApiV5AccountSetGreeksJSONBody defines parameters for PostApiV5AccountSetGreeks. +type PostApiV5AccountSetGreeksJSONBody struct { + // 希腊字母展示方式
`PA`:币本位,`BS`:美元本位 + GreeksType string `json:"greeksType"` +} + +// PostApiV5AccountSetLeverageJSONBody defines parameters for PostApiV5AccountSetLeverage. +type PostApiV5AccountSetLeverageJSONBody struct { + // 可选
保证金币种,仅适用于跨币种保证金模式的全仓`币币杠杆`。 + Ccy *string `json:"ccy,omitempty"` + + // 可选
产品ID:币对、合约
`instId`和`ccy`至少要传一个;如果两个都传,默认使用instId + InstId *string `json:"instId,omitempty"` + + // 必填
杠杆倍数 + Lever string `json:"lever"` + + // 保证金模式
`isolated`:逐仓,`cross`:全仓
如果`ccy`有效传值,该参数值只能为`cross`。 + MgnMode string `json:"mgnMode"` + + // 可选
持仓方向
`long`:双向持仓多头
`short`:双向持仓空头
`net`:单向持仓
在双向持仓且保证金模式为逐仓条件下必填,且仅可选择`long`或`short`,其他情况下非必填,默认`net`;仅适用于`交割/永续` + PosSide *string `json:"posSide,omitempty"` +} + +// PostApiV5AccountSetPositionModeJSONBody defines parameters for PostApiV5AccountSetPositionMode. +type PostApiV5AccountSetPositionModeJSONBody struct { + // 持仓方式
`long_short_mode`:双向持仓
`net_mode`:单向持仓 + PosMode string `json:"posMode"` +} + +// GetApiV5AccountTradeFeeParams defines parameters for GetApiV5AccountTradeFee. +type GetApiV5AccountTradeFeeParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType string `json:"instType"` + + // 产品ID,如:`BTC-USDT`
仅适用于instType为币币/币币杠杆 + InstId *string `json:"instId,omitempty"` + + // 合约标的指数,如:`BTC-USD`
仅适用于`instType`为`交割`/`永续`/`期权` + Uly *string `json:"uly,omitempty"` + + // 币种手续费类别
1:第一类币种费率 2:第二类币种费率 3:第三类币种费率 4:第四类币种费率 + Category *string `json:"category,omitempty"` +} + +// PostApiV5AccountPositionMarginBalanceJSONRequestBody defines body for PostApiV5AccountPositionMarginBalance for application/json ContentType. +type PostApiV5AccountPositionMarginBalanceJSONRequestBody = PostApiV5AccountPositionMarginBalanceJSONBody + +// PostApiV5AccountSetGreeksJSONRequestBody defines body for PostApiV5AccountSetGreeks for application/json ContentType. +type PostApiV5AccountSetGreeksJSONRequestBody = PostApiV5AccountSetGreeksJSONBody + +// PostApiV5AccountSetLeverageJSONRequestBody defines body for PostApiV5AccountSetLeverage for application/json ContentType. +type PostApiV5AccountSetLeverageJSONRequestBody = PostApiV5AccountSetLeverageJSONBody + +// PostApiV5AccountSetPositionModeJSONRequestBody defines body for PostApiV5AccountSetPositionMode for application/json ContentType. +type PostApiV5AccountSetPositionModeJSONRequestBody = PostApiV5AccountSetPositionModeJSONBody + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // GetApiV5AccountAccountPositionRisk request + GetApiV5AccountAccountPositionRisk(ctx context.Context, params *GetApiV5AccountAccountPositionRiskParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountBalance request + GetApiV5AccountBalance(ctx context.Context, params *GetApiV5AccountBalanceParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountBills request + GetApiV5AccountBills(ctx context.Context, params *GetApiV5AccountBillsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountBillsArchive request + GetApiV5AccountBillsArchive(ctx context.Context, params *GetApiV5AccountBillsArchiveParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountConfig request + GetApiV5AccountConfig(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountInterestAccrued request + GetApiV5AccountInterestAccrued(ctx context.Context, params *GetApiV5AccountInterestAccruedParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountInterestRate request + GetApiV5AccountInterestRate(ctx context.Context, params *GetApiV5AccountInterestRateParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountLeverageInfo request + GetApiV5AccountLeverageInfo(ctx context.Context, params *GetApiV5AccountLeverageInfoParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountMaxAvailSize request + GetApiV5AccountMaxAvailSize(ctx context.Context, params *GetApiV5AccountMaxAvailSizeParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountMaxLoan request + GetApiV5AccountMaxLoan(ctx context.Context, params *GetApiV5AccountMaxLoanParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountMaxSize request + GetApiV5AccountMaxSize(ctx context.Context, params *GetApiV5AccountMaxSizeParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountMaxWithdrawal request + GetApiV5AccountMaxWithdrawal(ctx context.Context, params *GetApiV5AccountMaxWithdrawalParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5AccountPositionMarginBalance request with any body + PostApiV5AccountPositionMarginBalanceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5AccountPositionMarginBalance(ctx context.Context, body PostApiV5AccountPositionMarginBalanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountPositions request + GetApiV5AccountPositions(ctx context.Context, params *GetApiV5AccountPositionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5AccountSetGreeks request with any body + PostApiV5AccountSetGreeksWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5AccountSetGreeks(ctx context.Context, body PostApiV5AccountSetGreeksJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5AccountSetLeverage request with any body + PostApiV5AccountSetLeverageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5AccountSetLeverage(ctx context.Context, body PostApiV5AccountSetLeverageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5AccountSetPositionMode request with any body + PostApiV5AccountSetPositionModeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5AccountSetPositionMode(ctx context.Context, body PostApiV5AccountSetPositionModeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5AccountTradeFee request + GetApiV5AccountTradeFee(ctx context.Context, params *GetApiV5AccountTradeFeeParams, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) GetApiV5AccountAccountPositionRisk(ctx context.Context, params *GetApiV5AccountAccountPositionRiskParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountAccountPositionRiskRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountBalance(ctx context.Context, params *GetApiV5AccountBalanceParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountBalanceRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountBills(ctx context.Context, params *GetApiV5AccountBillsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountBillsRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountBillsArchive(ctx context.Context, params *GetApiV5AccountBillsArchiveParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountBillsArchiveRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountConfig(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountConfigRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountInterestAccrued(ctx context.Context, params *GetApiV5AccountInterestAccruedParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountInterestAccruedRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountInterestRate(ctx context.Context, params *GetApiV5AccountInterestRateParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountInterestRateRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountLeverageInfo(ctx context.Context, params *GetApiV5AccountLeverageInfoParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountLeverageInfoRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountMaxAvailSize(ctx context.Context, params *GetApiV5AccountMaxAvailSizeParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountMaxAvailSizeRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountMaxLoan(ctx context.Context, params *GetApiV5AccountMaxLoanParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountMaxLoanRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountMaxSize(ctx context.Context, params *GetApiV5AccountMaxSizeParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountMaxSizeRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountMaxWithdrawal(ctx context.Context, params *GetApiV5AccountMaxWithdrawalParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountMaxWithdrawalRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountPositionMarginBalanceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountPositionMarginBalanceRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountPositionMarginBalance(ctx context.Context, body PostApiV5AccountPositionMarginBalanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountPositionMarginBalanceRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountPositions(ctx context.Context, params *GetApiV5AccountPositionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountPositionsRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountSetGreeksWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountSetGreeksRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountSetGreeks(ctx context.Context, body PostApiV5AccountSetGreeksJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountSetGreeksRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountSetLeverageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountSetLeverageRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountSetLeverage(ctx context.Context, body PostApiV5AccountSetLeverageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountSetLeverageRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountSetPositionModeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountSetPositionModeRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5AccountSetPositionMode(ctx context.Context, body PostApiV5AccountSetPositionModeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5AccountSetPositionModeRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5AccountTradeFee(ctx context.Context, params *GetApiV5AccountTradeFeeParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5AccountTradeFeeRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewGetApiV5AccountAccountPositionRiskRequest generates requests for GetApiV5AccountAccountPositionRisk +func NewGetApiV5AccountAccountPositionRiskRequest(server string, params *GetApiV5AccountAccountPositionRiskParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/account-position-risk") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountBalanceRequest generates requests for GetApiV5AccountBalance +func NewGetApiV5AccountBalanceRequest(server string, params *GetApiV5AccountBalanceParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/balance") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountBillsRequest generates requests for GetApiV5AccountBills +func NewGetApiV5AccountBillsRequest(server string, params *GetApiV5AccountBillsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/bills") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.MgnMode != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnMode", runtime.ParamLocationQuery, *params.MgnMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.CtType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ctType", runtime.ParamLocationQuery, *params.CtType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Type != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "type", runtime.ParamLocationQuery, *params.Type); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.SubType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "subType", runtime.ParamLocationQuery, *params.SubType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountBillsArchiveRequest generates requests for GetApiV5AccountBillsArchive +func NewGetApiV5AccountBillsArchiveRequest(server string, params *GetApiV5AccountBillsArchiveParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/bills-archive") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.MgnMode != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnMode", runtime.ParamLocationQuery, *params.MgnMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.CtType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ctType", runtime.ParamLocationQuery, *params.CtType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Type != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "type", runtime.ParamLocationQuery, *params.Type); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.SubType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "subType", runtime.ParamLocationQuery, *params.SubType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountConfigRequest generates requests for GetApiV5AccountConfig +func NewGetApiV5AccountConfigRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountInterestAccruedRequest generates requests for GetApiV5AccountInterestAccrued +func NewGetApiV5AccountInterestAccruedRequest(server string, params *GetApiV5AccountInterestAccruedParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/interest-accrued") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.MgnMode != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnMode", runtime.ParamLocationQuery, *params.MgnMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountInterestRateRequest generates requests for GetApiV5AccountInterestRate +func NewGetApiV5AccountInterestRateRequest(server string, params *GetApiV5AccountInterestRateParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/interest-rate") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountLeverageInfoRequest generates requests for GetApiV5AccountLeverageInfo +func NewGetApiV5AccountLeverageInfoRequest(server string, params *GetApiV5AccountLeverageInfoParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/leverage-info") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnMode", runtime.ParamLocationQuery, params.MgnMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountMaxAvailSizeRequest generates requests for GetApiV5AccountMaxAvailSize +func NewGetApiV5AccountMaxAvailSizeRequest(server string, params *GetApiV5AccountMaxAvailSizeParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/max-avail-size") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tdMode", runtime.ParamLocationQuery, params.TdMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.ReduceOnly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "reduceOnly", runtime.ParamLocationQuery, *params.ReduceOnly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountMaxLoanRequest generates requests for GetApiV5AccountMaxLoan +func NewGetApiV5AccountMaxLoanRequest(server string, params *GetApiV5AccountMaxLoanParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/max-loan") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnMode", runtime.ParamLocationQuery, params.MgnMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.MgnCcy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnCcy", runtime.ParamLocationQuery, *params.MgnCcy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountMaxSizeRequest generates requests for GetApiV5AccountMaxSize +func NewGetApiV5AccountMaxSizeRequest(server string, params *GetApiV5AccountMaxSizeParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/max-size") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tdMode", runtime.ParamLocationQuery, params.TdMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Px != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "px", runtime.ParamLocationQuery, *params.Px); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5AccountMaxWithdrawalRequest generates requests for GetApiV5AccountMaxWithdrawal +func NewGetApiV5AccountMaxWithdrawalRequest(server string, params *GetApiV5AccountMaxWithdrawalParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/max-withdrawal") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostApiV5AccountPositionMarginBalanceRequest calls the generic PostApiV5AccountPositionMarginBalance builder with application/json body +func NewPostApiV5AccountPositionMarginBalanceRequest(server string, body PostApiV5AccountPositionMarginBalanceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5AccountPositionMarginBalanceRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5AccountPositionMarginBalanceRequestWithBody generates requests for PostApiV5AccountPositionMarginBalance with any type of body +func NewPostApiV5AccountPositionMarginBalanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/position/margin-balance") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetApiV5AccountPositionsRequest generates requests for GetApiV5AccountPositions +func NewGetApiV5AccountPositionsRequest(server string, params *GetApiV5AccountPositionsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/positions") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.PosId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "posId", runtime.ParamLocationQuery, *params.PosId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostApiV5AccountSetGreeksRequest calls the generic PostApiV5AccountSetGreeks builder with application/json body +func NewPostApiV5AccountSetGreeksRequest(server string, body PostApiV5AccountSetGreeksJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5AccountSetGreeksRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5AccountSetGreeksRequestWithBody generates requests for PostApiV5AccountSetGreeks with any type of body +func NewPostApiV5AccountSetGreeksRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/set-greeks") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5AccountSetLeverageRequest calls the generic PostApiV5AccountSetLeverage builder with application/json body +func NewPostApiV5AccountSetLeverageRequest(server string, body PostApiV5AccountSetLeverageJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5AccountSetLeverageRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5AccountSetLeverageRequestWithBody generates requests for PostApiV5AccountSetLeverage with any type of body +func NewPostApiV5AccountSetLeverageRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/set-leverage") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5AccountSetPositionModeRequest calls the generic PostApiV5AccountSetPositionMode builder with application/json body +func NewPostApiV5AccountSetPositionModeRequest(server string, body PostApiV5AccountSetPositionModeJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5AccountSetPositionModeRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5AccountSetPositionModeRequestWithBody generates requests for PostApiV5AccountSetPositionMode with any type of body +func NewPostApiV5AccountSetPositionModeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/set-position-mode") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetApiV5AccountTradeFeeRequest generates requests for GetApiV5AccountTradeFee +func NewGetApiV5AccountTradeFeeRequest(server string, params *GetApiV5AccountTradeFeeParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/account/trade-fee") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "category", runtime.ParamLocationQuery, *params.Category); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetApiV5AccountAccountPositionRisk request + GetApiV5AccountAccountPositionRiskWithResponse(ctx context.Context, params *GetApiV5AccountAccountPositionRiskParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountAccountPositionRiskResponse, error) + + // GetApiV5AccountBalance request + GetApiV5AccountBalanceWithResponse(ctx context.Context, params *GetApiV5AccountBalanceParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountBalanceResponse, error) + + // GetApiV5AccountBills request + GetApiV5AccountBillsWithResponse(ctx context.Context, params *GetApiV5AccountBillsParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountBillsResponse, error) + + // GetApiV5AccountBillsArchive request + GetApiV5AccountBillsArchiveWithResponse(ctx context.Context, params *GetApiV5AccountBillsArchiveParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountBillsArchiveResponse, error) + + // GetApiV5AccountConfig request + GetApiV5AccountConfigWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5AccountConfigResponse, error) + + // GetApiV5AccountInterestAccrued request + GetApiV5AccountInterestAccruedWithResponse(ctx context.Context, params *GetApiV5AccountInterestAccruedParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountInterestAccruedResponse, error) + + // GetApiV5AccountInterestRate request + GetApiV5AccountInterestRateWithResponse(ctx context.Context, params *GetApiV5AccountInterestRateParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountInterestRateResponse, error) + + // GetApiV5AccountLeverageInfo request + GetApiV5AccountLeverageInfoWithResponse(ctx context.Context, params *GetApiV5AccountLeverageInfoParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountLeverageInfoResponse, error) + + // GetApiV5AccountMaxAvailSize request + GetApiV5AccountMaxAvailSizeWithResponse(ctx context.Context, params *GetApiV5AccountMaxAvailSizeParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxAvailSizeResponse, error) + + // GetApiV5AccountMaxLoan request + GetApiV5AccountMaxLoanWithResponse(ctx context.Context, params *GetApiV5AccountMaxLoanParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxLoanResponse, error) + + // GetApiV5AccountMaxSize request + GetApiV5AccountMaxSizeWithResponse(ctx context.Context, params *GetApiV5AccountMaxSizeParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxSizeResponse, error) + + // GetApiV5AccountMaxWithdrawal request + GetApiV5AccountMaxWithdrawalWithResponse(ctx context.Context, params *GetApiV5AccountMaxWithdrawalParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxWithdrawalResponse, error) + + // PostApiV5AccountPositionMarginBalance request with any body + PostApiV5AccountPositionMarginBalanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountPositionMarginBalanceResponse, error) + + PostApiV5AccountPositionMarginBalanceWithResponse(ctx context.Context, body PostApiV5AccountPositionMarginBalanceJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountPositionMarginBalanceResponse, error) + + // GetApiV5AccountPositions request + GetApiV5AccountPositionsWithResponse(ctx context.Context, params *GetApiV5AccountPositionsParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountPositionsResponse, error) + + // PostApiV5AccountSetGreeks request with any body + PostApiV5AccountSetGreeksWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetGreeksResponse, error) + + PostApiV5AccountSetGreeksWithResponse(ctx context.Context, body PostApiV5AccountSetGreeksJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetGreeksResponse, error) + + // PostApiV5AccountSetLeverage request with any body + PostApiV5AccountSetLeverageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetLeverageResponse, error) + + PostApiV5AccountSetLeverageWithResponse(ctx context.Context, body PostApiV5AccountSetLeverageJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetLeverageResponse, error) + + // PostApiV5AccountSetPositionMode request with any body + PostApiV5AccountSetPositionModeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetPositionModeResponse, error) + + PostApiV5AccountSetPositionModeWithResponse(ctx context.Context, body PostApiV5AccountSetPositionModeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetPositionModeResponse, error) + + // GetApiV5AccountTradeFee request + GetApiV5AccountTradeFeeWithResponse(ctx context.Context, params *GetApiV5AccountTradeFeeParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountTradeFeeResponse, error) +} + +type GetApiV5AccountAccountPositionRiskResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountAccountPositionRiskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountAccountPositionRiskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountBalanceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountBalanceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountBalanceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountBillsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountBillsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountBillsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountBillsArchiveResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountBillsArchiveResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountBillsArchiveResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountConfigResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountInterestAccruedResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountInterestAccruedResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountInterestAccruedResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountInterestRateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountInterestRateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountInterestRateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountLeverageInfoResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountLeverageInfoResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountLeverageInfoResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountMaxAvailSizeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountMaxAvailSizeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountMaxAvailSizeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountMaxLoanResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountMaxLoanResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountMaxLoanResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountMaxSizeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountMaxSizeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountMaxSizeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountMaxWithdrawalResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountMaxWithdrawalResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountMaxWithdrawalResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5AccountPositionMarginBalanceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5AccountPositionMarginBalanceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5AccountPositionMarginBalanceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountPositionsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountPositionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountPositionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5AccountSetGreeksResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5AccountSetGreeksResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5AccountSetGreeksResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5AccountSetLeverageResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5AccountSetLeverageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5AccountSetLeverageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5AccountSetPositionModeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5AccountSetPositionModeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5AccountSetPositionModeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5AccountTradeFeeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5AccountTradeFeeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5AccountTradeFeeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// GetApiV5AccountAccountPositionRiskWithResponse request returning *GetApiV5AccountAccountPositionRiskResponse +func (c *ClientWithResponses) GetApiV5AccountAccountPositionRiskWithResponse(ctx context.Context, params *GetApiV5AccountAccountPositionRiskParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountAccountPositionRiskResponse, error) { + rsp, err := c.GetApiV5AccountAccountPositionRisk(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountAccountPositionRiskResponse(rsp) +} + +// GetApiV5AccountBalanceWithResponse request returning *GetApiV5AccountBalanceResponse +func (c *ClientWithResponses) GetApiV5AccountBalanceWithResponse(ctx context.Context, params *GetApiV5AccountBalanceParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountBalanceResponse, error) { + rsp, err := c.GetApiV5AccountBalance(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountBalanceResponse(rsp) +} + +// GetApiV5AccountBillsWithResponse request returning *GetApiV5AccountBillsResponse +func (c *ClientWithResponses) GetApiV5AccountBillsWithResponse(ctx context.Context, params *GetApiV5AccountBillsParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountBillsResponse, error) { + rsp, err := c.GetApiV5AccountBills(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountBillsResponse(rsp) +} + +// GetApiV5AccountBillsArchiveWithResponse request returning *GetApiV5AccountBillsArchiveResponse +func (c *ClientWithResponses) GetApiV5AccountBillsArchiveWithResponse(ctx context.Context, params *GetApiV5AccountBillsArchiveParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountBillsArchiveResponse, error) { + rsp, err := c.GetApiV5AccountBillsArchive(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountBillsArchiveResponse(rsp) +} + +// GetApiV5AccountConfigWithResponse request returning *GetApiV5AccountConfigResponse +func (c *ClientWithResponses) GetApiV5AccountConfigWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5AccountConfigResponse, error) { + rsp, err := c.GetApiV5AccountConfig(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountConfigResponse(rsp) +} + +// GetApiV5AccountInterestAccruedWithResponse request returning *GetApiV5AccountInterestAccruedResponse +func (c *ClientWithResponses) GetApiV5AccountInterestAccruedWithResponse(ctx context.Context, params *GetApiV5AccountInterestAccruedParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountInterestAccruedResponse, error) { + rsp, err := c.GetApiV5AccountInterestAccrued(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountInterestAccruedResponse(rsp) +} + +// GetApiV5AccountInterestRateWithResponse request returning *GetApiV5AccountInterestRateResponse +func (c *ClientWithResponses) GetApiV5AccountInterestRateWithResponse(ctx context.Context, params *GetApiV5AccountInterestRateParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountInterestRateResponse, error) { + rsp, err := c.GetApiV5AccountInterestRate(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountInterestRateResponse(rsp) +} + +// GetApiV5AccountLeverageInfoWithResponse request returning *GetApiV5AccountLeverageInfoResponse +func (c *ClientWithResponses) GetApiV5AccountLeverageInfoWithResponse(ctx context.Context, params *GetApiV5AccountLeverageInfoParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountLeverageInfoResponse, error) { + rsp, err := c.GetApiV5AccountLeverageInfo(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountLeverageInfoResponse(rsp) +} + +// GetApiV5AccountMaxAvailSizeWithResponse request returning *GetApiV5AccountMaxAvailSizeResponse +func (c *ClientWithResponses) GetApiV5AccountMaxAvailSizeWithResponse(ctx context.Context, params *GetApiV5AccountMaxAvailSizeParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxAvailSizeResponse, error) { + rsp, err := c.GetApiV5AccountMaxAvailSize(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountMaxAvailSizeResponse(rsp) +} + +// GetApiV5AccountMaxLoanWithResponse request returning *GetApiV5AccountMaxLoanResponse +func (c *ClientWithResponses) GetApiV5AccountMaxLoanWithResponse(ctx context.Context, params *GetApiV5AccountMaxLoanParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxLoanResponse, error) { + rsp, err := c.GetApiV5AccountMaxLoan(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountMaxLoanResponse(rsp) +} + +// GetApiV5AccountMaxSizeWithResponse request returning *GetApiV5AccountMaxSizeResponse +func (c *ClientWithResponses) GetApiV5AccountMaxSizeWithResponse(ctx context.Context, params *GetApiV5AccountMaxSizeParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxSizeResponse, error) { + rsp, err := c.GetApiV5AccountMaxSize(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountMaxSizeResponse(rsp) +} + +// GetApiV5AccountMaxWithdrawalWithResponse request returning *GetApiV5AccountMaxWithdrawalResponse +func (c *ClientWithResponses) GetApiV5AccountMaxWithdrawalWithResponse(ctx context.Context, params *GetApiV5AccountMaxWithdrawalParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountMaxWithdrawalResponse, error) { + rsp, err := c.GetApiV5AccountMaxWithdrawal(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountMaxWithdrawalResponse(rsp) +} + +// PostApiV5AccountPositionMarginBalanceWithBodyWithResponse request with arbitrary body returning *PostApiV5AccountPositionMarginBalanceResponse +func (c *ClientWithResponses) PostApiV5AccountPositionMarginBalanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountPositionMarginBalanceResponse, error) { + rsp, err := c.PostApiV5AccountPositionMarginBalanceWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountPositionMarginBalanceResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5AccountPositionMarginBalanceWithResponse(ctx context.Context, body PostApiV5AccountPositionMarginBalanceJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountPositionMarginBalanceResponse, error) { + rsp, err := c.PostApiV5AccountPositionMarginBalance(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountPositionMarginBalanceResponse(rsp) +} + +// GetApiV5AccountPositionsWithResponse request returning *GetApiV5AccountPositionsResponse +func (c *ClientWithResponses) GetApiV5AccountPositionsWithResponse(ctx context.Context, params *GetApiV5AccountPositionsParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountPositionsResponse, error) { + rsp, err := c.GetApiV5AccountPositions(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountPositionsResponse(rsp) +} + +// PostApiV5AccountSetGreeksWithBodyWithResponse request with arbitrary body returning *PostApiV5AccountSetGreeksResponse +func (c *ClientWithResponses) PostApiV5AccountSetGreeksWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetGreeksResponse, error) { + rsp, err := c.PostApiV5AccountSetGreeksWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountSetGreeksResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5AccountSetGreeksWithResponse(ctx context.Context, body PostApiV5AccountSetGreeksJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetGreeksResponse, error) { + rsp, err := c.PostApiV5AccountSetGreeks(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountSetGreeksResponse(rsp) +} + +// PostApiV5AccountSetLeverageWithBodyWithResponse request with arbitrary body returning *PostApiV5AccountSetLeverageResponse +func (c *ClientWithResponses) PostApiV5AccountSetLeverageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetLeverageResponse, error) { + rsp, err := c.PostApiV5AccountSetLeverageWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountSetLeverageResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5AccountSetLeverageWithResponse(ctx context.Context, body PostApiV5AccountSetLeverageJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetLeverageResponse, error) { + rsp, err := c.PostApiV5AccountSetLeverage(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountSetLeverageResponse(rsp) +} + +// PostApiV5AccountSetPositionModeWithBodyWithResponse request with arbitrary body returning *PostApiV5AccountSetPositionModeResponse +func (c *ClientWithResponses) PostApiV5AccountSetPositionModeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetPositionModeResponse, error) { + rsp, err := c.PostApiV5AccountSetPositionModeWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountSetPositionModeResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5AccountSetPositionModeWithResponse(ctx context.Context, body PostApiV5AccountSetPositionModeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5AccountSetPositionModeResponse, error) { + rsp, err := c.PostApiV5AccountSetPositionMode(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5AccountSetPositionModeResponse(rsp) +} + +// GetApiV5AccountTradeFeeWithResponse request returning *GetApiV5AccountTradeFeeResponse +func (c *ClientWithResponses) GetApiV5AccountTradeFeeWithResponse(ctx context.Context, params *GetApiV5AccountTradeFeeParams, reqEditors ...RequestEditorFn) (*GetApiV5AccountTradeFeeResponse, error) { + rsp, err := c.GetApiV5AccountTradeFee(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5AccountTradeFeeResponse(rsp) +} + +// ParseGetApiV5AccountAccountPositionRiskResponse parses an HTTP response from a GetApiV5AccountAccountPositionRiskWithResponse call +func ParseGetApiV5AccountAccountPositionRiskResponse(rsp *http.Response) (*GetApiV5AccountAccountPositionRiskResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountAccountPositionRiskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountBalanceResponse parses an HTTP response from a GetApiV5AccountBalanceWithResponse call +func ParseGetApiV5AccountBalanceResponse(rsp *http.Response) (*GetApiV5AccountBalanceResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountBalanceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountBillsResponse parses an HTTP response from a GetApiV5AccountBillsWithResponse call +func ParseGetApiV5AccountBillsResponse(rsp *http.Response) (*GetApiV5AccountBillsResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountBillsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountBillsArchiveResponse parses an HTTP response from a GetApiV5AccountBillsArchiveWithResponse call +func ParseGetApiV5AccountBillsArchiveResponse(rsp *http.Response) (*GetApiV5AccountBillsArchiveResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountBillsArchiveResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountConfigResponse parses an HTTP response from a GetApiV5AccountConfigWithResponse call +func ParseGetApiV5AccountConfigResponse(rsp *http.Response) (*GetApiV5AccountConfigResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountInterestAccruedResponse parses an HTTP response from a GetApiV5AccountInterestAccruedWithResponse call +func ParseGetApiV5AccountInterestAccruedResponse(rsp *http.Response) (*GetApiV5AccountInterestAccruedResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountInterestAccruedResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountInterestRateResponse parses an HTTP response from a GetApiV5AccountInterestRateWithResponse call +func ParseGetApiV5AccountInterestRateResponse(rsp *http.Response) (*GetApiV5AccountInterestRateResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountInterestRateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountLeverageInfoResponse parses an HTTP response from a GetApiV5AccountLeverageInfoWithResponse call +func ParseGetApiV5AccountLeverageInfoResponse(rsp *http.Response) (*GetApiV5AccountLeverageInfoResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountLeverageInfoResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountMaxAvailSizeResponse parses an HTTP response from a GetApiV5AccountMaxAvailSizeWithResponse call +func ParseGetApiV5AccountMaxAvailSizeResponse(rsp *http.Response) (*GetApiV5AccountMaxAvailSizeResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountMaxAvailSizeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountMaxLoanResponse parses an HTTP response from a GetApiV5AccountMaxLoanWithResponse call +func ParseGetApiV5AccountMaxLoanResponse(rsp *http.Response) (*GetApiV5AccountMaxLoanResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountMaxLoanResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountMaxSizeResponse parses an HTTP response from a GetApiV5AccountMaxSizeWithResponse call +func ParseGetApiV5AccountMaxSizeResponse(rsp *http.Response) (*GetApiV5AccountMaxSizeResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountMaxSizeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountMaxWithdrawalResponse parses an HTTP response from a GetApiV5AccountMaxWithdrawalWithResponse call +func ParseGetApiV5AccountMaxWithdrawalResponse(rsp *http.Response) (*GetApiV5AccountMaxWithdrawalResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountMaxWithdrawalResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5AccountPositionMarginBalanceResponse parses an HTTP response from a PostApiV5AccountPositionMarginBalanceWithResponse call +func ParsePostApiV5AccountPositionMarginBalanceResponse(rsp *http.Response) (*PostApiV5AccountPositionMarginBalanceResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5AccountPositionMarginBalanceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountPositionsResponse parses an HTTP response from a GetApiV5AccountPositionsWithResponse call +func ParseGetApiV5AccountPositionsResponse(rsp *http.Response) (*GetApiV5AccountPositionsResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountPositionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5AccountSetGreeksResponse parses an HTTP response from a PostApiV5AccountSetGreeksWithResponse call +func ParsePostApiV5AccountSetGreeksResponse(rsp *http.Response) (*PostApiV5AccountSetGreeksResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5AccountSetGreeksResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5AccountSetLeverageResponse parses an HTTP response from a PostApiV5AccountSetLeverageWithResponse call +func ParsePostApiV5AccountSetLeverageResponse(rsp *http.Response) (*PostApiV5AccountSetLeverageResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5AccountSetLeverageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5AccountSetPositionModeResponse parses an HTTP response from a PostApiV5AccountSetPositionModeWithResponse call +func ParsePostApiV5AccountSetPositionModeResponse(rsp *http.Response) (*PostApiV5AccountSetPositionModeResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5AccountSetPositionModeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5AccountTradeFeeResponse parses an HTTP response from a GetApiV5AccountTradeFeeWithResponse call +func ParseGetApiV5AccountTradeFeeResponse(rsp *http.Response) (*GetApiV5AccountTradeFeeResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5AccountTradeFeeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "H4sIAAAAAAAC/+x823MTR/b/v6Ka39uWLHdPz9VvhpAsVeQXF5jNw25qNUiDUaJbpDGBTblKBoxlsDEX", + "2xBjY0wMmJvtbAjIkhz/MZkeSU/+F77V3TOj0UiyJSNy2fKTpL6ePqfPOZ8+3Uffc5FUIp1K6kkjyw18", + "PxbkYsnzKW7gey6qZyOZWNqIpZLcAPf/AubObmVuvbr51npwK/CvZOBfowCgyDn6oVc3n+IbK9WrO9at", + "p3j2x8rcupV/X1vK4Yl85YdS7Yfre+VpVoVnX5rlxerme+unK9b6qnVzpXJrEz+5yobrt8ezB8+0+vW3", + "IS2jJXRDz2T/FqgtP7GWd83Cm8qVbTxZCg9nLgdiRiA1aoSt6ana3Y298nSlvFD99Q6bEs9esea3SCFr", + "f+KSHhk1dLsxnr1Ty42zlr/lrvzttJ5Np5JZ3TuRtfK0snSTtamU7lmPln7LXWmkkAtyRsyI69wAd/rE", + "meHA4NBJLshd1DNZxsyLIjcW5FJpPamlY9wAh0IgBLkgl9aMC0QKXL+WjvVfFPu1SCQ1mjScz750Khsj", + "AunLxLLfkIYjukE+Umk9o5GKk1FugPtMNwbTsX+Ig6yX/TFk9z1NupK5HCZyA//0S9ssPsf3xis/lfCj", + "m41LC58Z+mI4vFdexIVxXBj3VX4+ePqzk/+/Xm0tP7aWr/tH+HJwiDSxtgqV0ht8O18pPvM1+fTs8NnT", + "J86QVmZxDU/9t2WrL4aGT35BZ7OWVqzlqxzZvNwA9+2onrnMBbmkliAiiCWzxvDlNJFKNnJBT2iEYwYp", + "GOCyRiaWHOHGxr4KchlH2KSeB4B8RFJJQ09SHmvpdDwWoVzu/zpL2PS9Zzz9kpZIE4mTPlEyNOCCXFQz", + "NMpeLfr1iW+5AQ7KAo+UkCSrSBJUGUKEoCSrXJA7p8U/cVpHIpe5Ae7Y8HEyRCxLe8qKIkghWQFI5iHg", + "IZJ4XuC5IKfTcUNIkZCIEJJUAaoSkrixoDPQ2TOfDHtHQgKUQ7ygihDyioQQAJCXnZFkhHgUQqooSoIq", + "ISjLUJA4wp90Kuuj0B6YMJhuvGPDx/tIWR8PgQhku2qYsdqWKRfkEiPJzxmPIplUNksklSJs1eLH6bAg", + "pCqewrNZMrYoKkAKKQoUVEiWnU5luQGONkynsqwj+05JQRAIPJJUURURhAiogFWeidGJk7pB10SMHgcl", + "HvAKrygqEkRanMiOkOHGgs4+SZ37Wo8Y3NjYWNCnKlb+Nr6xwpGK7GgioWUIIbaNePvMyr+3psfN0r3a", + "j7dqP7wghkEbIRrH2VrJfUV6+vX9nBbXkhG9Uw0/Zjc/QKtxYbzyfGavPI2fXdkrL4aPDR8Pt9EZIt8/", + "g7oASVYlRQkBQQIigpKAgMqLMtlaUd3QYnG2Tu2iFosf0+JsD9BftL+qIoBENaSqdKNEtOwF1spf4d3O", + "dFOeimnnHKpsvVEFpMpIDgFZ5lVVFaHg6IxvNP1btmVVFSEgwBBUJVVVVUHigtz5TOo/epIRASjzDT2j", + "Zw3nZzZF57K/e6iIZVNn006veL08oV06ldKSlFkAAKZepwnfGTMcLTqlX9QzrCiViX5KybCHyBojl91Z", + "je+0tP11dDhGNwPRD5nnVaTwIi136RhNx10Sib1pJweEiMlTZShAUYGqKlDe1cWBUIgHQFUV0RUGs37t", + "ZAF5pKoiCKmSIouIh7zq7gvdnlCWocIDiRchkgCPPHLZp3ODeEJAhYqg8kBFUAIKlHosL0FEIZXnFWKi", + "BBWJqvA7Si8kykDheejhT4M0vwpysUSGslLmQ7wq8EgmVl1UBR7KvqV7iJYBksUQEgWgyIIMaNMEHQgi", + "IaSoUJZUQRF4wAtNNp5MxYc8U8mKoij1NTuLTBka21cQQqKLfAhKoiwiKCp1UXrWj5DKIyTIUOmJda/e", + "eo9nF5h1Nwtvqr9cq03eMXd+qD1ZNndXrfHNjs18LB7PdmzkaeMj4ObzRMGP6OWaxjZL98ydmZbsjWVT", + "cc3Qo2RVtdxts3QvEKbWizJ1Yt0s3WtDhQOHulsl5WtLSuKxpK5lKHff/Ihv32FNA+FYkpxAdErP7Ixb", + "0djbLE0wwfUzKVtLU9Z8vh3/DiGe6ttneGa+FeGQEJa/W915HeDZ/rEe3AsgdysFhL3yYnXyJb6xbs08", + "wYXxgEh6lIt4++eARJrtLlc3x2uTd+xRZMKCqR+t8c2AQrpSPa2+3Q6o7kB4cpZICoK98mLlxa5Zuldd", + "fYrHdwOQUFP5uVQprdiTQUJU5c1CZf4pzt+1bq63YYrR/Y59c3t/rpjbW3jiKeUKnlnAk0XKFVzO4bVF", + "yhVczlVeFBk/tn8mpRL7SkrVOhvoqqo7r8lodD3k+2QxACVAG93EN9aruzv4xmOXlwEoQbcOT87irTve", + "Ot5lZVM/6JeXvQwIRV+FvSgIFR/THVKh2qKC9ADA3gKTs/bCIYDeIsIACHi3yKEBoHore3YguNvJHUv0", + "FrGxJLfIHUuut3JWAtwi30pgiwrSgxd9m9KhgZeaKyglvOyrcOjhFX8PmyqZUpXfspZWqqvT1vLVAJRh", + "vejJK7eUd0vNnSVcXAlAyNdtuk0ZRN4iShOU3aJ+ZtsbtUpGXkW05jYZXUJj6Tu62wEYYCK3eccDOGBv", + "UaeA97SYLAZ4gDwtJottNDQ7eu4QdotFrN6snfzE3L6Jp2b2ynnr4Vvr/vPK4jVrfsua2dgrT1UWr+H8", + "9drqL/j6BN7Y3itPm+XHpDBXNgtFvLmNi3N2iGzxWpj4/5PRdt5JO2/omQ8i8vYtm8iFrY9F5Dn9fCrT", + "LSt35/DDRyx2xuiqTc7uladrpQfVjTUIgLW82ma6eCwRM/7Ik+k552gAAFCgioCsqgqkx75zWvz4BYIs", + "+yRJCPGSrIqKJJKTn6oAnjSgnGTBCaQKCCJREFRJgiL0n0HP687M5zOpBAP+bpjllB1maYyvEHzXLrhC", + "WGGfHXwEQFUBAPE0OpJ0jivpVLZ+QmU/2MroecPWngGOrClLQLlnvRLF52y2enBFFmUZQpVWOn17gsSp", + "27R+Gbe23lorT6ubT/bK+eruHbNwFa+92CtPdYXE+7RM5ELsot4VIh+0+xwB8yNgfgTMj4D5ETA/AuZH", + "wPwImB8B8yNgfgTMm4H5lLWU7wKYR1LJ87GRThH5cdb6I19ORiLGqYs2m7VRI8Xuc4zMqB7kRjK6/k3W", + "lsOxM1yQi+sXdSKy+EXo/BpOpN3bantPxFPJkX9nL6Qyxr8TDHOOxsgCBaRAvud30rWJmcrORqcycO68", + "+rRIJDOqRzuVxkm736DdraMj0slPGk4IVJ+IjXOF4r4y2OdwcjLa5fHBAUfW+iouzx7qBFEn0NHv3p0p", + "PuLJiWknXlq33qwx/0kcjuN/mOex7r+r3X9r5X/eK0+fTcYuub9J3earyvO7xIU9LuPybO9cpp+w27c+", + "BmGHcZPMR9vOcvEa85e1h9ddf2kt5fDac7NQpDB42izM4NVXzImyXn9uV7r/4x7fJXiIelCn5LRm6K4b", + "hvWbb76lA2R+SFRlwEtIQUARm18t/d7z9+5+eGPVGt+sbmzhnfmuLW2GrqM7M0vX/j/zBMj7CqSVdKFn", + "q5xq2wr1UKDsUSveuYenZlgYDudWyCE5/6Jya7JTERMAkNFG9D7nnW0nIj5ldzpJ+hzajfbROGGjc7Pm", + "Nq3pcby26HRz0ZpZmKm+m6juTvLALLzcK0+RAWduVJ/freXu49n3xAouzrX0zHSig9xzRv92NJYhaIIh", + "p565a59rDrTw34dw152T+5EVo/m1pc3tuP1GCIKWxq7++JFgTao9Hz4URaw91DFHr2as+a1ONSqhXeqj", + "T836srH/dGw1P9cuDZJOZ0ifwyPTrrVJ7FaZPqYe0UjuYZUoEI5o2Qv09/IjVyUbVUvLXmgXjY12rVjt", + "7YDr1szSRC13pTK3bhZv4Zl5Vu4zF2bhJkGSdF1sv1U3nuCZ+Z4h6geb+PYzs1DEsy9ZmI/N6yMv7L3Q", + "aeeEM3p0NKJ/kYy3pOFcKhXXteTv8B6XvuscJXoKVR6FFKRAgRdUHokSz0vQeex5Ro/H6Wt0AEUkE/8r", + "AgEoSGkJ5HpoNijgxrObxEdTFN6N8YjT83vHZoMe93/ns+yHKEn7q7FuPaVT3UNn2YFOe6BqI/1eBXKV", + "3dbrqxP4+i9m4SbenaitlqzpSbyx6Bu6/SqO/5mgb/Pxp/6EmKUN2RTTiFLdWXuElbWdNdHOjg5Y3hn4", + "LmY4N3q5h1rN3BNTJVfDcW6lG93uEhIcoYEjNNBbNICfz1lTD8zSe+tx2We+du6xyFC9yf13ZnnRmp6y", + "D5lLOWthy8rfNotrZul9dWO1snG/aQxm28guK7wMs30QZhvNuv+ObKzdncr80+rmUzf1cf8J2iw8felP", + "bhIZPAEhIAIgqSJQFZEmELBaG5lIQkiQVUWSoSgDIPO8pH4MGGJub+GZhX5czpFd1TUg+S5mXIhmtO+0", + "eBem68t6p8MFgRqMzZ8/KJTQLn0ZZWlPvc/ZcwRZ3XnNEjs6FZ+Toduf0DIjsWSfJ5Mvncq2EORQKtsg", + "SSdN93Pav57ZRwyjnjWOpaKXO+Coh49awiBcapmnaR/3faEBl4NaNEr4WRdPOkOIN2JMuHTkps21O4FX", + "X/ms1JNH+MZjK7/AnqlUFq/VjbCjHPXdV5/f2VZ10juZ7aAA2IGTuezoZDaW3mktbOPbd9yrcpwrWw82", + "w0ndCPvfgKWSI+yh1zS+fYd1xmuLeO2tryGNrPhbVl4Um1uSWegDpHm33YFLZAWdy67f98DIR4IWpUiA", + "tQ2E2amVltBuB5Az5nX7/6xjGUcOdoevWmp2I2AY+0D7o0WjMZaRNtSw1X0TBw88MH+g0vXCJW1dtebf", + "epFYVwas47y0IbfD0RPYgyF210eHwku2g5rPDvCAuHyvLseZSaFEe8mimfbd3Bbgqf+2w5Y0af8PzTeP", + "2+pKw1hD9L8F2M+RoUvcAMeLkhRC9DWQm1YKVRHIsqjIKnJfCZ0Y/jtNTY8b2rEzzNjRH0OD7MeIlki4", + "NfSHU8OSbb0G48Tw38nW6OMhEBBo92cKvoTkuEa/Unp53h/Kt29D7W/ukT4e+5atEol8SBFUSVKgAhUe", + "IYqzCBBxL9QUVZIEEcmy6qQrN0cDPOnAEIZkBGVeEoEqKgpLomb5wOySFkGoQAhUHknNf/rA87IU4kVB", + "koAKgCoBkQtyqbTxDyfFPO2ThgQFqf7vELDdn0MAGcoIIAmIEEBZRqClPb6g16VIfziyMjJaVD/JwKeq", + "CEJDtnEjISzbuo+tFQBVRbwsSQAJrM5hE23Ai4IKRFFSAASyQv8xZsQlgHxn8/cO7DLN7i5nOasbfeyR", + "U+eY9oxufMa6fACObXhZNTS4HzD1Nm0+/ExXJ27gN/etzRn803xlrUiwW1PEY2jQdjjW0mtzhxyWwseo", + "66j8egtPXGWlB0IZDyF/JfTSxOpe7DjqTb3cHxrsP3YG5yetmSfdbD7nAr2r7edcoB92A1I2Qsptd0UE", + "jWxu45+u1Jaf9FU3fq3sbLBQmPcSc6+c96IW9vLxohYfpfS3CmU4BltsbV0JW/gDCdkn2uUNdfWWRnY9", + "TAhETQRWns80EFh9v94rAr1BgYMIE3yEUQTYyDlWRI9kzeLclzH+23OxnX/0X8WPBTmxkTBretKa32pB", + "mC9W+cFUOazZx5pS/jaZ0dnNWm7Kd/DeNwDbTuLuihovRH/LXekqENCKHhdtLzIV+S033hLz21FTfHc6", + "HIlcDlcnf8Zbd6rPxs3yY7OQo3j2IX52xXq0ZBbWzMLL2tUds/zYPe2zf8ZzoXUTzTbnO4om+N4/+Idy", + "BfehL1iJQ/NF9X3nfrpeyg+WamaWH+Ncea887YaSca6MZ19Wr+6YhaI9WBuptY+otBCbN6Lyh0RPfIxY", + "WvcOYhbmmkxW0TEUq2bpHbt0xKuv6MvPObM0wRZp3XzB6LfyCy5903jinVlacK8ra8uP3M5sc9kEPmx4", + "OtCQCRg+EIbUL2bZVvwrYZED7RkCnZrZXgRVqCk+zCslAl3cv29M2DrcMX5xo8L1W7KeYBjbtXj2t9eX", + "tE9PaIFC6sBj/6GSujvGPk7Hbd86GtESs/uI9Kt/s+LXm7WLnTanZeyvaQ7ZfyUN20fKvdMYJjVqLzvV", + "GHrK7qMJV51FIodJh0/1/91c/Pq+tHPKDohMftBjgA4jlV6/5ExtFoqMQ/1eRn3sJB7GRevxZGXxGsPP", + "TcTvQ3vYIT5M0AyTS7g/bLvY/jATQrt3eqPxy4dJ6bGmblZKb6pvt8lmzL9qTjCvvH5tFnKklrYnLW9N", + "0nxzUlOc9tcgp8+Uv0ZgNfjhQ19Nu5tezdBHUpk/9rrXoYGF8qJ6PHZRz9jBPP2SnonEsno9atqYb+nk", + "3Z2ieXcJ7RuKFlgkTqE2yFMC61mRCMoSlETA8718GsAeXNj/Gcge2jiyd8XQwiqOuaUt/q7Byr+vy8vp", + "NPbV2P8FAAD//379QwTUWwAA", +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %s", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + var res = make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + var resolvePath = PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + var pathToFile = url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} + diff --git a/okex/api/market/market.gen.go b/okex/api/market/market.gen.go new file mode 100644 index 0000000..d377a9a --- /dev/null +++ b/okex/api/market/market.gen.go @@ -0,0 +1,2086 @@ +// Package market provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.9.0 DO NOT EDIT. +package market + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "path" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + "github.com/getkin/kin-openapi/openapi3" +) + +// GetApiV5MarketBooksParams defines parameters for GetApiV5MarketBooks. +type GetApiV5MarketBooksParams struct { + // 产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 深度档位数量
最大值可传400,即买卖深度共800条
不填写此参数,默认返回1档深度数据 + Sz *string `json:"sz,omitempty"` +} + +// GetApiV5MarketCandlesParams defines parameters for GetApiV5MarketCandles. +type GetApiV5MarketCandlesParams struct { + // 产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] + Bar *string `json:"bar,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5MarketHistoryCandlesParams defines parameters for GetApiV5MarketHistoryCandles. +type GetApiV5MarketHistoryCandlesParams struct { + // 产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] + Bar *string `json:"bar,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5MarketIndexCandlesParams defines parameters for GetApiV5MarketIndexCandles. +type GetApiV5MarketIndexCandlesParams struct { + // 现货指数,如:`BTC-USD` + InstId string `json:"instId"` + + // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] + Bar *string `json:"bar,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5MarketIndexComponentsParams defines parameters for GetApiV5MarketIndexComponents. +type GetApiV5MarketIndexComponentsParams struct { + // 指数,如:`BTC-USDT` + Index string `json:"index"` +} + +// GetApiV5MarketIndexTickersParams defines parameters for GetApiV5MarketIndexTickers. +type GetApiV5MarketIndexTickersParams struct { + // 指数,如:`BTC-USD`
`instId`和`quoteCcy`必须填写一个 + InstId *string `json:"instId,omitempty"` + + // 指数计价单位
目前只有`USD`/`USDT`/`BTC`为计价单位的指数 + QuoteCcy *string `json:"quoteCcy,omitempty"` +} + +// GetApiV5MarketMarkPriceCandlesParams defines parameters for GetApiV5MarketMarkPriceCandles. +type GetApiV5MarketMarkPriceCandlesParams struct { + // 现货指数,如:`BTC-USD-SWAP` + InstId string `json:"instId"` + + // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] + Bar *string `json:"bar,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5MarketTickerParams defines parameters for GetApiV5MarketTicker. +type GetApiV5MarketTickerParams struct { + // 产品ID,如:`BTC-USD-SWAP` + InstId string `json:"instId"` +} + +// GetApiV5MarketTickersParams defines parameters for GetApiV5MarketTickers. +type GetApiV5MarketTickersParams struct { + // 产品类型
`SPOT`:币币
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数
仅适用于`交割/永续/期权`,如 `BTC-USD` + Uly *string `json:"uly,omitempty"` +} + +// GetApiV5MarketTradesParams defines parameters for GetApiV5MarketTrades. +type GetApiV5MarketTradesParams struct { + // 产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 分页返回的结果集数量,最大为500,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // GetApiV5MarketBooks request + GetApiV5MarketBooks(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketCandles request + GetApiV5MarketCandles(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketHistoryCandles request + GetApiV5MarketHistoryCandles(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketIndexCandles request + GetApiV5MarketIndexCandles(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketIndexComponents request + GetApiV5MarketIndexComponents(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketIndexTickers request + GetApiV5MarketIndexTickers(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketMarkPriceCandles request + GetApiV5MarketMarkPriceCandles(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketOpenOracle request + GetApiV5MarketOpenOracle(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketPlatform24Volume request + GetApiV5MarketPlatform24Volume(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketTicker request + GetApiV5MarketTicker(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketTickers request + GetApiV5MarketTickers(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5MarketTrades request + GetApiV5MarketTrades(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) GetApiV5MarketBooks(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketBooksRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketCandles(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketCandlesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketHistoryCandles(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketHistoryCandlesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketIndexCandles(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketIndexCandlesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketIndexComponents(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketIndexComponentsRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketIndexTickers(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketIndexTickersRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketMarkPriceCandles(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketMarkPriceCandlesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketOpenOracle(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketOpenOracleRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketPlatform24Volume(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketPlatform24VolumeRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketTicker(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketTickerRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketTickers(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketTickersRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5MarketTrades(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5MarketTradesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewGetApiV5MarketBooksRequest generates requests for GetApiV5MarketBooks +func NewGetApiV5MarketBooksRequest(server string, params *GetApiV5MarketBooksParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/books") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Sz != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "sz", runtime.ParamLocationQuery, *params.Sz); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketCandlesRequest generates requests for GetApiV5MarketCandles +func NewGetApiV5MarketCandlesRequest(server string, params *GetApiV5MarketCandlesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/candles") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Bar != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketHistoryCandlesRequest generates requests for GetApiV5MarketHistoryCandles +func NewGetApiV5MarketHistoryCandlesRequest(server string, params *GetApiV5MarketHistoryCandlesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/history-candles") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Bar != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketIndexCandlesRequest generates requests for GetApiV5MarketIndexCandles +func NewGetApiV5MarketIndexCandlesRequest(server string, params *GetApiV5MarketIndexCandlesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/index-candles") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Bar != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketIndexComponentsRequest generates requests for GetApiV5MarketIndexComponents +func NewGetApiV5MarketIndexComponentsRequest(server string, params *GetApiV5MarketIndexComponentsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/index-components") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "index", runtime.ParamLocationQuery, params.Index); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketIndexTickersRequest generates requests for GetApiV5MarketIndexTickers +func NewGetApiV5MarketIndexTickersRequest(server string, params *GetApiV5MarketIndexTickersParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/index-tickers") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.QuoteCcy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "quoteCcy", runtime.ParamLocationQuery, *params.QuoteCcy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketMarkPriceCandlesRequest generates requests for GetApiV5MarketMarkPriceCandles +func NewGetApiV5MarketMarkPriceCandlesRequest(server string, params *GetApiV5MarketMarkPriceCandlesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/mark-price-candles") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Bar != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketOpenOracleRequest generates requests for GetApiV5MarketOpenOracle +func NewGetApiV5MarketOpenOracleRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/open-oracle") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketPlatform24VolumeRequest generates requests for GetApiV5MarketPlatform24Volume +func NewGetApiV5MarketPlatform24VolumeRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/platform-24-volume") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketTickerRequest generates requests for GetApiV5MarketTicker +func NewGetApiV5MarketTickerRequest(server string, params *GetApiV5MarketTickerParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/ticker") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketTickersRequest generates requests for GetApiV5MarketTickers +func NewGetApiV5MarketTickersRequest(server string, params *GetApiV5MarketTickersParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/tickers") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5MarketTradesRequest generates requests for GetApiV5MarketTrades +func NewGetApiV5MarketTradesRequest(server string, params *GetApiV5MarketTradesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/market/trades") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetApiV5MarketBooks request + GetApiV5MarketBooksWithResponse(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketBooksResponse, error) + + // GetApiV5MarketCandles request + GetApiV5MarketCandlesWithResponse(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketCandlesResponse, error) + + // GetApiV5MarketHistoryCandles request + GetApiV5MarketHistoryCandlesWithResponse(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketHistoryCandlesResponse, error) + + // GetApiV5MarketIndexCandles request + GetApiV5MarketIndexCandlesWithResponse(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexCandlesResponse, error) + + // GetApiV5MarketIndexComponents request + GetApiV5MarketIndexComponentsWithResponse(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexComponentsResponse, error) + + // GetApiV5MarketIndexTickers request + GetApiV5MarketIndexTickersWithResponse(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexTickersResponse, error) + + // GetApiV5MarketMarkPriceCandles request + GetApiV5MarketMarkPriceCandlesWithResponse(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketMarkPriceCandlesResponse, error) + + // GetApiV5MarketOpenOracle request + GetApiV5MarketOpenOracleWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketOpenOracleResponse, error) + + // GetApiV5MarketPlatform24Volume request + GetApiV5MarketPlatform24VolumeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketPlatform24VolumeResponse, error) + + // GetApiV5MarketTicker request + GetApiV5MarketTickerWithResponse(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickerResponse, error) + + // GetApiV5MarketTickers request + GetApiV5MarketTickersWithResponse(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickersResponse, error) + + // GetApiV5MarketTrades request + GetApiV5MarketTradesWithResponse(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTradesResponse, error) +} + +type GetApiV5MarketBooksResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketBooksResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketBooksResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketCandlesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketCandlesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketCandlesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketHistoryCandlesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketHistoryCandlesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketHistoryCandlesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketIndexCandlesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketIndexCandlesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketIndexCandlesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketIndexComponentsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketIndexComponentsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketIndexComponentsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketIndexTickersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketIndexTickersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketIndexTickersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketMarkPriceCandlesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketMarkPriceCandlesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketMarkPriceCandlesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketOpenOracleResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketOpenOracleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketOpenOracleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketPlatform24VolumeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketPlatform24VolumeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketPlatform24VolumeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketTickerResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketTickerResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketTickerResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketTickersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketTickersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketTickersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5MarketTradesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5MarketTradesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5MarketTradesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// GetApiV5MarketBooksWithResponse request returning *GetApiV5MarketBooksResponse +func (c *ClientWithResponses) GetApiV5MarketBooksWithResponse(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketBooksResponse, error) { + rsp, err := c.GetApiV5MarketBooks(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketBooksResponse(rsp) +} + +// GetApiV5MarketCandlesWithResponse request returning *GetApiV5MarketCandlesResponse +func (c *ClientWithResponses) GetApiV5MarketCandlesWithResponse(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketCandlesResponse, error) { + rsp, err := c.GetApiV5MarketCandles(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketCandlesResponse(rsp) +} + +// GetApiV5MarketHistoryCandlesWithResponse request returning *GetApiV5MarketHistoryCandlesResponse +func (c *ClientWithResponses) GetApiV5MarketHistoryCandlesWithResponse(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketHistoryCandlesResponse, error) { + rsp, err := c.GetApiV5MarketHistoryCandles(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketHistoryCandlesResponse(rsp) +} + +// GetApiV5MarketIndexCandlesWithResponse request returning *GetApiV5MarketIndexCandlesResponse +func (c *ClientWithResponses) GetApiV5MarketIndexCandlesWithResponse(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexCandlesResponse, error) { + rsp, err := c.GetApiV5MarketIndexCandles(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketIndexCandlesResponse(rsp) +} + +// GetApiV5MarketIndexComponentsWithResponse request returning *GetApiV5MarketIndexComponentsResponse +func (c *ClientWithResponses) GetApiV5MarketIndexComponentsWithResponse(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexComponentsResponse, error) { + rsp, err := c.GetApiV5MarketIndexComponents(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketIndexComponentsResponse(rsp) +} + +// GetApiV5MarketIndexTickersWithResponse request returning *GetApiV5MarketIndexTickersResponse +func (c *ClientWithResponses) GetApiV5MarketIndexTickersWithResponse(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexTickersResponse, error) { + rsp, err := c.GetApiV5MarketIndexTickers(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketIndexTickersResponse(rsp) +} + +// GetApiV5MarketMarkPriceCandlesWithResponse request returning *GetApiV5MarketMarkPriceCandlesResponse +func (c *ClientWithResponses) GetApiV5MarketMarkPriceCandlesWithResponse(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketMarkPriceCandlesResponse, error) { + rsp, err := c.GetApiV5MarketMarkPriceCandles(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketMarkPriceCandlesResponse(rsp) +} + +// GetApiV5MarketOpenOracleWithResponse request returning *GetApiV5MarketOpenOracleResponse +func (c *ClientWithResponses) GetApiV5MarketOpenOracleWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketOpenOracleResponse, error) { + rsp, err := c.GetApiV5MarketOpenOracle(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketOpenOracleResponse(rsp) +} + +// GetApiV5MarketPlatform24VolumeWithResponse request returning *GetApiV5MarketPlatform24VolumeResponse +func (c *ClientWithResponses) GetApiV5MarketPlatform24VolumeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketPlatform24VolumeResponse, error) { + rsp, err := c.GetApiV5MarketPlatform24Volume(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketPlatform24VolumeResponse(rsp) +} + +// GetApiV5MarketTickerWithResponse request returning *GetApiV5MarketTickerResponse +func (c *ClientWithResponses) GetApiV5MarketTickerWithResponse(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickerResponse, error) { + rsp, err := c.GetApiV5MarketTicker(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketTickerResponse(rsp) +} + +// GetApiV5MarketTickersWithResponse request returning *GetApiV5MarketTickersResponse +func (c *ClientWithResponses) GetApiV5MarketTickersWithResponse(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickersResponse, error) { + rsp, err := c.GetApiV5MarketTickers(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketTickersResponse(rsp) +} + +// GetApiV5MarketTradesWithResponse request returning *GetApiV5MarketTradesResponse +func (c *ClientWithResponses) GetApiV5MarketTradesWithResponse(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTradesResponse, error) { + rsp, err := c.GetApiV5MarketTrades(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5MarketTradesResponse(rsp) +} + +// ParseGetApiV5MarketBooksResponse parses an HTTP response from a GetApiV5MarketBooksWithResponse call +func ParseGetApiV5MarketBooksResponse(rsp *http.Response) (*GetApiV5MarketBooksResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketBooksResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketCandlesResponse parses an HTTP response from a GetApiV5MarketCandlesWithResponse call +func ParseGetApiV5MarketCandlesResponse(rsp *http.Response) (*GetApiV5MarketCandlesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketCandlesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketHistoryCandlesResponse parses an HTTP response from a GetApiV5MarketHistoryCandlesWithResponse call +func ParseGetApiV5MarketHistoryCandlesResponse(rsp *http.Response) (*GetApiV5MarketHistoryCandlesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketHistoryCandlesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketIndexCandlesResponse parses an HTTP response from a GetApiV5MarketIndexCandlesWithResponse call +func ParseGetApiV5MarketIndexCandlesResponse(rsp *http.Response) (*GetApiV5MarketIndexCandlesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketIndexCandlesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketIndexComponentsResponse parses an HTTP response from a GetApiV5MarketIndexComponentsWithResponse call +func ParseGetApiV5MarketIndexComponentsResponse(rsp *http.Response) (*GetApiV5MarketIndexComponentsResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketIndexComponentsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketIndexTickersResponse parses an HTTP response from a GetApiV5MarketIndexTickersWithResponse call +func ParseGetApiV5MarketIndexTickersResponse(rsp *http.Response) (*GetApiV5MarketIndexTickersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketIndexTickersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketMarkPriceCandlesResponse parses an HTTP response from a GetApiV5MarketMarkPriceCandlesWithResponse call +func ParseGetApiV5MarketMarkPriceCandlesResponse(rsp *http.Response) (*GetApiV5MarketMarkPriceCandlesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketMarkPriceCandlesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketOpenOracleResponse parses an HTTP response from a GetApiV5MarketOpenOracleWithResponse call +func ParseGetApiV5MarketOpenOracleResponse(rsp *http.Response) (*GetApiV5MarketOpenOracleResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketOpenOracleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketPlatform24VolumeResponse parses an HTTP response from a GetApiV5MarketPlatform24VolumeWithResponse call +func ParseGetApiV5MarketPlatform24VolumeResponse(rsp *http.Response) (*GetApiV5MarketPlatform24VolumeResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketPlatform24VolumeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketTickerResponse parses an HTTP response from a GetApiV5MarketTickerWithResponse call +func ParseGetApiV5MarketTickerResponse(rsp *http.Response) (*GetApiV5MarketTickerResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketTickerResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketTickersResponse parses an HTTP response from a GetApiV5MarketTickersWithResponse call +func ParseGetApiV5MarketTickersResponse(rsp *http.Response) (*GetApiV5MarketTickersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketTickersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5MarketTradesResponse parses an HTTP response from a GetApiV5MarketTradesWithResponse call +func ParseGetApiV5MarketTradesResponse(rsp *http.Response) (*GetApiV5MarketTradesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5MarketTradesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "H4sIAAAAAAAC/+xa+1Pbxvb/V5j9/tYx1uot+bfm8b0wvbkwhbRzhzJjWVqDGttyLJlCGWaAhFcDOM37", + "EvKgoUkm9wbIo42xnfLHVJLxT/wLd3ZXGNuFxuaR3szAD3gknXP2nN3z+ezZI40C3UqmrRRKOTaIjI6F", + "gJmKWyAyCgxk6xkz7ZhWCkTA/7W577fKt55vr7/17y22fZNq+yYLIa/HyA/yF3/2ck+83Au3tLS9/s5/", + "Nek/X/GvPSovrns/XaGiTCAbKGb2u/qsW8toSeSgjP1ZW+XBT/6DLTf/sjy56c0Uo72ZkTbTabOyTtSf", + "n6vcWNspzZdLd7Z/+5EO6eUm/dsb+CaVPz+M9KyDAmEv92NlfIJK/j4++dmXyE5bKRvVDuQ/+rm8fI3K", + "lIs3/YfLv49P1nsIQsAxnQQCEfDl+Z7ets+7O0EIDKGMTSdqSARjIWClUUpLmyAC+DAMsyAE0poziGcY", + "MFraZIZEJqllLiGHiVnWJXJ/ADn4x0qjjIYnvdMAEfA35HyeNr8SLxDhM0QW29qdJBDpa1wpt/DMuznR", + "eW6nNO89ndwpLUXP9J5tv9hzrjcKQgANa8k08X73LsBLDiLgchZlRkAIpLQkfmymbKfTACGQQZezZgYZ", + "IOJksigEbH0QJTXsqjOSxpK2kzFTA2BsLNToiv/ulVd46q88cd8v+Lc3KjO5+rn0l8e91WfeeMnLrbul", + "xwKE2OmFN+7mhrdwh2p7U68UCP0HK/Wqbn7BW/m3N/0v/+Vqdd0rxXvba6vbW7e8+w9Zf+VJMP7tDX9h", + "7YAw7e/Bn4XUj+MP8gQ/5yDEP7qVclCKrJeWTidMnawY862Nwx6tsVedbqxjYNMQhIChORpZOc3Ga9/X", + "BwQWQimsgBCAYQlCXlE5nDRYmAX9/SEQM41aSZ5I8pCVFY5VAkmOSGIcA1biVFWSBF7iVQngMJL2AIgA", + "nJtBjFbsW6Q7YGxsLNS4bLPXvR8e4QUFdjaZ1DIjIAK2F995uTs0uei8YiRoA9grQNOz7RyOqx/rNSS5", + "rqWMBGo2zc8G0p9Qot/9tXL3bfn1Da/wtJqH3ngpyiaj9XnrPZ1s62OTDJ9kxCTDikmGh0mG7WC4Dkbo", + "YKQOhuU6GPYcw37NsBcY/gIjXWDYf/Yf4HxMy4CWPA3I+eUqddmffeNuXvPmFnZKs/79t/7dZ+WlqxQw", + "O6W58tJVb3a6svKLNz3lrW3ulObd0mN8c7zk5gve+qZXuEWZv7x0NerY0QO81OIOOhY/ry8Gft7ZOAk/", + "YyhuZVBrjtKBKeeUl67SXaNyf5ry3U5pnpKcmy+whN4ocdUxFaG3A1xKmEnT+esoqg+woipDTuIVHioi", + "CAE+LBNq4sOywJNfSZbpNcREpAgcJ7CEjjhJVXhBCUNB4RRBZUF/aF97fGBPVcmvoArBONiIoLKcAPFI", + "kizxHC/IYU7gVVXmKN0dD6/5c+P+8pxbWPXv3aS88kW5sFXdOZrluUHTdqzMSHtrfNdBtU5p75T2Tmnv", + "lPY+Iu3VEp63OO3lXu/R3k5p1i1Oufmi/8uEl5/YKc21QIRmykDDLdJgJ9ZpkgTLixvbb5/58zO08K8n", + "wlMePOXBUx485cEWyj9CJIcq+QKmq22iNU92e1of4LsDmK7Vks9Awy0x3UkmV33nsW8U6Kmh7mEQASIn", + "83yYI5HpgyACur44j922R5INz+2RZMxK0MCZIPDvBhw8TJgTIcBwrbWqhhUZkr8942fMlJbSUYP9OskW", + "h+FU0vAL7HdkrZhZbz0QaN17QVY5lVflPevdVsJKmWj4D+7XiH5wnP5QkBp1GZTQbCcwJ4YFlsPgUzmM", + "2aDDxENVEXleFFUV4+84kYgFZqcPiUXH1C8RFDUPxN5A5XAobNjjo7SkiHo35qOXs5aDzuojUW9rqrJS", + "pC1LNz/u5l/sh9wP1Sit1CTE1+21Fbf4zlu47b5fqPeyfH/Nm1vwci/85bkoDoKJEkJhcFRRN1+oVcW7", + "LbF3gIO7Yf6VvdRBc2CQEwZJWuMsNY1hggfafg+msD7Dre92FbCIlUap2mvbMi46Omy4VqrXFAZ1+9nY", + "Me9I2yvz/pWpFhCAf9rTGVNHLRbf+H831juOAry95+vPu/fdmsiT00r8tBI/rcRPthJvudY+xmL68cz2", + "2oZbfOc/Lh2qpMZE3G5lNJ1ORhPs1ZVGqS6qcKIVaxLZtjaASBRwGB7pTzm0pgQNVdH1ow0PD62vsBqU", + "kKEccXwoyVDmJFXiJVHm4cf/4wVOFIQjjAz6Q4DstSTTzvSeBRHAC7IqhQWMIdscSGlONrObLprCcoIB", + "DUPWJN0QJE2L67LIcTJncEiSY1CNQy0Wg3FZVHVRlFlOj0OdhRCJyJA0gxMVkTdUOW5IKqsLssirSNOh", + "YshIjkEd8XHJYJESl+IaKyoiNBSoqjKrGLysxXlZOtpssToO1zGTyHa0ZJq+YxbwKUmBx1H+U/i6+R8q", + "N3+jbcmWeSOd0Jy4lUm2c0L7kJXIJpulj+5AkRO+omonW6kOWYmzKRwzK3AcJG/9h6zERRs7xnEcd4xl", + "pLf5xsttcIK3kfPv/uqPF/3Z625htTKTa2Fe6YGqybmkR6lDv8T6aKXjyX/ZQU/jkirS475mX+r5Hi86", + "FBUOkC869iToNXkuiCJ+vHecEWVJYPc9xOxNie300viCO7uHd0kVJaKKbxDzfO3BRxREufHwI4oqJ9Ud", + "f+rvKDV3dr81gZyisqwsSwLNZWpJkDhRkUnzDqe8PkJvKyzLy2FZPM7jEj6m5l/QrKKHJndrxZ9YbznL", + "7ZbSvMmXteVXRe/htYYuQU93V290p7Tk5Se8/ETjQ4yCndKSv5EvF19612fLhacNIv9/sffil+d7sJRb", + "WPXmXu8r1dXd29n1D2Jq+ZH/4EodsrALf4IoklJHOo5Rl/zHM9UGQsNXXMWpyvhk+dZzt7AYpVEwNGSG", + "uhsN4XNa7Yud/ZzNJkbA/wDWVVVVw6SyrmKdrQG6oihKWFFqoC7W4ZwN2o1VlP+9SZTvjVtFOQV1Fed7", + "Q+/hXA2am613OWogTrarengf8w62+2XGUZCd0YymGyG9VPjT+Qij+XOv+Amee0f37dylaWMPsmRbMolS", + "LEtIgOAKGyCrThTVA5p1oZM0fjLv6Kf+4029ojXch8rjseqTP7R0CIyq+sFC16qP9Y/9NwAA//8BOFYd", + "GS4AAA==", +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %s", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + var res = make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + var resolvePath = PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + var pathToFile = url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} + diff --git a/okex/api/market/market_test.go b/okex/api/market/market_test.go new file mode 100644 index 0000000..fdd7c91 --- /dev/null +++ b/okex/api/market/market_test.go @@ -0,0 +1,25 @@ +package market + +import ( + "context" + "strconv" + "testing" + "time" +) + +func TestCandles(t *testing.T) { + ApiAddr := "https://www.okex.com/" + api, err := NewClientWithResponses(ApiAddr) + tEnd := time.Now().Add(-time.Hour * 24 * 365) + tStart := tEnd.Add(-time.Hour) + startStr := strconv.FormatInt((tStart.Unix() * 1000), 10) + endStr := strconv.FormatInt((tEnd.Unix() * 1000), 10) + bSize := "1m" + var params = GetApiV5MarketHistoryCandlesParams{InstId: "ETH-USDT-SWAP", Bar: &bSize, After: &endStr, Before: &startStr} + resp, err := api.GetApiV5MarketHistoryCandlesWithResponse(context.Background(), ¶ms) + if err != nil { + t.Fatal(err.Error()) + + } + t.Log(string(resp.Body), resp.JSON200) +} diff --git a/okex/api/public/public.gen.go b/okex/api/public/public.gen.go new file mode 100644 index 0000000..ee8c630 --- /dev/null +++ b/okex/api/public/public.gen.go @@ -0,0 +1,2857 @@ +// Package public provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.9.0 DO NOT EDIT. +package public + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "path" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + "github.com/getkin/kin-openapi/openapi3" +) + +// GetApiV5PublicDeliveryExerciseHistoryParams defines parameters for GetApiV5PublicDeliveryExerciseHistory. +type GetApiV5PublicDeliveryExerciseHistoryParams struct { + // 产品类型
`FUTURES`:交割合约,`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如:`BTC-USD`
仅适用于`交割/期权` + Uly string `json:"uly"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5PublicDiscountRateInterestFreeQuotaParams defines parameters for GetApiV5PublicDiscountRateInterestFreeQuota. +type GetApiV5PublicDiscountRateInterestFreeQuotaParams struct { + // 币种,如:`BTC` + Ccy *string `json:"ccy,omitempty"` + + // 折算率等级
`1`:第一档,`2`:第二档,`3`:第三档,`4`:第四档,`5`:第五档 + DiscountLv *string `json:"discountLv,omitempty"` +} + +// GetApiV5PublicEstimatedPriceParams defines parameters for GetApiV5PublicEstimatedPrice. +type GetApiV5PublicEstimatedPriceParams struct { + // 产品ID,如:`BTC-USD-200214`
适用于`交割/期权` + InstId string `json:"instId"` +} + +// GetApiV5PublicFundingRateParams defines parameters for GetApiV5PublicFundingRate. +type GetApiV5PublicFundingRateParams struct { + // 产品ID,如:`BTC-USDT-SWAP`
仅适用于`永续` + InstId *string `json:"instId,omitempty"` +} + +// GetApiV5PublicFundingRateHistoryParams defines parameters for GetApiV5PublicFundingRateHistory. +type GetApiV5PublicFundingRateHistoryParams struct { + // 产品ID,如:`BTC-USDT-SWAP`
仅适用于`永续` + InstId *string `json:"instId,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`fundingTime` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`fundingTime` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5PublicInstrumentsParams defines parameters for GetApiV5PublicInstruments. +type GetApiV5PublicInstrumentsParams struct { + // 产品类型
`SPOT`:币币;`MARGIN`:币币杠杆;`SWAP`:永续合约 `FUTURES`:交割合约;`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如:`BTC-USD`
仅适用于`交割/永续/期权`,`期权`必填 + Uly *string `json:"uly,omitempty"` + + // 产品ID,如 `BTC-USDT` + InstId *string `json:"instId,omitempty"` +} + +// GetApiV5PublicInsuranceFundParams defines parameters for GetApiV5PublicInsuranceFund. +type GetApiV5PublicInsuranceFundParams struct { + // 产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权 + InstType string `json:"instType"` + + // 产品类型
`liquidation_balance_deposit`:强平注入,`bankruptcy_loss`:穿仓亏损,`platform_revenue`:平台收入注入 + Type *string `json:"type,omitempty"` + + // 标的指数
仅适用于`交割/永续/期权`,且必填写 + Uly *string `json:"uly,omitempty"` + + // 币种,仅适用`币币杠杆`,且必填写 + Ccy *string `json:"ccy,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5PublicLiquidationOrdersParams defines parameters for GetApiV5PublicLiquidationOrders. +type GetApiV5PublicLiquidationOrdersParams struct { + // 产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权 + InstType string `json:"instType"` + + // 保证金模式
`cross`:全仓,`isolated`:逐仓 + MgnMode *string `json:"mgnMode,omitempty"` + + // 产品ID,仅适用于`币币杠杆` + InstId *string `json:"instId,omitempty"` + + // 币种,仅适用于全仓`币币杠杆` + Ccy *string `json:"ccy,omitempty"` + + // 合约标的指数
`交割/永续/期权`合约情况下,该参数必填 + Uly *string `json:"uly,omitempty"` + + // `this_week`:本周,`next_week`:次周,`quarter`:季度,`next_quarter`:次季度
`交割`合约情况下,该参数必填 + Alias *string `json:"alias,omitempty"` + + // 状态
`unfilled`:未成交,`filled`:已成交
默认为`unfilled`
`交割/永续`合约情况下,该参数必填 + State *string `json:"state,omitempty"` + + // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` + After *string `json:"after,omitempty"` + + // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` + Before *string `json:"before,omitempty"` + + // 分页返回的结果集数量,最大为100,不填默认返回100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5PublicMarkPriceParams defines parameters for GetApiV5PublicMarkPrice. +type GetApiV5PublicMarkPriceParams struct { + // 产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权 + InstType string `json:"instType"` + + // 产品ID,如:`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 合约标的指数,如:`BTC-USD` + Uly *string `json:"uly,omitempty"` +} + +// GetApiV5PublicOpenInterestParams defines parameters for GetApiV5PublicOpenInterest. +type GetApiV5PublicOpenInterestParams struct { + // 产品类型
`FUTURES`:交割合约,`SWAP`:永续合约,`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如:`BTC-USD`
仅适用于`交割/永续/期权` + Uly *string `json:"uly,omitempty"` + + // 产品ID,如:`BTC-USD-SWAP`
仅适用于`交割/永续/期权` + InstId *string `json:"instId,omitempty"` +} + +// GetApiV5PublicOptSummaryParams defines parameters for GetApiV5PublicOptSummary. +type GetApiV5PublicOptSummaryParams struct { + // 合约标的指数,如:`BTC-USD-200103-5500-C`
仅适用于`期权` + Uly string `json:"uly"` + + // 合约到期日,格式为`YYMMDD`,如 `200527` + ExpTime string `json:"expTime"` +} + +// GetApiV5PublicPositionTiersParams defines parameters for GetApiV5PublicPositionTiers. +type GetApiV5PublicPositionTiersParams struct { + // 产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权 + InstType string `json:"instType"` + + // 交易模式
`isolated`:逐仓,`cross`:全仓 + TdMode string `json:"tdMode"` + + // 产品ID,如:`BTC-USDT`
仅适用`币币杠杆`,且必填 + InstId *string `json:"instId,omitempty"` + + // 合约标的指数,如:`BTC-USD`
仅适用于`交割/永续/期权`,且必填 + Uly *string `json:"uly,omitempty"` + + // 指定档位 + Tier *string `json:"tier,omitempty"` +} + +// GetApiV5PublicPriceLimitParams defines parameters for GetApiV5PublicPriceLimit. +type GetApiV5PublicPriceLimitParams struct { + // 产品ID,如:`BTC-USDT-SWAP`
适用于`交割/永续/期权` + InstId string `json:"instId"` +} + +// GetApiV5PublicUnderlyingParams defines parameters for GetApiV5PublicUnderlying. +type GetApiV5PublicUnderlyingParams struct { + // 产品类型
`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权 + InstType string `json:"instType"` +} + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // GetApiV5PublicDeliveryExerciseHistory request + GetApiV5PublicDeliveryExerciseHistory(ctx context.Context, params *GetApiV5PublicDeliveryExerciseHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicDiscountRateInterestFreeQuota request + GetApiV5PublicDiscountRateInterestFreeQuota(ctx context.Context, params *GetApiV5PublicDiscountRateInterestFreeQuotaParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicEstimatedPrice request + GetApiV5PublicEstimatedPrice(ctx context.Context, params *GetApiV5PublicEstimatedPriceParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicFundingRate request + GetApiV5PublicFundingRate(ctx context.Context, params *GetApiV5PublicFundingRateParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicFundingRateHistory request + GetApiV5PublicFundingRateHistory(ctx context.Context, params *GetApiV5PublicFundingRateHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicInstruments request + GetApiV5PublicInstruments(ctx context.Context, params *GetApiV5PublicInstrumentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicInsuranceFund request + GetApiV5PublicInsuranceFund(ctx context.Context, params *GetApiV5PublicInsuranceFundParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicInterestRateLoanQuota request + GetApiV5PublicInterestRateLoanQuota(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicLiquidationOrders request + GetApiV5PublicLiquidationOrders(ctx context.Context, params *GetApiV5PublicLiquidationOrdersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicMarkPrice request + GetApiV5PublicMarkPrice(ctx context.Context, params *GetApiV5PublicMarkPriceParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicOpenInterest request + GetApiV5PublicOpenInterest(ctx context.Context, params *GetApiV5PublicOpenInterestParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicOptSummary request + GetApiV5PublicOptSummary(ctx context.Context, params *GetApiV5PublicOptSummaryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicPositionTiers request + GetApiV5PublicPositionTiers(ctx context.Context, params *GetApiV5PublicPositionTiersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicPriceLimit request + GetApiV5PublicPriceLimit(ctx context.Context, params *GetApiV5PublicPriceLimitParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicTime request + GetApiV5PublicTime(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5PublicUnderlying request + GetApiV5PublicUnderlying(ctx context.Context, params *GetApiV5PublicUnderlyingParams, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) GetApiV5PublicDeliveryExerciseHistory(ctx context.Context, params *GetApiV5PublicDeliveryExerciseHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicDeliveryExerciseHistoryRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicDiscountRateInterestFreeQuota(ctx context.Context, params *GetApiV5PublicDiscountRateInterestFreeQuotaParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicDiscountRateInterestFreeQuotaRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicEstimatedPrice(ctx context.Context, params *GetApiV5PublicEstimatedPriceParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicEstimatedPriceRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicFundingRate(ctx context.Context, params *GetApiV5PublicFundingRateParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicFundingRateRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicFundingRateHistory(ctx context.Context, params *GetApiV5PublicFundingRateHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicFundingRateHistoryRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicInstruments(ctx context.Context, params *GetApiV5PublicInstrumentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicInstrumentsRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicInsuranceFund(ctx context.Context, params *GetApiV5PublicInsuranceFundParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicInsuranceFundRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicInterestRateLoanQuota(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicInterestRateLoanQuotaRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicLiquidationOrders(ctx context.Context, params *GetApiV5PublicLiquidationOrdersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicLiquidationOrdersRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicMarkPrice(ctx context.Context, params *GetApiV5PublicMarkPriceParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicMarkPriceRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicOpenInterest(ctx context.Context, params *GetApiV5PublicOpenInterestParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicOpenInterestRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicOptSummary(ctx context.Context, params *GetApiV5PublicOptSummaryParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicOptSummaryRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicPositionTiers(ctx context.Context, params *GetApiV5PublicPositionTiersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicPositionTiersRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicPriceLimit(ctx context.Context, params *GetApiV5PublicPriceLimitParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicPriceLimitRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicTime(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicTimeRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5PublicUnderlying(ctx context.Context, params *GetApiV5PublicUnderlyingParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5PublicUnderlyingRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewGetApiV5PublicDeliveryExerciseHistoryRequest generates requests for GetApiV5PublicDeliveryExerciseHistory +func NewGetApiV5PublicDeliveryExerciseHistoryRequest(server string, params *GetApiV5PublicDeliveryExerciseHistoryParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/delivery-exercise-history") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicDiscountRateInterestFreeQuotaRequest generates requests for GetApiV5PublicDiscountRateInterestFreeQuota +func NewGetApiV5PublicDiscountRateInterestFreeQuotaRequest(server string, params *GetApiV5PublicDiscountRateInterestFreeQuotaParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/discount-rate-interest-free-quota") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.DiscountLv != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "discountLv", runtime.ParamLocationQuery, *params.DiscountLv); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicEstimatedPriceRequest generates requests for GetApiV5PublicEstimatedPrice +func NewGetApiV5PublicEstimatedPriceRequest(server string, params *GetApiV5PublicEstimatedPriceParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/estimated-price") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicFundingRateRequest generates requests for GetApiV5PublicFundingRate +func NewGetApiV5PublicFundingRateRequest(server string, params *GetApiV5PublicFundingRateParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/funding-rate") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicFundingRateHistoryRequest generates requests for GetApiV5PublicFundingRateHistory +func NewGetApiV5PublicFundingRateHistoryRequest(server string, params *GetApiV5PublicFundingRateHistoryParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/funding-rate-history") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicInstrumentsRequest generates requests for GetApiV5PublicInstruments +func NewGetApiV5PublicInstrumentsRequest(server string, params *GetApiV5PublicInstrumentsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/instruments") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicInsuranceFundRequest generates requests for GetApiV5PublicInsuranceFund +func NewGetApiV5PublicInsuranceFundRequest(server string, params *GetApiV5PublicInsuranceFundParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/insurance-fund") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Type != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "type", runtime.ParamLocationQuery, *params.Type); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicInterestRateLoanQuotaRequest generates requests for GetApiV5PublicInterestRateLoanQuota +func NewGetApiV5PublicInterestRateLoanQuotaRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/interest-rate-loan-quota") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicLiquidationOrdersRequest generates requests for GetApiV5PublicLiquidationOrders +func NewGetApiV5PublicLiquidationOrdersRequest(server string, params *GetApiV5PublicLiquidationOrdersParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/liquidation-orders") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.MgnMode != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "mgnMode", runtime.ParamLocationQuery, *params.MgnMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Ccy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ccy", runtime.ParamLocationQuery, *params.Ccy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Alias != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "alias", runtime.ParamLocationQuery, *params.Alias); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "state", runtime.ParamLocationQuery, *params.State); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicMarkPriceRequest generates requests for GetApiV5PublicMarkPrice +func NewGetApiV5PublicMarkPriceRequest(server string, params *GetApiV5PublicMarkPriceParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/mark-price") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicOpenInterestRequest generates requests for GetApiV5PublicOpenInterest +func NewGetApiV5PublicOpenInterestRequest(server string, params *GetApiV5PublicOpenInterestParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/open-interest") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicOptSummaryRequest generates requests for GetApiV5PublicOptSummary +func NewGetApiV5PublicOptSummaryRequest(server string, params *GetApiV5PublicOptSummaryParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/opt-summary") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "expTime", runtime.ParamLocationQuery, params.ExpTime); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicPositionTiersRequest generates requests for GetApiV5PublicPositionTiers +func NewGetApiV5PublicPositionTiersRequest(server string, params *GetApiV5PublicPositionTiersParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/position-tiers") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tdMode", runtime.ParamLocationQuery, params.TdMode); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Tier != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tier", runtime.ParamLocationQuery, *params.Tier); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicPriceLimitRequest generates requests for GetApiV5PublicPriceLimit +func NewGetApiV5PublicPriceLimitRequest(server string, params *GetApiV5PublicPriceLimitParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/price-limit") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicTimeRequest generates requests for GetApiV5PublicTime +func NewGetApiV5PublicTimeRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/time") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5PublicUnderlyingRequest generates requests for GetApiV5PublicUnderlying +func NewGetApiV5PublicUnderlyingRequest(server string, params *GetApiV5PublicUnderlyingParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/public/underlying") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetApiV5PublicDeliveryExerciseHistory request + GetApiV5PublicDeliveryExerciseHistoryWithResponse(ctx context.Context, params *GetApiV5PublicDeliveryExerciseHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicDeliveryExerciseHistoryResponse, error) + + // GetApiV5PublicDiscountRateInterestFreeQuota request + GetApiV5PublicDiscountRateInterestFreeQuotaWithResponse(ctx context.Context, params *GetApiV5PublicDiscountRateInterestFreeQuotaParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicDiscountRateInterestFreeQuotaResponse, error) + + // GetApiV5PublicEstimatedPrice request + GetApiV5PublicEstimatedPriceWithResponse(ctx context.Context, params *GetApiV5PublicEstimatedPriceParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicEstimatedPriceResponse, error) + + // GetApiV5PublicFundingRate request + GetApiV5PublicFundingRateWithResponse(ctx context.Context, params *GetApiV5PublicFundingRateParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicFundingRateResponse, error) + + // GetApiV5PublicFundingRateHistory request + GetApiV5PublicFundingRateHistoryWithResponse(ctx context.Context, params *GetApiV5PublicFundingRateHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicFundingRateHistoryResponse, error) + + // GetApiV5PublicInstruments request + GetApiV5PublicInstrumentsWithResponse(ctx context.Context, params *GetApiV5PublicInstrumentsParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicInstrumentsResponse, error) + + // GetApiV5PublicInsuranceFund request + GetApiV5PublicInsuranceFundWithResponse(ctx context.Context, params *GetApiV5PublicInsuranceFundParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicInsuranceFundResponse, error) + + // GetApiV5PublicInterestRateLoanQuota request + GetApiV5PublicInterestRateLoanQuotaWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5PublicInterestRateLoanQuotaResponse, error) + + // GetApiV5PublicLiquidationOrders request + GetApiV5PublicLiquidationOrdersWithResponse(ctx context.Context, params *GetApiV5PublicLiquidationOrdersParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicLiquidationOrdersResponse, error) + + // GetApiV5PublicMarkPrice request + GetApiV5PublicMarkPriceWithResponse(ctx context.Context, params *GetApiV5PublicMarkPriceParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicMarkPriceResponse, error) + + // GetApiV5PublicOpenInterest request + GetApiV5PublicOpenInterestWithResponse(ctx context.Context, params *GetApiV5PublicOpenInterestParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicOpenInterestResponse, error) + + // GetApiV5PublicOptSummary request + GetApiV5PublicOptSummaryWithResponse(ctx context.Context, params *GetApiV5PublicOptSummaryParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicOptSummaryResponse, error) + + // GetApiV5PublicPositionTiers request + GetApiV5PublicPositionTiersWithResponse(ctx context.Context, params *GetApiV5PublicPositionTiersParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicPositionTiersResponse, error) + + // GetApiV5PublicPriceLimit request + GetApiV5PublicPriceLimitWithResponse(ctx context.Context, params *GetApiV5PublicPriceLimitParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicPriceLimitResponse, error) + + // GetApiV5PublicTime request + GetApiV5PublicTimeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5PublicTimeResponse, error) + + // GetApiV5PublicUnderlying request + GetApiV5PublicUnderlyingWithResponse(ctx context.Context, params *GetApiV5PublicUnderlyingParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicUnderlyingResponse, error) +} + +type GetApiV5PublicDeliveryExerciseHistoryResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicDeliveryExerciseHistoryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicDeliveryExerciseHistoryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicDiscountRateInterestFreeQuotaResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicDiscountRateInterestFreeQuotaResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicDiscountRateInterestFreeQuotaResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicEstimatedPriceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicEstimatedPriceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicEstimatedPriceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicFundingRateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicFundingRateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicFundingRateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicFundingRateHistoryResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicFundingRateHistoryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicFundingRateHistoryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicInstrumentsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicInstrumentsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicInstrumentsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicInsuranceFundResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicInsuranceFundResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicInsuranceFundResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicInterestRateLoanQuotaResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicInterestRateLoanQuotaResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicInterestRateLoanQuotaResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicLiquidationOrdersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicLiquidationOrdersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicLiquidationOrdersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicMarkPriceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicMarkPriceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicMarkPriceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicOpenInterestResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicOpenInterestResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicOpenInterestResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicOptSummaryResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicOptSummaryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicOptSummaryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicPositionTiersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicPositionTiersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicPositionTiersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicPriceLimitResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicPriceLimitResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicPriceLimitResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicTimeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicTimeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicTimeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5PublicUnderlyingResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5PublicUnderlyingResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5PublicUnderlyingResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// GetApiV5PublicDeliveryExerciseHistoryWithResponse request returning *GetApiV5PublicDeliveryExerciseHistoryResponse +func (c *ClientWithResponses) GetApiV5PublicDeliveryExerciseHistoryWithResponse(ctx context.Context, params *GetApiV5PublicDeliveryExerciseHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicDeliveryExerciseHistoryResponse, error) { + rsp, err := c.GetApiV5PublicDeliveryExerciseHistory(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicDeliveryExerciseHistoryResponse(rsp) +} + +// GetApiV5PublicDiscountRateInterestFreeQuotaWithResponse request returning *GetApiV5PublicDiscountRateInterestFreeQuotaResponse +func (c *ClientWithResponses) GetApiV5PublicDiscountRateInterestFreeQuotaWithResponse(ctx context.Context, params *GetApiV5PublicDiscountRateInterestFreeQuotaParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicDiscountRateInterestFreeQuotaResponse, error) { + rsp, err := c.GetApiV5PublicDiscountRateInterestFreeQuota(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicDiscountRateInterestFreeQuotaResponse(rsp) +} + +// GetApiV5PublicEstimatedPriceWithResponse request returning *GetApiV5PublicEstimatedPriceResponse +func (c *ClientWithResponses) GetApiV5PublicEstimatedPriceWithResponse(ctx context.Context, params *GetApiV5PublicEstimatedPriceParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicEstimatedPriceResponse, error) { + rsp, err := c.GetApiV5PublicEstimatedPrice(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicEstimatedPriceResponse(rsp) +} + +// GetApiV5PublicFundingRateWithResponse request returning *GetApiV5PublicFundingRateResponse +func (c *ClientWithResponses) GetApiV5PublicFundingRateWithResponse(ctx context.Context, params *GetApiV5PublicFundingRateParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicFundingRateResponse, error) { + rsp, err := c.GetApiV5PublicFundingRate(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicFundingRateResponse(rsp) +} + +// GetApiV5PublicFundingRateHistoryWithResponse request returning *GetApiV5PublicFundingRateHistoryResponse +func (c *ClientWithResponses) GetApiV5PublicFundingRateHistoryWithResponse(ctx context.Context, params *GetApiV5PublicFundingRateHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicFundingRateHistoryResponse, error) { + rsp, err := c.GetApiV5PublicFundingRateHistory(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicFundingRateHistoryResponse(rsp) +} + +// GetApiV5PublicInstrumentsWithResponse request returning *GetApiV5PublicInstrumentsResponse +func (c *ClientWithResponses) GetApiV5PublicInstrumentsWithResponse(ctx context.Context, params *GetApiV5PublicInstrumentsParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicInstrumentsResponse, error) { + rsp, err := c.GetApiV5PublicInstruments(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicInstrumentsResponse(rsp) +} + +// GetApiV5PublicInsuranceFundWithResponse request returning *GetApiV5PublicInsuranceFundResponse +func (c *ClientWithResponses) GetApiV5PublicInsuranceFundWithResponse(ctx context.Context, params *GetApiV5PublicInsuranceFundParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicInsuranceFundResponse, error) { + rsp, err := c.GetApiV5PublicInsuranceFund(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicInsuranceFundResponse(rsp) +} + +// GetApiV5PublicInterestRateLoanQuotaWithResponse request returning *GetApiV5PublicInterestRateLoanQuotaResponse +func (c *ClientWithResponses) GetApiV5PublicInterestRateLoanQuotaWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5PublicInterestRateLoanQuotaResponse, error) { + rsp, err := c.GetApiV5PublicInterestRateLoanQuota(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicInterestRateLoanQuotaResponse(rsp) +} + +// GetApiV5PublicLiquidationOrdersWithResponse request returning *GetApiV5PublicLiquidationOrdersResponse +func (c *ClientWithResponses) GetApiV5PublicLiquidationOrdersWithResponse(ctx context.Context, params *GetApiV5PublicLiquidationOrdersParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicLiquidationOrdersResponse, error) { + rsp, err := c.GetApiV5PublicLiquidationOrders(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicLiquidationOrdersResponse(rsp) +} + +// GetApiV5PublicMarkPriceWithResponse request returning *GetApiV5PublicMarkPriceResponse +func (c *ClientWithResponses) GetApiV5PublicMarkPriceWithResponse(ctx context.Context, params *GetApiV5PublicMarkPriceParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicMarkPriceResponse, error) { + rsp, err := c.GetApiV5PublicMarkPrice(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicMarkPriceResponse(rsp) +} + +// GetApiV5PublicOpenInterestWithResponse request returning *GetApiV5PublicOpenInterestResponse +func (c *ClientWithResponses) GetApiV5PublicOpenInterestWithResponse(ctx context.Context, params *GetApiV5PublicOpenInterestParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicOpenInterestResponse, error) { + rsp, err := c.GetApiV5PublicOpenInterest(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicOpenInterestResponse(rsp) +} + +// GetApiV5PublicOptSummaryWithResponse request returning *GetApiV5PublicOptSummaryResponse +func (c *ClientWithResponses) GetApiV5PublicOptSummaryWithResponse(ctx context.Context, params *GetApiV5PublicOptSummaryParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicOptSummaryResponse, error) { + rsp, err := c.GetApiV5PublicOptSummary(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicOptSummaryResponse(rsp) +} + +// GetApiV5PublicPositionTiersWithResponse request returning *GetApiV5PublicPositionTiersResponse +func (c *ClientWithResponses) GetApiV5PublicPositionTiersWithResponse(ctx context.Context, params *GetApiV5PublicPositionTiersParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicPositionTiersResponse, error) { + rsp, err := c.GetApiV5PublicPositionTiers(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicPositionTiersResponse(rsp) +} + +// GetApiV5PublicPriceLimitWithResponse request returning *GetApiV5PublicPriceLimitResponse +func (c *ClientWithResponses) GetApiV5PublicPriceLimitWithResponse(ctx context.Context, params *GetApiV5PublicPriceLimitParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicPriceLimitResponse, error) { + rsp, err := c.GetApiV5PublicPriceLimit(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicPriceLimitResponse(rsp) +} + +// GetApiV5PublicTimeWithResponse request returning *GetApiV5PublicTimeResponse +func (c *ClientWithResponses) GetApiV5PublicTimeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5PublicTimeResponse, error) { + rsp, err := c.GetApiV5PublicTime(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicTimeResponse(rsp) +} + +// GetApiV5PublicUnderlyingWithResponse request returning *GetApiV5PublicUnderlyingResponse +func (c *ClientWithResponses) GetApiV5PublicUnderlyingWithResponse(ctx context.Context, params *GetApiV5PublicUnderlyingParams, reqEditors ...RequestEditorFn) (*GetApiV5PublicUnderlyingResponse, error) { + rsp, err := c.GetApiV5PublicUnderlying(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5PublicUnderlyingResponse(rsp) +} + +// ParseGetApiV5PublicDeliveryExerciseHistoryResponse parses an HTTP response from a GetApiV5PublicDeliveryExerciseHistoryWithResponse call +func ParseGetApiV5PublicDeliveryExerciseHistoryResponse(rsp *http.Response) (*GetApiV5PublicDeliveryExerciseHistoryResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicDeliveryExerciseHistoryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicDiscountRateInterestFreeQuotaResponse parses an HTTP response from a GetApiV5PublicDiscountRateInterestFreeQuotaWithResponse call +func ParseGetApiV5PublicDiscountRateInterestFreeQuotaResponse(rsp *http.Response) (*GetApiV5PublicDiscountRateInterestFreeQuotaResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicDiscountRateInterestFreeQuotaResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicEstimatedPriceResponse parses an HTTP response from a GetApiV5PublicEstimatedPriceWithResponse call +func ParseGetApiV5PublicEstimatedPriceResponse(rsp *http.Response) (*GetApiV5PublicEstimatedPriceResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicEstimatedPriceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicFundingRateResponse parses an HTTP response from a GetApiV5PublicFundingRateWithResponse call +func ParseGetApiV5PublicFundingRateResponse(rsp *http.Response) (*GetApiV5PublicFundingRateResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicFundingRateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicFundingRateHistoryResponse parses an HTTP response from a GetApiV5PublicFundingRateHistoryWithResponse call +func ParseGetApiV5PublicFundingRateHistoryResponse(rsp *http.Response) (*GetApiV5PublicFundingRateHistoryResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicFundingRateHistoryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicInstrumentsResponse parses an HTTP response from a GetApiV5PublicInstrumentsWithResponse call +func ParseGetApiV5PublicInstrumentsResponse(rsp *http.Response) (*GetApiV5PublicInstrumentsResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicInstrumentsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicInsuranceFundResponse parses an HTTP response from a GetApiV5PublicInsuranceFundWithResponse call +func ParseGetApiV5PublicInsuranceFundResponse(rsp *http.Response) (*GetApiV5PublicInsuranceFundResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicInsuranceFundResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicInterestRateLoanQuotaResponse parses an HTTP response from a GetApiV5PublicInterestRateLoanQuotaWithResponse call +func ParseGetApiV5PublicInterestRateLoanQuotaResponse(rsp *http.Response) (*GetApiV5PublicInterestRateLoanQuotaResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicInterestRateLoanQuotaResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicLiquidationOrdersResponse parses an HTTP response from a GetApiV5PublicLiquidationOrdersWithResponse call +func ParseGetApiV5PublicLiquidationOrdersResponse(rsp *http.Response) (*GetApiV5PublicLiquidationOrdersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicLiquidationOrdersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicMarkPriceResponse parses an HTTP response from a GetApiV5PublicMarkPriceWithResponse call +func ParseGetApiV5PublicMarkPriceResponse(rsp *http.Response) (*GetApiV5PublicMarkPriceResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicMarkPriceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicOpenInterestResponse parses an HTTP response from a GetApiV5PublicOpenInterestWithResponse call +func ParseGetApiV5PublicOpenInterestResponse(rsp *http.Response) (*GetApiV5PublicOpenInterestResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicOpenInterestResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicOptSummaryResponse parses an HTTP response from a GetApiV5PublicOptSummaryWithResponse call +func ParseGetApiV5PublicOptSummaryResponse(rsp *http.Response) (*GetApiV5PublicOptSummaryResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicOptSummaryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicPositionTiersResponse parses an HTTP response from a GetApiV5PublicPositionTiersWithResponse call +func ParseGetApiV5PublicPositionTiersResponse(rsp *http.Response) (*GetApiV5PublicPositionTiersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicPositionTiersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicPriceLimitResponse parses an HTTP response from a GetApiV5PublicPriceLimitWithResponse call +func ParseGetApiV5PublicPriceLimitResponse(rsp *http.Response) (*GetApiV5PublicPriceLimitResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicPriceLimitResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicTimeResponse parses an HTTP response from a GetApiV5PublicTimeWithResponse call +func ParseGetApiV5PublicTimeResponse(rsp *http.Response) (*GetApiV5PublicTimeResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicTimeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5PublicUnderlyingResponse parses an HTTP response from a GetApiV5PublicUnderlyingWithResponse call +func ParseGetApiV5PublicUnderlyingResponse(rsp *http.Response) (*GetApiV5PublicUnderlyingResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5PublicUnderlyingResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "H4sIAAAAAAAC/+xb61MTSbT/V6i+37ZI7Eze+eb62EsVrFxBb23tUmZIGpxlMhNnOlxYiypQIbAGUMFV", + "URbxsbq7CuzqrpjE6x+z0xPyiX/hVnfPhMkLEkx83NUvZrr7dJ8+fc6vz6O5CGJqIqkqSME6iFyc6ASS", + "MqSCyEUQR3pMk5JYUhUQAf/RYbx5W1h+urP50ry90PGd0vFdCkJvbJD9h8yFx2TxIVn8zciv7Gy+Mv+4", + "ZD5dN6+uFRY2yYPLZUOtD63W1xe9oiYmEEaa/kVHcfWBufrW2H5euPSapHPRfm28Q8IdagpHzcxc8cbG", + "bj5TyP+087/X+Ypk8ZJ5c4s28vEnxlAshZE1mCxeL05O8ZH/TF764jTSk6qiI+dC5trjwr2rfEwht2T+", + "fO+fyUvlHIJOgCUsIxABp0/09Xcc7e0CnWAUaTqXk8cNwUQnUJNIEZMSiACvG7o9oBMkRXyeShgcEZPS", + "kVH/kWRqUJZiR+JIlkaRNu5CY0iLSTpynZd0rGrjdOwwwvQ/NYk0kR5EVxxEwFcIH01KZ/29bILjFv0J", + "i/w/LWq6oi1LEPm28jyN7BOyNFX4I0d+vlq+w+jJM/1nTp/oi+7mV4zsIzL3J7k2W8j+spvPRE/19ned", + "+pr2mPfWzNXLoBOgMTGRZPKw6ABVIRABF1KIsaGICdorKTruH09SAWroQkrSUBxEsJZCnUCPnUcJkW4U", + "0wERoGNNUobBxERnJducFfN+urByxcyk+XmTXy7t5leiX/Yfc53pOx4t346Rmy5OXiosPzWyC1G+nyOc", + "+WgZ9xZ1He5T8vi7MW4ZxfNH5q2/i7demrMvjNdXydz8bn7WvPvSvPWEbujmljm/sZufK6xcIbMzxfW/", + "yMw02Xi9m88Y+fu0cTJvbGfJ5muSXeYWV1i5EsV6tA7X4hBGGmgBn9cWLD5/2moHn4NoSNVQc4zyhXfe", + "LpO7PxdWrnBzLd6dMW9uFdOLu/mMeW+SPHpibGc9EFLOtufJ+u/F3O2djUecygOhubpehyVZSkh4X44G", + "qD5YGEL7BQjpfzFVwUhhZismk7IUY4Z75Hudcn3RMV9J9ShNnE4NQSeIi1i0zBWLksxNl9oOM31LSV2e", + "MAwLQWrjY5TODT0BCkycQxtRAGWRojrw+MNBKAS8IS8M+QGX5T6zCxD6hbArACF0HauziI1WcTZdvSlC", + "DU5Rh9GBTpDQh0EEUEi1qNTB71EMg4mJic4KjTBnr5Ef16iuAD2VSIgUQsHOwiuy+JOFYzcyO+sZc/Xy", + "zsYWeXOTciIOUxkADqUdx6nwB+gElSAt6TE1pWCXJmLkkhSMNKRj15CGkOtCSsVio2BtzXNaxKjLmuWk", + "htB/sTkOgGyyPVV4Ml+Gd1UQVkebY7Hx5qzL/PF2YeNWYSFdeD5XyD6puCE80Ujh2TNje9Jcf0ivBYF/", + "ZzPWt9fqn7O+feyb3L1rffut8cvm+sM6HNsS7x79kEYoJjDVStDJJBgB3UzCNm9dzFOi5+Q4VqbnYT/o", + "BAlx7CijFyD7R5skhTdBboWVdKEyOl81nT1VTeoy4lA1sW8fYiepk8aehkracSYRILTQPMn0vDm1WXyw", + "SrK/kBsZrugVKtiEtSIdSwkRo7grqUkx1KBtnrCpehlRQ/5T1/Eq94NCn+DxVXghzbgg1gz7+FFd8aac", + "kTYbSS3wt/m3fD6nc6gjjGXUO8a1GbQZ+YsPrhj5LUvoHP2N3Cvzfr4JfRpKKXFJGWbg36AyneQkzLoO", + "q0n9rr7/Ptq7nztrbm0Xcs+jB2nKB9OMIYcU2PUPocfvoTBl9fRLjFNPQBBCguCzEatKo6ggyvXJalHQ", + "GD5ZvYoQLu9zruP3CHuQ1hol4+fAYxPyZonMze/8daWYvr7z8nVhIX1ITWsyDnRIoakQ8MMo3vuMjxy6", + "9mkESg0w/Dli+ow2DG0WZsjin4dEG7pBLZWwUn+NgEyXg+LwCaa+3lP90d38CtmeIttTu/m70Z6jp7/q", + "+nqvzVy9b67O0B6GRLv5FeemO+qnqO7un6KiK38K+Sm2WdtHpBGT9ZO8nSbrv++bo2qC2fILoKME/zW9", + "0v6P1ssQZUmkLiQ+L+nn/gehEdAJBkUdHWMhG43dRIyG2U3KQznck5JLcZ1t4rKkIFFjLWdFmfZC+4NP", + "xJODaCxpm3eZx+qAke6DYERGo0izV5AlHdeZUVZx3w8WnwlJKf1Wk/aENBq9kFLx3l65d33MEa3qmEOV", + "LI2yCwOP8JFYio2wKaEb0lmp+pSYbyVczU2a9+a4rlEH/PK08XbdnNpsDqhSmqjEkIsieeNYxYkoKr8D", + "WtXDpkxNbKLth02glxSmXei0zy5l6UJKijNZnhsUZSq3c3GUVHUJs63ns+T1C/PFUzL9mO5jUFRGtFQS", + "x8bPyaqu0yGFX98auSUju2jOr9EhSVnEQ6qWOKehUaSkEJvm9QuyuGUu/02mH/PJ6uwX8702k7FyYO4h", + "ENbYXubgSmbuNAN/TYNuKYtXYivq1KsavLQkoffJ5PU/lULJv6n+wNOg0C34An52uTJ8ABHgFYSQGwa9", + "QilDynPQPKUT8AWCQsAneGBI2Ev774M0vBCgYnb/hkJejwd6/UF3wB/ytDIl9HCheOdXkp4hj9LF9HXj", + "zZ3ig9WmbiMr/c+idFkVlaZqAHben0YQ3aqo2Ln/dh7moKhLMfYrZvsy/ZbrINJjtEMhzRnV+MIhH+Bq", + "NpySRY0n+zS7hmE5I9SZocfVPcq+7A0dU9EQiHhYcchJYuXG96iEaiqBLjoqJasXhO6gg/hsV2+NNQM1", + "1gz4y8lqLBqcGGihz8OwnMz+WlhIkxsZMrlGtqeKd641p2gOS3GpWpx5Lg2pWPce4SlO9ym4P3yl9jpA", + "b1d3NqeK6evm03WSX6zYakyzXBky/dTILVGGJV2VRYzitLU4ec3ILdXhLzGs9FDDO2wAVuaklDkELUyy", + "VfseRnaBb7ahNZv2OqrD4QqR13THLKrL02TmL2P76m4+s7P5mL/uaW0AHC2FjFwln5HrT+mpK2gM7zU/", + "W7eaL6REDSONacjzh4SrNBvr6KHDWWfNnR56bzzIbWp3hR//NienKthIKUOSLHOFNu/9Zs5eM7KP6D72", + "msmrP3lzRQmLuS7GdnZvjv0O89A75fHq58c1nx/XvB/ndnCkW9V1a8TgCCtMltxZy1FKqnqfxKahXO/9", + "+gFEQDgUdoc9gtcThMGQxwvDYeYOWy6wEA4HBK8vaNfd33U1D3R7YCAQDPiCfugNQsETLF/M47MWG6jO", + "bPeXp6NKFy5zuR188VRQKwv8LO4n08/I9B+F2Rkjt0TmbzadBkqI2khTJf0eURtpopr/70j/1C/4tdLT", + "aCAP3so0y3t+4tBfP7lLlfR9PW4w76d3Nraafs+gJpFSesTWoCmdSiLFjlzb87a4njl9WJtpR0GnPfUb", + "5xukg+r3zbD14Qs8TVifKoEI8PNkhirxMojf73f7/W23xcyUkVsyJ3PF9GJTtohdpakatETcZxEc9GD0", + "YN11CRB6oNfl90PoOrbvk4/9H6ztTdKuF/RWwXt2i3Jy6zF1Qu/nSX6RRiTffNPTc/x41C5kstfHwXoK", + "bZfwPqIndKI+clZlRUe3PyCwHKsU5y10GJJZmg66g76wTxC8AW/Abv6yr7pjWEzQVYELugPBgN/nCUNv", + "2G5nBJU9tZ7wVZxoydI4HjvKmD439PoE6+rjTEN3OBwKMgmLstVEjeI8whZjEEIYguFQ0Gu324yV9+g1", + "6qLcPd37g41RNCzaWUsIg0EvDFqtlnQc7VSvPlZpB/7/Sbt18Mrgh2ysGLlXTcArKytIquLCUuPp016L", + "qF/6nDp17POReXupZt60OklKGa7Ippbxy/rqlX7jViK1LZFOvSuufhG2xY9h3teTISf/LfE2zUyabKyY", + "6w+NN/P1jk46ICM20PYyF+oRx7pVUWFuIGUzoTFQ8oDa6ZCEONbtfI6TEMfYoxg/dDy6Yb+tiaCXv8Dp", + "GVZOijGsalY/e4bjXNwqqTGZ8FJZy9MqO+vzheU1skQ9T+PNfOlsGkZHTYohF8/GNQiNlKLbSt+18HXx", + "waFJtQ26Dgj+Pq6/khhMjXfbf8JTSxfrxzQ6kmVO6n0Pfy9x51pzNyxmb9caUp6S190+KbdVNoUXuUJu", + "jefum5BQSokjTR6nWtaYnM7sEbzDI9uPPDvZVnP71n7HSCHegfYn7J8Drcdg5w1eXzsmSj1VfgDLjvPy", + "z55sneQTAxP/FwAA//8rbxVWr0EAAA==", +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %s", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + var res = make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + var resolvePath = PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + var pathToFile = url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} + diff --git a/okex/api/trade/trade.gen.go b/okex/api/trade/trade.gen.go new file mode 100644 index 0000000..07e0304 --- /dev/null +++ b/okex/api/trade/trade.gen.go @@ -0,0 +1,3877 @@ +// Package trade provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.9.0 DO NOT EDIT. +package trade + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "path" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + "github.com/getkin/kin-openapi/openapi3" +) + +// CancelAlgoOrder defines model for CancelAlgoOrder. +type CancelAlgoOrder struct { + // 必填
策略委托单ID + AlgoId string `json:"algoId"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` +} + +// CancelBatchOrder defines model for CancelBatchOrder. +type CancelBatchOrder struct { + // 可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ClOrdId *string `json:"clOrdId,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。 + OrdId *string `json:"ordId,omitempty"` +} + +// PostApiV5TradeAmendBatchOrdersJSONBody defines parameters for PostApiV5TradeAmendBatchOrders. +type PostApiV5TradeAmendBatchOrdersJSONBody struct { + // 可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ClOrdId *string `json:"clOrdId,omitempty"` + + // 非必填
`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false` + CxlOnFail *bool `json:"cxlOnFail,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 可选
修改的新价格 + NewPx *string `json:"newPx,omitempty"` + + // 可选
修改的新数量,newSz和newPx不可同时为空。对于部分成交订单,该数量应包含已成交数量。 + NewSz *string `json:"newSz,omitempty"` + + // 可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。 + OrdId *string `json:"ordId,omitempty"` + + // 非必填
用户自定义修改事件ID,字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ReqId *string `json:"reqId,omitempty"` +} + +// PostApiV5TradeAmendOrderJSONBody defines parameters for PostApiV5TradeAmendOrder. +type PostApiV5TradeAmendOrderJSONBody struct { + // 可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ClOrdId *string `json:"clOrdId,omitempty"` + + // 非必填
`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false` + CxlOnFail *bool `json:"cxlOnFail,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 可选
修改的新价格 + NewPx *string `json:"newPx,omitempty"` + + // 可选
修改的新数量,newSz和newPx不可同时为空。对于部分成交订单,该数量应包含已成交数量。 + NewSz *string `json:"newSz,omitempty"` + + // 可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。 + OrdId *string `json:"ordId,omitempty"` + + // 非必填
用户自定义修改事件ID,字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ReqId *string `json:"reqId,omitempty"` +} + +// PostApiV5TradeBatchOrdersJSONBody defines parameters for PostApiV5TradeBatchOrders. +type PostApiV5TradeBatchOrdersJSONBody struct { + // 非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单 + Ccy *string `json:"ccy,omitempty"` + + // 非必填
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ClOrdId *string `json:"clOrdId,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续) + OrdType string `json:"ordType"` + + // 可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short` + PosSide *string `json:"posSide,omitempty"` + + // 可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单 + Px *string `json:"px,omitempty"` + + // 非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单 + ReduceOnly *bool `json:"reduceOnly,omitempty"` + + // 必填
订单方向。买:`buy` 卖:`sell` + Side string `json:"side"` + + // 必填
委托数量 + Sz string `json:"sz"` + + // 非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。 + Tag *string `json:"tag,omitempty"` + + // 必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金 + TdMode string `json:"tdMode"` + + // 非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单 + TgtCcy *string `json:"tgtCcy,omitempty"` +} + +// PostApiV5TradeCancelAdvanceAlgosJSONBody defines parameters for PostApiV5TradeCancelAdvanceAlgos. +type PostApiV5TradeCancelAdvanceAlgosJSONBody struct { + // 必填
策略委托单ID + AlgoId string `json:"algoId"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` +} + +// PostApiV5TradeCancelAlgosJSONBody defines parameters for PostApiV5TradeCancelAlgos. +type PostApiV5TradeCancelAlgosJSONBody []CancelAlgoOrder + +// PostApiV5TradeCancelBatchOrdersJSONBody defines parameters for PostApiV5TradeCancelBatchOrders. +type PostApiV5TradeCancelBatchOrdersJSONBody []CancelBatchOrder + +// PostApiV5TradeCancelOrderJSONBody defines parameters for PostApiV5TradeCancelOrder. +type PostApiV5TradeCancelOrderJSONBody struct { + // 可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ClOrdId *string `json:"clOrdId,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。 + OrdId *string `json:"ordId,omitempty"` +} + +// PostApiV5TradeClosePositionJSONBody defines parameters for PostApiV5TradeClosePosition. +type PostApiV5TradeClosePositionJSONBody struct { + // 可选
保证金币种,如:`USDT`。单币种保证金模式的全仓币币杠杆平仓必填 + Ccy *string `json:"ccy,omitempty"` + + // 必填
产品ID,如:`BTC-USDT-SWAP` + InstId string `json:"instId"` + + // 必填
保证金模式。全仓:`cross`;逐仓:`isolated` + MgnMode string `json:"mgnMode"` + + // 可选
持仓方向
单向持仓模式下:可不填写此参数,默认值`net`,如果填写,仅可以填写`net`
双向持仓模式下: 必须填写此参数,且仅可以填写 `long`:平多 ,`short`:平空 + PosSide *string `json:"posSide,omitempty"` +} + +// GetApiV5TradeFillsParams defines parameters for GetApiV5TradeFills. +type GetApiV5TradeFillsParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如`BTC-USD` + Uly *string `json:"uly,omitempty"` + + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 订单ID + OrdId *string `json:"ordId,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId` + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId` + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5TradeFillsHistoryParams defines parameters for GetApiV5TradeFillsHistory. +type GetApiV5TradeFillsHistoryParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如`BTC-USD` + Uly *string `json:"uly,omitempty"` + + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 订单ID + OrdId *string `json:"ordId,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId` + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId` + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5TradeOrderParams defines parameters for GetApiV5TradeOrder. +type GetApiV5TradeOrderParams struct { + // 产品ID,如 `BTC-USDT` + InstId string `json:"instId"` + + // 订单ID,ordId和clOrdId必须传一个,若传两个,以ordId为主 + OrdId *string `json:"ordId,omitempty"` + + // 用户自定义ID + ClOrdId *string `json:"clOrdId,omitempty"` +} + +// PostApiV5TradeOrderJSONBody defines parameters for PostApiV5TradeOrder. +type PostApiV5TradeOrderJSONBody struct { + // 非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单 + Ccy *string `json:"ccy,omitempty"` + + // 非必填
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。 + ClOrdId *string `json:"clOrdId,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续) + OrdType string `json:"ordType"` + + // 可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short` + PosSide *string `json:"posSide,omitempty"` + + // 可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单 + Px *string `json:"px,omitempty"` + + // 非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单 + ReduceOnly *bool `json:"reduceOnly,omitempty"` + + // 必填
订单方向。买:`buy` 卖:`sell` + Side string `json:"side"` + + // 必填
委托数量 + Sz string `json:"sz"` + + // 非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。 + Tag *string `json:"tag,omitempty"` + + // 必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金 + TdMode string `json:"tdMode"` + + // 非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单 + TgtCcy *string `json:"tgtCcy,omitempty"` +} + +// PostApiV5TradeOrderAlgoJSONBody defines parameters for PostApiV5TradeOrderAlgo. +type PostApiV5TradeOrderAlgoJSONBody struct { + // 非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单 + Ccy *string `json:"ccy,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId string `json:"instId"` + + // 必填
订单类型。
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托 + OrdType string `json:"ordType"` + + // 非必填
委托价格
委托价格为-1时,执行市价委托
适用于`计划委托` + OrderPx *string `json:"orderPx,omitempty"` + + // 可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short` + PosSide *string `json:"posSide,omitempty"` + + // 非必填
挂单限制价
适用于`冰山委托`和`时间加权委托` + PxLimit *string `json:"pxLimit,omitempty"` + + // 非必填
距离盘口的比例价距
适用于`冰山委托`和`时间加权委托` + PxSpread *string `json:"pxSpread,omitempty"` + + // 非必填
距离盘口的比例
pxVar和pxSpread只能传入一个
适用于`冰山委托`和`时间加权委托` + PxVar *string `json:"pxVar,omitempty"` + + // 非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单 + ReduceOnly *bool `json:"reduceOnly,omitempty"` + + // 必填
订单方向。买:`buy` 卖:`sell` + Side string `json:"side"` + + // 非必填
止损委托价,如果填写此参数,必须填写止损触发价
委托价格为-1时,执行市价止损
适用于`止盈止损委托` + SlOrdPx *string `json:"slOrdPx,omitempty"` + + // 非必填
止损触发价,如果填写此参数,必须填写止损委托价
适用于`止盈止损委托` + SlTriggerPx *string `json:"slTriggerPx,omitempty"` + + // 必填
委托数量 + Sz string `json:"sz"` + + // 非必填
单笔数量
适用于`冰山委托`和`时间加权委托` + SzLimit *string `json:"szLimit,omitempty"` + + // 必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金 + TdMode string `json:"tdMode"` + + // 非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单 + TgtCcy *string `json:"tgtCcy,omitempty"` + + // 非必填
挂单限制价
适用于`时间加权委托` + TimeInterval *string `json:"timeInterval,omitempty"` + + // 非必填
止盈委托价,如果填写此参数,必须填写止盈触发价
委托价格为-1时,执行市价止盈
适用于`止盈止损委托` + TpOrdPx *string `json:"tpOrdPx,omitempty"` + + // 非必填
止盈触发价,如果填写此参数,必须填写止盈委托价
适用于`止盈止损委托` + TpTriggerPx *string `json:"tpTriggerPx,omitempty"` + + // 非必填
计划委托触发价格
适用于`计划委托` + TriggerPx *string `json:"triggerPx,omitempty"` +} + +// GetApiV5TradeOrdersAlgoHistoryParams defines parameters for GetApiV5TradeOrdersAlgoHistory. +type GetApiV5TradeOrdersAlgoHistoryParams struct { + // 订单类型
`conditional`:单向止盈止损,`oco`:双向止盈止损,`trigger`:计划委托,`iceberg`:冰山委托,`twap`:时间加权委托 + OrdType string `json:"ordType"` + + // 策略委托单ID
`state`和`algoId`必填且只能填其一 + AlgoId *string `json:"algoId,omitempty"` + + // 订单状态
`effective`:已生效,`canceled`:已经撤销,`order_failed`:委托失败
`state`和`algoId`必填且只能填其一 + State *string `json:"state,omitempty"` + + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` + + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`ordId` + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5TradeOrdersAlgoPendingParams defines parameters for GetApiV5TradeOrdersAlgoPending. +type GetApiV5TradeOrdersAlgoPendingParams struct { + // 订单类型
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托 + OrdType string `json:"ordType"` + + // 策略委托单ID + AlgoId *string `json:"algoId,omitempty"` + + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` + + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的ordId + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5TradeOrdersHistoryParams defines parameters for GetApiV5TradeOrdersHistory. +type GetApiV5TradeOrdersHistoryParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如`BTC-USD` + Uly *string `json:"uly,omitempty"` + + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续) + OrdType *string `json:"ordType,omitempty"` + + // 订单状态
`canceled`:撤单成功
`filled`:完全成交 + State *string `json:"state,omitempty"` + + // 订单种类
`twap`:TWAP自动换币
`adl`:ADL自动减仓
`full_liquidation`:强制平仓
`partial_liquidation`:强制减仓
`delivery`:交割 + Category *string `json:"category,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的ordId + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5TradeOrdersHistoryArchiveParams defines parameters for GetApiV5TradeOrdersHistoryArchive. +type GetApiV5TradeOrdersHistoryArchiveParams struct { + // 产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType string `json:"instType"` + + // 合约标的指数,如`BTC-USD` + Uly *string `json:"uly,omitempty"` + + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续) + OrdType *string `json:"ordType,omitempty"` + + // 订单状态
`canceled`:撤单成功
`filled`:完全成交 + State *string `json:"state,omitempty"` + + // 订单种类
`twap`:TWAP自动换币
`adl`:ADL自动减仓
`full_liquidation`:强制平仓
`partial_liquidation`:强制减仓
`delivery`:交割 + Category *string `json:"category,omitempty"` + + // 请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId + After *string `json:"after,omitempty"` + + // 请求此ID之后(更新的数据)的分页内容,传的值为对应接口的ordId + Before *string `json:"before,omitempty"` + + // 返回结果的数量,默认100条 + Limit *string `json:"limit,omitempty"` +} + +// GetApiV5TradeOrdersPendingParams defines parameters for GetApiV5TradeOrdersPending. +type GetApiV5TradeOrdersPendingParams struct { + // 产品ID,如`BTC-USDT-SWAP` + InstId *string `json:"instId,omitempty"` + + // 产品类型。
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 + InstType *string `json:"instType,omitempty"` + + // 合约标的指数,如`BTC-USD` + Uly *string `json:"uly,omitempty"` + + // 订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续) + OrdType *string `json:"ordType,omitempty"` +} + +// PostApiV5TradeAmendBatchOrdersJSONRequestBody defines body for PostApiV5TradeAmendBatchOrders for application/json ContentType. +type PostApiV5TradeAmendBatchOrdersJSONRequestBody = PostApiV5TradeAmendBatchOrdersJSONBody + +// PostApiV5TradeAmendOrderJSONRequestBody defines body for PostApiV5TradeAmendOrder for application/json ContentType. +type PostApiV5TradeAmendOrderJSONRequestBody = PostApiV5TradeAmendOrderJSONBody + +// PostApiV5TradeBatchOrdersJSONRequestBody defines body for PostApiV5TradeBatchOrders for application/json ContentType. +type PostApiV5TradeBatchOrdersJSONRequestBody = PostApiV5TradeBatchOrdersJSONBody + +// PostApiV5TradeCancelAdvanceAlgosJSONRequestBody defines body for PostApiV5TradeCancelAdvanceAlgos for application/json ContentType. +type PostApiV5TradeCancelAdvanceAlgosJSONRequestBody = PostApiV5TradeCancelAdvanceAlgosJSONBody + +// PostApiV5TradeCancelAlgosJSONRequestBody defines body for PostApiV5TradeCancelAlgos for application/json ContentType. +type PostApiV5TradeCancelAlgosJSONRequestBody = PostApiV5TradeCancelAlgosJSONBody + +// PostApiV5TradeCancelBatchOrdersJSONRequestBody defines body for PostApiV5TradeCancelBatchOrders for application/json ContentType. +type PostApiV5TradeCancelBatchOrdersJSONRequestBody = PostApiV5TradeCancelBatchOrdersJSONBody + +// PostApiV5TradeCancelOrderJSONRequestBody defines body for PostApiV5TradeCancelOrder for application/json ContentType. +type PostApiV5TradeCancelOrderJSONRequestBody = PostApiV5TradeCancelOrderJSONBody + +// PostApiV5TradeClosePositionJSONRequestBody defines body for PostApiV5TradeClosePosition for application/json ContentType. +type PostApiV5TradeClosePositionJSONRequestBody = PostApiV5TradeClosePositionJSONBody + +// PostApiV5TradeOrderJSONRequestBody defines body for PostApiV5TradeOrder for application/json ContentType. +type PostApiV5TradeOrderJSONRequestBody = PostApiV5TradeOrderJSONBody + +// PostApiV5TradeOrderAlgoJSONRequestBody defines body for PostApiV5TradeOrderAlgo for application/json ContentType. +type PostApiV5TradeOrderAlgoJSONRequestBody = PostApiV5TradeOrderAlgoJSONBody + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // PostApiV5TradeAmendBatchOrders request with any body + PostApiV5TradeAmendBatchOrdersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeAmendBatchOrders(ctx context.Context, body PostApiV5TradeAmendBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeAmendOrder request with any body + PostApiV5TradeAmendOrderWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeAmendOrder(ctx context.Context, body PostApiV5TradeAmendOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeBatchOrders request with any body + PostApiV5TradeBatchOrdersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeBatchOrders(ctx context.Context, body PostApiV5TradeBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeCancelAdvanceAlgos request with any body + PostApiV5TradeCancelAdvanceAlgosWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeCancelAdvanceAlgos(ctx context.Context, body PostApiV5TradeCancelAdvanceAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeCancelAlgos request with any body + PostApiV5TradeCancelAlgosWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeCancelAlgos(ctx context.Context, body PostApiV5TradeCancelAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeCancelBatchOrders request with any body + PostApiV5TradeCancelBatchOrdersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeCancelBatchOrders(ctx context.Context, body PostApiV5TradeCancelBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeCancelOrder request with any body + PostApiV5TradeCancelOrderWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeCancelOrder(ctx context.Context, body PostApiV5TradeCancelOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeClosePosition request with any body + PostApiV5TradeClosePositionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeClosePosition(ctx context.Context, body PostApiV5TradeClosePositionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeFills request + GetApiV5TradeFills(ctx context.Context, params *GetApiV5TradeFillsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeFillsHistory request + GetApiV5TradeFillsHistory(ctx context.Context, params *GetApiV5TradeFillsHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeOrder request + GetApiV5TradeOrder(ctx context.Context, params *GetApiV5TradeOrderParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeOrder request with any body + PostApiV5TradeOrderWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeOrder(ctx context.Context, body PostApiV5TradeOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostApiV5TradeOrderAlgo request with any body + PostApiV5TradeOrderAlgoWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostApiV5TradeOrderAlgo(ctx context.Context, body PostApiV5TradeOrderAlgoJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeOrdersAlgoHistory request + GetApiV5TradeOrdersAlgoHistory(ctx context.Context, params *GetApiV5TradeOrdersAlgoHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeOrdersAlgoPending request + GetApiV5TradeOrdersAlgoPending(ctx context.Context, params *GetApiV5TradeOrdersAlgoPendingParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeOrdersHistory request + GetApiV5TradeOrdersHistory(ctx context.Context, params *GetApiV5TradeOrdersHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeOrdersHistoryArchive request + GetApiV5TradeOrdersHistoryArchive(ctx context.Context, params *GetApiV5TradeOrdersHistoryArchiveParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiV5TradeOrdersPending request + GetApiV5TradeOrdersPending(ctx context.Context, params *GetApiV5TradeOrdersPendingParams, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) PostApiV5TradeAmendBatchOrdersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeAmendBatchOrdersRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeAmendBatchOrders(ctx context.Context, body PostApiV5TradeAmendBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeAmendBatchOrdersRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeAmendOrderWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeAmendOrderRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeAmendOrder(ctx context.Context, body PostApiV5TradeAmendOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeAmendOrderRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeBatchOrdersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeBatchOrdersRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeBatchOrders(ctx context.Context, body PostApiV5TradeBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeBatchOrdersRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelAdvanceAlgosWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelAdvanceAlgosRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelAdvanceAlgos(ctx context.Context, body PostApiV5TradeCancelAdvanceAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelAdvanceAlgosRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelAlgosWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelAlgosRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelAlgos(ctx context.Context, body PostApiV5TradeCancelAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelAlgosRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelBatchOrdersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelBatchOrdersRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelBatchOrders(ctx context.Context, body PostApiV5TradeCancelBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelBatchOrdersRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelOrderWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelOrderRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeCancelOrder(ctx context.Context, body PostApiV5TradeCancelOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeCancelOrderRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeClosePositionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeClosePositionRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeClosePosition(ctx context.Context, body PostApiV5TradeClosePositionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeClosePositionRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeFills(ctx context.Context, params *GetApiV5TradeFillsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeFillsRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeFillsHistory(ctx context.Context, params *GetApiV5TradeFillsHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeFillsHistoryRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeOrder(ctx context.Context, params *GetApiV5TradeOrderParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeOrderRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeOrderWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeOrderRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeOrder(ctx context.Context, body PostApiV5TradeOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeOrderRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeOrderAlgoWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeOrderAlgoRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostApiV5TradeOrderAlgo(ctx context.Context, body PostApiV5TradeOrderAlgoJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostApiV5TradeOrderAlgoRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeOrdersAlgoHistory(ctx context.Context, params *GetApiV5TradeOrdersAlgoHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeOrdersAlgoHistoryRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeOrdersAlgoPending(ctx context.Context, params *GetApiV5TradeOrdersAlgoPendingParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeOrdersAlgoPendingRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeOrdersHistory(ctx context.Context, params *GetApiV5TradeOrdersHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeOrdersHistoryRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeOrdersHistoryArchive(ctx context.Context, params *GetApiV5TradeOrdersHistoryArchiveParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeOrdersHistoryArchiveRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetApiV5TradeOrdersPending(ctx context.Context, params *GetApiV5TradeOrdersPendingParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiV5TradeOrdersPendingRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewPostApiV5TradeAmendBatchOrdersRequest calls the generic PostApiV5TradeAmendBatchOrders builder with application/json body +func NewPostApiV5TradeAmendBatchOrdersRequest(server string, body PostApiV5TradeAmendBatchOrdersJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeAmendBatchOrdersRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeAmendBatchOrdersRequestWithBody generates requests for PostApiV5TradeAmendBatchOrders with any type of body +func NewPostApiV5TradeAmendBatchOrdersRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/amend-batch-orders") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeAmendOrderRequest calls the generic PostApiV5TradeAmendOrder builder with application/json body +func NewPostApiV5TradeAmendOrderRequest(server string, body PostApiV5TradeAmendOrderJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeAmendOrderRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeAmendOrderRequestWithBody generates requests for PostApiV5TradeAmendOrder with any type of body +func NewPostApiV5TradeAmendOrderRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/amend-order") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeBatchOrdersRequest calls the generic PostApiV5TradeBatchOrders builder with application/json body +func NewPostApiV5TradeBatchOrdersRequest(server string, body PostApiV5TradeBatchOrdersJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeBatchOrdersRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeBatchOrdersRequestWithBody generates requests for PostApiV5TradeBatchOrders with any type of body +func NewPostApiV5TradeBatchOrdersRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/batch-orders") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeCancelAdvanceAlgosRequest calls the generic PostApiV5TradeCancelAdvanceAlgos builder with application/json body +func NewPostApiV5TradeCancelAdvanceAlgosRequest(server string, body PostApiV5TradeCancelAdvanceAlgosJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeCancelAdvanceAlgosRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeCancelAdvanceAlgosRequestWithBody generates requests for PostApiV5TradeCancelAdvanceAlgos with any type of body +func NewPostApiV5TradeCancelAdvanceAlgosRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/cancel-advance-algos") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeCancelAlgosRequest calls the generic PostApiV5TradeCancelAlgos builder with application/json body +func NewPostApiV5TradeCancelAlgosRequest(server string, body PostApiV5TradeCancelAlgosJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeCancelAlgosRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeCancelAlgosRequestWithBody generates requests for PostApiV5TradeCancelAlgos with any type of body +func NewPostApiV5TradeCancelAlgosRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/cancel-algos") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeCancelBatchOrdersRequest calls the generic PostApiV5TradeCancelBatchOrders builder with application/json body +func NewPostApiV5TradeCancelBatchOrdersRequest(server string, body PostApiV5TradeCancelBatchOrdersJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeCancelBatchOrdersRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeCancelBatchOrdersRequestWithBody generates requests for PostApiV5TradeCancelBatchOrders with any type of body +func NewPostApiV5TradeCancelBatchOrdersRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/cancel-batch-orders") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeCancelOrderRequest calls the generic PostApiV5TradeCancelOrder builder with application/json body +func NewPostApiV5TradeCancelOrderRequest(server string, body PostApiV5TradeCancelOrderJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeCancelOrderRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeCancelOrderRequestWithBody generates requests for PostApiV5TradeCancelOrder with any type of body +func NewPostApiV5TradeCancelOrderRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/cancel-order") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeClosePositionRequest calls the generic PostApiV5TradeClosePosition builder with application/json body +func NewPostApiV5TradeClosePositionRequest(server string, body PostApiV5TradeClosePositionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeClosePositionRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeClosePositionRequestWithBody generates requests for PostApiV5TradeClosePosition with any type of body +func NewPostApiV5TradeClosePositionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/close-position") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetApiV5TradeFillsRequest generates requests for GetApiV5TradeFills +func NewGetApiV5TradeFillsRequest(server string, params *GetApiV5TradeFillsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/fills") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.OrdId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordId", runtime.ParamLocationQuery, *params.OrdId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5TradeFillsHistoryRequest generates requests for GetApiV5TradeFillsHistory +func NewGetApiV5TradeFillsHistoryRequest(server string, params *GetApiV5TradeFillsHistoryParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/fills-history") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.OrdId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordId", runtime.ParamLocationQuery, *params.OrdId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5TradeOrderRequest generates requests for GetApiV5TradeOrder +func NewGetApiV5TradeOrderRequest(server string, params *GetApiV5TradeOrderParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/order") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.OrdId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordId", runtime.ParamLocationQuery, *params.OrdId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.ClOrdId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "clOrdId", runtime.ParamLocationQuery, *params.ClOrdId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostApiV5TradeOrderRequest calls the generic PostApiV5TradeOrder builder with application/json body +func NewPostApiV5TradeOrderRequest(server string, body PostApiV5TradeOrderJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeOrderRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeOrderRequestWithBody generates requests for PostApiV5TradeOrder with any type of body +func NewPostApiV5TradeOrderRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/order") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostApiV5TradeOrderAlgoRequest calls the generic PostApiV5TradeOrderAlgo builder with application/json body +func NewPostApiV5TradeOrderAlgoRequest(server string, body PostApiV5TradeOrderAlgoJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostApiV5TradeOrderAlgoRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostApiV5TradeOrderAlgoRequestWithBody generates requests for PostApiV5TradeOrderAlgo with any type of body +func NewPostApiV5TradeOrderAlgoRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/order-algo") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetApiV5TradeOrdersAlgoHistoryRequest generates requests for GetApiV5TradeOrdersAlgoHistory +func NewGetApiV5TradeOrdersAlgoHistoryRequest(server string, params *GetApiV5TradeOrdersAlgoHistoryParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/orders-algo-history") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordType", runtime.ParamLocationQuery, params.OrdType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.AlgoId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "algoId", runtime.ParamLocationQuery, *params.AlgoId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "state", runtime.ParamLocationQuery, *params.State); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5TradeOrdersAlgoPendingRequest generates requests for GetApiV5TradeOrdersAlgoPending +func NewGetApiV5TradeOrdersAlgoPendingRequest(server string, params *GetApiV5TradeOrdersAlgoPendingParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/orders-algo-pending") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordType", runtime.ParamLocationQuery, params.OrdType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.AlgoId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "algoId", runtime.ParamLocationQuery, *params.AlgoId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5TradeOrdersHistoryRequest generates requests for GetApiV5TradeOrdersHistory +func NewGetApiV5TradeOrdersHistoryRequest(server string, params *GetApiV5TradeOrdersHistoryParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/orders-history") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.OrdType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordType", runtime.ParamLocationQuery, *params.OrdType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "state", runtime.ParamLocationQuery, *params.State); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "category", runtime.ParamLocationQuery, *params.Category); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5TradeOrdersHistoryArchiveRequest generates requests for GetApiV5TradeOrdersHistoryArchive +func NewGetApiV5TradeOrdersHistoryArchiveRequest(server string, params *GetApiV5TradeOrdersHistoryArchiveParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/orders-history-archive") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.OrdType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordType", runtime.ParamLocationQuery, *params.OrdType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "state", runtime.ParamLocationQuery, *params.State); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "category", runtime.ParamLocationQuery, *params.Category); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetApiV5TradeOrdersPendingRequest generates requests for GetApiV5TradeOrdersPending +func NewGetApiV5TradeOrdersPendingRequest(server string, params *GetApiV5TradeOrdersPendingParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v5/trade/orders-pending") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.InstId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.InstType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, *params.InstType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Uly != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.OrdType != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ordType", runtime.ParamLocationQuery, *params.OrdType); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // PostApiV5TradeAmendBatchOrders request with any body + PostApiV5TradeAmendBatchOrdersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendBatchOrdersResponse, error) + + PostApiV5TradeAmendBatchOrdersWithResponse(ctx context.Context, body PostApiV5TradeAmendBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendBatchOrdersResponse, error) + + // PostApiV5TradeAmendOrder request with any body + PostApiV5TradeAmendOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendOrderResponse, error) + + PostApiV5TradeAmendOrderWithResponse(ctx context.Context, body PostApiV5TradeAmendOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendOrderResponse, error) + + // PostApiV5TradeBatchOrders request with any body + PostApiV5TradeBatchOrdersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeBatchOrdersResponse, error) + + PostApiV5TradeBatchOrdersWithResponse(ctx context.Context, body PostApiV5TradeBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeBatchOrdersResponse, error) + + // PostApiV5TradeCancelAdvanceAlgos request with any body + PostApiV5TradeCancelAdvanceAlgosWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAdvanceAlgosResponse, error) + + PostApiV5TradeCancelAdvanceAlgosWithResponse(ctx context.Context, body PostApiV5TradeCancelAdvanceAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAdvanceAlgosResponse, error) + + // PostApiV5TradeCancelAlgos request with any body + PostApiV5TradeCancelAlgosWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAlgosResponse, error) + + PostApiV5TradeCancelAlgosWithResponse(ctx context.Context, body PostApiV5TradeCancelAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAlgosResponse, error) + + // PostApiV5TradeCancelBatchOrders request with any body + PostApiV5TradeCancelBatchOrdersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelBatchOrdersResponse, error) + + PostApiV5TradeCancelBatchOrdersWithResponse(ctx context.Context, body PostApiV5TradeCancelBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelBatchOrdersResponse, error) + + // PostApiV5TradeCancelOrder request with any body + PostApiV5TradeCancelOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelOrderResponse, error) + + PostApiV5TradeCancelOrderWithResponse(ctx context.Context, body PostApiV5TradeCancelOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelOrderResponse, error) + + // PostApiV5TradeClosePosition request with any body + PostApiV5TradeClosePositionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeClosePositionResponse, error) + + PostApiV5TradeClosePositionWithResponse(ctx context.Context, body PostApiV5TradeClosePositionJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeClosePositionResponse, error) + + // GetApiV5TradeFills request + GetApiV5TradeFillsWithResponse(ctx context.Context, params *GetApiV5TradeFillsParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeFillsResponse, error) + + // GetApiV5TradeFillsHistory request + GetApiV5TradeFillsHistoryWithResponse(ctx context.Context, params *GetApiV5TradeFillsHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeFillsHistoryResponse, error) + + // GetApiV5TradeOrder request + GetApiV5TradeOrderWithResponse(ctx context.Context, params *GetApiV5TradeOrderParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrderResponse, error) + + // PostApiV5TradeOrder request with any body + PostApiV5TradeOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderResponse, error) + + PostApiV5TradeOrderWithResponse(ctx context.Context, body PostApiV5TradeOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderResponse, error) + + // PostApiV5TradeOrderAlgo request with any body + PostApiV5TradeOrderAlgoWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderAlgoResponse, error) + + PostApiV5TradeOrderAlgoWithResponse(ctx context.Context, body PostApiV5TradeOrderAlgoJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderAlgoResponse, error) + + // GetApiV5TradeOrdersAlgoHistory request + GetApiV5TradeOrdersAlgoHistoryWithResponse(ctx context.Context, params *GetApiV5TradeOrdersAlgoHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersAlgoHistoryResponse, error) + + // GetApiV5TradeOrdersAlgoPending request + GetApiV5TradeOrdersAlgoPendingWithResponse(ctx context.Context, params *GetApiV5TradeOrdersAlgoPendingParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersAlgoPendingResponse, error) + + // GetApiV5TradeOrdersHistory request + GetApiV5TradeOrdersHistoryWithResponse(ctx context.Context, params *GetApiV5TradeOrdersHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersHistoryResponse, error) + + // GetApiV5TradeOrdersHistoryArchive request + GetApiV5TradeOrdersHistoryArchiveWithResponse(ctx context.Context, params *GetApiV5TradeOrdersHistoryArchiveParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersHistoryArchiveResponse, error) + + // GetApiV5TradeOrdersPending request + GetApiV5TradeOrdersPendingWithResponse(ctx context.Context, params *GetApiV5TradeOrdersPendingParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersPendingResponse, error) +} + +type PostApiV5TradeAmendBatchOrdersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeAmendBatchOrdersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeAmendBatchOrdersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeAmendOrderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeAmendOrderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeAmendOrderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeBatchOrdersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeBatchOrdersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeBatchOrdersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeCancelAdvanceAlgosResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeCancelAdvanceAlgosResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeCancelAdvanceAlgosResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeCancelAlgosResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeCancelAlgosResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeCancelAlgosResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeCancelBatchOrdersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeCancelBatchOrdersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeCancelBatchOrdersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeCancelOrderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeCancelOrderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeCancelOrderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeClosePositionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeClosePositionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeClosePositionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeFillsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeFillsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeFillsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeFillsHistoryResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeFillsHistoryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeFillsHistoryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeOrderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeOrderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeOrderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeOrderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeOrderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeOrderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostApiV5TradeOrderAlgoResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } +} + +// Status returns HTTPResponse.Status +func (r PostApiV5TradeOrderAlgoResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostApiV5TradeOrderAlgoResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeOrdersAlgoHistoryResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeOrdersAlgoHistoryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeOrdersAlgoHistoryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeOrdersAlgoPendingResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeOrdersAlgoPendingResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeOrdersAlgoPendingResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeOrdersHistoryResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeOrdersHistoryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeOrdersHistoryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeOrdersHistoryArchiveResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeOrdersHistoryArchiveResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeOrdersHistoryArchiveResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetApiV5TradeOrdersPendingResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r GetApiV5TradeOrdersPendingResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiV5TradeOrdersPendingResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// PostApiV5TradeAmendBatchOrdersWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeAmendBatchOrdersResponse +func (c *ClientWithResponses) PostApiV5TradeAmendBatchOrdersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendBatchOrdersResponse, error) { + rsp, err := c.PostApiV5TradeAmendBatchOrdersWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeAmendBatchOrdersResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeAmendBatchOrdersWithResponse(ctx context.Context, body PostApiV5TradeAmendBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendBatchOrdersResponse, error) { + rsp, err := c.PostApiV5TradeAmendBatchOrders(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeAmendBatchOrdersResponse(rsp) +} + +// PostApiV5TradeAmendOrderWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeAmendOrderResponse +func (c *ClientWithResponses) PostApiV5TradeAmendOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendOrderResponse, error) { + rsp, err := c.PostApiV5TradeAmendOrderWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeAmendOrderResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeAmendOrderWithResponse(ctx context.Context, body PostApiV5TradeAmendOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeAmendOrderResponse, error) { + rsp, err := c.PostApiV5TradeAmendOrder(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeAmendOrderResponse(rsp) +} + +// PostApiV5TradeBatchOrdersWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeBatchOrdersResponse +func (c *ClientWithResponses) PostApiV5TradeBatchOrdersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeBatchOrdersResponse, error) { + rsp, err := c.PostApiV5TradeBatchOrdersWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeBatchOrdersResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeBatchOrdersWithResponse(ctx context.Context, body PostApiV5TradeBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeBatchOrdersResponse, error) { + rsp, err := c.PostApiV5TradeBatchOrders(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeBatchOrdersResponse(rsp) +} + +// PostApiV5TradeCancelAdvanceAlgosWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeCancelAdvanceAlgosResponse +func (c *ClientWithResponses) PostApiV5TradeCancelAdvanceAlgosWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAdvanceAlgosResponse, error) { + rsp, err := c.PostApiV5TradeCancelAdvanceAlgosWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelAdvanceAlgosResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeCancelAdvanceAlgosWithResponse(ctx context.Context, body PostApiV5TradeCancelAdvanceAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAdvanceAlgosResponse, error) { + rsp, err := c.PostApiV5TradeCancelAdvanceAlgos(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelAdvanceAlgosResponse(rsp) +} + +// PostApiV5TradeCancelAlgosWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeCancelAlgosResponse +func (c *ClientWithResponses) PostApiV5TradeCancelAlgosWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAlgosResponse, error) { + rsp, err := c.PostApiV5TradeCancelAlgosWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelAlgosResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeCancelAlgosWithResponse(ctx context.Context, body PostApiV5TradeCancelAlgosJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelAlgosResponse, error) { + rsp, err := c.PostApiV5TradeCancelAlgos(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelAlgosResponse(rsp) +} + +// PostApiV5TradeCancelBatchOrdersWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeCancelBatchOrdersResponse +func (c *ClientWithResponses) PostApiV5TradeCancelBatchOrdersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelBatchOrdersResponse, error) { + rsp, err := c.PostApiV5TradeCancelBatchOrdersWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelBatchOrdersResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeCancelBatchOrdersWithResponse(ctx context.Context, body PostApiV5TradeCancelBatchOrdersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelBatchOrdersResponse, error) { + rsp, err := c.PostApiV5TradeCancelBatchOrders(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelBatchOrdersResponse(rsp) +} + +// PostApiV5TradeCancelOrderWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeCancelOrderResponse +func (c *ClientWithResponses) PostApiV5TradeCancelOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelOrderResponse, error) { + rsp, err := c.PostApiV5TradeCancelOrderWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelOrderResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeCancelOrderWithResponse(ctx context.Context, body PostApiV5TradeCancelOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeCancelOrderResponse, error) { + rsp, err := c.PostApiV5TradeCancelOrder(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeCancelOrderResponse(rsp) +} + +// PostApiV5TradeClosePositionWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeClosePositionResponse +func (c *ClientWithResponses) PostApiV5TradeClosePositionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeClosePositionResponse, error) { + rsp, err := c.PostApiV5TradeClosePositionWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeClosePositionResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeClosePositionWithResponse(ctx context.Context, body PostApiV5TradeClosePositionJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeClosePositionResponse, error) { + rsp, err := c.PostApiV5TradeClosePosition(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeClosePositionResponse(rsp) +} + +// GetApiV5TradeFillsWithResponse request returning *GetApiV5TradeFillsResponse +func (c *ClientWithResponses) GetApiV5TradeFillsWithResponse(ctx context.Context, params *GetApiV5TradeFillsParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeFillsResponse, error) { + rsp, err := c.GetApiV5TradeFills(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeFillsResponse(rsp) +} + +// GetApiV5TradeFillsHistoryWithResponse request returning *GetApiV5TradeFillsHistoryResponse +func (c *ClientWithResponses) GetApiV5TradeFillsHistoryWithResponse(ctx context.Context, params *GetApiV5TradeFillsHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeFillsHistoryResponse, error) { + rsp, err := c.GetApiV5TradeFillsHistory(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeFillsHistoryResponse(rsp) +} + +// GetApiV5TradeOrderWithResponse request returning *GetApiV5TradeOrderResponse +func (c *ClientWithResponses) GetApiV5TradeOrderWithResponse(ctx context.Context, params *GetApiV5TradeOrderParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrderResponse, error) { + rsp, err := c.GetApiV5TradeOrder(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeOrderResponse(rsp) +} + +// PostApiV5TradeOrderWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeOrderResponse +func (c *ClientWithResponses) PostApiV5TradeOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderResponse, error) { + rsp, err := c.PostApiV5TradeOrderWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeOrderResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeOrderWithResponse(ctx context.Context, body PostApiV5TradeOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderResponse, error) { + rsp, err := c.PostApiV5TradeOrder(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeOrderResponse(rsp) +} + +// PostApiV5TradeOrderAlgoWithBodyWithResponse request with arbitrary body returning *PostApiV5TradeOrderAlgoResponse +func (c *ClientWithResponses) PostApiV5TradeOrderAlgoWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderAlgoResponse, error) { + rsp, err := c.PostApiV5TradeOrderAlgoWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeOrderAlgoResponse(rsp) +} + +func (c *ClientWithResponses) PostApiV5TradeOrderAlgoWithResponse(ctx context.Context, body PostApiV5TradeOrderAlgoJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV5TradeOrderAlgoResponse, error) { + rsp, err := c.PostApiV5TradeOrderAlgo(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostApiV5TradeOrderAlgoResponse(rsp) +} + +// GetApiV5TradeOrdersAlgoHistoryWithResponse request returning *GetApiV5TradeOrdersAlgoHistoryResponse +func (c *ClientWithResponses) GetApiV5TradeOrdersAlgoHistoryWithResponse(ctx context.Context, params *GetApiV5TradeOrdersAlgoHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersAlgoHistoryResponse, error) { + rsp, err := c.GetApiV5TradeOrdersAlgoHistory(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeOrdersAlgoHistoryResponse(rsp) +} + +// GetApiV5TradeOrdersAlgoPendingWithResponse request returning *GetApiV5TradeOrdersAlgoPendingResponse +func (c *ClientWithResponses) GetApiV5TradeOrdersAlgoPendingWithResponse(ctx context.Context, params *GetApiV5TradeOrdersAlgoPendingParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersAlgoPendingResponse, error) { + rsp, err := c.GetApiV5TradeOrdersAlgoPending(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeOrdersAlgoPendingResponse(rsp) +} + +// GetApiV5TradeOrdersHistoryWithResponse request returning *GetApiV5TradeOrdersHistoryResponse +func (c *ClientWithResponses) GetApiV5TradeOrdersHistoryWithResponse(ctx context.Context, params *GetApiV5TradeOrdersHistoryParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersHistoryResponse, error) { + rsp, err := c.GetApiV5TradeOrdersHistory(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeOrdersHistoryResponse(rsp) +} + +// GetApiV5TradeOrdersHistoryArchiveWithResponse request returning *GetApiV5TradeOrdersHistoryArchiveResponse +func (c *ClientWithResponses) GetApiV5TradeOrdersHistoryArchiveWithResponse(ctx context.Context, params *GetApiV5TradeOrdersHistoryArchiveParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersHistoryArchiveResponse, error) { + rsp, err := c.GetApiV5TradeOrdersHistoryArchive(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeOrdersHistoryArchiveResponse(rsp) +} + +// GetApiV5TradeOrdersPendingWithResponse request returning *GetApiV5TradeOrdersPendingResponse +func (c *ClientWithResponses) GetApiV5TradeOrdersPendingWithResponse(ctx context.Context, params *GetApiV5TradeOrdersPendingParams, reqEditors ...RequestEditorFn) (*GetApiV5TradeOrdersPendingResponse, error) { + rsp, err := c.GetApiV5TradeOrdersPending(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiV5TradeOrdersPendingResponse(rsp) +} + +// ParsePostApiV5TradeAmendBatchOrdersResponse parses an HTTP response from a PostApiV5TradeAmendBatchOrdersWithResponse call +func ParsePostApiV5TradeAmendBatchOrdersResponse(rsp *http.Response) (*PostApiV5TradeAmendBatchOrdersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeAmendBatchOrdersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeAmendOrderResponse parses an HTTP response from a PostApiV5TradeAmendOrderWithResponse call +func ParsePostApiV5TradeAmendOrderResponse(rsp *http.Response) (*PostApiV5TradeAmendOrderResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeAmendOrderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeBatchOrdersResponse parses an HTTP response from a PostApiV5TradeBatchOrdersWithResponse call +func ParsePostApiV5TradeBatchOrdersResponse(rsp *http.Response) (*PostApiV5TradeBatchOrdersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeBatchOrdersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeCancelAdvanceAlgosResponse parses an HTTP response from a PostApiV5TradeCancelAdvanceAlgosWithResponse call +func ParsePostApiV5TradeCancelAdvanceAlgosResponse(rsp *http.Response) (*PostApiV5TradeCancelAdvanceAlgosResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeCancelAdvanceAlgosResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeCancelAlgosResponse parses an HTTP response from a PostApiV5TradeCancelAlgosWithResponse call +func ParsePostApiV5TradeCancelAlgosResponse(rsp *http.Response) (*PostApiV5TradeCancelAlgosResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeCancelAlgosResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeCancelBatchOrdersResponse parses an HTTP response from a PostApiV5TradeCancelBatchOrdersWithResponse call +func ParsePostApiV5TradeCancelBatchOrdersResponse(rsp *http.Response) (*PostApiV5TradeCancelBatchOrdersResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeCancelBatchOrdersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeCancelOrderResponse parses an HTTP response from a PostApiV5TradeCancelOrderWithResponse call +func ParsePostApiV5TradeCancelOrderResponse(rsp *http.Response) (*PostApiV5TradeCancelOrderResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeCancelOrderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeClosePositionResponse parses an HTTP response from a PostApiV5TradeClosePositionWithResponse call +func ParsePostApiV5TradeClosePositionResponse(rsp *http.Response) (*PostApiV5TradeClosePositionResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeClosePositionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeFillsResponse parses an HTTP response from a GetApiV5TradeFillsWithResponse call +func ParseGetApiV5TradeFillsResponse(rsp *http.Response) (*GetApiV5TradeFillsResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeFillsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeFillsHistoryResponse parses an HTTP response from a GetApiV5TradeFillsHistoryWithResponse call +func ParseGetApiV5TradeFillsHistoryResponse(rsp *http.Response) (*GetApiV5TradeFillsHistoryResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeFillsHistoryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeOrderResponse parses an HTTP response from a GetApiV5TradeOrderWithResponse call +func ParseGetApiV5TradeOrderResponse(rsp *http.Response) (*GetApiV5TradeOrderResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeOrderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeOrderResponse parses an HTTP response from a PostApiV5TradeOrderWithResponse call +func ParsePostApiV5TradeOrderResponse(rsp *http.Response) (*PostApiV5TradeOrderResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeOrderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostApiV5TradeOrderAlgoResponse parses an HTTP response from a PostApiV5TradeOrderAlgoWithResponse call +func ParsePostApiV5TradeOrderAlgoResponse(rsp *http.Response) (*PostApiV5TradeOrderAlgoResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostApiV5TradeOrderAlgoResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AdditionalProperties map[string]map[string]interface{} `json:"-"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeOrdersAlgoHistoryResponse parses an HTTP response from a GetApiV5TradeOrdersAlgoHistoryWithResponse call +func ParseGetApiV5TradeOrdersAlgoHistoryResponse(rsp *http.Response) (*GetApiV5TradeOrdersAlgoHistoryResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeOrdersAlgoHistoryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeOrdersAlgoPendingResponse parses an HTTP response from a GetApiV5TradeOrdersAlgoPendingWithResponse call +func ParseGetApiV5TradeOrdersAlgoPendingResponse(rsp *http.Response) (*GetApiV5TradeOrdersAlgoPendingResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeOrdersAlgoPendingResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeOrdersHistoryResponse parses an HTTP response from a GetApiV5TradeOrdersHistoryWithResponse call +func ParseGetApiV5TradeOrdersHistoryResponse(rsp *http.Response) (*GetApiV5TradeOrdersHistoryResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeOrdersHistoryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeOrdersHistoryArchiveResponse parses an HTTP response from a GetApiV5TradeOrdersHistoryArchiveWithResponse call +func ParseGetApiV5TradeOrdersHistoryArchiveResponse(rsp *http.Response) (*GetApiV5TradeOrdersHistoryArchiveResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeOrdersHistoryArchiveResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetApiV5TradeOrdersPendingResponse parses an HTTP response from a GetApiV5TradeOrdersPendingWithResponse call +func ParseGetApiV5TradeOrdersPendingResponse(rsp *http.Response) (*GetApiV5TradeOrdersPendingResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiV5TradeOrdersPendingResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "H4sIAAAAAAAC/+w9W1PbSLp/hdKepymT+BIY4I1JZvZQtXNCTZjdh91ULGxBtBGWRxIkzBRVhgQwwcYk", + "XGMgCTnckiyYzOSAsZ3hx6CW7Cf/hVPdLcmSLIFsTBISPWFJ3a3v6+9+afEbEWIHomyEigg80fEbwYfu", + "UgMk+nmdjIQoppPpZ29yYYqDt6IcG6U4gabQAJLpZ7vC8FeY4kMcHRVoNkJ0EOB4HKy//deg1xsI9XLo", + "LyXvLsoLm2B7XppaBsmFrhuEhxCGoxTRQfACR0f6iREPQUd4wemCYm4bzI123SgXEmBrrFxIB7/rud78", + "860bPcHqpUc8BEf9MkhzVJjo+Kf6Ho+KwW1tAtv7byokQFgw9t+RQuiuDfoh5iYXtgQ3lSnFpozggr1X", + "UvywOPkG7KXFo6ni3iu0C6ZBu0tSJlkuxEEiB+ITYGMb7KfAxLNyYUrMzkgL+2B3SU4/kvOPwGwcIp7K", + "iPlNaTkj5zJ47klsVM5l8EgxO19aOAa5reLWKFjd8TUH/OKHpHg0XVp6fxIb+6gE8BCs871SN6dcSDSh", + "aeBpQtlscDxeWs+LhZdiNiZm35QLieL0JrrcwJdifhNNEbM5MZu3RNOaGap5YARtSB9bDfRfmsQPx/L8", + "TjHzXlqeafpXpElBQIE/swkevyg+/CDNbILU/8rzO1L8sLQaA+Nx+Vm+9GyiXEjgRyD1Riyki5lD6d2Y", + "tLMuTb+QZzLg1UO83FVlPePuGK++6SY5coASKI7/pqm09kpaOxazu/LYEZjMB3u44SZaaGIHhaCUmCo9", + "3SsXEnJhsfjnE/xKkBqTFvbhTTz++wdUaFCglMEg9aQUG8UjT2Jj3/xE8VE2wlP6F0kvNuXVaTxGzs9J", + "z1dPYmNGCCEBaIGBO/vT97d6mjq7uwgPMURxPN5M3xUv4o8oFSGjNNFBBK54r/gIDxElhbtI0K6SUfrq", + "UMtVgSPD1FVygIqEm3uhYDazUDLRmCjLC/AvFFASkgkyG9HN8kJnlP57Sw+c2glnViSaJzAjULzwHRse", + "RiLNRgQqghYio1GGDqGlrv6bh5D+RlAPyIEoxOSfv2miQqhcT3iICHX/1q9EB4HhVzi+IgNnTfJbTLrt", + "UVTyV6F/Qg+Ym5EfSJqpRqq09txKCwX7SIanguVCWswmIXqPd6SnGyC50BQUuEH0wHAXfJjDuIvHe9L8", + "Edh4V3y/KS0dQE2S2cSPpOUMmN0qrcaKW6Pa5NJ87CQ2VsovF/c2xGxOeW8FiV6WZSgycsFaNELd737g", + "jOIYQTn9SFrcF/OH0suCzYKQ+2pdUFrYL02myoUEmg+eJhBgYjYJUhkwm5CWDsRsTn6dO4mNgcyRmJsp", + "PdwB8QkpPivmNvAu4x3HC4HcPEiMg9m34PB3PAbft2GTz8eWIA1iBYsNu2JboIkh3lIxNy3mDzAPfFoJ", + "rMU0VgZCQUM3FPsAd8Pv9TpQqBXVRobDNHxEMt0GJVfll2k6GC4ehs+8hIcIkwKJ1LKmFFWcqlSqRrLK", + "Df56ZSX+R76f6CCQum7cYrc9xIC6rtVmGplHis+Cxy8QOfjBgQGSG4Y3p45Kkymos5ILkHJkPw9phCwb", + "cRuOtbKTrOa7OjWQ2Nut2zTWY+RcG+faONfGuTbOtXE12rhPa5Acm6J6grWLjNNYLtyDUWboAVqAseYD", + "GIl6vWiPaLRdvYPD8AJbLS8M6ITwj3gnQyR/1zaes1vcb7+4v3rx0+K+0LBjWRSP14qZ0dLkE5AdlbeT", + "mgaGsJpG5sdLsTF5fkfMzYDkAh6vTZd21kEhJWan5fQjML4j5uektZfS2gRWPZZmzs5y20DqJshUvnGy", + "Nt4e+V0ePJ+uyriA7JiYP0TmJx0cILl7lBA0jig9m62MQGxqGgBSb8BoeoC8R3HKKCizd9gIM2weOb5T", + "erijGLT4ovx2GiT/AKlF6SAOp/Wx90wT8Ag8ARwd4KFg6rX44RmcQLOhoCU6KHV8xmQ2KtADJHMHoXQH", + "LlUuxHWcvQGmfj+JjUr7WTm/Wy5MWdEhyvK3kJA6Mb1SYhTKwuIRmH1ignp1B6QSYPaJMkQVIExNaHmz", + "82J+HC8qTb9uCjJspD/YJMUXm4L8XZYTLLkk6tAzwtuFfSJ7QVdofxIb1dEXXkGywb9wCzGXyelH9sLO", + "UeHBEHUzwjjXTNgBhXw2mRLzc+VCAjuzeANUjzeBnVHl+hSNlR0F2VFrnaTzWnlrwtoKGCbsSWxMPNqH", + "/NU7OBxsAslF+JunGMaSRPyvzl6BSYSdQKt1BLLf8W4q4L6clHf/vEiVifkWa02kMtvO0piqXXOmMTek", + "ZUVUbOwYfogUBc8ypECFYfhTis2K+bmmcmElGOJYnq/WUWJ+rrT23GIZaG7RErqnlnj0C9drMLyaDtZT", + "Ge4zEiYrtIvvt0F2FHEZyVN3QiGzpi3urYv5w8qwXwZZwWpctVzYCa5dWUyhmSIvFdOEePtyesrsPYG/", + "T0ZbdR6zzx+41tLa1m7jIisC2MjkDVT/zjzmEKo+NpPhIfijmWT6WYPnbHolCt3BxD549w7zGzRySwel", + "pffg8Utp7aG8O1V6uyzntvVlWC1ElTIp6T/r0moMbKQV8UcL+rxi9o2pcEt4TvXalZoxBrsTQX0e512t", + "MFeCmWqPG/rhjsad4lJ/wZXsz1c4q4l2YZEqYmc7CahFHp3IoZWMxcVsUsn+OJZSde7UhYjox5DN5lv/", + "6Ox2KqDKYIOU0gI1gPb7vziqj+gg/nK10q1yVWlVuWruU6mwCclx5LArAsOnsGYNzF9PFsfcRXMhuRwn", + "VfZT6+o1sJmuIegS8ZmTQtZ5imAXXPNCZY0aOLWmohem67mqXogmPkS6CuiJKbRNGvBDJDNoWx8zs+eI", + "h/BXradQonpFCxJZ+D8jX1edze1l+2IK9hdoFJ0qFoblqeYoy9N4PYeqBc7qVic1sqSOnSUPMdAfUcsG", + "HMtD66qlLwmGPaO2bpXOsC6KWhcRgkhATmJjdvUCrVigT8+Boz/gHSSFFye3aIMshVfbMkcvMCIEcUUI", + "ocwRyjSVCys4+2TISV1kYjm5UJ1VLhdQWJBNgvW3YOKZtLuh9XbiDCqIFYIRSgjinZKer+KBSMuMY92L", + "76BR5mJAwvKNTViDVb9SS21rqyrZbQjm0R9gI91ULiSULDe+J7/OOQ92VRK6RduaVZ6YnxM/JJXs5PgO", + "OPrDifrroxkGYd1PWSi9v1I6nfcDGuoholpfMkLfCBqWW6tcaPBW980exBNIZZge/tj501+7/qfyGGsU", + "8wpQ8suFNK7ygNm4nNsyDfnh556ff/r+FmqpQUUhy1E3u3u6bqK3SasvpLWHhI7IBIQT+VlEB/HLIMUN", + "Ex4iQg7AR5BPlXypkRf1uriK1au0AgJJejkppx9JiUksWWBrTFVxQZu3DzKotOz8RUYlWq1B7VBEoljD", + "e1RXyGZJLBO1rYgb53c3um6IR9NgCrqb0sp7aWkb7tnCvpTcKxemoBWKT5TW/w9MjIO9I6ifCi/hzVhB", + "zOZA5gjk5pVO/fSjYC/NMF1hO7zJPgGFCfUDOTujALm4f1FA9lJ9LEfVCOXxPFh5jlv4MVy49wlbD5/X", + "K62t27xObXOwf9vtc+rgM1Qr3g2ig/D5fD5C13pA9PpakdBSIaUl40fCQ/RRFNbCfRSFSjroN80w3Q+I", + "DqK9vV25RA2LAYtYqtnv9Qb87coTZWVFpeiUe8Dn97e2t7W2BFpaA99e8yJYTO6ZqSFEqTh4CKR21SoF", + "vObhz5b2b73+1kBbwNvWgmLzrxTzBtjB4swhSC0qbQvLM3J+olyIF4+fiNkpsPFaaQ1wZBab79K8wHLD", + "NZjH/1ZmuFbStZKulXStpGslXSt52aykmH0jrcYdGkotIX+2gVQT8Q4so6qMmwzZ2orx0eXXT9XO5zA/", + "uvTu+bK7jVP3pvZ7W0uiSsEnVElkKPSDKkjwATnUj2QM/g710AhMI1N7iBApUP3I3YJyEFLlUy/TZ8qw", + "Vy/B6oXyPm/tAs1QQ5C7Cb/X1F10rcW6HzzCEB1Ei5W0RysqhqN6SUHBAv/WEDE2kUPMEVroooej+/sp", + "Trsh4EUYeohSO84DBk2i9p2ruUui0uuGnkd1ywtR0/IVPQRxH7SkWeMUkXqqaV0azVioHY+jpHzDK33Y", + "ycYt1VqH11nVvgacP6iuEWJIcHKvVkhwn7jl630IrOq3B4xvx70reB/KhbjWUFwuTOGOA+fAaHPP3Brr", + "fbl2KmR97L06YOpj79UJTcup0NBsqA5oaDZUFzQj7rkS91yJe67EPVfinitxz5W450rccyXuuZLLfK7E", + "+YkSlIJBDexOu5dQoNQJJzQyWMLdK7uv5JW4tPtKSr4oF+IhNqLSxZkrrLY/Vfxh3RJnZtGqnWN97KvF", + "u9CvvuKtinqV21bhF7bLRtzYEFsvTmyIPRsXRg+uArAxC6B/4BxzO9RV3E3BX3FvHcSflgtxAY+vF2dl", + "Or6ne+05iWpNP1OYiI9mwJAsRPVSXH+9OCjTrfM7f0MRfwcR0PY4+uBWlKNIpDoUMlmE4OiXOtlviadF", + "rKk/XgKJc5+M1k2Z+2T0o6PkIQR6gOqKCBQ3ROKs2RcQw16KaC+oU6mollyluU3j2RCLxlVpQdM4RRjR", + "Z4uQ1sDsaBqlCBFaUXdkyrzWfTKKSs86Pte422pzsBJw6mzZBjv6J2I21+zDn1eSpraL6wl9YGmKj7UA", + "SY958DKGi4rcOo3KEmMguVB6NgviB2L+0G5X9JQOgqeJYDVdbcBR9Y3TuOZwTd7KyyvLuFQsZebFP6eh", + "F3y41njY/k5y5wPMOAQtCJ4mVKRB6k3x4Qex8BKMb+JiU6NRcMNwfRiuelxOdwLpQE1hmBqw9W3TxnZq", + "OKu4vQVST6oExoH2sdK8FUbQa+dT6G7wI2tCVwO8JnQ1vM4Ld4MyJZp34tReJBfk/8zj9Rotg26+4/PN", + "d5i91MYaRacMEq1ZL8kr8Tr0krwSP5deklfi55RvQ1RaE7p16CX9Jp0X7pqh1ruJGuxV3qhjt/KLT8x9", + "vAP1+qP0NWbheJSGq61vGJ+e72T6WYfNw/rYrtbADnprttEcduUsQzj4yCZuQ7NOC9YqbVvGVJ5NV9T5", + "O4ervuNi2iXUOYMsNGaqIJZPMTuPHW6oIMYPxGzMrgkWs2Id7WTy4wMpZm7qpvr6qJBAD6HP/YLD3+X5", + "F9JCHG4rPvSODTh8kE/hjz0gKkK2udNH0upzjC76InCD8cWdRnX0VH8FDe6fY59547vC1WbFz7glHIHo", + "doSr7ZfCIMmorXz4SsntVq5/Va6qDKtFgyZK0+OWzO96rtt/5MfQR6ncsWyi1H8SACfv/U4qJJWUtDEX", + "TWjZGIsuSpvGSU3v2uStDT1Wyhl8Q/+kMX/toKOycon6QJUbF9xaCWYmQOp3k00E8aXi+k6tfk2UioQh", + "1Wr0a7qVaRfo13zuCetP7wM10Je5tMbdteWXwpafBqFryV1LXmXJfV+2BZdW34C9hBSfPa8RryMv4R5o", + "dg80n5HTsCK60kOO6Kqk+U0jcB9xuZDWOstNAyrtxciT03eXm/+JEnsPjbHvKzc7dKjNO31Ka7jZn7To", + "Ek877jI/o5/8dB+wMTkmfSYJfxsN6xvzTtKMmk7aS4BxZTMblxZSINxOyu/yNu5zzz86u5V/W5V8Va0w", + "yDCKADpv/A0PwkVoMxqDDKTVL4N0GCk3hFAhB+IH+BNlZk4jOYEm7WZYvSBMMfQQxQ1X9I3dUUz1TKPr", + "9blen3t81tHx2Y96ehZrvEt/fhYnebB6Le7tgw8L6nH+h84/emP0EptJLnSXHqLq8BY7lZmu0+g6ja7T", + "6DqNrtPoOo2u0+g6ja7TeEmcxjq+AcXXUx10WBn8WL6J3iGtPjXztdS2PprL6bqCn9QV/ETmSG+NWn1t", + "/kCL/1qb199mtEYRlhtAFXILm6RZJK/eJOFqlmaVTjFKlv9ExVjvwmGdaoparuhPgQe8vrZAy7eBdm9L", + "eyDQ4mttO8UuGY+3Rijtk1At7fjfRmuWyWsyTQpU5/wimM/SOFkWwxxaJr1hMtCvoQUv/f/at69zjWj3", + "qlX5hrQ8VxEIPGXk9sj/BwAA///A/WQcF48AAA==", +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %s", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + var res = make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + var resolvePath = PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + var pathToFile = url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} + diff --git a/okex/def.go b/okex/def.go new file mode 100644 index 0000000..e7fd9a0 --- /dev/null +++ b/okex/def.go @@ -0,0 +1,290 @@ +package okex + +type OKEXConfig struct { + Name string + ApiKey string + SecretKey string + Passphrase string + TdMode string + IsTest bool +} + +type AlgoOrder struct { + ActualPx string `json:"actualPx"` + ActualSide string `json:"actualSide"` + ActualSz string `json:"actualSz"` + AlgoID string `json:"algoId"` + CTime string `json:"cTime"` + Ccy string `json:"ccy"` + InstID string `json:"instId"` + InstType string `json:"instType"` + Lever string `json:"lever"` + NotionalUsd string `json:"notionalUsd"` + OrdID string `json:"ordId"` + OrdPx string `json:"ordPx"` + OrdType string `json:"ordType"` + PosSide string `json:"posSide"` + ReduceOnly string `json:"reduceOnly"` + Side string `json:"side"` + SlOrdPx string `json:"slOrdPx"` + SlTriggerPx string `json:"slTriggerPx"` + State string `json:"state"` + Sz string `json:"sz"` + TdMode string `json:"tdMode"` + TgtCcy string `json:"tgtCcy"` + TpOrdPx string `json:"tpOrdPx"` + TpTriggerPx string `json:"tpTriggerPx"` + TriggerPx string `json:"triggerPx"` + TriggerTime string `json:"triggerTime"` +} + +type OrderNormal struct { + AccFillSz string `json:"accFillSz"` + AmendResult string `json:"amendResult"` + AvgPx string `json:"avgPx"` + CTime string `json:"cTime"` + Category string `json:"category"` + Ccy string `json:"ccy"` + ClOrdID string `json:"clOrdId"` + Code string `json:"code"` + ExecType string `json:"execType"` + Fee string `json:"fee"` + FeeCcy string `json:"feeCcy"` + FillFee string `json:"fillFee"` + FillFeeCcy string `json:"fillFeeCcy"` + FillNotionalUsd string `json:"fillNotionalUsd"` + FillPx string `json:"fillPx"` + FillSz string `json:"fillSz"` + FillTime string `json:"fillTime"` + InstID string `json:"instId"` + InstType string `json:"instType"` + Lever string `json:"lever"` + Msg string `json:"msg"` + NotionalUsd string `json:"notionalUsd"` + OrdID string `json:"ordId"` + OrdType string `json:"ordType"` + Pnl string `json:"pnl"` + PosSide string `json:"posSide"` + Px string `json:"px"` + Rebate string `json:"rebate"` + RebateCcy string `json:"rebateCcy"` + ReduceOnly string `json:"reduceOnly"` + ReqID string `json:"reqId"` + Side string `json:"side"` + SlOrdPx string `json:"slOrdPx"` + SlTriggerPx string `json:"slTriggerPx"` + SlTriggerPxType string `json:"slTriggerPxType"` + Source string `json:"source"` + State string `json:"state"` + Sz string `json:"sz"` + Tag string `json:"tag"` + TdMode string `json:"tdMode"` + TgtCcy string `json:"tgtCcy"` + TpOrdPx string `json:"tpOrdPx"` + TpTriggerPx string `json:"tpTriggerPx"` + TpTriggerPxType string `json:"tpTriggerPxType"` + TradeID string `json:"tradeId"` + UTime string `json:"uTime"` +} + +type CandleResp struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data [][9]string `json:"data"` +} + +type OKEXOrder struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data []struct { + ClOrdID string `json:"clOrdId"` + OrdID string `json:"ordId"` + Tag string `json:"tag"` + SCode string `json:"sCode"` + SMsg string `json:"sMsg"` + } `json:"data"` +} + +type OKEXAlgoOrder struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data []struct { + AlgoID string `json:"algoId"` + SCode string `json:"sCode"` + SMsg string `json:"sMsg"` + } `json:"data"` +} + +type InstrumentResp struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data []Instrument `json:"data"` +} + +type Instrument struct { + InstType string `json:"instType"` // 产品类型 + InstID string `json:"instId"` // 产品id, 如 BTC-USD-SWAP + Uly string `json:"uly"` // 标的指数,如 BTC-USD,仅适用于交割/永续/期权 + Category string `json:"category"` // 手续费档位,每个交易产品属于哪个档位手续费 + BaseCcy string `json:"baseCcy"` // 交易货币币种,如 BTC-USDT 中的 BTC ,仅适用于币币 + QuoteCcy string `json:"quoteCcy"` // 计价货币币种,如 BTC-USDT 中的USDT ,仅适用于币币 + SettleCcy string `json:"settleCcy"` // 盈亏结算和保证金币种,如 BTC 仅适用于交割/永续/期权 + CtVal string `json:"ctVal"` // 合约面值,仅适用于交割/永续/期权 + CtMult string `json:"ctMult"` // 合约乘数,仅适用于交割/永续/期权 + CtValCcy string `json:"ctValCcy"` // 合约面值计价币种,仅适用于交割/永续/期权 + OptType string `json:"optType"` // 期权类型,C或P 仅适用于期权 + Stk string `json:"stk"` // 行权价格,仅适用于期权 + ListTime string `json:"listTime"` // 上线日期 Unix时间戳的毫秒数格式,如 1597026383085 + ExpTime string `json:"expTime"` // 交割/行权日期,仅适用于交割 和 期权 Unix时间戳的毫秒数格式,如 1597026383085 + Lever string `json:"lever"` // 该instId支持的最大杠杆倍数,不适用于币币、期权 + TickSz string `json:"tickSz"` // 下单价格精度,如 0.0001 + LotSz string `json:"lotSz"` // 下单数量精度,如 BTC-USDT-SWAP:1 + MinSz string `json:"minSz"` // 最小下单数量 + CtType string `json:"ctType"` // linear:正向合约 inverse:反向合约 仅适用于交割/永续 + Alias string `json:"alias"` // 合约日期别名 this_week:本周 next_week:次周 quarter:季度 next_quarter:次季度 仅适用于交割 + State string `json:"state"` // 产品状态 live:交易中 suspend:暂停中 preopen:预上线settlement:资金费结算 +} + +type AccountConfig struct { + Code string `json:"code"` + Data []struct { + AcctLv string `json:"acctLv"` + AutoLoan bool `json:"autoLoan"` + CtIsoMode string `json:"ctIsoMode"` + GreeksType string `json:"greeksType"` + Level string `json:"level"` + LevelTmp string `json:"levelTmp"` + MgnIsoMode string `json:"mgnIsoMode"` + PosMode string `json:"posMode"` + SpotOffsetType string `json:"spotOffsetType"` + UID string `json:"uid"` + Label string `json:"label"` + RoleType string `json:"roleType"` + TraderInsts []any `json:"traderInsts"` + OpAuth string `json:"opAuth"` + IP string `json:"ip"` + } `json:"data"` + Msg string `json:"msg"` +} + +type AccountPosition struct { + Adl string `json:"adl"` + AvailPos string `json:"availPos"` + AvgPx string `json:"avgPx"` + CTime string `json:"cTime"` + Ccy string `json:"ccy"` + DeltaBS string `json:"deltaBS"` + DeltaPA string `json:"deltaPA"` + GammaBS string `json:"gammaBS"` + GammaPA string `json:"gammaPA"` + Imr string `json:"imr"` + InstID string `json:"instId"` + InstType string `json:"instType"` + Interest string `json:"interest"` + Last string `json:"last"` + UsdPx string `json:"usdPx"` + Lever string `json:"lever"` + Liab string `json:"liab"` + LiabCcy string `json:"liabCcy"` + LiqPx string `json:"liqPx"` + MarkPx string `json:"markPx"` + Margin string `json:"margin"` + MgnMode string `json:"mgnMode"` + MgnRatio string `json:"mgnRatio"` + Mmr string `json:"mmr"` + NotionalUsd string `json:"notionalUsd"` + OptVal string `json:"optVal"` + PTime string `json:"pTime"` + Pos string `json:"pos"` + PosCcy string `json:"posCcy"` + PosID string `json:"posId"` + PosSide string `json:"posSide"` + SpotInUseAmt string `json:"spotInUseAmt"` + SpotInUseCcy string `json:"spotInUseCcy"` + ThetaBS string `json:"thetaBS"` + ThetaPA string `json:"thetaPA"` + TradeID string `json:"tradeId"` + BizRefID string `json:"bizRefId"` + BizRefType string `json:"bizRefType"` + QuoteBal string `json:"quoteBal"` + BaseBal string `json:"baseBal"` + BaseBorrowed string `json:"baseBorrowed"` + BaseInterest string `json:"baseInterest"` + QuoteBorrowed string `json:"quoteBorrowed"` + QuoteInterest string `json:"quoteInterest"` + UTime string `json:"uTime"` + Upl string `json:"upl"` + UplRatio string `json:"uplRatio"` + VegaBS string `json:"vegaBS"` + VegaPA string `json:"vegaPA"` + CloseOrderAlgo []struct { + AlgoID string `json:"algoId"` + SlTriggerPx string `json:"slTriggerPx"` + SlTriggerPxType string `json:"slTriggerPxType"` + TpTriggerPx string `json:"tpTriggerPx"` + TpTriggerPxType string `json:"tpTriggerPxType"` + CloseFraction string `json:"closeFraction"` + } `json:"closeOrderAlgo"` +} + +type AccountPositionResp struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data []AccountPosition `json:"data"` +} + +type AccountBalance struct { + AdjEq string `json:"adjEq"` + Details []struct { + AvailBal string `json:"availBal"` + AvailEq string `json:"availEq"` + CashBal string `json:"cashBal"` + Ccy string `json:"ccy"` + CrossLiab string `json:"crossLiab"` + DisEq string `json:"disEq"` + Eq string `json:"eq"` + EqUsd string `json:"eqUsd"` + FrozenBal string `json:"frozenBal"` + Interest string `json:"interest"` + IsoEq string `json:"isoEq"` + IsoLiab string `json:"isoLiab"` + IsoUpl string `json:"isoUpl"` + Liab string `json:"liab"` + MaxLoan string `json:"maxLoan"` + MgnRatio string `json:"mgnRatio"` + NotionalLever string `json:"notionalLever"` + OrdFrozen string `json:"ordFrozen"` + Twap string `json:"twap"` + UTime string `json:"uTime"` + Upl string `json:"upl"` + UplLiab string `json:"uplLiab"` + StgyEq string `json:"stgyEq"` + SpotInUseAmt string `json:"spotInUseAmt"` + } `json:"details"` + Imr string `json:"imr"` + IsoEq string `json:"isoEq"` + MgnRatio string `json:"mgnRatio"` + Mmr string `json:"mmr"` + NotionalUsd string `json:"notionalUsd"` + OrdFroz string `json:"ordFroz"` + TotalEq string `json:"totalEq"` + UTime string `json:"uTime"` +} + +type AccountBalanceResp struct { + Code string `json:"code"` + Data []AccountBalance `json:"data"` + Msg string `json:"msg"` +} + +type CancelNormalResp struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data []OrderNormal `json:"data"` +} + +type CancelAlgoResp struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data []AlgoOrder `json:"data"` +} diff --git a/okex/docs/account.json b/okex/docs/account.json new file mode 100644 index 0000000..0c4c017 --- /dev/null +++ b/okex/docs/account.json @@ -0,0 +1,1390 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "REST API", + "version": "v5", + "description": "# 使用说明 \n 该功能接口用户需先登陆,接口只会请求模拟环境

*Parameters* 面板中点击`Try it out`按钮,编辑请求参数,点击`Execute`按钮发送请求。*Responses* 面板中查看请求结果。
" + }, + "tags": [ + { + "name": "Account", + "description": "账户" + } + ], + "paths": { + "/api/v5/account/balance": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取账户中资金余额信息", + "parameters": [ + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "adjEq": "10679688.0460531643092577", + "details": [ + { + "availBal": "", + "availEq": "9930359.9998", + "cashBal": "9930359.9998", + "ccy": "USDT", + "crossLiab": "0", + "disEq": "9439737.0772999514", + "eq": "9930359.9998", + "eqUsd": "9933041.196999946", + "frozenBal": "0", + "interest": "0", + "isoEq": "0", + "isoLiab": "0", + "isoUpl": "0", + "liab": "0", + "maxLoan": "10000", + "mgnRatio": "", + "notionalLever": "", + "ordFrozen": "0", + "twap": "0", + "uTime": "1620722938250", + "upl": "0", + "uplLiab": "0", + "stgyEq": "0" + }, + { + "availBal": "", + "availEq": "33.6799714158199414", + "cashBal": "33.2009985", + "ccy": "BTC", + "crossLiab": "0", + "disEq": "1239950.9687532129092577", + "eq": "33.771820625136023", + "eqUsd": "1239950.9687532129092577", + "frozenBal": "0.0918492093160816", + "interest": "0", + "isoEq": "0", + "isoLiab": "0", + "isoUpl": "0", + "liab": "0", + "maxLoan": "1453.92289531493594", + "mgnRatio": "", + "notionalLever": "", + "ordFrozen": "0", + "twap": "0", + "uTime": "1620722938250", + "upl": "0.570822125136023", + "uplLiab": "0", + "stgyEq": "0" + } + ], + "imr": "3372.2942371050594217", + "isoEq": "0", + "mgnRatio": "70375.35408747017", + "mmr": "134.8917694842024", + "notionalUsd": "33722.9423710505978888", + "ordFroz": "0", + "totalEq": "11172992.1657531589092577", + "uTime": "1623392334718" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/positions": { + "get": { + "tags": [ + "Account" + ], + "summary": "查看持仓信息", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`
支持多个instId查询(不超过10个),半角逗号分隔", + "schema": { + "type": "string" + } + }, + { + "name": "posId", + "in": "query", + "description": "持仓ID,支持多个posId查询(不超过20个),半角逗号分割", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "adl": "1", + "availPos": "1", + "avgPx": "2566.31", + "cTime": "1619507758793", + "ccy": "ETH", + "deltaBS": "", + "deltaPA": "", + "gammaBS": "", + "gammaPA": "", + "imr": "", + "instId": "ETH-USD-210430", + "instType": "FUTURES", + "interest": "0", + "last": "2566.22", + "lever": "10", + "liab": "", + "liabCcy": "", + "liqPx": "2352.8496681818233", + "margin": "0.0003896645377994", + "mgnMode": "isolated", + "mgnRatio": "11.731726509588816", + "mmr": "0.0000311811092368", + "notionalUsd": "2276.2546609009605", + "optVal": "", + "pTime": "1619507761462", + "pos": "1", + "posCcy": "", + "posId": "307173036051017730", + "posSide": "long", + "thetaBS": "", + "thetaPA": "", + "tradeId": "109844", + "uTime": "1619507761462", + "upl": "-0.0000009932766034", + "uplRatio": "-0.0025490556801078", + "vegaBS": "", + "vegaPA": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/account-position-risk": { + "get": { + "tags": [ + "Account" + ], + "summary": "查看账户持仓风险", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "data": [ + { + "adjEq": "174238.6793649711331679", + "balData": [ + { + "ccy": "BTC", + "disEq": "78846.7803721021362242", + "eq": "1.3863533369419636" + }, + { + "ccy": "USDT", + "disEq": "73417.2495112863300127", + "eq": "73323.395564963177146" + } + ], + "posData": [ + { + "ccy": "USDT", + "instId": "BTC-USDT-210507", + "instType": "FUTURES", + "mgnMode": "cross", + "notionalCcy": "0.98", + "notionalUsd": "55806.8814912", + "pos": "98", + "posCcy": "", + "posId": "310423695953113090", + "posSide": "net" + } + ], + "ts": "1620282889345" + } + ], + "msg": "" + } + } + } + } + } + } + } + }, + "/api/v5/account/bills": { + "get": { + "tags": [ + "Account" + ], + "summary": "账单流水查询(近七天)", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + } + }, + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + } + }, + { + "name": "mgnMode", + "in": "query", + "description": "仓位类型
`isolated`:逐仓 `cross`:全仓", + "schema": { + "type": "string" + } + }, + { + "name": "ctType", + "in": "query", + "description": "合约类型
`linear`:正向合约 `inverse`:反向合约
仅交割/永续有效", + "schema": { + "type": "string" + } + }, + { + "name": "type", + "in": "query", + "description": "账单类型
1:划转 2:交易 3:交割 4:自动换币 5:强平 6:保证金划转 7:扣息 8:资金费 9:自动减仓 10:穿仓补偿 11:系统换币 12:策略划拨", + "schema": { + "type": "string" + } + }, + { + "name": "subType", + "in": "query", + "description": "子账单类型
1:买入 2:卖出 3:开多 4:开空 5:平多 6:平空 9:扣息 11:转入 12:转出 160:手动追加保证金 161:手动减少保证金 162:自动追加保证金 114:自动换币买入 115:自动换币卖出 118:系统换币转入 119:系统换币转出 100:强减平多 101:强减平空 102:强减买入 103:强减卖出 104:强平平多 105:强平平空 106:强平买入 107:强平卖出 110:强平换币转入 111:强平换币转出 125:自动减仓平多 126:自动减仓平空 127:自动减仓买入 128:自动减仓卖出 170:到期行权 171:到期被行权 172:到期作废 112:交割平多 113:交割平空 117:交割/期权穿仓补偿 173:资金费支出 174:资金费收入 200:系统转入 201:手动转入 202:系统转出 203:手动转出", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "bal": "0.0000819307998198", + "balChg": "-664.2679586599999802", + "billId": "310394313544966151", + "ccy": "USDT", + "fee": "0", + "from": "", + "instId": "LTC-USDT", + "instType": "SPOT", + "mgnMode": "cross", + "notes": "", + "ordId": "310394313519800320", + "pnl": "0", + "posBal": "0", + "posBalChg": "0", + "subType": "2", + "sz": "664.26795866", + "to": "", + "ts": "1620275771196", + "type": "2" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/bills-archive": { + "get": { + "tags": [ + "Account" + ], + "summary": "账单流水查询(近三月)", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + } + }, + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + } + }, + { + "name": "mgnMode", + "in": "query", + "description": "仓位类型
`isolated`:逐仓 `cross`:全仓", + "schema": { + "type": "string" + } + }, + { + "name": "ctType", + "in": "query", + "description": "合约类型
`linear`:正向合约 `inverse`:反向合约
仅交割/永续有效", + "schema": { + "type": "string" + } + }, + { + "name": "type", + "in": "query", + "description": "账单类型
1:划转 2:交易 3:交割 4:自动换币 5:强平 6:保证金划转 7:扣息 8:资金费 9:自动减仓 10:穿仓补偿 11:系统换币 12:策略划拨", + "schema": { + "type": "string" + } + }, + { + "name": "subType", + "in": "query", + "description": "子账单类型
1:买入 2:卖出 3:开多 4:开空 5:平多 6:平空 9:扣息 11:转入 12:转出 160:手动追加保证金 161:手动减少保证金 162:自动追加保证金 114:自动换币买入 115:自动换币卖出 118:系统换币转入 119:系统换币转出 100:强减平多 101:强减平空 102:强减买入 103:强减卖出 104:强平平多 105:强平平空 106:强平买入 107:强平卖出 110:强平换币转入 111:强平换币转出 125:自动减仓平多 126:自动减仓平空 127:自动减仓买入 128:自动减仓卖出 170:到期行权 171:到期被行权 172:到期作废 112:交割平多 113:交割平空 117:交割/期权穿仓补偿 173:资金费支出 174:资金费收入 200:系统转入 201:手动转入 202:系统转出 203:手动转出", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "bal": "0.0000819307998198", + "balChg": "-664.2679586599999802", + "billId": "310394313544966151", + "ccy": "USDT", + "fee": "0", + "from": "", + "instId": "LTC-USDT", + "instType": "SPOT", + "mgnMode": "cross", + "notes": "", + "ordId": "310394313519800320", + "pnl": "0", + "posBal": "0", + "posBalChg": "0", + "subType": "2", + "sz": "664.26795866", + "to": "", + "ts": "1620275771196", + "type": "2" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/config": { + "get": { + "tags": [ + "Account" + ], + "summary": "查看账户配置", + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "uid": "43812", + "acctLv": "2", + "posMode": "long_short_mode", + "autoLoan": true, + "greeksType": "BS", + "level": "lv1", + "levelTmp": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/set-position-mode": { + "post": { + "tags": [ + "Account" + ], + "summary": "设置持仓模式", + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "posMode" + ], + "type": "object", + "properties": { + "posMode": { + "type": "string", + "description": "持仓方式
`long_short_mode`:双向持仓
`net_mode`:单向持仓", + "example": "long_short_mode" + } + } + }, + "examples": { + "1": { + "summary": "设置双向持仓", + "value": { + "posMode": "long_short_mode" + } + }, + "2": { + "summary": "设置单向持仓", + "value": { + "posMode": "net_mode" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "posMode": "long_short_mode" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/set-leverage": { + "post": { + "tags": [ + "Account" + ], + "summary": "设置杠杆倍数", + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "mgnMode", + "lever" + ], + "type": "object", + "properties": { + "lever": { + "type": "string", + "description": "必填
杠杆倍数" + }, + "mgnMode": { + "type": "string", + "description": "保证金模式
`isolated`:逐仓,`cross`:全仓
如果`ccy`有效传值,该参数值只能为`cross`。" + }, + "instId": { + "type": "string", + "description": "可选
产品ID:币对、合约
`instId`和`ccy`至少要传一个;如果两个都传,默认使用instId" + }, + "ccy": { + "type": "string", + "description": "可选
保证金币种,仅适用于跨币种保证金模式的全仓`币币杠杆`。" + }, + "posSide": { + "type": "string", + "description": "可选
持仓方向
`long`:双向持仓多头
`short`:双向持仓空头
`net`:单向持仓
在双向持仓且保证金模式为逐仓条件下必填,且仅可选择`long`或`short`,其他情况下非必填,默认`net`;仅适用于`交割/永续`" + } + } + }, + "examples": { + "1": { + "summary": "币对层面-设置逐仓杠杆倍数(币币杠杆)", + "value": { + "instId": "BTC-USDT", + "lever": "5", + "mgnMode": "isolated" + } + }, + "2": { + "summary": "币对层面-设置单币种保证金模式下全仓杠杆倍数(币币杠杆)", + "value": { + "instId": "BTC-USDT", + "lever": "5", + "mgnMode": "cross" + } + }, + "3": { + "summary": "币种层面-设置跨币种保证金模式下全仓杠杆倍数(币币杠杆)", + "value": { + "ccy": "BTC", + "lever": "5", + "mgnMode": "cross" + } + }, + "4": { + "summary": "合约层面-设置合约多头逐仓杠杆倍数", + "value": { + "instId": "BTC-USDT-SWAP", + "lever": "5", + "posSide": "long", + "mgnMode": "isolated" + } + }, + "5": { + "summary": "指数层面-设置合约的全仓杠杆倍数", + "value": { + "instId": "BTC-USDT-SWAP", + "lever": "5", + "mgnMode": "cross" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "lever": "30", + "mgnMode": "isolated", + "instId": "BTC-USDT-SWAP", + "posSide": "long" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/max-size": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取最大可买卖/开仓数量", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`
支持多产品ID查询(不超过5个),半角逗号分隔", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "tdMode", + "in": "query", + "description": "交易模式
`cross`:全仓 `isolated`:逐仓 `cash`:非保证金", + "schema": { + "type": "string" + }, + "required": true, + "example": "cash" + }, + { + "name": "ccy", + "in": "query", + "description": "保证金币种,仅适用于单币种保证金模式下的全仓杠杆订单", + "schema": { + "type": "string" + } + }, + { + "name": "px", + "in": "query", + "description": "委托价格
当不填委托价时会按当前最新成交价计算
当指定多个`instId`查询时,忽略该参数,按当前最新成交价计算", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "ccy": "BTC", + "instId": "BTC-USDT", + "maxBuy": "0.0500695098559788", + "maxSell": "64.4798671570072269" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/max-avail-size": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取最大可用数量", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`
支持多产品ID查询(不超过5个),半角逗号分隔", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "tdMode", + "in": "query", + "description": "交易模式
`cross`:全仓 `isolated`:逐仓 `cash`:非保证金", + "schema": { + "type": "string" + }, + "required": true, + "example": "cash" + }, + { + "name": "ccy", + "in": "query", + "description": "保证金币种,仅适用于单币种保证金模式下的全仓杠杆订单", + "schema": { + "type": "string" + } + }, + { + "name": "reduceOnly", + "in": "query", + "description": "是否为只减仓模式,仅适用于`币币杠杆`", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "availBuy": "1923.8381424923562261", + "availSell": "1.0153700035040838", + "instId": "BTC-USDT" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/position/margin-balance": { + "post": { + "tags": [ + "Account" + ], + "summary": "调整保证金", + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "instId", + "posSide", + "type" + ], + "type": "object", + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT-SWAP`", + "example": "" + }, + "posSide": { + "type": "string", + "description": "必填
持仓方向,默认值是`net`
`long`:双向持仓多头
`short`:双向持仓空头
`net`:单向持仓", + "example": "" + }, + "type": { + "type": "string", + "description": "必填
增加/减少保证金
`add`:增加 `reduce`:减少", + "example": "" + }, + "amt": { + "type": "string", + "description": "必填
增加或减少的保证金数量", + "example": "" + } + } + }, + "example": { + "instId": "BTC-USDT-SWAP", + "posSide": "long", + "type": "add", + "amt": "1" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instId": "BTC-USDT-SWAP", + "posSide": "long", + "amt": "1", + "type": "add" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/leverage-info": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取杠杆倍数", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT-SWAP`
支持多产品ID查询(不超过20个),半角逗号分隔", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT-SWAP" + }, + { + "name": "mgnMode", + "in": "query", + "description": "保证金模式
`cross`:全仓 `isolated`:逐仓", + "schema": { + "type": "string" + }, + "required": true, + "example": "cross" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instId": "BTC-USDT-SWAP", + "mgnMode": "cross", + "posSide": "long", + "lever": "10" + }, + { + "instId": "BTC-USDT-SWAP", + "mgnMode": "cross", + "posSide": "short", + "lever": "10" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/max-loan": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取交易产品最大可借", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "mgnMode", + "in": "query", + "description": "仓位类型
`cross`:全仓 `isolated`:逐仓", + "schema": { + "type": "string" + }, + "required": true, + "example": "isolated" + }, + { + "name": "mgnCcy", + "in": "query", + "description": "保证金币种,如:`BTC`
币币杠杆单币种全仓情况下必须指定保证金币种", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instId": "BTC-USDT", + "mgnMode": "isolated", + "mgnCcy": "", + "maxLoan": "0.1", + "ccy": "BTC", + "side": "sell" + }, + { + "instId": "BTC-USDT", + "mgnMode": "isolated", + "mgnCcy": "", + "maxLoan": "0.2", + "ccy": "USDT", + "side": "buy" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/trade-fee": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取当前账户交易手续费费率", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + }, + "required": true, + "example": "SPOT" + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`
仅适用于instType为币币/币币杠杆", + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD`
仅适用于`instType`为`交割`/`永续`/`期权`", + "schema": { + "type": "string" + } + }, + { + "name": "category", + "in": "query", + "description": "币种手续费类别
1:第一类币种费率 2:第二类币种费率 3:第三类币种费率 4:第四类币种费率", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "category": "1", + "delivery": "", + "exercise": "", + "instType": "SPOT", + "level": "Lv1", + "maker": "-0.0008", + "taker": "-0.001", + "ts": "1631761650229" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/interest-accrued": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取计息记录", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`", + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + }, + { + "name": "mgnMode", + "in": "query", + "description": "保证金模式
`isolated`:逐仓 `cross`:全仓", + "schema": { + "type": "string" + }, + "example": "cross" + }, + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "查询在此之前的内容,值为时间戳,Unix时间戳为毫秒数格式", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "查询在此之后的内容,值为时间戳,Unix时间戳为毫秒数格式", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instId": "BTC-USDT", + "ccy": "USDT", + "mgnMode": "cross", + "interestRate": "0.00001", + "liab": "2", + "interest": "0.02", + "ts": "1597026383085" + }, + { + "instId": "BTC-USDT", + "ccy": "USDT", + "mgnMode": "cross", + "interestRate": "0.00001", + "liab": "2", + "interest": "0.02", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/interest-rate": { + "get": { + "tags": [ + "Account" + ], + "summary": "获取用户当前杠杆借币利率", + "parameters": [ + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "ccy": "BTC", + "interestRate": "0.0001" + }, + { + "ccy": "LTC", + "interestRate": "0.0003" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/set-greeks": { + "post": { + "tags": [ + "Account" + ], + "summary": "期权希腊字母PA/BS切换", + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "greeksType" + ], + "type": "object", + "properties": { + "greeksType": { + "type": "string", + "description": "希腊字母展示方式
`PA`:币本位,`BS`:美元本位" + } + } + }, + "example": { + "greeksType": "PA" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "greeksType": "PA" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/account/max-withdrawal": { + "get": { + "tags": [ + "Account" + ], + "summary": "查看账户最大可转余额", + "parameters": [ + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + }, + "example": "BTC" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "ccy": "BTC", + "maxWd": "100" + } + ] + } + } + } + } + } + } + } + } + } +} diff --git a/okex/docs/market.json b/okex/docs/market.json new file mode 100644 index 0000000..8ea1df3 --- /dev/null +++ b/okex/docs/market.json @@ -0,0 +1,804 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "REST API", + "version": "v5", + "description": "# 使用说明 \n 接口只会请求模拟环境

*Parameters* 面板中点击`Try it out`按钮,编辑请求参数,点击`Execute`按钮发送请求。*Responses* 面板中查看请求结果。
" + }, + "tags": [ + { + "name": "Market Data", + "description": "行情数据" + } + ], + "paths": { + "/api/v5/market/tickers": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取所有产品行情信息", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数
仅适用于`交割/永续/期权`,如 `BTC-USD`", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "LTC-USD-SWAP", + "last": "9999.99", + "lastSz": "0.1", + "askPx": "9999.99", + "askSz": "11", + "bidPx": "8888.88", + "bidSz": "5", + "open24h": "9000", + "high24h": "10000", + "low24h": "8888.88", + "volCcy24h": "2222", + "vol24h": "2222", + "sodUtc0": "0.1", + "sodUtc8": "0.1", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/ticker": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取单个产品行情信息", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USD-SWAP`", + "required": true, + "schema": { + "type": "string" + }, + "example": "BTC-USD-SWAP" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "BTC-USD-SWAP", + "last": "56956.1", + "lastSz": "3", + "askPx": "56959.1", + "askSz": "10582", + "bidPx": "56959", + "bidSz": "4552", + "open24h": "55926", + "high24h": "57641.1", + "low24h": "54570.1", + "volCcy24h": "81137.755", + "vol24h": "46258703", + "ts": "1620289117764", + "sodUtc0": "55926", + "sodUtc8": "55926" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/index-tickers": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取指数行情", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "指数,如:`BTC-USD`
`instId`和`quoteCcy`必须填写一个", + "schema": { + "type": "string" + }, + "example": "BTC-USD" + }, + { + "name": "quoteCcy", + "in": "query", + "description": "指数计价单位
目前只有`USD`/`USDT`/`BTC`为计价单位的指数", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instId": "BTC-USDT", + "idxPx": "0.1", + "high24h": "0.5", + "low24h": "0.1", + "open24h": "0.1", + "sodUtc0": "0.1", + "sodUtc8": "0.1", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/books": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取产品深度", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "sz", + "in": "query", + "description": "深度档位数量
最大值可传400,即买卖深度共800条
不填写此参数,默认返回1档深度数据", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "asks": [ + [ + "41006.8", + "0.60038921", + "0", + "1" + ] + ], + "bids": [ + [ + "41006.3", + "0.30178218", + "0", + "2" + ] + ], + "ts": "1629966436396" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/candles": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取所有交易产品K线数据", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "bar", + "in": "query", + "description": "时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y]", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + [ + "1597026383085", + "3.721", + "3.743", + "3.677", + "3.708", + "8422410", + "22698348.04828491" + ], + [ + "1597026383085", + "3.731", + "3.799", + "3.494", + "3.72", + "24912403", + "67632347.24399722" + ] + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/history-candles": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取交易产品历史K线数据(仅主流币)", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "bar", + "in": "query", + "description": "时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y]", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + [ + "1597026383085", + "3.721", + "3.743", + "3.677", + "3.708", + "8422410", + "22698348.04828491" + ], + [ + "1597026383085", + "3.731", + "3.799", + "3.494", + "3.72", + "24912403", + "67632347.24399722" + ] + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/index-candles": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取指数K线数据", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "现货指数,如:`BTC-USD`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "bar", + "in": "query", + "description": "时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y]", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + [ + "1597026383085", + "3.721", + "3.743", + "3.677", + "3.708", + "8422410", + "22698348.04828491" + ], + [ + "1597026383085", + "3.731", + "3.799", + "3.494", + "3.72", + "24912403", + "67632347.24399722" + ] + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/mark-price-candles": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取标记价格K线数据", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "现货指数,如:`BTC-USD-SWAP`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USD-SWAP" + }, + { + "name": "bar", + "in": "query", + "description": "时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y]", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + [ + "1597026383085", + "3.721", + "3.743", + "3.677", + "3.708" + ], + [ + "1597026383085", + "3.731", + "3.799", + "3.494", + "3.72" + ] + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/trades": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取交易产品公共成交数据", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USDT" + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为500,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instId": "BTC-USDT", + "tradeId": "9", + "px": "0.016", + "sz": "50", + "side": "buy", + "ts": "1597026383085" + }, + { + "instId": "BTC-USDT", + "tradeId": "9", + "px": "0.016", + "sz": "50", + "side": "buy", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/platform-24-volume": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取平台24小时总成交量", + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "volUsd": "2222", + "volCny": "14220.8" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/market/open-oracle": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "Oracle上链交易数据", + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": { + "messages": [ + "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000060d98cc000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000081a06ed800000000000000000000000000000000000000000000000000000000000000006707269636573000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034254430000000000000000000000000000000000000000000000000000000000" + ], + "prices": { + "BTC": "34796.4" + }, + "signatures": [ + "0xa8124d0dd7a6cd46aafc752272d2e67b09f0abb0f759c55712cf0c100e5ed6ad25853d97fd691c47539eac08d7e7b0ce3f6d1e8f6fa15850d8099718d37af376000000000000000000000000000000000000000000000000000000000000001c" + ], + "timestamp": "1624870080" + } + } + } + } + } + } + } + } + }, + "/api/v5/market/index-components": { + "get": { + "tags": [ + "Market Data" + ], + "summary": "获取指数成分数据", + "parameters": [ + { + "name": "index", + "in": "query", + "description": "指数,如:`BTC-USDT`", + "required": true, + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": { + "components": [ + { + "symbol": "BTC/USDT", + "symPx": "52733.2", + "wgt": "0.250", + "cnvPx": "52733.2", + "exch": "OKEx" + }, + { + "symbol": "BTC/USDT", + "symPx": "52739.87000000", + "wgt": "0.250", + "cnvPx": "52739.87000000", + "exch": "Binance" + }, + { + "symbol": "BTC/USDT", + "symPx": "52729.1", + "wgt": "0.250", + "cnvPx": "52729.1", + "exch": "Huobi" + }, + { + "symbol": "BTC/USDT", + "symPx": "52739.47929397", + "wgt": "0.250", + "cnvPx": "52739.47929397", + "exch": "Poloniex" + } + ], + "last": "52735.4123234925", + "index": "BTC-USDT", + "ts": "1630985335599" + } + } + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/okex/docs/public.json b/okex/docs/public.json new file mode 100644 index 0000000..8375af2 --- /dev/null +++ b/okex/docs/public.json @@ -0,0 +1,1125 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "REST API", + "version": "1.0", + "description": "# 使用说明 \n 接口只会请求模拟环境

*Parameters* 面板中点击`Try it out`按钮,编辑请求参数,点击`Execute`按钮发送请求。*Responses* 面板中查看请求结果。
" + }, + "tags": [ + { + "name": "Public Data", + "description": "公共数据" + } + ], + "paths": { + "/api/v5/public/instruments": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取所有产品行情信息", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币;`MARGIN`:币币杠杆;`SWAP`:永续合约 `FUTURES`:交割合约;`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD`
仅适用于`交割/永续/期权`,`期权`必填", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如 `BTC-USDT`", + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "LTC-USD-SWAP", + "uly": "LTC-USD", + "category": "1", + "baseCcy": "", + "quoteCcy": "", + "settleCcy": "LTC", + "ctVal": "10", + "ctMult": "1", + "ctValCcy": "USD", + "optType": "C", + "stk": "", + "listTime": "1597026383085", + "expTime": "1597026383085", + "lever": "10", + "tickSz": "0.01", + "lotSz": "1", + "minSz": "1", + "ctType": "linear", + "alias": "this_week", + "state": "live" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/delivery-exercise-history": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取交割和行权记录", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`FUTURES`:交割合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "FUTURES" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD`
仅适用于`交割/期权`", + "schema": { + "type": "string" + }, + "required": true, + "example": "BTC-USD" + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "ts": "1597026383085", + "details": [ + { + "type": "delivery", + "instId": "BTC-USD-190927", + "px": "0.016" + } + ] + }, + { + "ts": "1597026383085", + "details": [ + { + "instId": "BTC-USD-200529-6000-C", + "type": "exercised", + "px": "0.016" + }, + { + "instId": "BTC-USD-200529-8000-C", + "type": "exercised", + "px": "0.016" + } + ] + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/open-interest": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取持仓总量", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`FUTURES`:交割合约,`SWAP`:永续合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SWAP" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD`
仅适用于`交割/永续/期权`", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USD-SWAP`
仅适用于`交割/永续/期权`", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "BTC-USDT-SWAP", + "oi": "5000", + "oiCcy": "555.55", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/funding-rate": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取永续合约当前资金费率", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT-SWAP`
仅适用于`永续`", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "data": [ + { + "fundingRate": "0.0001515", + "fundingTime": "1622822400000", + "instId": "BTC-USD-SWAP", + "instType": "SWAP", + "nextFundingRate": "0.00029", + "nextFundingTime": "1622851200000" + } + ], + "msg": "" + } + } + } + } + } + } + } + }, + "/api/v5/public/funding-rate-history": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取永续合约历史资金费率", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT-SWAP`
仅适用于`永续`", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`fundingTime`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`fundingTime`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "data": [ + { + "fundingRate": "0.0001515", + "fundingTime": "1622822400000", + "instId": "BTC-USD-SWAP", + "instType": "SWAP", + "nextFundingRate": "0.00029", + "nextFundingTime": "1622851200000" + } + ], + "msg": "" + } + } + } + } + } + } + } + }, + "/api/v5/public/price-limit": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取限价", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT-SWAP`
适用于`交割/永续/期权`", + "required": true, + "schema": { + "type": "string" + }, + "example": "BTC-USDT-SWAP" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "BTC-USDT-SWAP", + "buyLmt": "200", + "sellLmt": "300", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/opt-summary": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取期权定价", + "parameters": [ + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD-200103-5500-C`
仅适用于`期权`", + "required": true, + "schema": { + "type": "string" + }, + "example": "BTC-USD-200103-5500-C" + }, + { + "name": "expTime", + "in": "query", + "description": "合约到期日,格式为`YYMMDD`,如 `200527`", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "OPTION", + "instId": "BTC-USD-200103-5500-C", + "uly": "BTC-USD", + "delta": "0.7494223636", + "gamma": "-0.6765419039", + "theta": "-0.0000809873", + "vega": "0.0000077307", + "deltaBS": "0.7494223636", + "gammaBS": "-0.6765419039", + "thetaBS": "-0.0000809873", + "vegaBS": "0.0000077307", + "realVol": "0", + "bidVol": "", + "askVol": "1.5625", + "markVol": "0.9987", + "lever": "4.0342", + "ts": "1597026383085" + }, + { + "instType": "OPTION", + "instId": "BTC-USD-200103-6500-C", + "uly": "BTC-USD", + "delta": "0.7494223636", + "gamma": "-0.6765419039", + "theta": "-0.0000809873", + "vega": "0.0000077307", + "deltaBS": "0.7494223636", + "gammaBS": "-0.6765419039", + "thetaBS": "-0.0000809873", + "vegaBS": "0.0000077307", + "realVol": "0", + "bidVol": "", + "askVol": "1.5625", + "markVol": "0.9987", + "lever": "4.0342", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/estimated-price": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取预估交割/行权价格", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USD-200214`
适用于`交割/期权`", + "required": true, + "schema": { + "type": "string" + }, + "example": "BTC-USD-200214" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "FUTURES", + "instId": "BTC-USD-200214", + "settlePx": "200", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/discount-rate-interest-free-quota": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取免息额度和币种折算率等级", + "parameters": [ + { + "name": "ccy", + "in": "query", + "description": "币种,如:`BTC`", + "schema": { + "type": "string" + }, + "example": "BTC" + }, + { + "name": "discountLv", + "in": "query", + "description": "折算率等级
`1`:第一档,`2`:第二档,`3`:第三档,`4`:第四档,`5`:第五档", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "amt": "1", + "ccy": "LTC", + "discountInfo": [ + { + "discountRate": "0.95", + "maxAmt": "2000000", + "minAmt": "0" + }, + { + "discountRate": "0.85", + "maxAmt": "4000000", + "minAmt": "2000000" + }, + { + "discountRate": "0.5", + "maxAmt": "8000000", + "minAmt": "4000000" + }, + { + "discountRate": "0", + "maxAmt": "", + "minAmt": "8000000" + } + ], + "discountLv": "2" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/time": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取系统时间", + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/liquidation-orders": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取平台公共爆仓单信息", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "MARGIN" + }, + { + "name": "mgnMode", + "in": "query", + "description": "保证金模式
`cross`:全仓,`isolated`:逐仓", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,仅适用于`币币杠杆`", + "schema": { + "type": "string" + } + }, + { + "name": "ccy", + "in": "query", + "description": "币种,仅适用于全仓`币币杠杆`", + "schema": { + "type": "string" + } + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数
`交割/永续/期权`合约情况下,该参数必填", + "schema": { + "type": "string" + } + }, + { + "name": "alias", + "in": "query", + "description": "`this_week`:本周,`next_week`:次周,`quarter`:季度,`next_quarter`:次季度
`交割`合约情况下,该参数必填", + "schema": { + "type": "string" + } + }, + { + "name": "state", + "in": "query", + "description": "状态
`unfilled`:未成交,`filled`:已成交
默认为`unfilled`
`交割/永续`合约情况下,该参数必填", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "data": [ + { + "details": [ + { + "bkLoss": "0", + "bkPx": "", + "ccy": "USDT", + "posSide": "", + "side": "", + "sz": "989.9123170781309932", + "ts": "1629962347000" + }, + { + "bkLoss": "0", + "bkPx": "", + "ccy": "USDT", + "posSide": "", + "side": "", + "sz": "10.1066764750370217", + "ts": "1629961447000" + } + ], + "instId": "BTC-USDT", + "instType": "MARGIN", + "totalLoss": "0", + "uly": "" + } + ], + "msg": "" + } + } + } + } + } + } + } + }, + "/api/v5/public/mark-price": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取标记价格", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SWAP" + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD`", + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "BTC-USDT-SWAP", + "markPx": "200", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/position-tiers": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取衍生品仓位档位", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "MARGIN" + }, + { + "name": "tdMode", + "in": "query", + "description": "交易模式
`isolated`:逐仓,`cross`:全仓", + "schema": { + "type": "string" + }, + "required": true, + "example": "cross" + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如:`BTC-USDT`
仅适用`币币杠杆`,且必填", + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如:`BTC-USD`
仅适用于`交割/永续/期权`,且必填", + "schema": { + "type": "string" + } + }, + { + "name": "tier", + "in": "query", + "description": "指定档位", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "baseMaxLoan": "50", + "imr": "0.1", + "instId": "BTC-USDT", + "maxLever": "10", + "maxSz": "50", + "minSz": "0", + "mmr": "0.03", + "optMgnFactor": "0", + "quoteMaxLoan": "500000", + "tier": "1", + "uly": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/interest-rate-loan-quota": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取杠杆利率和借币限额", + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "data": [ + { + "basic": [ + { + "ccy": "USDT", + "quota": "300000", + "rate": "0.00024984" + } + ], + "vip": [ + { + "irDiscount": "0.7", + "loanQuotaCoef": 6, + "level": "VIP1" + }, + { + "irDiscount": "0.65", + "loanQuotaCoef": 7, + "level": "VIP2" + } + ], + "regular": [ + { + "irDiscount": "1", + "loanQuotaCoef": 1, + "level": "Lv1" + }, + { + "irDiscount": "0.95", + "loanQuotaCoef": 2, + "level": "Lv2" + } + ] + } + ], + "msg": "" + } + } + } + } + } + } + } + }, + "/api/v5/public/underlying": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取衍生品标的指数", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SWAP" + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + [ + "LTC-USDT", + "BTC-USDT", + "ETC-USDT" + ] + ] + } + } + } + } + } + } + } + }, + "/api/v5/public/insurance-fund": { + "get": { + "tags": [ + "Public Data" + ], + "summary": "获取风险准备金余额", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`MARGIN`:币币杠杆,`SWAP`:永续合约,`FUTURES`:交割合约,`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SWAP" + }, + { + "name": "type", + "in": "query", + "description": "产品类型
`liquidation_balance_deposit`:强平注入,`bankruptcy_loss`:穿仓亏损,`platform_revenue`:平台收入注入", + "schema": { + "type": "string" + } + }, + { + "name": "uly", + "in": "query", + "description": "标的指数
仅适用于`交割/永续/期权`,且必填写", + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + }, + { + "name": "ccy", + "in": "query", + "description": "币种,仅适用`币币杠杆`,且必填写", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "分页返回的结果集数量,最大为100,不填默认返回100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "data": [ + { + "details": [ + { + "amt": "0.2465", + "balance": "3228.0732", + "ccy": "BTC", + "ts": "1646726421082", + "type": "liquidation_balance_deposit" + } + ], + "total": "883110357.6581" + } + ], + "msg": "" + } + } + } + } + } + } + } + } + + }, + "components": {} +} diff --git a/okex/docs/trade.json b/okex/docs/trade.json new file mode 100644 index 0000000..b45892a --- /dev/null +++ b/okex/docs/trade.json @@ -0,0 +1,2015 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "REST API", + "version": "1.0", + "description": "# 使用说明 \n 该功能接口用户需先登陆,接口只会请求模拟环境

*Parameters* 面板中点击`Try it out`按钮,编辑请求参数,点击`Execute`按钮发送请求。*Responses* 面板中查看请求结果。
" + }, + "tags": [ + { + "name": "Trade", + "description": "交易" + } + ], + "paths": { + "/api/v5/trade/order": { + "post": { + "tags": [ + "Trade" + ], + "summary": "下单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId", + "tdMode", + "side", + "ordType", + "sz" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "tdMode": { + "type": "string", + "description": "必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金" + }, + "side": { + "type": "string", + "description": "必填
订单方向。买:`buy` 卖:`sell`" + }, + "ordType": { + "type": "string", + "description": "必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续)" + }, + "sz": { + "type": "string", + "description": "必填
委托数量" + }, + "px": { + "type": "string", + "description": "可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单" + }, + "posSide": { + "type": "string", + "description": "可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short`" + }, + "ccy": { + "type": "string", + "description": "非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单" + }, + "clOrdId": { + "type": "string", + "description": "非必填
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + }, + "tag": { + "type": "string", + "description": "非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。" + }, + "reduceOnly": { + "type": "boolean", + "description": "非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单" + }, + "tgtCcy": { + "type": "string", + "description": "非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单" + } + } + }, + "examples": { + "1": { + "summary": "币币限价下单", + "value": { + "instId": "BTC-USDT", + "tdMode": "cash", + "side": "buy", + "ordType": "limit", + "px": "1000", + "sz": "0.01" + } + }, + "2": { + "summary": "币币市价下单", + "value": { + "instId": "BTC-USDT", + "tdMode": "cash", + "side": "buy", + "ordType": "market", + "sz": "100" + } + }, + "3": { + "summary": "高级限价(post_only)委托", + "value": { + "instId": "BTC-USDT", + "ordType": "post_only", + "px": "1000", + "side": "buy", + "sz": "1", + "tdMode": "cash" + } + }, + "4": { + "summary": "高级限价(fok)委托", + "value": { + "instId": "BTC-USDT", + "ordType": "fok", + "px": "1000", + "side": "buy", + "sz": "1", + "tdMode": "cash" + } + }, + "5": { + "summary": "高级限价(ioc)委托", + "value": { + "instId": "BTC-USDT", + "ordType": "ioc", + "px": "1000", + "side": "buy", + "sz": "1", + "tdMode": "cash" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "oktswap6", + "ordId": "12345689", + "tag": "", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + }, + "get": { + "tags": [ + "Trade" + ], + "summary": "获取订单信息", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如 `BTC-USDT`", + "required": true, + "schema": { + "type": "string" + }, + "example": "BTC-USDT" + }, + { + "name": "ordId", + "in": "query", + "description": "订单ID,ordId和clOrdId必须传一个,若传两个,以ordId为主", + "schema": { + "type": "string" + } + }, + { + "name": "clOrdId", + "in": "query", + "description": "用户自定义ID", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "ccy": "", + "ordId": "123445", + "clOrdId": "b1", + "tag": "", + "px": "999", + "sz": "3", + "pnl": "5", + "ordType": "limit", + "side": "buy", + "posSide": "long", + "tdMode": "isolated", + "accFillSz": "0", + "fillPx": "0", + "tradeId": "0", + "fillSz": "0", + "fillTime": "0", + "state": "live", + "avgPx": "0", + "lever": "20", + "tpTriggerPx": "", + "tpOrdPx": "", + "slTriggerPx": "", + "slOrdPx": "", + "feeCcy": "", + "fee": "", + "rebateCcy": "", + "rebate": "", + "tgtCcy": "", + "category": "", + "uTime": "1597026383085", + "cTime": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/batch-orders": { + "post": { + "tags": [ + "Trade" + ], + "summary": "批量下单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId", + "tdMode", + "side", + "ordType", + "sz" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "tdMode": { + "type": "string", + "description": "必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金" + }, + "side": { + "type": "string", + "description": "必填
订单方向。买:`buy` 卖:`sell`" + }, + "ordType": { + "type": "string", + "description": "必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续)" + }, + "sz": { + "type": "string", + "description": "必填
委托数量" + }, + "px": { + "type": "string", + "description": "可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单" + }, + "posSide": { + "type": "string", + "description": "可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short`" + }, + "ccy": { + "type": "string", + "description": "非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单" + }, + "clOrdId": { + "type": "string", + "description": "非必填
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + }, + "tag": { + "type": "string", + "description": "非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。" + }, + "reduceOnly": { + "type": "boolean", + "description": "非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单" + }, + "tgtCcy": { + "type": "string", + "description": "非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单" + } + } + }, + "example": [ + { + "instId": "BTC-USDT", + "tdMode": "cash", + "side": "buy", + "ordType": "limit", + "px": "1000", + "sz": "0.01" + }, + { + "instId": "BTC-USDT", + "tdMode": "cash", + "side": "buy", + "ordType": "limit", + "px": "1200", + "sz": "0.02" + } + ] + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "oktswap6", + "ordId": "12345689", + "tag": "", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/cancel-order": { + "post": { + "tags": [ + "Trade" + ], + "summary": "撤单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "ordId": { + "type": "string", + "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" + }, + "clOrdId": { + "type": "string", + "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + } + } + }, + "examples": { + "1": { + "summary": "按ordId撤单", + "value": { + "ordId": "string", + "instId": "BTC-USDT" + } + }, + "2": { + "summary": "按clOrdId撤单", + "value": { + "clOrdId": "string", + "instId": "BTC-USDT" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "string", + "ordId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/cancel-batch-orders": { + "post": { + "tags": [ + "Trade" + ], + "summary": "批量撤单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items":{ + "$ref": "#/components/schemas/CancelBatchOrder" + } + }, + "example": [ + { + "ordId": "string", + "instId": "BTC-USDT" + }, + { + "ordId": "string", + "instId": "BTC-USDT" + } + ] + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "string", + "ordId": "string", + "sCode": "0", + "sMsg": "" + }, + { + "clOrdId": "string", + "ordId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/amend-order": { + "post": { + "tags": [ + "Trade" + ], + "summary": "改单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "ordId": { + "type": "string", + "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" + }, + "clOrdId": { + "type": "string", + "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + }, + "newSz": { + "type": "string", + "description": "可选
修改的新数量,newSz和newPx不可同时为空。对于部分成交订单,该数量应包含已成交数量。" + }, + "newPx": { + "type": "string", + "description": "可选
修改的新价格" + }, + "cxlOnFail": { + "type": "boolean", + "description": "非必填
`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false`" + }, + "reqId": { + "type": "string", + "description": "非必填
用户自定义修改事件ID,字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + } + } + }, + "example": { + "ordId": "string", + "newSz": "0.2", + "instId": "BTC-USDT" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "", + "ordId": "string", + "reqId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/amend-batch-orders": { + "post": { + "tags": [ + "Trade" + ], + "summary": "批量改单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "ordId": { + "type": "string", + "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" + }, + "clOrdId": { + "type": "string", + "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + }, + "newSz": { + "type": "string", + "description": "可选
修改的新数量,newSz和newPx不可同时为空。对于部分成交订单,该数量应包含已成交数量。" + }, + "newPx": { + "type": "string", + "description": "可选
修改的新价格" + }, + "cxlOnFail": { + "type": "boolean", + "description": "非必填
`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false`" + }, + "reqId": { + "type": "string", + "description": "非必填
用户自定义修改事件ID,字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + } + } + }, + "example": [ + { + "ordId": "string", + "newSz": "0.1", + "instId": "BTC-USDT" + }, + { + "ordId": "string", + "newSz": "0.2", + "instId": "BTC-USDT" + } + ] + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "string", + "ordId": "string", + "reqId": "string", + "sCode": "0", + "sMsg": "" + }, + { + "clOrdId": "string", + "ordId": "string", + "reqId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/close-position": { + "post": { + "tags": [ + "Trade" + ], + "summary": "仓位市价全平", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId", + "mgnMode" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT-SWAP`" + }, + "mgnMode": { + "type": "string", + "description": "必填
保证金模式。全仓:`cross`;逐仓:`isolated`" + }, + "posSide": { + "type": "string", + "description": "可选
持仓方向
单向持仓模式下:可不填写此参数,默认值`net`,如果填写,仅可以填写`net`
双向持仓模式下: 必须填写此参数,且仅可以填写 `long`:平多 ,`short`:平空" + }, + "ccy": { + "type": "string", + "description": "可选
保证金币种,如:`USDT`。单币种保证金模式的全仓币币杠杆平仓必填" + } + } + }, + "example": { + "instId": "BTC-USDT-SWAP", + "mgnMode": "cross", + "posSide": "long" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "clOrdId": "", + "ordId": "string", + "reqId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/orders-pending": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取未成交订单列表", + "parameters": [ + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "instType", + "in": "query", + "description": "产品类型。
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如`BTC-USD`", + "schema": { + "type": "string" + } + }, + { + "name": "ordType", + "in": "query", + "description": "订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "accFillSz": "0", + "avgPx": "", + "cTime": "1618235248028", + "category": "normal", + "ccy": "", + "clOrdId": "", + "fee": "0", + "feeCcy": "BTC", + "fillPx": "", + "fillSz": "0", + "fillTime": "", + "instId": "BTC-USDT", + "instType": "SPOT", + "lever": "5.6", + "ordId": "301835739059335168", + "ordType": "limit", + "pnl": "0", + "posSide": "net", + "px": "59200", + "rebate": "0", + "rebateCcy": "USDT", + "side": "buy", + "slOrdPx": "", + "slTriggerPx": "", + "state": "live", + "sz": "1", + "tag": "", + "tdMode": "cross", + "tgtCcy": "", + "tpOrdPx": "", + "tpTriggerPx": "", + "tradeId": "", + "uTime": "1618235248028" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/orders-history": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取历史订单记录(近七天)", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如`BTC-USD`", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "ordType", + "in": "query", + "description": "订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)", + "schema": { + "type": "string" + } + }, + { + "name": "state", + "in": "query", + "description": "订单状态
`canceled`:撤单成功
`filled`:完全成交", + "schema": { + "type": "string" + } + }, + { + "name": "category", + "in": "query", + "description": "订单种类
`twap`:TWAP自动换币
`adl`:ADL自动减仓
`full_liquidation`:强制平仓
`partial_liquidation`:强制减仓
`delivery`:交割", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "ccy": "", + "ordId": "123445", + "clOrdId": "b1", + "tag": "", + "px": "999", + "sz": "3", + "ordType": "limit", + "side": "buy", + "posSide": "long", + "tdMode": "isolated", + "accFillSz": "0", + "fillPx": "0", + "tradeId": "0", + "fillSz": "0", + "fillTime": "0", + "state": "filled", + "avgPx": "0", + "lever": "20", + "tpTriggerPx": "", + "tpOrdPx": "", + "slTriggerPx": "", + "slOrdPx": "", + "feeCcy": "", + "fee": "", + "rebateCcy": "", + "rebate": "", + "tgtCcy": "", + "pnl": "", + "category": "", + "uTime": "1597026383085", + "cTime": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/orders-history-archive": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取历史订单记录(近三个月)", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如`BTC-USD`", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "ordType", + "in": "query", + "description": "订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)", + "schema": { + "type": "string" + } + }, + { + "name": "state", + "in": "query", + "description": "订单状态
`canceled`:撤单成功
`filled`:完全成交", + "schema": { + "type": "string" + } + }, + { + "name": "category", + "in": "query", + "description": "订单种类
`twap`:TWAP自动换币
`adl`:ADL自动减仓
`full_liquidation`:强制平仓
`partial_liquidation`:强制减仓
`delivery`:交割", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "ccy": "", + "ordId": "123445", + "clOrdId": "b1", + "tag": "", + "px": "999", + "sz": "3", + "ordType": "limit", + "side": "buy", + "posSide": "long", + "tdMode": "isolated", + "accFillSz": "0", + "fillPx": "0", + "tradeId": "0", + "fillSz": "0", + "fillTime": "0", + "state": "filled", + "avgPx": "0", + "lever": "20", + "tpTriggerPx": "", + "tpOrdPx": "", + "slTriggerPx": "", + "slOrdPx": "", + "feeCcy": "", + "fee": "", + "rebateCcy": "", + "rebate": "", + "tgtCcy": "", + "pnl": "", + "category": "", + "uTime": "1597026383085", + "cTime": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/fills": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取成交明细(近三天)", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如`BTC-USD`", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "ordId", + "in": "query", + "description": "订单ID", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "tradeId": "123", + "ordId": "312269865356374016", + "clOrdId": "b16", + "billId": "1111", + "tag": "", + "fillPx": "999", + "fillSz": "3", + "side": "buy", + "posSide": "long", + "execType": "M", + "feeCcy": "", + "fee": "", + "ts": "1597026383085" + }, + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "tradeId": "123", + "ordId": "312269865356374016", + "clOrdId": "b16", + "billId": "1111", + "tag": "", + "fillPx": "999", + "fillSz": "3", + "side": "buy", + "posSide": "long", + "execType": "M", + "feeCcy": "", + "fee": "", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/fills-history": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取成交明细(近三个月)", + "parameters": [ + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "required": true, + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "uly", + "in": "query", + "description": "合约标的指数,如`BTC-USD`", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "ordId", + "in": "query", + "description": "订单ID", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`billId`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "tradeId": "123", + "ordId": "312269865356374016", + "clOrdId": "b16", + "billId": "1111", + "tag": "", + "fillPx": "999", + "fillSz": "3", + "side": "buy", + "posSide": "long", + "execType": "M", + "feeCcy": "", + "fee": "", + "ts": "1597026383085" + }, + { + "instType": "FUTURES", + "instId": "BTC-USD-200329", + "tradeId": "123", + "ordId": "312269865356374016", + "clOrdId": "b16", + "billId": "1111", + "tag": "", + "fillPx": "999", + "fillSz": "3", + "side": "buy", + "posSide": "long", + "execType": "M", + "feeCcy": "", + "fee": "", + "ts": "1597026383085" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/order-algo": { + "post": { + "tags": [ + "Trade" + ], + "summary": "策略委托下单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId", + "tdMode", + "side", + "ordType", + "sz" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "tdMode": { + "type": "string", + "description": "必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金" + }, + "side": { + "type": "string", + "description": "必填
订单方向。买:`buy` 卖:`sell`" + }, + "ordType": { + "type": "string", + "description": "必填
订单类型。
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托" + }, + "sz": { + "type": "string", + "description": "必填
委托数量" + }, + "posSide": { + "type": "string", + "description": "可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short`" + }, + "ccy": { + "type": "string", + "description": "非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单" + }, + "reduceOnly": { + "type": "boolean", + "description": "非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单" + }, + "tgtCcy": { + "type": "string", + "description": "非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单" + }, + "tpTriggerPx": { + "type": "string", + "description": "非必填
止盈触发价,如果填写此参数,必须填写止盈委托价
适用于`止盈止损委托`" + }, + "tpOrdPx": { + "type": "string", + "description": "非必填
止盈委托价,如果填写此参数,必须填写止盈触发价
委托价格为-1时,执行市价止盈
适用于`止盈止损委托`" + }, + "slTriggerPx": { + "type": "string", + "description": "非必填
止损触发价,如果填写此参数,必须填写止损委托价
适用于`止盈止损委托`" + }, + "slOrdPx": { + "type": "string", + "description": "非必填
止损委托价,如果填写此参数,必须填写止损触发价
委托价格为-1时,执行市价止损
适用于`止盈止损委托`" + }, + "triggerPx": { + "type": "string", + "description": "非必填
计划委托触发价格
适用于`计划委托`" + }, + "orderPx": { + "type": "string", + "description": "非必填
委托价格
委托价格为-1时,执行市价委托
适用于`计划委托`" + }, + "pxVar": { + "type": "string", + "description": "非必填
距离盘口的比例
pxVar和pxSpread只能传入一个
适用于`冰山委托`和`时间加权委托`" + }, + "pxSpread": { + "type": "string", + "description": "非必填
距离盘口的比例价距
适用于`冰山委托`和`时间加权委托`" + }, + "szLimit": { + "type": "string", + "description": "非必填
单笔数量
适用于`冰山委托`和`时间加权委托`" + }, + "pxLimit": { + "type": "string", + "description": "非必填
挂单限制价
适用于`冰山委托`和`时间加权委托`" + }, + "timeInterval": { + "type": "string", + "description": "非必填
挂单限制价
适用于`时间加权委托`" + } + } + }, + "examples": { + "1": { + "summary": "单向止盈止损(conditional)委托", + "value": { + "instId": "BTC-USDT-SWAP", + "ordType": "conditional", + "posSide": "long", + "side": "buy", + "sz": "1", + "tdMode": "isolated", + "tpOrdPx": "1000.0", + "tpTriggerPx": "1000.0" + } + }, + "2": { + "summary": "双向止盈止损(oco)委托", + "value": { + "instId": "BTC-USDT-SWAP", + "ordType": "oco", + "posSide": "long", + "side": "buy", + "sz": "1", + "tdMode": "isolated", + "tpOrdPx": "10000.0", + "tpTriggerPx": "10000.0", + "slOrdPx": "100000.0", + "slTriggerPx": "100000.0" + } + }, + "3": { + "summary": "计划(trigger)委托", + "value": { + "instId": "BTC-USDT-SWAP", + "ordType": "trigger", + "orderPx": "1000", + "posSide": "long", + "side": "buy", + "sz": "1", + "tdMode": "isolated", + "triggerPx": "1000.0" + } + }, + "4": { + "summary": "冰山(iceberg)委托", + "value": { + "instId": "BTC-USDT-SWAP", + "ordType": "iceberg", + "side": "buy", + "posSide": "long", + "pxLimit": "30000.0", + "pxSpread": "10.0", + "sz": "10", + "szLimit": "2", + "tdMode": "isolated" + } + }, + "5": { + "summary": "时间加权(twap)委托", + "value": { + "instId": "BTC-USDT-SWAP", + "ordType": "twap", + "side": "buy", + "posSide": "long", + "pxLimit": "30000.0", + "pxSpread": "10.0", + "sz": "10", + "szLimit": "2", + "tdMode": "isolated", + "timeInterval": "5" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "algoId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/cancel-algos": { + "post": { + "tags": [ + "Trade" + ], + "summary": "撤销策略委托订单", + "description": "撤销策略委托订单(不包含冰山委托、时间加权等高级策略订单),每次最多可以撤销10个策略委托单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CancelAlgoOrder" + } + }, + "example": [ + { + "algoId": "string", + "instId": "BTC-USDT-SWAP" + }, + { + "algoId": "string", + "instId": "BTC-USDT-SWAP" + } + ] + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "algoId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/cancel-advance-algos": { + "post": { + "tags": [ + "Trade" + ], + "summary": "撤销高级策略委托订单", + "description": "撤销冰山委托、时间加权等高级策略委托订单,每次最多可以撤销10个策略委托单", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "instId", + "algoId" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "algoId": { + "type": "string", + "description": "必填
策略委托单ID" + } + } + }, + "example": [ + { + "algoId": "string", + "instId": "BTC-USDT" + }, + { + "algoId": "string", + "instId": "BTC-USDT" + } + ] + } + }, + "required": true + }, + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": {} + }, + "example": { + "code": "0", + "msg": "", + "data": [ + { + "algoId": "string", + "sCode": "0", + "sMsg": "" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/orders-algo-pending": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取未完成策略委托单列表", + "parameters": [ + { + "name": "ordType", + "in": "query", + "description": "订单类型
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托", + "schema": { + "type": "string" + }, + "required": true, + "example": "conditional" + }, + { + "name": "algoId", + "in": "query", + "description": "策略委托单ID", + "schema": { + "type": "string" + } + }, + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + } + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "BTC-USDT-SWAP", + "ordId": "string", + "ccy": "BTC", + "algoId": "string", + "sz": "10", + "ordType": "oco", + "side": "buy", + "posSide": "long", + "tdMode": "cross", + "tgtCcy": "", + "state": "1", + "lever": "20", + "tpTriggerPx": "", + "tpOrdPx": "", + "slTriggerPx": "", + "triggerPx": "99", + "ordPx": "12", + "actualSz": "", + "actualPx": "", + "actualSide": "", + "pxVar": "", + "pxSpread": "", + "pxLimit": "", + "szLimit": "", + "timeInterval": "", + "triggerTime": "1597026383085", + "cTime": "1597026383000" + } + ] + } + } + } + } + } + } + } + }, + "/api/v5/trade/orders-algo-history": { + "get": { + "tags": [ + "Trade" + ], + "summary": "获取历史策略委托单列表", + "parameters": [ + { + "name": "ordType", + "in": "query", + "description": "订单类型
`conditional`:单向止盈止损,`oco`:双向止盈止损,`trigger`:计划委托,`iceberg`:冰山委托,`twap`:时间加权委托", + "schema": { + "type": "string" + }, + "required": true, + "example": "conditional" + }, + { + "name": "algoId", + "in": "query", + "description": "策略委托单ID
`state`和`algoId`必填且只能填其一", + "schema": { + "type": "string" + } + }, + { + "name": "state", + "in": "query", + "description": "订单状态
`effective`:已生效,`canceled`:已经撤销,`order_failed`:委托失败
`state`和`algoId`必填且只能填其一", + "schema": { + "type": "string" + } + }, + { + "name": "instType", + "in": "query", + "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", + "schema": { + "type": "string" + }, + "example": "SPOT" + }, + { + "name": "instId", + "in": "query", + "description": "产品ID,如`BTC-USDT-SWAP`", + "schema": { + "type": "string" + } + }, + { + "name": "after", + "in": "query", + "description": "请求此ID之前(更旧的数据)的分页内容,传的值为对应接口的ordId", + "schema": { + "type": "string" + } + }, + { + "name": "before", + "in": "query", + "description": "请求此ID之后(更新的数据)的分页内容,传的值为对应接口的`ordId`", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "description": "返回结果的数量,默认100条", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "成功", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "code": "0", + "msg": "", + "data": [ + { + "instType": "SWAP", + "instId": "BTC-USDT-SWAP", + "ordId": "string", + "ccy": "BTC", + "algoId": "string", + "sz": "10", + "ordType": "oco", + "side": "buy", + "posSide": "long", + "tdMode": "cross", + "tgtCcy": "", + "state": "effective", + "lever": "20", + "tpTriggerPx": "", + "tpOrdPx": "", + "slTriggerPx": "", + "triggerPx": "99", + "ordPx": "12", + "actualSz": "", + "actualPx": "", + "actualSide": "", + "pxVar": "", + "pxSpread": "", + "pxLimit": "", + "szLimit": "", + "timeInterval": "", + "triggerTime": "1597026383085", + "cTime": "1597026383000" + } + ] + } + } + } + } + } + } + } + } + }, + "components": { + "schemas":{ + "CancelBatchOrder":{ + "type": "object", + "required": [ + "instId" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "ordId": { + "type": "string", + "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" + }, + "clOrdId": { + "type": "string", + "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" + } + } + }, + "CancelAlgoOrder": { + "type": "object", + "required": [ + "instId", + "algoId" + ], + "properties": { + "instId": { + "type": "string", + "description": "必填
产品ID,如:`BTC-USDT`" + }, + "algoId": { + "type": "string", + "description": "必填
策略委托单ID" + } + } + } + } + } + } +} diff --git a/okex/gen.sh b/okex/gen.sh new file mode 100644 index 0000000..7771806 --- /dev/null +++ b/okex/gen.sh @@ -0,0 +1,4 @@ +oapi-codegen -package trade -alias-types -generate types,client,spec docs/trade.json > api/trade/trade.gen.go +oapi-codegen -package account -alias-types -generate types,client,spec docs/account.json > api/account/account.gen.go +oapi-codegen -package market -alias-types -generate types,client,spec docs/market.json > api/market/market.gen.go +oapi-codegen -package public -alias-types -generate types,client,spec docs/public.json > api/public/public.gen.go diff --git a/okex/okex.go b/okex/okex.go new file mode 100644 index 0000000..eb9f4b5 --- /dev/null +++ b/okex/okex.go @@ -0,0 +1,849 @@ +package okex + +import ( + "bytes" + "context" + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "sort" + "strconv" + "strings" + "sync" + "time" + + "git.qtrade.icu/coin-quant/exchange" + "git.qtrade.icu/coin-quant/exchange/okex/api/account" + "git.qtrade.icu/coin-quant/exchange/okex/api/market" + "git.qtrade.icu/coin-quant/exchange/okex/api/public" + "git.qtrade.icu/coin-quant/exchange/okex/api/trade" + "git.qtrade.icu/coin-quant/exchange/ws" + . "git.qtrade.icu/coin-quant/trademodel" + "github.com/gorilla/websocket" + log "github.com/sirupsen/logrus" +) + +var ( + background = context.Background() + + ApiAddr = "https://www.okx.com/" + WSOkexPUbilc = "wss://wsaws.okx.com:8443/ws/v5/public" + WSOkexPrivate = "wss://wsaws.okx.com:8443/ws/v5/private" + + TypeSPOT = "SPOT" //币币 + TypeMARGIN = "MARGIN" // 币币杠杆 + TypeSWAP = "SWAP" //永续合约 + TypeFUTURES = "FUTURES" //交割合约 + TypeOption = "OPTION" //期权 + + PosNetMode = "net_mode" + PosLongShortMode = "long_short_mode" +) + +var _ exchange.Exchange = &OkxTrader{} + +func init() { + exchange.RegisterExchange("okx", NewOkexExchange) +} + +type OkxTrader struct { + Name string + tradeApi *trade.ClientWithResponses + marketApi *market.ClientWithResponses + publicApi *public.ClientWithResponses + accountApi *account.ClientWithResponses + + tradeCb exchange.WatchFn + positionCb exchange.WatchFn + balanceCb exchange.WatchFn + depthCb exchange.WatchFn + tradeMarketCb exchange.WatchFn + klineCb exchange.WatchFn + + closeCh chan bool + + cfg *OKEXConfig + + klineLimit int + wsUser *ws.WSConn + wsPublic *ws.WSConn + + ordersCache sync.Map + stopOrdersCache sync.Map + + posMode string + + watchPublics []OPParam + + instType string + timeout time.Duration + symbols map[string]Symbol +} + +func NewOkexExchange(cfg exchange.Config, cltName string) (e exchange.Exchange, err error) { + b, err := NewOkxTrader(cfg, cltName) + if err != nil { + return + } + e = b + return +} + +func NewOkxTrader(cfg exchange.Config, cltName string) (b *OkxTrader, err error) { + b = new(OkxTrader) + b.Name = "okx" + b.instType = "SWAP" + if cltName == "" { + cltName = "okx" + } + b.symbols = make(map[string]Symbol) + b.klineLimit = 100 + b.timeout = time.Second * 10 + var okxCfg OKEXConfig + err = cfg.UnmarshalKey(fmt.Sprintf("exchanges.%s", cltName), &okxCfg) + if err != nil { + return nil, err + } + b.cfg = &okxCfg + + // isDebug := cfg.GetBool(fmt.Sprintf("exchanges.%s.debug", cltName)) + if b.cfg.TdMode == "" { + b.cfg.TdMode = "isolated" + } + log.Infof("okex %s, tdMode: %s, isTest: %t", cltName, b.cfg.TdMode, b.cfg.IsTest) + + b.closeCh = make(chan bool) + + b.tradeApi, err = trade.NewClientWithResponses(ApiAddr) + if err != nil { + return + } + b.marketApi, err = market.NewClientWithResponses(ApiAddr) + if err != nil { + return + } + b.publicApi, err = public.NewClientWithResponses(ApiAddr) + if err != nil { + return + } + b.accountApi, err = account.NewClientWithResponses(ApiAddr) + if err != nil { + return + } + clientProxy := cfg.GetString("proxy") + if clientProxy != "" { + var proxyURL *url.URL + proxyURL, err = url.Parse(clientProxy) + if err != nil { + return + } + clt := b.tradeApi.ClientInterface.(*trade.Client).Client.(*http.Client) + *clt = http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} + clt = b.marketApi.ClientInterface.(*market.Client).Client.(*http.Client) + *clt = http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} + clt = b.publicApi.ClientInterface.(*public.Client).Client.(*http.Client) + *clt = http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} + clt = b.accountApi.ClientInterface.(*account.Client).Client.(*http.Client) + *clt = http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} + websocket.DefaultDialer.Proxy = http.ProxyURL(proxyURL) + websocket.DefaultDialer.HandshakeTimeout = time.Second * 60 + } + _, err = b.Symbols() + if err != nil { + return nil, err + } + if b.cfg.ApiKey != "" { + err = b.getAccountConfig() + } + return +} + +func (b *OkxTrader) Info() exchange.ExchangeInfo { + info := exchange.ExchangeInfo{ + Name: "okx", + Value: "okx", + Desc: "okx api", + KLineLimit: exchange.FetchLimit{ + Limit: b.klineLimit, + }, + } + return info +} + +func (b *OkxTrader) SetInstType(instType string) { + b.instType = instType +} + +func (b *OkxTrader) auth(ctx context.Context, req *http.Request) (err error) { + var temp []byte + if req.Method != "GET" { + temp, err = io.ReadAll(req.Body) + if err != nil { + return + } + req.Body.Close() + buf := bytes.NewBuffer(temp) + req.Body = io.NopCloser(buf) + } else { + if req.URL.RawQuery != "" { + temp = []byte(fmt.Sprintf("?%s", req.URL.RawQuery)) + } + } + var signStr string + tmStr := time.Now().UTC().Format("2006-01-02T15:04:05.000Z") + signStr = fmt.Sprintf("%s%s%s%s", tmStr, req.Method, req.URL.Path, string(temp)) + h := hmac.New(sha256.New, []byte(b.cfg.SecretKey)) + h.Write([]byte(signStr)) + ret := h.Sum(nil) + n := base64.StdEncoding.EncodedLen(len(ret)) + dst := make([]byte, n) + base64.StdEncoding.Encode(dst, ret) + sign := string(dst) + + req.Header.Set("Content-Type", "application/json") + req.Header.Set("OK-ACCESS-KEY", b.cfg.ApiKey) + req.Header.Set("OK-ACCESS-SIGN", sign) + + req.Header.Set("OK-ACCESS-TIMESTAMP", tmStr) + req.Header.Set("OK-ACCESS-PASSPHRASE", b.cfg.Passphrase) + return +} + +func (b *OkxTrader) Start() (err error) { + fmt.Println("start okx") + err = b.runPublic() + if err != nil { + return + } + err = b.runPrivate() + if err != nil { + return + } + fmt.Println("start okx finished") + return +} +func (b *OkxTrader) Stop() (err error) { + b.wsPublic.Close() + b.wsUser.Close() + close(b.closeCh) + return +} + +func (b *OkxTrader) customReq(ctx context.Context, req *http.Request) error { + if b.cfg.IsTest { + req.Header.Set("x-simulated-trading", "1") + } + return nil +} +func (b *OkxTrader) getAccountConfig() (err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + resp, err := b.accountApi.GetApiV5AccountConfigWithResponse(ctx, b.auth, b.customReq) + if err != nil { + return err + } + var accountCfg AccountConfig + err = json.Unmarshal(resp.Body, &accountCfg) + if err != nil { + return err + } + if accountCfg.Code != "0" { + err = fmt.Errorf("[%s]%s", accountCfg.Code, accountCfg.Msg) + return + } + // long_short_mode:双向持仓 net_mode:单向持仓 + // 仅适用交割/永续 + b.posMode = accountCfg.Data[0].PosMode + log.Infof("posMode: %s", b.posMode) + if b.posMode != PosNetMode { + log.Warnf("account posmode is %s, stop order will failed if no position", b.posMode) + } + return nil +} + +// KlineChan get klines +func (b *OkxTrader) GetKline(symbol, bSize string, start, end time.Time) (data []*Candle, err error) { + // fmt.Println("GetKline:", symbol, bSize, start, end) + + nStart := start.Unix() * 1000 + nEnd := end.UnixMilli() + tempEnd := nEnd + var resp *market.GetApiV5MarketHistoryCandlesResponse + var startStr, endStr string + + ctx, cancel := context.WithTimeout(background, time.Second*3) + startStr = strconv.FormatInt(nStart, 10) + tempEnd = nStart + 100*60*1000 + if tempEnd > nEnd { + tempEnd = nEnd + } + endStr = strconv.FormatInt(tempEnd, 10) + var params = market.GetApiV5MarketHistoryCandlesParams{InstId: symbol, Bar: &bSize, Before: &startStr, After: &endStr} + resp, err = b.marketApi.GetApiV5MarketHistoryCandlesWithResponse(ctx, ¶ms, b.customReq) + cancel() + if err != nil { + return + } + data, err = parseCandles(resp) + if err != nil { + if strings.Contains(err.Error(), "Requests too frequent.") { + err = fmt.Errorf("requests too frequent %w", exchange.ErrRetry) + } + return + } + sort.Slice(data, func(i, j int) bool { + return data[i].Start < data[j].Start + }) + + return +} + +func (b *OkxTrader) Watch(param exchange.WatchParam, fn exchange.WatchFn) (err error) { + symbol := param.Param["symbol"] + log.Info("okex watch:", param) + switch param.Type { + case exchange.WatchTypeCandle: + var p = OPParam{ + OP: "subscribe", + Args: []interface{}{ + OPArg{Channel: "candle1m", InstType: b.instType, InstID: symbol}, + }, + } + b.klineCb = fn + b.watchPublics = append(b.watchPublics, p) + err = b.wsPublic.WriteMsg(p) + case exchange.WatchTypeDepth: + var p = OPParam{ + OP: "subscribe", + Args: []interface{}{ + OPArg{Channel: "books5", InstType: b.instType, InstID: symbol}, + }, + } + b.depthCb = fn + b.watchPublics = append(b.watchPublics, p) + err = b.wsPublic.WriteMsg(p) + case exchange.WatchTypeTradeMarket: + var p = OPParam{ + OP: "subscribe", + Args: []interface{}{ + OPArg{Channel: "trades", InstType: b.instType, InstID: symbol}, + }, + } + b.tradeMarketCb = fn + b.watchPublics = append(b.watchPublics, p) + err = b.wsPublic.WriteMsg(p) + case exchange.WatchTypeTrade: + b.tradeCb = fn + case exchange.WatchTypePosition: + b.positionCb = fn + err = b.fetchBalanceAndPosition() + case exchange.WatchTypeBalance: + b.balanceCb = fn + err = b.fetchBalanceAndPosition() + default: + err = fmt.Errorf("unknown wath param: %s", param.Type) + } + return +} +func (b *OkxTrader) fetchBalanceAndPosition() (err error) { + err = b.fetchBalance() + if err != nil { + return err + } + err = b.fetchPosition() + return +} + +func (b *OkxTrader) fetchPosition() (err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + var params = account.GetApiV5AccountPositionsParams{InstType: &b.instType} + resp, err := b.accountApi.GetApiV5AccountPositionsWithResponse(ctx, ¶ms, b.auth, b.customReq) + if err != nil { + return err + } + if b.positionCb == nil { + return + } + var data AccountPositionResp + err = json.Unmarshal(resp.Body, &data) + if err != nil { + return err + } + for _, v := range data.Data { + var pos Position + pos.Hold = parseFloat(v.Pos) + pos.Price = parseFloat(v.AvgPx) + pos.Symbol = v.InstID + if pos.Hold > 0 { + pos.Type = Long + } else { + pos.Type = Short + } + pos.ProfitRatio = parseFloat(v.UplRatio) + if pos.Hold == 0 { + log.Warnf("fetch position return 0: %s", string(resp.Body)) + continue + } + b.positionCb(&pos) + } + + return +} + +func (b *OkxTrader) fetchBalance() (err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + var ccy = "USDT" + var param = account.GetApiV5AccountBalanceParams{Ccy: &ccy} + resp, err := b.accountApi.GetApiV5AccountBalanceWithResponse(ctx, ¶m, b.auth, b.customReq) + if err != nil { + return err + } + if b.balanceCb == nil { + return + } + var balance AccountBalanceResp + err = json.Unmarshal(resp.Body, &balance) + if err != nil { + return err + } + for _, v := range balance.Data { + for _, d := range v.Details { + if d.Ccy == ccy { + var bal Balance + bal.Available = parseFloat(d.AvailBal) + bal.Balance = parseFloat(d.CashBal) + bal.Currency = ccy + bal.Frozen = parseFloat(d.OrdFrozen) + b.balanceCb(&bal) + break + } + } + } + return +} + +func (b *OkxTrader) processStopOrder(act TradeAction) (ret *Order, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + var side, posSide string + // open: side = posSide, close: side!=posSide + if act.Action.IsLong() { + side = "buy" + posSide = "short" + } else { + side = "sell" + posSide = "long" + } + reduceOnly := true + var orderPx = "-1" + triggerPx := fmt.Sprintf("%f", act.Price) + // PostApiV5TradeOrderAlgoJSONBody defines parameters for PostApiV5TradeOrderAlgo. + params := trade.PostApiV5TradeOrderAlgoJSONBody{ + // 非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单 + // Ccy *string `json:"ccy,omitempty"` + + // 必填
产品ID,如:`BTC-USDT` + InstId: act.Symbol, + + // 必填
订单类型。
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托 + OrdType: "conditional", + + // 非必填
委托价格
委托价格为-1时,执行市价委托
适用于`计划委托` + OrderPx: &orderPx, + + // 可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short` + PosSide: &posSide, + + // 非必填
挂单限制价
适用于`冰山委托`和`时间加权委托` + // PxLimit *string `json:"pxLimit,omitempty"` + + // 非必填
距离盘口的比例价距
适用于`冰山委托`和`时间加权委托` + // PxSpread *string `json:"pxSpread,omitempty"` + + // 非必填
距离盘口的比例
pxVar和pxSpread只能传入一个
适用于`冰山委托`和`时间加权委托` + // PxVar *string `json:"pxVar,omitempty"` + + // 非必填
是否只减仓,`true` 或 `false`,默认`false` + // 仅适用于币币杠杆,以及买卖模式下的交割/永续 + ReduceOnly: &reduceOnly, + + // 必填
订单方向。买:`buy` 卖:`sell` + Side: side, + + // 非必填
止损委托价,如果填写此参数,必须填写止损触发价
委托价格为-1时,执行市价止损
适用于`止盈止损委托` + SlOrdPx: &orderPx, + + // 非必填
止损触发价,如果填写此参数,必须填写止损委托价
适用于`止盈止损委托` + SlTriggerPx: &triggerPx, + + // 必填
委托数量 + Sz: fmt.Sprintf("%d", int(act.Amount)), + + // 非必填
单笔数量
适用于`冰山委托`和`时间加权委托` + // SzLimit *string `json:"szLimit,omitempty"` + + // 必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金 + TdMode: b.cfg.TdMode, + + // 非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单 + // TgtCcy *string `json:"tgtCcy,omitempty"` + + // 非必填
挂单限制价
适用于`时间加权委托` + // TimeInterval *string `json:"timeInterval,omitempty"` + + // 非必填
止盈委托价,如果填写此参数,必须填写止盈触发价
委托价格为-1时,执行市价止盈
适用于`止盈止损委托` + // TpOrdPx , + + // 非必填
止盈触发价,如果填写此参数,必须填写止盈委托价
适用于`止盈止损委托` + // TpTriggerPx *string `json:"tpTriggerPx,omitempty"` + + // 非必填
计划委托触发价格
适用于`计划委托` + // TriggerPx *string `json:"triggerPx,omitempty"` + } + if b.posMode == PosNetMode { + params.PosSide = nil + } + resp, err := b.tradeApi.PostApiV5TradeOrderAlgoWithResponse(ctx, params, b.auth, b.customReq) + if err != nil { + return + } + + orders, err := parsePostAlgoOrders(act.Symbol, "open", side, act.Price, act.Amount, resp.Body) + if err != nil { + return + } + if len(orders) != 1 { + err = fmt.Errorf("orders len not match: %#v", orders) + log.Warnf(err.Error()) + return + } + ret = orders[0] + ret.Remark = "stop" + return +} +func (b *OkxTrader) CancelOrder(old *Order) (order *Order, err error) { + _, ok := b.ordersCache.Load(old.OrderID) + if ok { + order, err = b.cancelNormalOrder(old) + if err != nil { + return + } + b.ordersCache.Delete(old.OrderID) + } + _, ok = b.stopOrdersCache.Load(old.OrderID) + if ok { + order, err = b.cancelAlgoOrder(old) + b.stopOrdersCache.Delete(old.OrderID) + } + return +} + +func (b *OkxTrader) cancelNormalOrder(old *Order) (order *Order, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + + var body trade.PostApiV5TradeCancelOrderJSONRequestBody + body.InstId = old.Symbol + body.OrdId = &old.OrderID + + cancelResp, err := b.tradeApi.PostApiV5TradeCancelOrderWithResponse(ctx, body, b.auth, b.customReq) + if err != nil { + return + } + temp := OKEXOrder{} + err = json.Unmarshal(cancelResp.Body, &temp) + if err != nil { + return + } + if temp.Code != "0" { + err = errors.New(string(cancelResp.Body)) + } + order = old + if len(temp.Data) > 0 { + order.OrderID = temp.Data[0].OrdID + } + return +} + +func (b *OkxTrader) cancelAlgoOrder(old *Order) (order *Order, err error) { + ctx, cancel := context.WithTimeout(background, time.Second*2) + defer cancel() + + var body = make(trade.PostApiV5TradeCancelAlgosJSONBody, 1) + body[0] = trade.CancelAlgoOrder{AlgoId: old.OrderID, InstId: old.Symbol} + + cancelResp, err := b.tradeApi.PostApiV5TradeCancelAlgosWithResponse(ctx, body, b.auth, b.customReq) + if err != nil { + return + } + temp := OKEXAlgoOrder{} + err = json.Unmarshal(cancelResp.Body, &temp) + if err != nil { + return + } + if temp.Code != "0" { + err = errors.New(string(cancelResp.Body)) + } + order = old + if len(temp.Data) > 0 { + order.OrderID = temp.Data[0].AlgoID + } + return +} + +func (b *OkxTrader) ProcessOrder(act TradeAction) (ret *Order, err error) { + symbol, ok := b.symbols[act.Symbol] + if ok { + price := symbol.FixPrice(act.Price) + if price != act.Price { + log.Infof("okx change order price form %f to %f", act.Price, price) + act.Price = price + } + } + if act.Action.IsStop() { + // if no position: + // stopOrder will fail when posMode = long_short_mode + // stopOrder will success when posMode =net_mode + ret, err = b.processStopOrder(act) + if err != nil { + return + } + b.stopOrdersCache.Store(ret.OrderID, ret) + return + } + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + var side, posSide, px string + if act.Action.IsLong() { + side = "buy" + if act.Action.IsOpen() { + posSide = "long" + } else { + posSide = "short" + } + } else { + side = "sell" + if act.Action.IsOpen() { + posSide = "short" + } else { + posSide = "long" + } + } + ordType := "limit" + tag := "trade" + px = fmt.Sprintf("%f", act.Price) + params := trade.PostApiV5TradeOrderJSONRequestBody{ + //ClOrdId *string `json:"clOrdId,omitempty"` + // 必填
产品ID,如:`BTC-USDT` + InstId: act.Symbol, + // 必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续) + OrdType: ordType, + + // 可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short` + PosSide: &posSide, + + // 可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单 + Px: &px, + + // 非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单 + // ReduceOnly: &reduceOnly, + // 必填
订单方向。买:`buy` 卖:`sell` + Side: side, + // 必填
委托数量 + Sz: fmt.Sprintf("%d", int(act.Amount)), + // 非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。 + Tag: &tag, + // 必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金 + TdMode: b.cfg.TdMode, + // 非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单 + // TgtCcy *string `json:"tgtCcy,omitempty"` + } + if b.posMode == PosNetMode { + params.PosSide = nil + } + resp, err := b.tradeApi.PostApiV5TradeOrderWithResponse(ctx, params, b.auth, b.customReq) + if err != nil { + return + } + orders, err := parsePostOrders(act.Symbol, "open", side, act.Price, act.Amount, resp.Body) + if err != nil { + return + } + if len(orders) != 1 { + err = fmt.Errorf("orders len not match: %#v", orders) + log.Warnf(err.Error()) + return + } + ret = orders[0] + b.ordersCache.Store(ret.OrderID, ret) + return +} + +func (b *OkxTrader) cancelAllNormal() (orders []*Order, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + instType := b.instType + var params = trade.GetApiV5TradeOrdersPendingParams{ + // InstId: &b.symbol, + InstType: &instType, + } + resp, err := b.tradeApi.GetApiV5TradeOrdersPendingWithResponse(ctx, ¶ms, b.auth, b.customReq) + if err != nil { + return + } + var orderResp CancelNormalResp + err = json.Unmarshal(resp.Body, &orderResp) + if err != nil { + return + } + if orderResp.Code != "0" { + err = errors.New(string(resp.Body)) + return + } + if len(orderResp.Data) == 0 { + return + } + + var body trade.PostApiV5TradeCancelBatchOrdersJSONRequestBody + for _, v := range orderResp.Data { + temp := v.OrdID + body = append(body, trade.CancelBatchOrder{ + InstId: v.InstID, + OrdId: &temp, + }) + } + + cancelResp, err := b.tradeApi.PostApiV5TradeCancelBatchOrdersWithResponse(ctx, body, b.auth, b.customReq) + if err != nil { + return + } + temp := OKEXOrder{} + err = json.Unmarshal(cancelResp.Body, &temp) + if err != nil { + return + } + if temp.Code != "0" { + err = errors.New(string(cancelResp.Body)) + } + return +} + +func (b *OkxTrader) cancelAllAlgo() (orders []*Order, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + instType := b.instType + var params = trade.GetApiV5TradeOrdersAlgoPendingParams{ + OrdType: "conditional", + // InstId: &b.symbol, + InstType: &instType, + } + resp, err := b.tradeApi.GetApiV5TradeOrdersAlgoPendingWithResponse(ctx, ¶ms, b.auth, b.customReq) + if err != nil { + return + } + var orderResp CancelAlgoResp + err = json.Unmarshal(resp.Body, &orderResp) + if err != nil { + return + } + if orderResp.Code != "0" { + err = errors.New(string(resp.Body)) + return + } + if len(orderResp.Data) == 0 { + return + } + + var body trade.PostApiV5TradeCancelAlgosJSONRequestBody + for _, v := range orderResp.Data { + body = append(body, trade.CancelAlgoOrder{ + InstId: v.InstID, + AlgoId: v.AlgoID, + }) + } + + cancelResp, err := b.tradeApi.PostApiV5TradeCancelAlgosWithResponse(ctx, body, b.auth, b.customReq) + if err != nil { + return + } + temp := OKEXAlgoOrder{} + err = json.Unmarshal(cancelResp.Body, &temp) + if err != nil { + return + } + if temp.Code != "0" { + err = errors.New(string(cancelResp.Body)) + } + return +} +func (b *OkxTrader) CancelAllOrders() (orders []*Order, err error) { + temp, err := b.cancelAllNormal() + if err != nil { + return + } + orders, err = b.cancelAllAlgo() + if err != nil { + return + } + orders = append(temp, orders...) + return +} + +func (b *OkxTrader) Symbols() (symbols []Symbol, err error) { + ctx, cancel := context.WithTimeout(background, b.timeout) + defer cancel() + resp, err := b.publicApi.GetApiV5PublicInstrumentsWithResponse(ctx, &public.GetApiV5PublicInstrumentsParams{InstType: b.instType}, b.customReq) + if err != nil { + return + } + var instruments InstrumentResp + err = json.Unmarshal(resp.Body, &instruments) + if instruments.Code != "0" { + err = errors.New(string(resp.Body)) + return + } + var value, amountPrecision float64 + symbols = make([]Symbol, len(instruments.Data)) + for i, v := range instruments.Data { + value, err = strconv.ParseFloat(v.TickSz, 64) + if err != nil { + return + } + amountPrecision, err = strconv.ParseFloat(v.LotSz, 64) + if err != nil { + return + } + symbolInfo := Symbol{ + Name: v.InstID, + Exchange: "okx", + Symbol: v.InstID, + Resolutions: "1m,5m,15m,30m,1h,4h,1d,1w", + Precision: int(float64(1) / value), + AmountPrecision: int(float64(1) / amountPrecision), + PriceStep: value, + AmountStep: 0, + } + value, err = strconv.ParseFloat(v.MinSz, 64) + if err != nil { + return + } + symbolInfo.AmountStep = value + symbols[i] = symbolInfo + } + if len(symbols) > 0 { + symbolMap := make(map[string]Symbol) + for _, v := range symbols { + symbolMap[v.Symbol] = v + } + b.symbols = symbolMap + } + return +} diff --git a/okex/okex_test.go b/okex/okex_test.go new file mode 100644 index 0000000..8fad6f9 --- /dev/null +++ b/okex/okex_test.go @@ -0,0 +1,156 @@ +package okex + +import ( + "fmt" + "testing" + "time" + + "git.qtrade.icu/coin-quant/exchange" + "git.qtrade.icu/coin-quant/trademodel" + log "github.com/sirupsen/logrus" + "github.com/spf13/viper" +) + +var ( + testClt *OkxTrader +) + +func getTestClt() *OkxTrader { + cfgPath := "../test/test.yaml" + cfg := viper.New() + cfg.SetConfigFile(cfgPath) + err := cfg.ReadInConfig() + if err != nil { + log.Fatal("ReadInConfig failed:" + err.Error()) + } + testClt, err = NewOkxTrader(exchange.WrapViper(cfg), "okx") + if err != nil { + log.Fatal("create client failed:" + err.Error()) + } + testClt.Start() + return testClt +} + +func TestMain(m *testing.M) { + testClt = getTestClt() + m.Run() +} + +func TestSymbols(t *testing.T) { + symbols, err := testClt.Symbols() + if err != nil { + t.Fatal(err.Error()) + } + for _, v := range symbols { + t.Log(v.Symbol, v.Precision, v.PriceStep, v.AmountPrecision, v.AmountStep) + } +} + +func TestKline(t *testing.T) { + // start, _ := time.Parse("2006-01-02 15:04:05", "2023-01-01 00:00:00") + start := time.Now().Add(time.Minute * -5) + end := start.Add(time.Hour + time.Second) + datas, err := testClt.GetKline("BTC-USDT-SWAP", "1m", start, end) + if err != nil { + t.Fatal(err) + } + for _, v := range datas { + t.Log(v) + } + if len(datas) != 60 { + t.Fatal("Kline resp not match:", len(datas)) + } +} + +func TestOrder(t *testing.T) { + order, err := testClt.ProcessOrder(trademodel.TradeAction{ + Symbol: "APT-USDT-SWAP", + Action: trademodel.OpenShort, + Amount: 1, + Price: 20, + Time: time.Now(), + }) + if err != nil { + t.Fatal(err.Error()) + } + t.Log(*order) + time.Sleep(time.Second) + _, err = testClt.CancelAllOrders() + if err != nil { + t.Fatal(err.Error()) + } +} + +func TestStopOrder(t *testing.T) { + order, err := testClt.ProcessOrder(trademodel.TradeAction{ + Symbol: "APT-USDT-SWAP", + Action: trademodel.StopShort, + Amount: 1, + Price: 17, + Time: time.Now(), + }) + if err != nil { + t.Fatal(err.Error()) + } + t.Log(*order) + time.Sleep(time.Second) + _, err = testClt.CancelAllOrders() + if err != nil { + t.Fatal(err.Error()) + } +} + +func TestCancelAllOrder(t *testing.T) { + _, err := testClt.CancelAllOrders() + if err != nil { + t.Fatal(err.Error()) + } +} + +func TestCancelOrder(t *testing.T) { + act := trademodel.TradeAction{ + Action: trademodel.OpenLong, + Amount: 1, + Price: 2000, + Time: time.Now(), + } + order, err := testClt.ProcessOrder(act) + if err != nil { + t.Fatal(err.Error()) + } + t.Log(*order) + time.Sleep(time.Second * 5) + ret, err := testClt.CancelOrder(order) + if err != nil { + t.Fatal(err.Error()) + } + t.Log("ret:", *ret) +} + +func TestCancelStopOrder(t *testing.T) { + act := trademodel.TradeAction{ + Action: trademodel.StopLong, + Amount: 1, + Price: 2000, + Time: time.Now(), + } + order, err := testClt.ProcessOrder(act) + if err != nil { + t.Fatal(err.Error()) + } + t.Log(*order) + time.Sleep(time.Second * 5) + ret, err := testClt.CancelOrder(order) + if err != nil { + t.Fatal(err.Error()) + } + t.Log("ret:", *ret) +} + +func TestDepth(t *testing.T) { + param := exchange.WatchParam{Type: exchange.WatchTypeDepth, Param: map[string]string{"symbol": "ETH-USDT-SWAP", "name": "depth"}} + testClt.Watch(param, func(data interface{}) { + fmt.Println(data) + }) + time.Sleep(time.Second * 10) +} diff --git a/okex/okex_ws.go b/okex/okex_ws.go new file mode 100644 index 0000000..9e2f152 --- /dev/null +++ b/okex/okex_ws.go @@ -0,0 +1,359 @@ +package okex + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "errors" + "fmt" + "github.com/bitly/go-simplejson" + "strconv" + "time" + + "git.qtrade.icu/coin-quant/exchange/ws" + . "git.qtrade.icu/coin-quant/trademodel" + "github.com/mitchellh/mapstructure" + log "github.com/sirupsen/logrus" +) + +func (b *OkxTrader) runPrivate() (err error) { + b.wsUser, err = ws.NewWSConn(WSOkexPrivate, func(ws *ws.WSConn) error { + login := OPParam{ + OP: "login", + Args: []interface{}{NewLoginArg(b.cfg.ApiKey, b.cfg.Passphrase, b.cfg.SecretKey)}, + } + return ws.WriteMsg(login) + }, b.parseUserMsg) + return +} + +type LoginArg struct { + ApiKey string `json:"apiKey"` + Passphrase string `json:"passphrase"` + Timestamp int64 `json:"timestamp"` + Sign string `json:"sign"` +} + +func NewLoginArg(apiKey, pass, secret string) *LoginArg { + a := new(LoginArg) + a.ApiKey = apiKey + a.Passphrase = pass + t := time.Now() + a.Timestamp = t.Unix() + src := fmt.Sprintf("%dGET/users/self/verify", a.Timestamp) + h := hmac.New(sha256.New, []byte(secret)) + h.Write([]byte(src)) + ret := h.Sum(nil) + n := base64.StdEncoding.EncodedLen(len(ret)) + dst := make([]byte, n) + base64.StdEncoding.Encode(dst, ret) + a.Sign = string(dst) + return a +} + +type OPArg struct { + Channel string `json:"channel"` + InstType string `json:"instType"` + Uly string `json:"uly,omitempty"` + InstID string `json:"instId,omitempty"` +} + +type OPParam struct { + OP string `json:"op"` + Args []interface{} `json:"args"` +} + +func (b *OkxTrader) getSymbolSub() (p OPParam) { + p.OP = "subscribe" + p.Args = append(p.Args, OPArg{Channel: "orders", InstType: "ANY"}) + p.Args = append(p.Args, OPArg{Channel: "orders-algo", InstType: "ANY"}) + p.Args = append(p.Args, OPArg{Channel: "algo-advance", InstType: "ANY"}) + p.Args = append(p.Args, OPArg{Channel: "positions", InstType: "ANY"}) + return +} + +// {"arg":{"channel":"trades","instId":"BSV-USD-210924"},"data":[{"instId":"BSV-USD-210924","tradeId":"1957771","px":"166.5","sz":"22","side":"sell","ts":"1621862533713"}]} +// {"arg":{"channel":"books","instId":"BSV-USD-210924"},"action":"update","data":[{"asks":[["167.4","54","0","1"]],"bids":[["164.81","0","0","0"],["164.69","79","0","1"]],"ts":"1621862579059","checksum":71082836}]} +// books5 {"arg":{"channel":"books5","instId":"BSV-USD-210924"},"data":[{"asks":[["166.35","20","0","1"],["166.4","135","0","2"],["166.42","86","0","1"],["166.45","310","0","1"],["166.46","61","0","2"]],"bids":[["166.14","33","0","1"],["166.07","106","0","1"],["166.05","2","0","1"],["166.04","97","0","1"],["165.98","20","0","1"]],"instId":"BSV-USD-210924","ts":"1621862688397"}]} + +func (b *OkxTrader) parseUserMsg(message []byte) (err error) { + var sj *simplejson.Json + var evt string + var channel string + + sj, err = simplejson.NewJson(message) + if err != nil { + log.Warnf("parse json error:%s", string(message)) + return + } + evtValue, ok := sj.CheckGet("event") + if ok { + evt, err = evtValue.String() + if err != nil { + log.Warnf("login error:%s %s", string(message), err.Error()) + return + } + switch evt { + case "error": + log.Errorf("recv error: %s", string(message)) + return + case "login": + var code string + code, err = sj.Get("code").String() + if code != "0" { + log.Warnf("login error:%s %s", string(message), err.Error()) + return + } + param := b.getSymbolSub() + err = b.wsUser.WriteMsg(param) + if err != nil { + return + } + default: + } + return + } + arg, ok := sj.CheckGet("arg") + if !ok { + return + } + channelValue, ok := arg.CheckGet("channel") + if !ok { + return + } + channel, err = channelValue.String() + if err != nil { + log.Warnf("channelValue %v is not string error:%s", channelValue, err.Error()) + return + } + switch channel { + case "orders": + var orders []OrderNormal + orders, err = parseOkexOrder(sj.Get("data")) + if err != nil { + log.Warnf("parseOkexOrder error:%s, %s", orders, err.Error()) + return + } + for _, v := range orders { + o := v.GetOrder() + if o == nil { + continue + } + o.Status = OrderStatusFilled + b.ordersCache.Delete(v.OrdID) + b.stopOrdersCache.Delete(v.OrdID) + if b.tradeCb != nil { + b.tradeCb(o) + } + } + + case "orders-algo": + // 算法单最终还是会生成一个普通单子 + var algoOrders []AlgoOrder + algoOrders, err = parseOkexAlgoOrder(sj.Get("data")) + if err != nil { + log.Warnf("parseOkexAlgoOrder error:%s, %s", algoOrders, err.Error()) + return + } + for _, v := range algoOrders { + if v.State == "filled" { + b.stopOrdersCache.Delete(v.AlgoID) + } + } + case "algo-advance": + case "positions": + var pos []OKEXPos + pos, err = parseOkexPos(sj.Get("data")) + if err != nil { + log.Warnf("parseOkexPos error:%s, %s", pos, err.Error()) + return + } + for _, v := range pos { + t := v.GetPos() + if t == nil { + continue + } + if b.positionCb != nil { + b.positionCb(t) + } + } + default: + } + return +} + +func (o *OrderNormal) GetOrder() (ret *Order) { + if o.State != "filled" { + return + } + var side = transSide(o.Side) + ret = &Order{ + OrderID: o.OrdID, + Symbol: o.InstID, + // Currency:o. + Amount: parseFloat(o.Sz), + Price: parseFloat(o.AvgPx), + Status: o.State, + Side: side, + Time: parseTime(o.FillTime), + } + return +} + +func transSide(oSide string) (side string) { + switch oSide { + case "buy": + side = "long" + case "sell": + side = "short" + default: + side = oSide + } + return +} + +func parseTime(v string) time.Time { + n, err := strconv.ParseInt(v, 10, 64) + if err != nil { + log.Errorf("parseTime failed: %s", err.Error()) + return time.Now() + } + return time.Unix(n/1000, (n%1000)*int64(time.Millisecond)) +} + +// {"accFillSz":"0","amendResult":"","avgPx":"0","cTime":"1639669567849","category":"normal","ccy":"","clOrdId":"","code":"0","execType":"","fee":"0","feeCcy":"USDT","fillFee":"0","fillFeeCcy":"","fillNotionalUsd":"","fillPx":"","fillSz":"0","fillTime":"","instId":"SOL-USDT-SWAP","instType":"SWAP","lever":"10","msg":"","notionalUsd":"185.666","ordId":"391737792421838866","ordType":"limit","pnl":"0","posSide":"short","px":"200","rebate":"0","rebateCcy":"USDT","reduceOnly":"false","reqId":"","side":"sell","slOrdPx":"","slTriggerPx":"","slTriggerPxType":"last","source":"","state":"live","sz":"1","tag":"","tdMode":"isolated","tgtCcy":"","tpOrdPx":"","tpTriggerPx":"","tpTriggerPxType":"last","tradeId":"","uTime":"1639669567849"} +func parseOkexOrder(sj *simplejson.Json) (orders []OrderNormal, err error) { + arr, err := sj.Array() + if err != nil { + return + } + var ret map[string]interface{} + var ok bool + for _, v := range arr { + ret, ok = v.(map[string]interface{}) + if !ok { + err = errors.New("parseOrderBook error") + return + } + var o OrderNormal + err = mapstructure.Decode(ret, &o) + if err != nil { + return + } + orders = append(orders, o) + } + return +} + +func parseOkexPos(sj *simplejson.Json) (trades []OKEXPos, err error) { + arr, err := sj.Array() + if err != nil { + return + } + var ret map[string]interface{} + var ok bool + for _, v := range arr { + ret, ok = v.(map[string]interface{}) + if !ok { + err = errors.New("parseOkexTrades error") + return + } + var t OKEXPos + err = mapstructure.Decode(ret, &t) + if err != nil { + return + } + trades = append(trades, t) + } + return +} + +type OKEXPos struct { + Adl string `json:"adl"` + AvailPos string `json:"availPos"` + AvgPx string `json:"avgPx"` + CTime string `json:"cTime"` + Ccy string `json:"ccy"` + DeltaBS string `json:"deltaBS"` + DeltaPA string `json:"deltaPA"` + GammaBS string `json:"gammaBS"` + GammaPA string `json:"gammaPA"` + Imr string `json:"imr"` + InstID string `json:"instId"` + InstType string `json:"instType"` + Interest string `json:"interest"` + Last string `json:"last"` + Lever string `json:"lever"` + Liab string `json:"liab"` + LiabCcy string `json:"liabCcy"` + LiqPx string `json:"liqPx"` + MarkPx string `json:"markPx"` + Margin string `json:"margin"` + MgnMode string `json:"mgnMode"` + MgnRatio string `json:"mgnRatio"` + Mmr string `json:"mmr"` + NotionalUsd string `json:"notionalUsd"` + OptVal string `json:"optVal"` + PTime string `json:"pTime"` + Pos string `json:"pos"` + PosCcy string `json:"posCcy"` + PosID string `json:"posId"` + PosSide string `json:"posSide"` + ThetaBS string `json:"thetaBS"` + ThetaPA string `json:"thetaPA"` + TradeID string `json:"tradeId"` + UTime string `json:"uTime"` + Upl string `json:"upl"` + UplRatio string `json:"uplRatio"` + VegaBS string `json:"vegaBS"` + VegaPA string `json:"vegaPA"` +} + +func (ot *OKEXPos) GetPos() (pos *Position) { + var typ int + hold := parseFloat(ot.Pos) + if ot.PosSide == "long" { + typ = Long + } else if ot.PosSide == "short" { + typ = Short + hold = 0 - hold + } else if ot.PosSide == "net" { + if hold > 0 { + typ = Long + } else { + typ = Short + } + } + price := parseFloat(ot.AvgPx) + pos = &Position{ + Symbol: ot.InstID, + Type: typ, + Hold: hold, + Price: price, + ProfitRatio: parseFloat(ot.Upl), + } + return +} + +func parseOkexAlgoOrder(sj *simplejson.Json) (orders []AlgoOrder, err error) { + arr, err := sj.Array() + if err != nil { + return + } + var ret map[string]interface{} + var ok bool + for _, v := range arr { + ret, ok = v.(map[string]interface{}) + if !ok { + err = errors.New("parseOrderBook error") + return + } + var o AlgoOrder + err = mapstructure.Decode(ret, &o) + if err != nil { + return + } + orders = append(orders, o) + } + return +} diff --git a/okex/okex_ws_public.go b/okex/okex_ws_public.go new file mode 100644 index 0000000..bd739f2 --- /dev/null +++ b/okex/okex_ws_public.go @@ -0,0 +1,312 @@ +package okex + +import ( + "errors" + "fmt" + "github.com/bitly/go-simplejson" + "strconv" + "time" + + "git.qtrade.icu/coin-quant/exchange/ws" + log "github.com/sirupsen/logrus" + + . "git.qtrade.icu/coin-quant/trademodel" +) + +func (b *OkxTrader) runPublic() (err error) { + b.wsPublic, err = ws.NewWSConn(WSOkexPUbilc, func(ws *ws.WSConn) error { + // watch when reconnect + for _, v := range b.watchPublics { + err1 := ws.WriteMsg(v) + if err1 != nil { + return err1 + } + } + return nil + }, b.parsePublicMsg) + return +} +func (b *OkxTrader) parsePublicMsg(message []byte) (err error) { + sj, err := simplejson.NewJson(message) + if err != nil { + log.Warnf("parse json error:%s", string(message)) + return + } + _, ok := sj.CheckGet("event") + if ok { + return + } + arg, ok := sj.CheckGet("arg") + if !ok { + return + } + channelValue, ok := arg.CheckGet("channel") + if !ok { + return + } + symbol, err := arg.Get("instId").String() + if err != nil { + log.Warnf("okex public ws message instId not found %s, %s", string(message), err.Error()) + } + _ = symbol + channel, err := channelValue.String() + if err != nil { + log.Warnf("channelValue %v is not string error:%s", channelValue, err.Error()) + return + } + switch channel { + case "books5": + value, ok := sj.CheckGet("data") + if !ok { + return + + } + if b.depthCb == nil { + return + } + var depths5 []*Depth + depths5, err = parseOkexBooks5(value) + if err != nil { + log.Warnf("parseOkexBooks5 failed:%s, %s", string(message), err.Error()) + return + } + for _, v := range depths5 { + b.depthCb(v) + } + + case "trades": + value, ok := sj.CheckGet("data") + if !ok { + return + } + if b.tradeMarketCb == nil { + return + } + var trades []*Trade + trades, err = parseOkexTrade(value) + if err != nil { + log.Warnf("parseOkexTrade failed:%s, %s", string(message), err.Error()) + return + } + for _, v := range trades { + b.tradeMarketCb(v) + } + case "candle1m": + value, ok := sj.CheckGet("data") + if !ok { + return + } + // fmt.Println("candle1m:", string(message)) + var candles []*Candle + candles, err = parseWsCandle(value) + if err != nil { + log.Warnf("parseWsCandle failed:%s, %s", string(message), err.Error()) + return + } + if len(candles) == 0 { + return + } else if len(candles) != 1 { + log.Warnf("parseWsCandle candles len warn :%d, %v", len(candles), err) + } + if b.klineCb == nil { + return + } + b.klineCb(candles[0]) + + default: + } + return +} + +// books5 {"arg":{"channel":"books5","instId":"BSV-USD-210924"},"data":[{"asks":[["166.35","20","0","1"],["166.4","135","0","2"],["166.42","86","0","1"],["166.45","310","0","1"],["166.46","61","0","2"]],"bids":[["166.14","33","0","1"],["166.07","106","0","1"],["166.05","2","0","1"],["166.04","97","0","1"],["165.98","20","0","1"]],"instId":"BSV-USD-210924","ts":"1621862688397"}]} +func parseOkexBooks5(sj *simplejson.Json) (depths []*Depth, err error) { + arr, err := sj.Array() + if err != nil { + err = fmt.Errorf("parseOkexBooks5 not array: %w", err) + return + } + + var obj, asks, bids *simplejson.Json + var askInfo, bidInfo []DepthInfo + var tsStr string + var nTs int64 + for k := range arr { + obj = sj.GetIndex(k) + asks = obj.Get("asks") + bids = obj.Get("bids") + if asks == nil || bids == nil { + err = errors.New("data error") + return + } + askInfo, err = parseOrderBook(asks) + if err != nil { + return + } + bidInfo, err = parseOrderBook(bids) + if err != nil { + return + } + tsStr, err = obj.Get("ts").String() + if err != nil { + return + } + dp := Depth{Buys: bidInfo, Sells: askInfo} + nTs, err = strconv.ParseInt(tsStr, 10, 64) + if err != nil { + return + } + dp.UpdateTime = time.Unix(nTs/1000, (nTs%1000)*int64(time.Millisecond)) + depths = append(depths, &dp) + } + return +} + +func parseOrderBook(sj *simplejson.Json) (datas []DepthInfo, err error) { + arr, err := sj.Array() + if err != nil { + return + } + var ret []interface{} + var ok bool + for _, v := range arr { + ret, ok = v.([]interface{}) + if !ok { + err = errors.New("parseOrderBook error") + return + } + if len(ret) != 4 { + err = errors.New("parseOrderBook len error") + return + } + di := DepthInfo{Price: getFloat(ret[0]), Amount: getFloat(ret[1])} + datas = append(datas, di) + } + return +} + +func parseOkexTrade(sj *simplejson.Json) (trades []*Trade, err error) { + arr, err := sj.Array() + if err != nil { + return + } + // {"instId":"BSV-USD-210924","tradeId":"1957771","px":"166.5","sz":"22","side":"sell","ts":"1621862533713"} + var temp map[string]interface{} + var ok bool + for _, v := range arr { + temp, ok = v.(map[string]interface{}) + if !ok { + log.Warnf("data error:%#v", temp) + continue + } + var t Trade + t.Remark = getStr(temp, "instId") + t.ID = getStr(temp, "tradeId") + t.Side = getStr(temp, "side") + t.Price = getStrFloat(temp, "px") + t.Amount = getStrFloat(temp, "sz") + nTs := getStrTs(temp, "ts") + t.Time = time.Unix(nTs/1000, int64(time.Millisecond)*(nTs%1000)) + trades = append(trades, &t) + } + return +} + +func getStrTs(dict map[string]interface{}, key string) (nTs int64) { + str := getStr(dict, key) + if str == "" { + log.Warnf("getStrTs of %s empty", key) + return + } + nTs, err := strconv.ParseInt(str, 10, 64) + if err != nil { + log.Warnf("getStrTs of %s parse int err: %s", key, err.Error()) + return + } + return nTs + // t = time.Unix(nTs/1000, (nTs%1000)*int64(time.Millisecond)) + return +} + +func getStrFloat(dict map[string]interface{}, key string) float64 { + str := getStr(dict, key) + if str == "" { + log.Warnf("getStrFloat of %s empty", key) + return 0 + } + f, err := strconv.ParseFloat(str, 64) + if err != nil { + log.Warnf("getStrFloat of %s failed: %s", key, err.Error()) + return 0 + } + return f +} + +func getStr(dict map[string]interface{}, key string) string { + v, ok := dict[key] + if !ok { + log.Warnf("getStr of %s empty", key) + return "" + } + str, ok := v.(string) + if !ok { + log.Warnf("getStr of %s type error: %#v", key, v) + return "" + } + return str +} + +func getFloat(v interface{}) float64 { + str, ok := v.(string) + if !ok { + return 0 + } + f, err := strconv.ParseFloat(str, 64) + if err != nil { + log.Warnf("getFloat %#v failed: %s", v, err.Error()) + return 0 + } + return f +} + +func parseWsCandle(sj *simplejson.Json) (ret []*Candle, err error) { + arr, err := sj.Array() + if err != nil { + return + } + // {"instId":"BSV-USD-210924","tradeId":"1957771","px":"166.5","sz":"22","side":"sell","ts":"1621862533713"} + var values []interface{} + var ok bool + var nTs int64 + for _, v := range arr { + values, ok = v.([]interface{}) + if !ok { + log.Warnf("transWsCandle data error:%#v", values) + continue + } + if len(values) != 9 { + log.Warnf("transWsCandle data len error:%#v", values) + continue + } + nTs, err = strconv.ParseInt(values[0].(string), 10, 64) + if err != nil { + panic(fmt.Sprintf("trans candle error: %#v", values)) + return + } + // unfinished kline + if values[8].(string) == "0" { + continue + } + temp := Candle{ + ID: 0, + Start: nTs / 1000, + Open: parseFloat(values[1].(string)), + High: parseFloat(values[2].(string)), + Low: parseFloat(values[3].(string)), + Close: parseFloat(values[4].(string)), + Volume: parseFloat(values[5].(string)), + Turnover: parseFloat(values[7].(string)), + } + ret = append(ret, &temp) + } + return +} diff --git a/okex/tool.go b/okex/tool.go new file mode 100644 index 0000000..139f144 --- /dev/null +++ b/okex/tool.go @@ -0,0 +1,124 @@ +package okex + +import ( + "encoding/json" + "errors" + "fmt" + "git.qtrade.icu/coin-quant/exchange/okex/api/market" + . "git.qtrade.icu/coin-quant/trademodel" + "strconv" + "time" +) + +func transCandle(values [9]string) (ret *Candle) { + nTs, err := strconv.ParseInt(values[0], 10, 64) + if err != nil { + panic(fmt.Sprintf("trans candle error: %#v", values)) + return nil + } + ret = &Candle{ + ID: 0, + Start: nTs / 1000, + Open: parseFloat(values[1]), + High: parseFloat(values[2]), + Low: parseFloat(values[3]), + Close: parseFloat(values[4]), + Volume: parseFloat(values[5]), + Turnover: parseFloat(values[7]), + } + return +} + +func parseFloat(str string) float64 { + if str == "" { + return 0 + } + f, err := strconv.ParseFloat(str, 64) + if err != nil { + panic("okex parseFloat error:" + err.Error()) + } + return f +} + +func parseCandles(resp *market.GetApiV5MarketHistoryCandlesResponse) (candles []*Candle, err error) { + var candleResp CandleResp + err = json.Unmarshal(resp.Body, &candleResp) + if err != nil { + return + } + if candleResp.Code != "0" { + err = errors.New(string(resp.Body)) + return + } + for _, v := range candleResp.Data { + // unfinished candle + if v[8] == "0" { + continue + } + temp := transCandle(v) + candles = append(candles, temp) + } + return +} + +func parsePostOrders(symbol, status, side string, amount, price float64, body []byte) (ret []*Order, err error) { + temp := OKEXOrder{} + err = json.Unmarshal(body, &temp) + if err != nil { + return + } + if temp.Code != "0" { + err = fmt.Errorf("error resp: %s", string(body)) + return + } + for _, v := range temp.Data { + if v.SCode != "0" { + err = fmt.Errorf("%s %s", v.SCode, v.SMsg) + return + } + + temp := &Order{ + OrderID: v.OrdID, + Symbol: symbol, + // Currency + Side: side, + Status: status, + Price: price, + Amount: amount, + Time: time.Now(), + } + ret = append(ret, temp) + } + return +} + +func parsePostAlgoOrders(symbol, status, side string, amount, price float64, body []byte) (ret []*Order, err error) { + temp := OKEXAlgoOrder{} + err = json.Unmarshal(body, &temp) + if err != nil { + return + } + if temp.Code != "0" { + err = fmt.Errorf("error resp: %s", string(body)) + return + } + for _, v := range temp.Data { + if v.SCode != "0" { + err = fmt.Errorf("%s %s", v.SCode, v.SMsg) + return + } + + temp := &Order{ + OrderID: v.AlgoID, + Symbol: symbol, + // Currency + Side: side, + Status: status, + Price: price, + Amount: amount, + Time: time.Now(), + } + ret = append(ret, temp) + } + return +} diff --git a/pool.go b/pool.go new file mode 100644 index 0000000..7d609be --- /dev/null +++ b/pool.go @@ -0,0 +1,49 @@ +package exchange + +import ( + "fmt" + "github.com/spf13/viper" + "sync" +) + +var ( + exchangeFactory = map[string]NewExchangeFn{} + + exchangeMutex sync.Mutex + exchanges = map[string]Exchange{} +) + +type NewExchangeFn func(cfg Config, cltName string) (t Exchange, err error) + +func RegisterExchange(name string, fn NewExchangeFn) { + exchangeFactory[name] = fn +} + +func NewExchange(name string, cfg Config, cltName string) (ex Exchange, err error) { + exchangeMutex.Lock() + defer exchangeMutex.Unlock() + if cfg.GetBool("share_exchange") { + v, ok := exchanges[cltName] + if ok { + ex = v + return + } + defer func() { + if err == nil { + exchanges[cltName] = ex + } + }() + } + fn, ok := exchangeFactory[name] + if !ok { + err = fmt.Errorf("no such exchange %s", name) + return + } + ex, err = fn(cfg, cltName) + return +} + +func NewExchangeViper(name, cltName string) (ex Exchange, err error) { + cfg := WrapViper(viper.GetViper()) + return NewExchange(name, cfg, cltName) +} diff --git a/ws/ws.go b/ws/ws.go new file mode 100644 index 0000000..362596e --- /dev/null +++ b/ws/ws.go @@ -0,0 +1,204 @@ +package ws + +import ( + "bytes" + "fmt" + "net/url" + "sync" + "time" + + "github.com/gorilla/websocket" + log "github.com/sirupsen/logrus" +) + +var ( + pongMsg = []byte("pong") +) + +type WSInitFn func(ws *WSConn) error +type MessageFn func(message []byte) error +type PingFn func(ws *WSConn) error +type PongFn func(message []byte) bool + +func defaultPingFn(ws *WSConn) error { + return ws.WriteText("ping") +} + +func defaultPongFn(message []byte) bool { + return bytes.Equal(pongMsg, message) +} + +type WSConn struct { + addr string + ws *websocket.Conn + initFn WSInitFn + messageFn MessageFn + pingFn PingFn + pongFn PongFn + closeCh chan int + writeMuetx sync.Mutex + wg sync.WaitGroup +} + +func NewWSConnWithPingPong(addr string, initFn WSInitFn, messageFn MessageFn, ping PingFn, pong PongFn) (conn *WSConn, err error) { + conn = new(WSConn) + conn.addr = addr + conn.initFn = initFn + conn.messageFn = messageFn + conn.closeCh = make(chan int, 1) + conn.pingFn = ping + conn.pongFn = pong + err = conn.connect() + return +} + +func NewWSConn(addr string, initFn WSInitFn, messageFn MessageFn) (conn *WSConn, err error) { + conn = new(WSConn) + conn.addr = addr + conn.initFn = initFn + conn.pingFn = defaultPingFn + conn.pongFn = defaultPongFn + conn.messageFn = messageFn + conn.closeCh = make(chan int, 1) + err = conn.connect() + if err != nil { + return + } + return +} + +func (conn *WSConn) SetPingPongFn(ping PingFn, pong PongFn) { + conn.pingFn = ping + conn.pongFn = pong +} + +func (conn *WSConn) Close() (err error) { + close(conn.closeCh) + conn.wg.Wait() + return +} + +func (conn *WSConn) WriteText(value string) (err error) { + conn.writeMuetx.Lock() + if conn.ws != nil { + err = conn.ws.WriteMessage(websocket.TextMessage, []byte(value)) + } else { + log.Warnf("WriteText ignore conn of %s not init", conn.addr) + } + conn.writeMuetx.Unlock() + return +} + +func (conn *WSConn) WriteMsg(value interface{}) (err error) { + conn.writeMuetx.Lock() + if conn.ws != nil { + err = conn.ws.WriteJSON(value) + } else { + log.Warnf("WriteMsg ignore conn of %s not init", conn.addr) + } + conn.writeMuetx.Unlock() + return +} + +func (conn *WSConn) connect() (err error) { + u, err := url.Parse(conn.addr) + if err != nil { + return + } + conn.ws, _, err = websocket.DefaultDialer.Dial(u.String(), nil) + if err != nil { + err = fmt.Errorf("connect to %s failed: %w", conn.addr, err) + return + } + if conn.initFn != nil { + err = conn.initFn(conn) + if err != nil { + conn.ws.Close() + return + } + } + go conn.loop() + return +} + +func (conn *WSConn) loop() { + ws := conn.ws + ch := make(chan []byte, 1024) + needReconn := make(chan bool, 1) + go conn.readLoop(ws, ch, needReconn) + var msg []byte + var err error + var lastMsgTime time.Time + ticker := time.NewTicker(time.Second * 5) + + conn.wg.Add(1) + defer conn.wg.Done() + var ok bool + defer ticker.Stop() +Out: + for { + select { + case msg, ok = <-ch: + if !ok { + break Out + } + lastMsgTime = time.Now() + + if conn.pongFn != nil && conn.pongFn(msg) { + continue + } + err = conn.messageFn(msg) + if err != nil { + break Out + } + case <-ticker.C: + dur := time.Since(lastMsgTime) + if dur > time.Second*5 { + if conn.pingFn != nil { + err1 := conn.pingFn(conn) + if err1 != nil { + log.Errorf("ws pingFn failed: %s", err1.Error()) + } + } + } + case <-conn.closeCh: + return + } + } + reConn := <-needReconn + if reConn { + for i := 0; i != 100; i++ { + err = conn.connect() + if err == nil { + break + } + log.Errorf("ws reconnect %d to failed: %s", i, err.Error()) + time.Sleep(time.Second) + } + } +} + +func (conn *WSConn) readLoop(ws *websocket.Conn, ch chan []byte, needConn chan bool) { + defer func() { + ws.Close() + close(ch) + close(needConn) + }() + var message []byte + var err error + for { + select { + case <-conn.closeCh: + needConn <- false + return + default: + } + _, message, err = ws.ReadMessage() + if err != nil { + log.Printf("%s ws read error: %s", conn.addr, err.Error()) + needConn <- true + return + } + ch <- message + } +} diff --git a/ws/ws_test.go b/ws/ws_test.go new file mode 100644 index 0000000..0523e11 --- /dev/null +++ b/ws/ws_test.go @@ -0,0 +1,53 @@ +package ws + +import ( + "fmt" + "testing" + "time" + + "github.com/gorilla/websocket" +) + +func TestWsConn(t *testing.T) { + initFn := func(ws *WSConn) error { + var p = map[string]interface{}{ + "op": "subscribe", + "args": []interface{}{ + map[string]interface{}{"channel": "trades", "instType": "SWAP", "instId": "BTC-USDT-SWAP"}, + }, + } + return ws.WriteMsg(p) + } + messageFn := func(msg []byte) error { + fmt.Println("msg:", string(msg)) + return nil + } + conn, err := NewWSConn("wss://wsaws.okx.com:8443/ws/v5/public", initFn, messageFn) + if err != nil { + t.Fatal(err.Error()) + } + time.Sleep(time.Second * 5) + conn.Close() +} + +func TestWsPing(t *testing.T) { + initFn := func(ws *WSConn) error { + return nil + } + messageFn := func(msg []byte) error { + fmt.Println("msg:", string(msg)) + return nil + } + pongFn := func(msg []byte) bool { + fmt.Println("recv pong msg:", string(msg)) + return true + } + conn, err := NewWSConn("wss://wsaws.okx.com:8443/ws/v5/public", initFn, messageFn) + if err != nil { + t.Fatal(err.Error()) + } + conn.SetPingPongFn(defaultPingFn, pongFn) + conn.ws.WriteMessage(websocket.TextMessage, []byte("ping")) + time.Sleep(time.Second * 15) + conn.Close() +}