gateio

package
v0.0.0-...-db5ea55 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_URL     string = "https://data.gate.io"
	Private_URL string = "https://api.gateio.io"
)
View Source
const (
	DEFAULT_ID           = 19
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_TXFEE        = 0.005
	DEFAULT_WITHDRAW     = true
	DEFAULT_DEPOSIT      = true
	DEFAULT_CONFIRMATION = 2
	DEFAULT_LISTED       = true
)

Variables

This section is empty.

Functions

func ComputeHmac512

func ComputeHmac512(strMessage string, strSecret string) string

Types

type AccountBalances

type AccountBalances struct {
	Result    string          `json:"result"`
	Available json.RawMessage `json:"available"`
	Locked    json.RawMessage `json:"locked"`
	Code      int             `json:"code"`
	Message   string          `json:"message"`
}

type CancelOrder

type CancelOrder struct {
	Result bool `json:"result"`
	Order  struct {
		OrderNumber   string  `json:"orderNumber"`
		Status        string  `json:"status"`
		CurrencyPair  string  `json:"currencyPair"`
		Type          string  `json:"type"`
		Rate          string  `json:"rate"`
		Amount        string  `json:"amount"`
		InitialRate   string  `json:"initialRate"`
		InitialAmount string  `json:"initialAmount"`
		FilledAmount  string  `json:"filledAmount"`
		FilledRate    string  `json:"filledRate"`
		FeePercentage float64 `json:"feePercentage"`
		FeeValue      string  `json:"feeValue"`
		FeeCurrency   string  `json:"feeCurrency"`
		Fee           string  `json:"fee"`
		Timestamp     int     `json:"timestamp"`
	} `json:"order"`
	Message string `json:"message"`
	Code    int    `json:"code"`
	Elapsed string `json:"elapsed"`
}

type CoinsConstrain

type CoinsConstrain struct {
	Result string                  `json:"result"`
	Coins  []map[string]*Constrain `json:"coins"`
}

type CoinsData

type CoinsData struct {
	Result string `json:"result"`
	Data   []struct {
		No          int         `json:"no"`
		Symbol      string      `json:"symbol"`
		Name        string      `json:"name"`
		NameEn      string      `json:"name_en"`
		NameCn      string      `json:"name_cn"`
		Pair        string      `json:"pair"`
		Rate        string      `json:"rate"`
		VolA        string      `json:"vol_a"`
		VolB        string      `json:"vol_b"`
		CurrA       string      `json:"curr_a"`
		CurrB       string      `json:"curr_b"`
		CurrSuffix  string      `json:"curr_suffix"`
		RatePercent string      `json:"rate_percent"`
		Trend       string      `json:"trend"`
		Supply      interface{} `json:"supply"`
		Marketcap   interface{} `json:"marketcap"`
		Lq          string      `json:"lq"`
	} `json:"data"`
}

type Constrain

type Constrain struct {
	Delisted         int `json:"delisted"`
	WithdrawDisabled int `json:"withdraw_disabled"`
	WithdrawDelayed  int `json:"withdraw_delayed"`
	DepositDisabled  int `json:"deposit_disabled"`
	TradeDisabled    int `json:"trade_disabled"`
}

type FreeBalance

type FreeBalance struct {
	Result    string            `json:"result"`
	Available map[string]string `json:"available"`
	Locked    map[string]string `json:"locked"`
	Code      int               `json:"code"`
	Message   string            `json:"message"`
}

type Gateio

type Gateio struct {
	ID      int
	Name    string `bson:"name"`
	Website string `bson:"website"`

	API_KEY    string
	API_SECRET string

	Source    exchange.DataSource // / exchange API / microservicve api 1 / PSQL
	SourceURI string
}

func CreateGateio

func CreateGateio(config *exchange.Config) *Gateio

*************************************************

func (*Gateio) ApiKeyPost

func (e *Gateio) ApiKeyPost(strRequestPath string, mapParams map[string]string) string

************** Signature Http Request ************** Method: API Request and Signature is required Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Create mapParams Depend on API Signature request Step 3: Add HttpGetRequest below strUrl if API has different requests

func (*Gateio) CanDeposit

func (e *Gateio) CanDeposit(coin *coin.Coin) bool

func (*Gateio) CanWithdraw

func (e *Gateio) CanWithdraw(coin *coin.Coin) bool

func (*Gateio) CancelAllOrder

func (e *Gateio) CancelAllOrder() error

func (*Gateio) CancelOrder

func (e *Gateio) CancelOrder(order *exchange.Order) error

func (*Gateio) DeleteCoin

func (e *Gateio) DeleteCoin(coin *coin.Coin)

func (*Gateio) DeletePair

func (e *Gateio) DeletePair(pair *pair.Pair)

func (*Gateio) DoAccountOperation

func (e *Gateio) DoAccountOperation(operation *exchange.AccountOperation) error

************** Private API **************

func (*Gateio) GetBalance

func (e *Gateio) GetBalance(coin *coin.Coin) float64

func (*Gateio) GetCoinBySymbol

func (e *Gateio) GetCoinBySymbol(symbol string) *coin.Coin

func (*Gateio) GetCoinConstraint

func (e *Gateio) GetCoinConstraint(coin *coin.Coin) *exchange.CoinConstraint

************** Coins on the Exchanges **************

func (*Gateio) GetCoins

func (e *Gateio) GetCoins() []*coin.Coin

func (*Gateio) GetCoinsData

func (e *Gateio) GetCoinsData() error

************** Public API ************** Get Coins Information (If API provide) Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Gateio) GetConfirmation

func (e *Gateio) GetConfirmation(coin *coin.Coin) int

func (*Gateio) GetConstraintFetchMethod

func (e *Gateio) GetConstraintFetchMethod(pair *pair.Pair) *exchange.ConstrainFetchMethod

*************** Exchange Constraint ***************

func (*Gateio) GetFee

func (e *Gateio) GetFee(pair *pair.Pair) float64

*************** Pair Constraint ***************

func (*Gateio) GetID

func (e *Gateio) GetID() int

*************** Exchange Information ***************

func (*Gateio) GetLotSize

func (e *Gateio) GetLotSize(pair *pair.Pair) float64

func (*Gateio) GetName

func (e *Gateio) GetName() exchange.ExchangeName

func (*Gateio) GetPairBySymbol

func (e *Gateio) GetPairBySymbol(symbol string) *pair.Pair

func (*Gateio) GetPairConstraint

func (e *Gateio) GetPairConstraint(pair *pair.Pair) *exchange.PairConstraint

************** Pairs on the Exchanges **************

func (*Gateio) GetPairs

func (e *Gateio) GetPairs() []*pair.Pair

func (*Gateio) GetPairsData

func (e *Gateio) GetPairsData() error
GetPairsData - Get Pairs Information (If API provide)

Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Gateio) GetPriceFilter

func (e *Gateio) GetPriceFilter(pair *pair.Pair) float64

func (*Gateio) GetSymbolByCoin

func (e *Gateio) GetSymbolByCoin(coin *coin.Coin) string

func (*Gateio) GetSymbolByPair

func (e *Gateio) GetSymbolByPair(pair *pair.Pair) string

func (*Gateio) GetTradingWebURL

func (e *Gateio) GetTradingWebURL(pair *pair.Pair) string

func (*Gateio) GetTxFee

func (e *Gateio) GetTxFee(coin *coin.Coin) float64

*************** Coin Constraint ***************

func (*Gateio) HasPair

func (e *Gateio) HasPair(pair *pair.Pair) bool

func (*Gateio) InitData

func (e *Gateio) InitData() error

func (*Gateio) LimitBuy

func (e *Gateio) LimitBuy(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Gateio) LimitSell

func (e *Gateio) LimitSell(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Gateio) ListOrders

func (e *Gateio) ListOrders() ([]*exchange.Order, error)

func (*Gateio) LoadPublicData

func (e *Gateio) LoadPublicData(operation *exchange.PublicOperation) error

func (*Gateio) OrderBook

func (e *Gateio) OrderBook(pair *pair.Pair) (*exchange.Maker, error)

Get Pair Market Depth Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Get Exchange Pair Code ex. symbol := e.GetPairCode(p) Step 4: Modify API Path(strRequestUrl) Step 5: Add Params - Depend on API request Step 6: Convert the response to Standard Maker struct

func (*Gateio) OrderStatus

func (e *Gateio) OrderStatus(order *exchange.Order) error

func (*Gateio) SetCoinConstraint

func (e *Gateio) SetCoinConstraint(coinConstraint *exchange.CoinConstraint)

func (*Gateio) SetConstraint

func (e *Gateio) SetConstraint() error

func (*Gateio) SetPairConstraint

func (e *Gateio) SetPairConstraint(pairConstraint *exchange.PairConstraint)

func (*Gateio) UpdateAllBalances

func (e *Gateio) UpdateAllBalances()

func (*Gateio) UpdateConstraint

func (e *Gateio) UpdateConstraint()

func (*Gateio) Withdraw

func (e *Gateio) Withdraw(coin *coin.Coin, quantity float64, addr, tag string) bool

func (*Gateio) WithdrawKeyRequest

func (e *Gateio) WithdrawKeyRequest(strRequestPath string, mapParams map[string]string) string

type OrderBook

type OrderBook struct {
	Elapsed string     `json:"elapsed"`
	Asks    [][]string `json:"asks"`
	Bids    [][]string `json:"bids"`
	Result  string     `json:"result"`
}

type OrderStatus

type OrderStatus struct {
	Result string `json:"result"`
	Order  struct {
		ID            string `json:"id"`
		Status        string `json:"status"`
		Pair          string `json:"pair"`
		Type          string `json:"type"`
		Rate          string `json:"rate"`
		Amount        string `json:"amount"`
		InitialRate   string `json:"initial_rate"`
		InitialAmount string `json:"initial_amount"`
	} `json:"order"`
	Message string `json:"message"`
}

type Pair

type Pair struct {
	DecimalPlaces int     `json:"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"`
}

type PairsData

type PairsData struct {
	Result string             `json:"result"`
	Pairs  []map[string]*Pair `json:"pairs"`
}

type PlaceOrder

type PlaceOrder struct {
	Result        string  `json:"result"`
	Message       string  `json:"message"`
	Code          int     `json:"code"`
	Ctime         float64 `json:"ctime"`
	Side          int     `json:"side"`
	OrderNumber   int     `json:"orderNumber"`
	Rate          string  `json:"rate"`
	LeftAmount    string  `json:"leftAmount"`
	DealStock     string  `json:"deal_stock"`
	DealMoney     string  `json:"deal_money"`
	FilledAmount  string  `json:"filledAmount"`
	FilledRate    string  `json:"filledRate"`
	FeePercentage float64 `json:"feePercentage"`
	FeeValue      string  `json:"feeValue"`
	FeeCurrency   string  `json:"feeCurrency"`
	Fee           string  `json:"fee"`
}

type TradeHistory

type TradeHistory struct {
	Elapsed string `json:"elapsed"`
	Result  string `json:"result"`
	Data    []struct {
		TradeID   string `json:"tradeID"`
		Total     string `json:"total"`
		Date      string `json:"date"`
		Rate      string `json:"rate"`
		Amount    string `json:"amount"`
		Timestamp string `json:"timestamp"`
		Type      string `json:"type"`
	} `json:"data"`
}

type WithdrawResponse

type WithdrawResponse struct {
	Result  string `json:"result"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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