gateio

package
v0.14.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BTC_USDT   = "btc_usdt"
	BTC3L_USDT = "btc3l_usdt"
	BTC3S_USDT = "btc3s_usdt"
	SERO_USDT  = "sero_usdt"

	BTC   = "BTC"
	BTC3L = "BTC3L"
	BTC3S = "BTC3S"
	USDT  = "USDT"
	SERO  = "SERO"
)
View Source
const (
	OrderTypeNormal = "gtc"
	OrderTypeGTC    = "gtc"
	OrderTypeIOC    = "ioc"
	OrderTypePOC    = "poc"
)

used by buy/sell

View Source
const (
	OrderStatusOpen      = "open"
	OrderStatusCancelled = "cancelled"
	OrderStatusClosed    = "closed"

	OrderTypeBuy  = "buy"
	OrderTypeSell = "sell"
)
View Source
const (
	GET  = "GET"
	POST = "POST"
)
View Source
const (
	DefaultHost = "gateio.life"
)

Variables

View Source
var (
	PricePrecision = map[string]int{
		BTC_USDT:   2,
		BTC3L_USDT: 4,
		BTC3S_USDT: 4,
		SERO_USDT:  5,
	}
	AmountPrecision = map[string]int{
		BTC_USDT:   4,
		BTC3L_USDT: 3,
		BTC3S_USDT: 3,
		SERO_USDT:  3,
	}
	MinAmount = map[string]float64{
		BTC_USDT:   0.0001,
		BTC3L_USDT: 0.001,
		BTC3S_USDT: 0.001,
		SERO_USDT:  0.001,
	}
	MinTotal = map[string]int64{
		BTC_USDT:   1,
		BTC3L_USDT: 1,
		BTC3S_USDT: 1,
		SERO_USDT:  1,
	}
)

Functions

func Buy1 added in v0.10.13

func Buy1(bids []Quote) (price, amount float64)

func Fee

func Fee(fee, feeCoin, gtFee, pointFee string) (feeMap map[string]string)

func Sell1 added in v0.10.13

func Sell1(asks []Quote) (price, amount float64)

Types

type GateIO

type GateIO struct {
	Key    string
	Secret string
	// contains filtered or unexported fields
}

func New

func New(key, secret, host string) *GateIO

func (*GateIO) AvailableBalance

func (g *GateIO) AvailableBalance() (map[string]decimal.Decimal, error)

Get account fund balances

func (*GateIO) Broadcast

func (g *GateIO) Broadcast(order exchange.Order)

func (*GateIO) Buy

func (g *GateIO) Buy(symbol string, price, amount decimal.Decimal, orderType, text string) (orderId uint64, err error)

订单类型("gtc":普通订单(默认);“ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC);"poc":被动委托(只挂单,不吃单)(Pending-Or-Cancelled,POC)) Place order buy

func (*GateIO) BuyOrder

func (g *GateIO) BuyOrder(symbol string, price, amount decimal.Decimal, orderType, text string) (resp ResponseOrder, err error)

func (*GateIO) CancelAllOrders

func (g *GateIO) CancelAllOrders(types string, currencyPair string) (res ResponseCancel, err error)

Cancel all orders

func (*GateIO) CancelOrder

func (g *GateIO) CancelOrder(currencyPair string, orderNumber uint64) (ok bool, err error)

Cancel order

func (*GateIO) Candles

func (g *GateIO) Candles(currencyPair string, groupSec, rangeHour int) (candles []exchange.Candle, err error)

获取Candle

func (*GateIO) GetCandle added in v0.10.13

func (g *GateIO) GetCandle(symbol string, groupSec, rangeHour int) (candles hs.Candle, err error)

获取Candle

func (*GateIO) GetOrder

func (g *GateIO) GetOrder(orderNumber uint64, currencyPair string) (order exchange.Order, err error)

Get order status

func (*GateIO) GetPairs

func (g *GateIO) GetPairs() (string, error)

all support pairs

func (*GateIO) IsOrderClose

func (g *GateIO) IsOrderClose(symbol string, orderId uint64) (order exchange.Order, closed bool)

func (*GateIO) LastPrice added in v0.10.13

func (g *GateIO) LastPrice(symbol string) (decimal.Decimal, error)

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 added in v0.10.13

func (g *GateIO) OrderBook(symbol string) (ResponseOrderBook, error)

Depth of pair

func (*GateIO) Sell

func (g *GateIO) Sell(symbol string, price, amount decimal.Decimal, orderType, text string) (orderId uint64, err error)

Place order sell

func (*GateIO) Ticker

func (g *GateIO) Ticker(currencyPair string) (*exchange.Ticker, error)

Market Info

func (g *GateIO) marketinfo() string {
	var method string = "GET"
	url :=  "/marketinfo"
	param := ""
	var ret string = g.httpDo(method, url, param)
	return ret
}

// 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

func (g *GateIO) TradeHistory(params string) (string, error)

Trade History

type MyTradeHistoryResult

type MyTradeHistoryResult struct {
	Result  string     `json:"result"`
	Message string     `json:"message"`
	Code    int        `json:"code"`
	Trades  []RawTrade `json:"trades"`
}

type Quote added in v0.10.13

type Quote [2]float64

type RawCandle

type RawCandle [6]float64

type RawOrderInGetOrder

type RawOrderInGetOrder struct {
	OrderNumber  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   string
	Status        string // 记录状态 DONE:完成; CANCEL:取消; REQUEST:请求中
	CurrencyPair  string
	Type          string
	Rate          int64  // 价格
	Amount        string // 买卖数量
	Total         string
	InitialRate   int64  // 下单价格
	InitialAmount string // 下单数量
	FilledRate    string // 成交价格
	FilledAmount  string // 成交数量
	Timestamp     string
}

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 ResponseBalances struct {
	Result    string `json:"result"`
	Available map[string]string
	Locked    map[string]string
}

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 ResponseCancel struct {
	Result  bool
	Code    int
	Message string
}

type ResponseCandles

type ResponseCandles struct {
	Result  string // true
	Elapsed string
	Data    []RawCandle
}

type ResponseGetOrder

type ResponseGetOrder struct {
	Result  string
	Message string
	Code    int
	Elapsed string
	Order   RawOrderInGetOrder
}

type ResponseOpenOrders

type ResponseOpenOrders struct {
	Result  string
	Message string
	Code    int64
	Elapsed string
	Orders  []RawOrderInOpenOrders
}

type ResponseOrder

type ResponseOrder struct {
	Result       string
	OrderNumber  uint64
	Rate         string
	LeftAmount   string // 剩余数量
	FilledAmount string // 成交数量
	FilledRate   string // 成交价格
	Text         string // 用户自定义订单标识,必须以固定前缀 "t-"开头,不计算前缀的情况下,长度限制为 16 字节,范围 [0-9a-zA-Z-_.]。
	Message      string
}

type ResponseOrderBook added in v0.10.13

type ResponseOrderBook struct {
	Result string
	Asks   []Quote
	Bids   []Quote
}

type ResponseSell

type ResponseSell ResponseOrder

type ResponseTicker

type ResponseTicker struct {
	Result        string // true
	Elapsed       string
	Last          string // 最新成交价
	LowestAsk     string // 卖1,卖方最低价
	HighestBid    string // 买1,买方最高价
	PercentChange string //涨跌百分比
	BaseVolume    string //交易量
	QuoteVolume   string // 兑换货币交易量
	High24hr      string // 24小时最高价
	Low24hr       string // 24小时最低价
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL