huobi

package
v0.0.0-...-5439e55 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT_ID           = 11
	DEFAULT_TAKER_FEE    = 0.002
	DEFAULT_MAKER_FEE    = 0.002
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_PRICE_FILTER = 0.00000001
	DEFAULT_TXFEE        = 0.005

	TRADE_HISTORY_MAX_LIMIT = 2000
)
View Source
const (
	API_URL string = "https://api.huobi.pro"
)

Variables

This section is empty.

Functions

func CreateSign

func CreateSign(mapParams map[string]string, strMethod, strHostUrl, strRequestPath, strSecretKey string) string

func MapSortByKey

func MapSortByKey(mapValue map[string]string) string

Types

type AccountBalances

type AccountBalances struct {
	ID    int    `json:"id"`
	Type  string `json:"type"`
	State string `json:"state"`
	List  []struct {
		Currency string `json:"currency"`
		Type     string `json:"type"`
		Balance  string `json:"balance"`
		Address  string `json:"address"`
	} `json:"list"`
}

type AccountsReturn

type AccountsReturn []struct {
	ID      int64  `json:"id"`
	Type    string `json:"type"`
	State   string `json:"state"`
	SubType string `json:"sub-type"`
}

type CoinsData

type CoinsData []struct {
	Currency string `json:"currency"`
	Chains   []struct {
		Chain                  string `json:"chain"`
		NumOfConfirmations     int    `json:"numOfConfirmations"`
		NumOfFastConfirmations int    `json:"numOfFastConfirmations"`
		DepositStatus          string `json:"depositStatus"`
		MinDepositAmt          string `json:"minDepositAmt"`
		WithdrawStatus         string `json:"withdrawStatus"`
		MinWithdrawAmt         string `json:"minWithdrawAmt"`
		WithdrawPrecision      int    `json:"withdrawPrecision"`
		MaxWithdrawAmt         string `json:"maxWithdrawAmt"`
		WithdrawQuotaPerDay    string `json:"withdrawQuotaPerDay"`
		WithdrawQuotaPerYear   string `json:"withdrawQuotaPerYear"`
		WithdrawQuotaTotal     string `json:"withdrawQuotaTotal"`
		WithdrawFeeType        string `json:"withdrawFeeType"`
		TransactFeeWithdraw    string `json:"transactFeeWithdraw"`
		MinTransactFeeWithdraw string `json:"minTransactFeeWithdraw"`
	} `json:"chains"`
	InstStatus string `json:"instStatus"`
}

type DWHistory

type DWHistory struct {
	ID         int     `json:"id"`
	Type       string  `json:"type"`
	Currency   string  `json:"currency"`
	TxHash     string  `json:"tx-hash"`
	Amount     float64 `json:"amount"`
	Address    string  `json:"address"`
	AddressTag string  `json:"address-tag"`
	Fee        int     `json:"fee"`
	State      string  `json:"state"`
	CreatedAt  int64   `json:"created-at"`
	UpdatedAt  int64   `json:"updated-at"`
}

type DepositAddress

type DepositAddress struct {
	Currency   string `json:"currency"`
	Address    string `json:"address"`
	AddressTag string `json:"addressTag"`
	Chain      string `json:"chain"`
}

type Huobi

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

	API_KEY    string
	API_SECRET string
	Account_ID string

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

func CreateHuobi

func CreateHuobi(config *exchange.Config) *Huobi

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

func (*Huobi) ApiKeyRequest

func (e *Huobi) ApiKeyRequest(strMethod string, mapParams map[string]string, strRequestPath 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 (*Huobi) CanDeposit

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

func (*Huobi) CanWithdraw

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

func (*Huobi) CancelAllOrder

func (e *Huobi) CancelAllOrder() error

func (*Huobi) CancelOrder

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

func (*Huobi) DeleteCoin

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

func (*Huobi) DeletePair

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

func (*Huobi) DoAccountOperation

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

func (*Huobi) GetAccounts

func (e *Huobi) GetAccounts() string

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

func (*Huobi) GetBalance

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

func (*Huobi) GetCoinBySymbol

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

func (*Huobi) GetCoinConstraint

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

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

func (*Huobi) GetCoins

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

func (*Huobi) GetCoinsData

func (e *Huobi) 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 (*Huobi) GetConfirmation

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

func (*Huobi) GetConstraintFetchMethod

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

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

func (*Huobi) GetFee

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

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

func (*Huobi) GetID

func (e *Huobi) GetID() int

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

func (*Huobi) GetLotSize

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

func (*Huobi) GetName

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

func (*Huobi) GetPairBySymbol

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

func (*Huobi) GetPairConstraint

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

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

func (*Huobi) GetPairs

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

func (*Huobi) GetPairsData

func (e *Huobi) 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 (*Huobi) GetPriceFilter

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

func (*Huobi) GetSymbolByCoin

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

func (*Huobi) GetSymbolByPair

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

func (*Huobi) GetTradingWebURL

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

func (*Huobi) GetTxFee

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

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

func (*Huobi) HasPair

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

func (*Huobi) InitData

func (e *Huobi) InitData() error

func (*Huobi) LimitBuy

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

func (*Huobi) LimitSell

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

func (*Huobi) ListOrders

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

func (*Huobi) LoadPublicData

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

************** PUBLIC API **************

func (*Huobi) OrderBook

func (e *Huobi) 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 (*Huobi) OrderStatus

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

func (*Huobi) SetCoinConstraint

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

func (*Huobi) SetPairConstraint

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

func (*Huobi) UpdateAllBalances

func (e *Huobi) UpdateAllBalances()

func (*Huobi) UpdateConstraint

func (e *Huobi) UpdateConstraint()

func (*Huobi) Withdraw

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

type JsonResponse

type JsonResponse struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Status  string          `json:"status"`
	Data    json.RawMessage `json:"data"`
	Tick    json.RawMessage `json:"tick"`
	ErrCode string          `json:"err-code"`
	ErrMsg  string          `json:"err-msg"`
}

type KLines

type KLines []struct {
	ID     int64   `json:"id"`
	Amount float64 `json:"amount"`
	Count  int     `json:"count"`
	Open   float64 `json:"open"`
	Close  float64 `json:"close"`
	Low    float64 `json:"low"`
	High   float64 `json:"high"`
	Vol    float64 `json:"vol"`
}

type OrderBook

type OrderBook struct {
	Bids    [][]float64 `json:"bids"`
	Asks    [][]float64 `json:"asks"`
	ID      interface{} `json:"id"`
	Ts      int64       `json:"ts"`
	Version int64       `json:"version"`
}

type OrderStatus

type OrderStatus struct {
	ID               int    `json:"id"`
	Symbol           string `json:"symbol"`
	AccountID        int    `json:"account-id"`
	Amount           string `json:"amount"`
	Price            string `json:"price"`
	CreatedAt        int64  `json:"created-at"`
	Type             string `json:"type"`
	FieldAmount      string `json:"field-amount"`
	FieldCashAmount  string `json:"field-cash-amount"`
	FieldFees        string `json:"field-fees"`
	FilledAmount     string `json:"filled-amount"`
	FilledCashAmount string `json:"filled-cash-amount"`
	FilledFees       string `json:"filled-fees"`
	FinishedAt       int64  `json:"finished-at"`
	UserID           int    `json:"user-id"`
	Source           string `json:"source"`
	State            string `json:"state"`
	CanceledAt       int    `json:"canceled-at"`
	Exchange         string `json:"exchange"`
	Batch            string `json:"batch"`
}

type PairsData

type PairsData []struct {
	BaseCurrency             string  `json:"base-currency"`
	QuoteCurrency            string  `json:"quote-currency"`
	PricePrecision           int     `json:"price-precision"`
	AmountPrecision          int     `json:"amount-precision"`
	SymbolPartition          string  `json:"symbol-partition"`
	Symbol                   string  `json:"symbol"`
	State                    string  `json:"state"`
	ValuePrecision           int     `json:"value-precision"`
	MinOrderAmt              float64 `json:"min-order-amt"`
	MaxOrderAmt              float64 `json:"max-order-amt"`
	MinOrderValue            float64 `json:"min-order-value"`
	LeverageRatio            float64 `json:"leverage-ratio,omitempty"`
	SuperMarginLeverageRatio float64 `json:"super-margin-leverage-ratio,omitempty"`
	FundingLeverageRatio     float64 `json:"funding-leverage-ratio,omitempty"`
}

type SubAccountBalances

type SubAccountBalances []struct {
	ID   int    `json:"id"`
	Type string `json:"type"`
	List []struct {
		Currency string `json:"currency"`
		Type     string `json:"type"`
		Balance  string `json:"balance"`
	} `json:"list"`
}

type SubAccountList

type SubAccountList []struct {
	ID      int    `json:"id"`
	Type    string `json:"type"`
	Subtype string `json:"subtype"` // sub account type
	State   string `json:"state"`
}

type SubAllAccountBalances

type SubAllAccountBalances []struct {
	Currency string `json:"currency"`
	Type     string `json:"type"`
	Balance  string `json:"balance"`
}

type SubTransfer

type SubTransfer struct {
	Status  string `json:"status"`
	Data    int    `json:"data"`
	ErrCode string `json:"err-code"`
	ErrMsg  string `json:"err-msg"`
}

type TickerPrice

type TickerPrice []struct {
	Symbol  string  `json:"symbol"`
	Open    float64 `json:"open"`
	High    float64 `json:"high"`
	Low     float64 `json:"low"`
	Close   float64 `json:"close"`
	Amount  float64 `json:"amount"`
	Vol     float64 `json:"vol"`
	Count   int     `json:"count"`
	Bid     float64 `json:"bid"`
	BidSize float64 `json:"bidSize"`
	Ask     float64 `json:"ask"`
	AskSize float64 `json:"askSize"`
}

type TradeHistory

type TradeHistory struct {
	Status string `json:"status"`
	Ch     string `json:"ch"`
	Ts     uint   `json:"ts"`
	Data   []struct {
		ID   uint `json:"id"`
		Ts   uint `json:"ts"`
		Data []struct {
			Amount  float64 `json:"amount"`
			TradeID uint    `json:"trade-id"`
			Ts      int64   `json:"ts"`
			// ID        uint64  `json:"id"`
			Price     float64 `json:"price"`
			Direction string  `json:"direction"`
		} `json:"data"`
	} `json:"data"`
}

type TransferHistory

type TransferHistory []struct {
	AccountID    int     `json:"accountId"`
	Currency     string  `json:"currency"`
	TransactAmt  float64 `json:"transactAmt"`
	TransactType string  `json:"transactType"`
	TransferType string  `json:"transferType"`
	TransactID   int     `json:"transactId"`
	TransactTime int64   `json:"transactTime"`
	Transferer   int     `json:"transferer"`
	Transferee   int     `json:"transferee"`
}

Jump to

Keyboard shortcuts

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