Documentation ¶
Index ¶
- Constants
- type AuthenticationRequest
- type Futures
- func (f *Futures) AddDualMargin(ctx context.Context, settle, contract string, margin decimal.Decimal) ([]exchange.Position, error)
- func (f *Futures) AddMargin(ctx context.Context, settle, contract string, margin decimal.Decimal) (exchange.Position, error)
- func (f *Futures) Candle(ctx context.Context, settle string, contract string, from, to int64, limit int, ...) (fym.Candle, error)
- func (f *Futures) CommonLiquidation(ctx context.Context, settle, contract string, from, to int64, limit int) ([]exchange.FuturesLiquidation, error)
- func (f *Futures) GetContract(ctx context.Context, settle, contract string) (exchange.Contract, error)
- func (f *Futures) GetDualPosition(ctx context.Context, settle string, contract string) ([]exchange.Position, error)
- func (f *Futures) GetPosition(ctx context.Context, settle, contract string) (exchange.Position, error)
- func (f *Futures) ListContracts(ctx context.Context, settle string) ([]exchange.Contract, error)
- func (f *Futures) ListFuturesAccounts(ctx context.Context, settle string) (exchange.FuturesBalance, error)
- func (f *Futures) ListPositions(ctx context.Context, settle string) ([]exchange.Position, error)
- func (f *Futures) ListTrades(ctx context.Context, settle string, contract string, limit int, from, to int64) ([]exchange.FuturesTrade, error)
- func (f *Futures) Orderbook(ctx context.Context, settle, contract string, limit int, interval float32) (exchange.FuturesOrderbook, error)
- func (f *Futures) SetDualMode(ctx context.Context, settle string, newDualMode bool) (exchange.FuturesBalance, error)
- func (f *Futures) UpdateDualLeverage(ctx context.Context, settle, contract string, newLeverage int) ([]exchange.Position, error)
- func (f *Futures) UpdateDualRiskLimit(ctx context.Context, settle, contract string, newRiskLimit int) ([]exchange.Position, error)
- func (f *Futures) UpdateLeverage(ctx context.Context, settle, contract string, newLeverage int) (exchange.Position, error)
- func (f *Futures) UpdateRiskLimit(ctx context.Context, settle, contract string, newRiskLimit int) (exchange.Position, error)
- type GateAuthentication
- type GateIO
- func (g *GateIO) AllSymbols(ctx context.Context) (symbols []exchange.Symbol, err error)
- func (g *GateIO) BuyFromOrderBook(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) BuyFromTicker(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) BuyLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) BuyMarket(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) BuyOrder(symbol string, price, amount decimal.Decimal, orderType, text string) (resp ResponseOrder, err error)
- func (g *GateIO) BuyStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) CancelAllOrders(types string, currencyPair string) (res ResponseCancel, err error)
- func (g *GateIO) CancelOrder(symbol string, orderNumber uint64) error
- func (g *GateIO) CandleBySize(symbol string, period time.Duration, size int) (candle fym.Candle, err error)
- func (g *GateIO) CandleFrom(symbol, clientId string, period time.Duration, from, to time.Time) (fym.Candle, error)
- func (g GateIO) FormatSymbol(base, quote string) string
- func (g *GateIO) GetCandle(symbol string, groupSec, rangeHour int) (candles fym.Candle, err error)
- func (g *GateIO) GetFee(symbol string) (fee exchange.Fee, err error)
- func (g *GateIO) GetOrder(orderId uint64, symbol string) (order exchange.Order, err error)
- func (g *GateIO) GetOrderById(orderId uint64, symbol string) (order exchange.Order, err error)
- func (g *GateIO) GetOrderString(orderId uint64, symbol string) (string, error)
- func (g *GateIO) GetPairs() (pairs []string, err error)
- func (g *GateIO) GetSymbol(ctx context.Context, symbol string) (s exchange.Symbol, err error)
- func (g *GateIO) IsFullFilled(symbol string, orderId uint64) (order exchange.Order, filled bool, err error)
- func (g *GateIO) Last24hVolume(symbol string) (decimal.Decimal, error)
- func (g *GateIO) LastPrice(symbol string) (decimal.Decimal, error)
- func (g *GateIO) MarketInfo() (res ResponseMarketInfo, err error)
- func (g *GateIO) MyTradeHistory(currencyPair string) (*MyTradeHistoryResult, error)
- func (g *GateIO) OpenOrders() (res ResponseOpenOrders, err error)
- func (g *GateIO) OrderBook(symbol string) (ResponseOrderBook, error)
- func (g *GateIO) ReqBalance(ctx context.Context, currencies []string)
- func (g *GateIO) ReqCandlestick(ctx context.Context, symbol, clientId string, period time.Duration, ...) (fym.Candle, error)
- func (g *GateIO) ReqOrder(ctx context.Context, symbol, clientId string) (orders []exchange.Order, err error)
- func (g *GateIO) ReqPing(ctx context.Context, id int64) (string, error)
- func (g *GateIO) ReqTicker(ctx context.Context, id int64, symbol string, period time.Duration) (fym.Ticker, error)
- func (g *GateIO) ReqTime(ctx context.Context, id int64) (int64, error)
- func (g *GateIO) SellFromOrderBook(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) SellFromTicker(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) SellLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) SellMarket(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) SellStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)
- func (g *GateIO) SpotAvailableBalance() (map[string]decimal.Decimal, error)
- func (g *GateIO) SpotBalance() (map[string]decimal.Decimal, error)
- func (g *GateIO) SubBalance(currencies []string)
- func (g *GateIO) SubCandlestick(symbol, clientId string, period time.Duration, ...)
- func (g *GateIO) SubOrder(symbol, clientId string, responseHandler exchange.ResponseHandler)
- func (g *GateIO) SubTicker(id int64, symbol string, responseHandler exchange.ResponseHandler)
- func (g *GateIO) SubscribeCandlestick(symbol, clientId string, period time.Duration, ...)
- func (g *GateIO) SubscribeCandlestickWithReq(symbol, clientId string, period time.Duration, ...)
- func (g *GateIO) SubscribeOrder(symbol, clientId string, responseHandler exchange.ResponseHandler)
- func (g *GateIO) Ticker(currencyPair string) (*exchange.Ticker, error)
- func (g *GateIO) TradeHistory(params string) (string, error)
- func (g *GateIO) UnsubBalance(currencies []string)
- func (g *GateIO) UnsubCandlestick(symbol, clientId string)
- func (g *GateIO) UnsubOrder(symbol, clientId string)
- func (g *GateIO) UnsubTicker(id int64, symbol string)
- func (g *GateIO) UnsubscribeCandlestick(symbol, clientId string, period time.Duration)
- func (g *GateIO) UnsubscribeCandlestickWithReq(symbol, clientId string, period time.Duration)
- func (g *GateIO) UnsubscribeOrder(symbol, clientId string)
- type MyTradeHistoryResult
- type PrivateWebsocketClient
- func (c *PrivateWebsocketClient) Init(host, path string, apiKey, secretKey string, logger *zap.SugaredLogger) *PrivateWebsocketClient
- func (c *PrivateWebsocketClient) ReqBalance(id int64, assets []string)
- func (c *PrivateWebsocketClient) ReqBalanceHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *PrivateWebsocketClient) ReqOrder(id int64, symbol string, offset, limit uint64)
- func (c *PrivateWebsocketClient) ReqOrderHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *PrivateWebsocketClient) SetHandler(connectedHandler base.ConnectedHandler, responseHandler base.ResponseHandler)
- func (c *PrivateWebsocketClient) SubBalance(id int64, assets []string)
- func (c *PrivateWebsocketClient) SubBalanceHandler(handler exchange.ResponseHandler) base.ResponseHandler
- func (c *PrivateWebsocketClient) SubOrder(id int64, symbols []string)
- func (c *PrivateWebsocketClient) SubOrderHandler(handler exchange.ResponseHandler) base.ResponseHandler
- func (c *PrivateWebsocketClient) UnsubBalance(id int64, assets []string)
- func (c *PrivateWebsocketClient) UnsubOrder(id int64, symbols []string)
- type Quote
- type RawCandle
- type RawOrderInGetOrder
- type RawOrderInOpenOrders
- type RawSymbol
- type RawTrade
- type ResponseBalances
- type ResponseBuy
- type ResponseCancel
- type ResponseCandles
- type ResponseGetOrder
- type ResponseMarketInfo
- type ResponseOpenOrders
- type ResponseOrder
- type ResponseOrderBook
- type ResponseReqOrder
- type ResponseSell
- type ResponseTicker
- type ResponseWsBase
- type ResponseWsKline
- type ResponseWsTicker
- type SpotV4
- func (g *SpotV4) AllSymbols(ctx context.Context) (symbols []exchange.Symbol, err error)
- func (g *SpotV4) AvailableBalance(ctx context.Context) (map[string]decimal.Decimal, error)
- func (g *SpotV4) Balance(ctx context.Context) ([]exchange.Balance, error)
- func (g *SpotV4) BuyLimit(ctx context.Context, symbol, clientOrderId string, ...) (exchange.Order, error)
- func (g *SpotV4) BuyMarket(ctx context.Context, symbol exchange.Symbol, clientOrderId string, ...) (exchange.Order, error)
- func (g *SpotV4) BuyStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)
- func (g *SpotV4) CancelAllOrders(ctx context.Context, symbol string) ([]exchange.Order, error)
- func (g *SpotV4) CancelOrder(ctx context.Context, symbol string, orderId uint64) (exchange.Order, error)
- func (g *SpotV4) CandleBySize(symbol string, period time.Duration, size int) (fym.Candle, error)
- func (g *SpotV4) CandleBySizeContext(ctx context.Context, symbol string, period time.Duration, size int) (fym.Candle, error)
- func (g *SpotV4) Currencies(ctx context.Context) ([]gateapi.Currency, error)
- func (g *SpotV4) GetOrder(ctx context.Context, symbol string, orderId uint64) (exchange.Order, error)
- func (g *SpotV4) GetSymbol(ctx context.Context, symbol string) (s exchange.Symbol, err error)
- func (g *SpotV4) IsFullFilled(ctx context.Context, symbol string, orderId uint64) (order exchange.Order, filled bool, err error)
- func (g *SpotV4) Last24hVolume(ctx context.Context, symbol string) (decimal.Decimal, error)
- func (g *SpotV4) LastPrice(ctx context.Context, symbol string) (decimal.Decimal, error)
- func (g *SpotV4) ListOpenOrders(ctx context.Context, symbol string) ([]exchange.Order, error)
- func (g *SpotV4) ListOrders(ctx context.Context, symbol, status string) ([]exchange.Order, error)
- func (g *SpotV4) MyTrades(ctx context.Context, symbol, orderId string) ([]exchange.Trade, error)
- func (g *SpotV4) Name() string
- func (g *SpotV4) ReqBalance(ctx context.Context, currencies []string)
- func (g *SpotV4) ReqCandlestick(ctx context.Context, symbol, clientId string, period time.Duration, ...) (fym.Candle, error)
- func (g *SpotV4) ReqOrder(ctx context.Context, symbol, clientId string) (orders []exchange.Order, err error)
- func (g *SpotV4) ReqPing(ctx context.Context, id int64) (string, error)
- func (g *SpotV4) ReqTicker(ctx context.Context, id int64, symbol string, period time.Duration) (fym.Ticker, error)
- func (g *SpotV4) ReqTime(ctx context.Context, id int64) (int64, error)
- func (g *SpotV4) SellLimit(ctx context.Context, symbol, text string, price, amount decimal.Decimal) (exchange.Order, error)
- func (g *SpotV4) SellMarket(ctx context.Context, symbol exchange.Symbol, clientOrderId string, ...) (exchange.Order, error)
- func (g *SpotV4) SellStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)
- func (g *SpotV4) SubBalance(currencies []string)
- func (g *SpotV4) SubCandlestick(symbol, clientId string, period time.Duration, ...)
- func (g *SpotV4) SubOrder(ctx context.Context, symbol, clientId string, ...)
- func (g *SpotV4) SubTicker(id int64, symbol string, responseHandler exchange.ResponseHandler)
- func (g *SpotV4) SubscribeCandlestick(symbol, clientId string, period time.Duration, ...)
- func (g *SpotV4) SubscribeCandlestickWithReq(symbol, clientId string, period time.Duration, ...)
- func (g *SpotV4) SubscribeOrder(ctx context.Context, symbol, clientId string, ...)
- func (g *SpotV4) Ticker(ctx context.Context, symbol string) (exchange.Ticker, error)
- func (g *SpotV4) Tickers(ctx context.Context) ([]exchange.Ticker, error)
- func (g *SpotV4) UnsubBalance(currencies []string)
- func (g *SpotV4) UnsubCandlestick(symbol, clientId string)
- func (g *SpotV4) UnsubTicker(id int64, symbol string)
- func (g *SpotV4) UnsubscribeCandlestick(symbol, clientId string, period time.Duration)
- func (g *SpotV4) UnsubscribeCandlestickWithReq(symbol, clientId string, period time.Duration)
- type UpdateWsBase
- type V2
- func (g *V2) AllSymbols(ctx context.Context) (symbols []exchange.Symbol, err error)
- func (g *V2) BuyLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
- func (g *V2) BuyMarket(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
- func (g *V2) BuyOrder(symbol string, price, amount decimal.Decimal, orderType, text string) (resp ResponseOrder, err error)
- func (g *V2) BuyStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)
- func (g *V2) CancelAllOrders(types string, currencyPair string) (res ResponseCancel, err error)
- func (g *V2) CancelOrder(symbol string, orderNumber uint64) error
- func (g *V2) CandleBySize(symbol string, period time.Duration, size int) (candle fym.Candle, err error)
- func (g *V2) CandleFrom(symbol, clientId string, period time.Duration, from, to time.Time) (fym.Candle, error)
- func (g *V2) GetCandle(symbol string, groupSec, rangeHour int) (candles fym.Candle, err error)
- func (g *V2) GetFee(symbol string) (fee exchange.Fee, err error)
- func (g *V2) GetOrder(orderId uint64, symbol string) (order exchange.Order, err error)
- func (g *V2) GetOrderById(orderId uint64, symbol string) (order exchange.Order, err error)
- func (g *V2) GetOrderString(orderId uint64, symbol string) (string, error)
- func (g *V2) GetPairs() (pairs []string, err error)
- func (g *V2) GetSymbol(ctx context.Context, symbol string) (s exchange.Symbol, err error)
- func (g *V2) IsFullFilled(symbol string, orderId uint64) (order exchange.Order, filled bool, err error)
- func (g *V2) Last24hVolume(symbol string) (decimal.Decimal, error)
- func (g *V2) LastPrice(symbol string) (decimal.Decimal, error)
- func (g *V2) MarketInfo() (res ResponseMarketInfo, err error)
- func (g *V2) MyTradeHistory(symbol string, orderId uint64) ([]exchange.Trade, error)
- func (g *V2) OpenOrders() ([]exchange.Order, error)
- func (g *V2) OrderBook(symbol string) (ResponseOrderBook, error)
- func (g *V2) ReqBalance(ctx context.Context, currencies []string)
- func (g *V2) ReqCandlestick(ctx context.Context, symbol, clientId string, period time.Duration, ...) (fym.Candle, error)
- func (g *V2) ReqOrder(ctx context.Context, symbol, clientId string) (orders []exchange.Order, err error)
- func (g *V2) ReqPing(ctx context.Context, id int64) (string, error)
- func (g *V2) ReqTicker(ctx context.Context, id int64, symbol string, period time.Duration) (fym.Ticker, error)
- func (g *V2) ReqTime(ctx context.Context, id int64) (int64, error)
- func (g *V2) SellLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
- func (g *V2) SellMarket(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
- func (g *V2) SellStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)
- func (g *V2) SpotAvailableBalance() (map[string]decimal.Decimal, error)
- func (g *V2) SpotBalance() (map[string]decimal.Decimal, error)
- func (g *V2) SpotBalanceDetail() (map[string]exchange.Balance, error)
- func (g *V2) SubBalance(currencies []string)
- func (g *V2) SubCandlestick(symbol, clientId string, period time.Duration, ...)
- func (g *V2) SubOrder(symbol, clientId string, responseHandler exchange.ResponseHandler)
- func (g *V2) SubTicker(id int64, symbol string, responseHandler exchange.ResponseHandler)
- func (g *V2) Ticker(currencyPair string) (*exchange.Ticker, error)
- func (g *V2) TradeHistory(params string) (string, error)
- func (g *V2) UnsubBalance(currencies []string)
- func (g *V2) UnsubCandlestick(symbol, clientId string)
- func (g *V2) UnsubOrder(symbol, clientId string)
- func (g *V2) UnsubTicker(id int64, symbol string)
- type WebsocketClient
- func (c *WebsocketClient) Auth(api, secret string)
- func (c *WebsocketClient) AuthHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) Init(host, path string, logger *zap.SugaredLogger) *WebsocketClient
- func (c *WebsocketClient) Ping(id int64)
- func (c *WebsocketClient) PingHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) ReqCandle(id int64, symbol string, start, end, interval int64)
- func (c *WebsocketClient) ReqCandleHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) ReqTicker(id int64, symbol string, period int64)
- func (c *WebsocketClient) ReqTickerHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) SetHandler(connectedHandler base.ConnectedHandler, responseHandler base.ResponseHandler)
- func (c *WebsocketClient) SubCandle(id int64, symbol string, interval int64)
- func (c *WebsocketClient) SubCandleHandler(handler exchange.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) SubTicker(id int64, symbol string)
- func (c *WebsocketClient) SubTickerHandler(handler exchange.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) Time(id int64)
- func (c *WebsocketClient) TimeHandler(handler base.ResponseHandler) base.ResponseHandler
- func (c *WebsocketClient) UnsubCandle(id int64)
- func (c *WebsocketClient) UnsubTicker(id int64)
- type WebsocketRequest
- type WsOrderRecord
Constants ¶
const ( DefaultMaker = 0.002 DefaultTaker = 0.002 )
const ( // 订单类型("gtc":普通订单(默认); // “ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC); // "poc":被动委托(只挂单,不吃单)(Pending-Or-Cancelled,POC)) OrderTypeNormal = "gtc" OrderTypeGTC = "gtc" OrderTypeIOC = "ioc" OrderTypePOC = "poc" )
used by buy/sell
const ( OrderStatusOpen = "open" OrderStatusCancelled = "cancelled" OrderStatusClosed = "closed" OrderTypeBuy = "buy" OrderTypeSell = "sell" )
const ( WsIntervalSecond = 5 WsReconnectSecond = 60 )
const ( DefaultHost = "gateio.life" WsPathV3 = "/v3" WsPathV4 = "/v4" )
const ( GET = "GET" POST = "POST" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationRequest ¶
type AuthenticationRequest struct { Apikey string `json:"apikey"` Signature string `json:"signature"` Nonce int64 `json:"nonce"` }
func (AuthenticationRequest) ToJson ¶
func (ar AuthenticationRequest) ToJson() (string, error)
type Futures ¶
type Futures struct { Key string Secret string Logger *zap.SugaredLogger // contains filtered or unexported fields }
func NewFutures ¶
func NewFutures(key, secret, host string, logger *zap.SugaredLogger) *Futures
func (*Futures) AddDualMargin ¶
func (*Futures) Candle ¶
func (f *Futures) Candle(ctx context.Context, settle string, contract string, from, to int64, limit int, interval time.Duration) (fym.Candle, error)
from, to is unix timestamp in seconds
func (*Futures) CommonLiquidation ¶
func (*Futures) GetContract ¶
func (*Futures) GetDualPosition ¶
func (*Futures) GetPosition ¶
func (*Futures) ListContracts ¶
func (*Futures) ListFuturesAccounts ¶
func (*Futures) ListPositions ¶
func (*Futures) ListTrades ¶
func (*Futures) SetDualMode ¶
func (f *Futures) SetDualMode(ctx context.Context, settle string, newDualMode bool) (exchange.FuturesBalance, error)
设置持仓模式
func (*Futures) UpdateDualLeverage ¶
func (f *Futures) UpdateDualLeverage(ctx context.Context, settle, contract string, newLeverage int) ([]exchange.Position, error)
更新双仓模式下的头寸杠杆
func (*Futures) UpdateDualRiskLimit ¶
func (f *Futures) UpdateDualRiskLimit(ctx context.Context, settle, contract string, newRiskLimit int) ([]exchange.Position, error)
更新双仓模式下的头寸风险限额
type GateAuthentication ¶
type GateAuthentication struct {
// contains filtered or unexported fields
}
func (*GateAuthentication) Build ¶
func (a *GateAuthentication) Build() (string, error)
func (*GateAuthentication) Init ¶
func (a *GateAuthentication) Init(apiKey, secretKey string)
type GateIO ¶
type GateIO struct { Key string Secret string Logger *zap.SugaredLogger // contains filtered or unexported fields }
gateio APIv4 版本的RESTful接口封装
func (*GateIO) AllSymbols ¶
func (*GateIO) BuyFromOrderBook ¶
func (g *GateIO) BuyFromOrderBook(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
BuyFromOrderBook use order book and take the sell1
func (*GateIO) BuyFromTicker ¶
func (g *GateIO) BuyFromTicker(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
BuyFromTicker use Ticker's last price to place order. // may can't fill when big bull
func (*GateIO) BuyLimit ¶
func (g *GateIO) BuyLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
订单类型("gtc":普通订单(默认);“ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC);"poc":被动委托(只挂单,不吃单)(Pending-Or-Cancelled,POC)) Place order buy
func (*GateIO) BuyMarket ¶
func (g *GateIO) BuyMarket(symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)
BuyMarket use Ticker's last price to place order. may can't fill when big bull
func (*GateIO) BuyStopLimit ¶
func (*GateIO) CancelAllOrders ¶
func (g *GateIO) CancelAllOrders(types string, currencyPair string) (res ResponseCancel, err error)
Cancel all orders
func (*GateIO) CancelOrder ¶
Cancel order
func (*GateIO) CandleBySize ¶
func (g *GateIO) CandleBySize(symbol string, period time.Duration, size int) (candle fym.Candle, err error)
获取Candle
func (*GateIO) CandleFrom ¶
func (GateIO) FormatSymbol ¶
func (*GateIO) GetOrderById ¶
func (*GateIO) GetOrderString ¶
Get order as string, just for test gate's getOrder interface, only use in gateio_test.go
func (*GateIO) IsFullFilled ¶
func (*GateIO) Last24hVolume ¶
func (*GateIO) MarketInfo ¶
func (g *GateIO) MarketInfo() (res ResponseMarketInfo, err error)
Market Info
func (*GateIO) MyTradeHistory ¶
func (g *GateIO) MyTradeHistory(currencyPair string) (*MyTradeHistoryResult, error)
获取我的24小时内成交记录
func (*GateIO) OpenOrders ¶
func (g *GateIO) OpenOrders() (res ResponseOpenOrders, err error)
Get my open order list
func (*GateIO) OrderBook ¶
func (g *GateIO) OrderBook(symbol string) (ResponseOrderBook, error)
Depth of pair
func (*GateIO) ReqCandlestick ¶
func (*GateIO) SellFromOrderBook ¶
func (g *GateIO) SellFromOrderBook(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
SellFromOrderBook use order book and take the buy1
func (*GateIO) SellFromTicker ¶
func (g *GateIO) SellFromTicker(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
SellFromTicker use Ticker's last price to place order. may can't fill when big bear
func (*GateIO) SellLimit ¶
func (g *GateIO) SellLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
Place order sell
func (*GateIO) SellMarket ¶
func (g *GateIO) SellMarket(symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error)
SellMarket use Ticker's last price to place order. may can't fill when big bear
func (*GateIO) SellStopLimit ¶
func (*GateIO) SpotAvailableBalance ¶
Get account fund balances
func (*GateIO) SpotBalance ¶
Get account fund balances
func (*GateIO) SubBalance ¶
func (*GateIO) SubCandlestick ¶
func (*GateIO) SubOrder ¶
func (g *GateIO) SubOrder(symbol, clientId string, responseHandler exchange.ResponseHandler)
func (*GateIO) SubTicker ¶
func (g *GateIO) SubTicker(id int64, symbol string, responseHandler exchange.ResponseHandler)
func (*GateIO) SubscribeCandlestick ¶
func (*GateIO) SubscribeCandlestickWithReq ¶
func (*GateIO) SubscribeOrder ¶
func (g *GateIO) SubscribeOrder(symbol, clientId string, responseHandler exchange.ResponseHandler)
func (*GateIO) Ticker ¶
// Market Details
func (g *GateIO) marketlist() string { var method string = "GET" url := "/marketlist" param := "" var ret string = g.httpDo(method, url, param) return ret }
// tickers
func (g *GateIO) tickers() string { var method string = "GET" url := "/tickers" param := "" var ret string = g.httpDo(method, url, param) return ret }
ticker
func (*GateIO) TradeHistory ¶
Trade History
func (*GateIO) UnsubBalance ¶
func (*GateIO) UnsubCandlestick ¶
func (*GateIO) UnsubOrder ¶
func (*GateIO) UnsubTicker ¶
func (*GateIO) UnsubscribeCandlestick ¶
func (*GateIO) UnsubscribeCandlestickWithReq ¶
func (*GateIO) UnsubscribeOrder ¶
type MyTradeHistoryResult ¶
type PrivateWebsocketClient ¶
type PrivateWebsocketClient struct { base.WebsocketBase // contains filtered or unexported fields }
func (*PrivateWebsocketClient) Init ¶
func (c *PrivateWebsocketClient) Init(host, path string, apiKey, secretKey string, logger *zap.SugaredLogger) *PrivateWebsocketClient
Initializer
func (*PrivateWebsocketClient) ReqBalance ¶
func (c *PrivateWebsocketClient) ReqBalance(id int64, assets []string)
func (*PrivateWebsocketClient) ReqBalanceHandler ¶
func (c *PrivateWebsocketClient) ReqBalanceHandler(handler base.ResponseHandler) base.ResponseHandler
ReqBalanceHandler cast the raw result to gate order object list
func (*PrivateWebsocketClient) ReqOrder ¶
func (c *PrivateWebsocketClient) ReqOrder(id int64, symbol string, offset, limit uint64)
func (*PrivateWebsocketClient) ReqOrderHandler ¶
func (c *PrivateWebsocketClient) ReqOrderHandler(handler base.ResponseHandler) base.ResponseHandler
ReqOrderHandler cast the raw result to gate order object list
func (*PrivateWebsocketClient) SetHandler ¶
func (c *PrivateWebsocketClient) SetHandler( connectedHandler base.ConnectedHandler, responseHandler base.ResponseHandler)
Set callback handler
func (*PrivateWebsocketClient) SubBalance ¶
func (c *PrivateWebsocketClient) SubBalance(id int64, assets []string)
func (*PrivateWebsocketClient) SubBalanceHandler ¶
func (c *PrivateWebsocketClient) SubBalanceHandler(handler exchange.ResponseHandler) base.ResponseHandler
func (*PrivateWebsocketClient) SubOrder ¶
func (c *PrivateWebsocketClient) SubOrder(id int64, symbols []string)
func (*PrivateWebsocketClient) SubOrderHandler ¶
func (c *PrivateWebsocketClient) SubOrderHandler(handler exchange.ResponseHandler) base.ResponseHandler
client handler got a exchange.Order as response if everything's ok
func (*PrivateWebsocketClient) UnsubBalance ¶
func (c *PrivateWebsocketClient) UnsubBalance(id int64, assets []string)
func (*PrivateWebsocketClient) UnsubOrder ¶
func (c *PrivateWebsocketClient) UnsubOrder(id int64, symbols []string)
type RawOrderInGetOrder ¶
type RawOrderInGetOrder struct { OrderNumber string Text string Status string // 订单状态 open已挂单 cancelled已取消 closed已完成 CurrencyPair string `json:"currencyPair"` Type string // sell, buy Rate string // 价格 Amount string // 买卖数量 InitialRate string // 下单价格 InitialAmount string // 下单数量 //FilledRate interface{} // string when open, float64 when closed FilledAmount string FeePercentage float64 FeeValue string FeeCurrency string Fee string Timestamp int64 }
type RawOrderInOpenOrders ¶
type RawOrderInOpenOrders struct { OrderNumber uint64 Status string // 记录状态 DONE:完成; CANCEL:取消; REQUEST:请求中 CurrencyPair string Type string Rate string // 价格 Amount string // 买卖数量 Total string InitialRate string // 下单价格 InitialAmount string // 下单数量 FilledRate string // 成交价格 FilledAmount string // 成交数量 Timestamp int64 }
type RawSymbol ¶
type RawSymbol struct { PricePrecision int32 `json:"decimal_places"` AmountPrecision int32 `json:"amount_decimal_places"` MinAmount float64 `json:"min_amount"` MinAmountA float64 `json:"min_amount_a"` MinAmountB float64 `json:"min_amount_b"` Fee float64 `json:"fee"` TradeDisabled int `json:"trade_disabled"` BuyDisabled int `json:"buy_disabled"` SellDisabled int `json:"sell_disabled"` }
type RawTrade ¶
type RawTrade struct { TradeId uint64 `json:"tradeID"` OrderNumber uint64 `json:"orderNumber"` Pair string `json:"pair"` Type string `json:"type"` Rate string `json:"rate"` Amount string `json:"amount"` Total float64 `json:"total"` Date string `json:"date"` TimeUnix int64 `json:"time_unix"` Role string `json:"role"` Fee string `json:"fee"` FeeCoin string `json:"fee_coin"` GtFee string `json:"gt_fee"` PointFee string `json:"point_fee"` }
from api result
type ResponseBalances ¶
type ResponseBuy ¶
type ResponseBuy struct { Result string Message string Code int OrderNumber uint64 Market string // 交易对 CTime float64 `json:"ctime"` // 时间戳: 1585793595.5014, 秒.毫秒 Side int Iceberg string Rate string // 下单价格 FilledRate string // 成交价格 LeftAmount string // 剩余数量 FilledAmount string // 成交数量 FeePercentage float64 FeeValue string FeeCurrency string Fee string }
type ResponseCancel ¶
type ResponseCandles ¶
type ResponseGetOrder ¶
type ResponseGetOrder struct { Result string Message string Code int Elapsed string Order RawOrderInGetOrder }
type ResponseMarketInfo ¶
type ResponseOpenOrders ¶
type ResponseOpenOrders struct { Result string Message string Code int64 Elapsed string Orders []RawOrderInOpenOrders }
type ResponseOrder ¶
type ResponseOrderBook ¶
type ResponseReqOrder ¶
type ResponseReqOrder struct { Offset int64 `json:"offset"` Limit int64 `json:"limit"` // Total 是全部的订单个数,而不是当前批次取到多少 Total int64 `json:"total"` Records []WsOrderRecord `json:"records"` }
ResponseReqOrder 是order.query请求返回的主结构
type ResponseSell ¶
type ResponseSell ResponseOrder
type ResponseTicker ¶
type ResponseWsBase ¶
type ResponseWsBase struct { Id int64 `json:"id"` Error interface{} `json:"error"` Result interface{} `json:"result"` }
type ResponseWsKline ¶
type ResponseWsTicker ¶
type SpotV4 ¶
type SpotV4 struct { Key string Secret string Logger *zap.SugaredLogger // contains filtered or unexported fields }
SpotV4 is gate.io API v4 wrapper GetXxx/Xxx: RESTful GET ReqXxx: websocket query SubXxx/UnsubXxx: websocket subscribe or unsubscribe
func (*SpotV4) AllSymbols ¶
func (*SpotV4) AvailableBalance ¶
AvailableBalance returns account available balances
func (*SpotV4) BuyLimit ¶
func (g *SpotV4) BuyLimit(ctx context.Context, symbol, clientOrderId string, price, amount decimal.Decimal) (exchange.Order, error)
订单类型("gtc":普通订单(默认);“ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC);"poc":被动委托(只挂单,不吃单)(Pending-Or-Cancelled,POC))
func (*SpotV4) BuyMarket ¶
func (g *SpotV4) BuyMarket(ctx context.Context, symbol exchange.Symbol, clientOrderId string, total decimal.Decimal) (exchange.Order, error)
BuyMarket use Ticker's last price to place order. may can't fill when big bull
func (*SpotV4) BuyStopLimit ¶
func (*SpotV4) CancelAllOrders ¶
cancel all orders
func (*SpotV4) CancelOrder ¶
func (g *SpotV4) CancelOrder(ctx context.Context, symbol string, orderId uint64) (exchange.Order, error)
Cancel order
func (*SpotV4) CandleBySize ¶
获取一定数量的k线 可以用于策略启动时的查询
func (*SpotV4) CandleBySizeContext ¶
func (*SpotV4) Currencies ¶
list all currencies
func (*SpotV4) IsFullFilled ¶
func (*SpotV4) Last24hVolume ¶
func (*SpotV4) ListOpenOrders ¶
list open orders by symbol
func (*SpotV4) ListOrders ¶
list all orders by status (open, finished)
func (*SpotV4) ReqCandlestick ¶
func (*SpotV4) SellLimit ¶
func (g *SpotV4) SellLimit(ctx context.Context, symbol, text string, price, amount decimal.Decimal) (exchange.Order, error)
Place order sell
func (*SpotV4) SellMarket ¶
func (g *SpotV4) SellMarket(ctx context.Context, symbol exchange.Symbol, clientOrderId string, amount decimal.Decimal) (exchange.Order, error)
SellMarket use Ticker's last price to place order. may can't fill when big bear
func (*SpotV4) SellStopLimit ¶
func (*SpotV4) SubBalance ¶
func (*SpotV4) SubCandlestick ¶
func (*SpotV4) SubOrder ¶
func (g *SpotV4) SubOrder(ctx context.Context, symbol, clientId string, responseHandler exchange.ResponseHandler)
TODO: 应该改造为使用context,当context取消时,自动退出订阅
func (*SpotV4) SubTicker ¶
func (g *SpotV4) SubTicker(id int64, symbol string, responseHandler exchange.ResponseHandler)
func (*SpotV4) SubscribeCandlestick ¶
func (*SpotV4) SubscribeCandlestickWithReq ¶
func (*SpotV4) SubscribeOrder ¶
func (*SpotV4) UnsubBalance ¶
func (*SpotV4) UnsubCandlestick ¶
func (*SpotV4) UnsubTicker ¶
func (*SpotV4) UnsubscribeCandlestick ¶
type UpdateWsBase ¶
type V2 ¶
type V2 struct { Key string Secret string Logger *zap.SugaredLogger // contains filtered or unexported fields }
func (*V2) AllSymbols ¶
func (*V2) BuyLimit ¶
func (g *V2) BuyLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
订单类型("gtc":普通订单(默认);“ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC);"poc":被动委托(只挂单,不吃单)(Pending-Or-Cancelled,POC)) Place order buy
func (*V2) BuyStopLimit ¶
func (*V2) CancelAllOrders ¶
func (g *V2) CancelAllOrders(types string, currencyPair string) (res ResponseCancel, err error)
Cancel all orders
func (*V2) CancelOrder ¶
Cancel order
func (*V2) CandleBySize ¶
func (g *V2) CandleBySize(symbol string, period time.Duration, size int) (candle fym.Candle, err error)
获取Candle
func (*V2) CandleFrom ¶
func (*V2) GetOrderById ¶
func (*V2) GetOrderString ¶
Get order as string, just for test gate's getOrder interface, only use in gateio_test.go
func (*V2) IsFullFilled ¶
func (*V2) MyTradeHistory ¶
获取我的24小时内成交记录
func (*V2) OrderBook ¶
func (g *V2) OrderBook(symbol string) (ResponseOrderBook, error)
Depth of pair
func (*V2) ReqCandlestick ¶
func (*V2) SellLimit ¶
func (g *V2) SellLimit(symbol, text string, price, amount decimal.Decimal) (orderId uint64, err error)
Place order sell
func (*V2) SellMarket ¶
func (*V2) SellStopLimit ¶
func (*V2) SpotAvailableBalance ¶
Get account fund balances
func (*V2) SpotBalance ¶
Get account fund balances
func (*V2) SpotBalanceDetail ¶
Get spot balances in details
func (*V2) SubBalance ¶
func (*V2) SubCandlestick ¶
func (*V2) SubOrder ¶
func (g *V2) SubOrder(symbol, clientId string, responseHandler exchange.ResponseHandler)
func (*V2) SubTicker ¶
func (g *V2) SubTicker(id int64, symbol string, responseHandler exchange.ResponseHandler)
func (*V2) Ticker ¶
// Market Details
func (g *V2) marketlist() string { var method string = "GET" url := "/marketlist" param := "" var ret string = g.httpDo(method, url, param) return ret }
// tickers
func (g *V2) tickers() string { var method string = "GET" url := "/tickers" param := "" var ret string = g.httpDo(method, url, param) return ret }
ticker
func (*V2) UnsubBalance ¶
func (*V2) UnsubCandlestick ¶
func (*V2) UnsubOrder ¶
func (*V2) UnsubTicker ¶
type WebsocketClient ¶
type WebsocketClient struct { base.WebsocketBase // contains filtered or unexported fields }
func (*WebsocketClient) Auth ¶
func (c *WebsocketClient) Auth(api, secret string)
func (*WebsocketClient) AuthHandler ¶
func (c *WebsocketClient) AuthHandler(handler base.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) Init ¶
func (c *WebsocketClient) Init(host, path string, logger *zap.SugaredLogger) *WebsocketClient
Initializer
func (*WebsocketClient) Ping ¶
func (c *WebsocketClient) Ping(id int64)
func (*WebsocketClient) PingHandler ¶
func (c *WebsocketClient) PingHandler(handler base.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) ReqCandle ¶
func (c *WebsocketClient) ReqCandle(id int64, symbol string, start, end, interval int64)
start, end, interval unit is second
func (*WebsocketClient) ReqCandleHandler ¶
func (c *WebsocketClient) ReqCandleHandler(handler base.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) ReqTicker ¶
func (c *WebsocketClient) ReqTicker(id int64, symbol string, period int64)
func (*WebsocketClient) ReqTickerHandler ¶
func (c *WebsocketClient) ReqTickerHandler(handler base.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) SetHandler ¶
func (c *WebsocketClient) SetHandler( connectedHandler base.ConnectedHandler, responseHandler base.ResponseHandler)
Set callback handler
func (*WebsocketClient) SubCandle ¶
func (c *WebsocketClient) SubCandle(id int64, symbol string, interval int64)
func (*WebsocketClient) SubCandleHandler ¶
func (c *WebsocketClient) SubCandleHandler(handler exchange.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) SubTicker ¶
func (c *WebsocketClient) SubTicker(id int64, symbol string)
func (*WebsocketClient) SubTickerHandler ¶
func (c *WebsocketClient) SubTickerHandler(handler exchange.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) Time ¶
func (c *WebsocketClient) Time(id int64)
func (*WebsocketClient) TimeHandler ¶
func (c *WebsocketClient) TimeHandler(handler base.ResponseHandler) base.ResponseHandler
func (*WebsocketClient) UnsubCandle ¶
func (c *WebsocketClient) UnsubCandle(id int64)
func (*WebsocketClient) UnsubTicker ¶
func (c *WebsocketClient) UnsubTicker(id int64)
type WebsocketRequest ¶
type WebsocketRequest struct { Id int64 `json:"id"` Method string `json:"method"` Params []interface{} `json:"params"` }
func (WebsocketRequest) String ¶
func (r WebsocketRequest) String() string
type WsOrderRecord ¶
type WsOrderRecord struct { Id uint64 `json:"id"` Market string `json:"market"` User int64 `json:"user"` CTime float64 `json:"ctime"` FTime float64 `json:"ftime"` Price string `json:"price"` Amount string `json:"amount"` Left string `json:"left"` DealFee string `json:"dealFee"` OrderType int `json:"orderType"` Type int `json:"type"` FilledAmount string `json:"filledAmount"` FilledTotal string `json:"filledTotal"` // 文档中有,但实际上却没有该字段 Text string `json:"text"` // 以下字段不在文档中,是调试时看到的字段 Tif int64 `json:"tif"` MTime float64 `json:"mtime"` Iceberg string `json:"iceberg"` // 冰山 DealFeeRebate string `json:"deal_fee_rebate"` DealPointFee string `json:"deal_point_fee"` GtDiscount string `json:"gt_discount"` GtMakerFee string `json:"gt_maker_fee"` GtTakerFee string `json:"gt_taker_fee"` DealGtFee string `json:"deal_gt_fee"` }
WsOrderRecord 在order.query和order.update都相同,可以通用 差别是order.update里不含text