huobi

package
v0.0.0-...-2fde92b Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HB_POINT_ACCOUNT = "point"
	HB_SPOT_ACCOUNT  = "spot"
)

Variables

View Source
var (
	FuturesContractInfos []FuturesContractInfo
)
View Source
var HBPOINT = NewCurrency("HBPOINT", "")

Functions

func ParseCurrencyPairFromSpotWsCh

func ParseCurrencyPairFromSpotWsCh(ch string) goex.CurrencyPair

func ParseDepthFromResponse

func ParseDepthFromResponse(r DepthResponse) goex.Depth

Types

type AccountInfo

type AccountInfo struct {
	Id    string
	Type  string
	State string
}

type BaseResponse

type BaseResponse struct {
	Status  string          `json:"status"`
	Ch      string          `json:"ch"`
	Ts      int64           `json:"ts"`
	ErrCode int             `json:"err_code"`
	ErrMsg  string          `json:"err_msg"`
	Data    json.RawMessage `json:"data"`
}

type DepthResponse

type DepthResponse struct {
	Bids [][]float64
	Asks [][]float64
	Ts   int64 `json:"ts"`
}

type DetailResponse

type DetailResponse struct {
	Id     int64
	Open   float64
	Close  float64
	High   float64
	Low    float64
	Amount float64
	Vol    float64
	Count  int64
}

"id": 1539842340, "mrid": 268041138, "open": 6740.47, "close": 7800, "high": 7800, "low": 6726.13, "amount": 477.1200312075244664773339914558562673572, "vol": 32414, "count": 1716 }

type Hbdm

type Hbdm struct {
	// contains filtered or unexported fields
}

func NewHbdm

func NewHbdm(conf *APIConfig) *Hbdm

func (*Hbdm) FutureCancelOrder

func (dm *Hbdm) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*Hbdm) GetContractValue

func (dm *Hbdm) GetContractValue(currencyPair CurrencyPair) (float64, error)

func (*Hbdm) GetDeliveryTime

func (dm *Hbdm) GetDeliveryTime() (int, int, int, int)

func (*Hbdm) GetExchangeName

func (dm *Hbdm) GetExchangeName() string

func (*Hbdm) GetExchangeRate

func (dm *Hbdm) GetExchangeRate() (float64, error)

func (*Hbdm) GetFee

func (dm *Hbdm) GetFee() (float64, error)

func (*Hbdm) GetFutureDepth

func (dm *Hbdm) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*Hbdm) GetFutureEstimatedPrice

func (dm *Hbdm) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*Hbdm) GetFutureIndex

func (dm *Hbdm) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*Hbdm) GetFutureOrder

func (dm *Hbdm) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

func (*Hbdm) GetFutureOrderHistory

func (dm *Hbdm) GetFutureOrderHistory(pair CurrencyPair, contractType string, optional ...OptionalParameter) ([]FutureOrder, error)

func (*Hbdm) GetFutureOrders

func (dm *Hbdm) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*Hbdm) GetFuturePosition

func (dm *Hbdm) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*Hbdm) GetFutureTicker

func (dm *Hbdm) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*Hbdm) GetFutureUserinfo

func (dm *Hbdm) GetFutureUserinfo(currencyPair ...CurrencyPair) (*FutureAccount, error)

func (*Hbdm) GetKlineRecords

func (dm *Hbdm) GetKlineRecords(contract_type string, currency CurrencyPair, period KlinePeriod, size int, opt ...OptionalParameter) ([]FutureKline, error)

func (*Hbdm) GetTrades

func (dm *Hbdm) GetTrades(contract_type string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*Hbdm) GetUnfinishFutureOrders

func (dm *Hbdm) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*Hbdm) LimitFuturesOrder

func (dm *Hbdm) LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)

func (*Hbdm) MarketFuturesOrder

func (dm *Hbdm) MarketFuturesOrder(currencyPair CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error)

func (*Hbdm) PlaceFutureOrder

func (dm *Hbdm) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error)

func (*Hbdm) PlaceFutureOrder2

func (dm *Hbdm) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)

type HbdmSwap

type HbdmSwap struct {
	// contains filtered or unexported fields
}

func NewHbdmSwap

func NewHbdmSwap(c *APIConfig) *HbdmSwap

func (*HbdmSwap) FutureCancelOrder

func (swap *HbdmSwap) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*HbdmSwap) GetContractValue

func (swap *HbdmSwap) GetContractValue(currencyPair CurrencyPair) (float64, error)

func (*HbdmSwap) GetDeliveryTime

func (swap *HbdmSwap) GetDeliveryTime() (int, int, int, int)

func (*HbdmSwap) GetExchangeName

func (swap *HbdmSwap) GetExchangeName() string

func (*HbdmSwap) GetFee

func (swap *HbdmSwap) GetFee() (float64, error)

func (*HbdmSwap) GetFutureDepth

func (swap *HbdmSwap) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*HbdmSwap) GetFutureEstimatedPrice

func (swap *HbdmSwap) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*HbdmSwap) GetFutureIndex

func (swap *HbdmSwap) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*HbdmSwap) GetFutureOrder

func (swap *HbdmSwap) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

func (*HbdmSwap) GetFutureOrderHistory

func (swap *HbdmSwap) GetFutureOrderHistory(pair CurrencyPair, contractType string, optional ...OptionalParameter) ([]FutureOrder, error)

func (*HbdmSwap) GetFutureOrders

func (swap *HbdmSwap) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*HbdmSwap) GetFuturePosition

func (swap *HbdmSwap) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*HbdmSwap) GetFutureTicker

func (swap *HbdmSwap) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*HbdmSwap) GetFutureUserinfo

func (swap *HbdmSwap) GetFutureUserinfo(currencyPair ...CurrencyPair) (*FutureAccount, error)

func (*HbdmSwap) GetKlineRecords

func (swap *HbdmSwap) GetKlineRecords(contractType string, currency CurrencyPair, period KlinePeriod, size int, opt ...OptionalParameter) ([]FutureKline, error)

func (*HbdmSwap) GetTrades

func (swap *HbdmSwap) GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*HbdmSwap) GetUnfinishFutureOrders

func (swap *HbdmSwap) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*HbdmSwap) LimitFuturesOrder

func (swap *HbdmSwap) LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)

func (*HbdmSwap) MarketFuturesOrder

func (swap *HbdmSwap) MarketFuturesOrder(currencyPair CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error)

func (*HbdmSwap) PlaceFutureOrder

func (swap *HbdmSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error)

type HbdmSwapWs

type HbdmSwapWs struct {
	*WsBuilder
	sync.Once
	// contains filtered or unexported fields
}

func NewHbdmLinearSwapWs

func NewHbdmLinearSwapWs() *HbdmSwapWs

构建usdt本位永续合约ws

func NewHbdmSwapWs

func NewHbdmSwapWs() *HbdmSwapWs

func (*HbdmSwapWs) DepthCallback

func (ws *HbdmSwapWs) DepthCallback(call func(depth *Depth))

func (*HbdmSwapWs) SetCallbacks

func (ws *HbdmSwapWs) SetCallbacks(tickerCallback func(*FutureTicker),
	depthCallback func(*Depth),
	tradeCallback func(*Trade, string))

func (*HbdmSwapWs) SubscribeDepth

func (ws *HbdmSwapWs) SubscribeDepth(pair CurrencyPair, contract string) error

func (*HbdmSwapWs) SubscribeTicker

func (ws *HbdmSwapWs) SubscribeTicker(pair CurrencyPair, contract string) error

func (*HbdmSwapWs) SubscribeTrade

func (ws *HbdmSwapWs) SubscribeTrade(pair CurrencyPair, contract string) error

func (*HbdmSwapWs) TickerCallback

func (ws *HbdmSwapWs) TickerCallback(call func(ticker *FutureTicker))

func (*HbdmSwapWs) TradeCallback

func (ws *HbdmSwapWs) TradeCallback(call func(trade *Trade, contract string))

type HbdmWs

type HbdmWs struct {
	*WsBuilder
	sync.Once
	// contains filtered or unexported fields
}

func NewHbdmWs

func NewHbdmWs() *HbdmWs

func (*HbdmWs) DepthCallback

func (hbdmWs *HbdmWs) DepthCallback(call func(depth *Depth))

func (*HbdmWs) SetCallbacks

func (hbdmWs *HbdmWs) SetCallbacks(tickerCallback func(*FutureTicker),
	depthCallback func(*Depth),
	tradeCallback func(*Trade, string))

func (*HbdmWs) SubscribeDepth

func (hbdmWs *HbdmWs) SubscribeDepth(pair CurrencyPair, contract string) error

func (*HbdmWs) SubscribeTicker

func (hbdmWs *HbdmWs) SubscribeTicker(pair CurrencyPair, contract string) error

func (*HbdmWs) SubscribeTrade

func (hbdmWs *HbdmWs) SubscribeTrade(pair CurrencyPair, contract string) error

func (*HbdmWs) TickerCallback

func (hbdmWs *HbdmWs) TickerCallback(call func(ticker *FutureTicker))

func (*HbdmWs) TradeCallback

func (hbdmWs *HbdmWs) TradeCallback(call func(trade *Trade, contract string))

type HuoBiPro

type HuoBiPro struct {
	Symbols map[string]HuoBiProSymbol
	// contains filtered or unexported fields
}

func NewHuoBiPro

func NewHuoBiPro(client *http.Client, apikey, secretkey, accountId string) *HuoBiPro

func NewHuoBiProPoint

func NewHuoBiProPoint(client *http.Client, apikey, secretkey string) *HuoBiPro

*

  • 点卡账户

func NewHuoBiProSpot

func NewHuoBiProSpot(client *http.Client, apikey, secretkey string) *HuoBiPro

*

*现货交易

func NewHuobiWithConfig

func NewHuobiWithConfig(config *APIConfig) *HuoBiPro

func (*HuoBiPro) CancelOrder

func (hbpro *HuoBiPro) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

func (*HuoBiPro) GetAccount

func (hbpro *HuoBiPro) GetAccount() (*Account, error)

func (*HuoBiPro) GetAccountInfo

func (hbpro *HuoBiPro) GetAccountInfo(acc string) (AccountInfo, error)

func (*HuoBiPro) GetCurrenciesList

func (hbpro *HuoBiPro) GetCurrenciesList() ([]string, error)

func (*HuoBiPro) GetCurrenciesPrecision

func (hbpro *HuoBiPro) GetCurrenciesPrecision() ([]HuoBiProSymbol, error)

func (*HuoBiPro) GetDepth

func (hbpro *HuoBiPro) GetDepth(size int, currency CurrencyPair) (*Depth, error)

func (*HuoBiPro) GetExchangeName

func (hbpro *HuoBiPro) GetExchangeName() string

func (*HuoBiPro) GetKlineRecords

func (hbpro *HuoBiPro) GetKlineRecords(currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error)

倒序

func (*HuoBiPro) GetOneOrder

func (hbpro *HuoBiPro) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

func (*HuoBiPro) GetOrderHistorys

func (hbpro *HuoBiPro) GetOrderHistorys(currency CurrencyPair, optional ...OptionalParameter) ([]Order, error)

func (*HuoBiPro) GetTicker

func (hbpro *HuoBiPro) GetTicker(currencyPair CurrencyPair) (*Ticker, error)

func (*HuoBiPro) GetTrades

func (hbpro *HuoBiPro) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*HuoBiPro) GetUnfinishOrders

func (hbpro *HuoBiPro) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*HuoBiPro) LimitBuy

func (hbpro *HuoBiPro) LimitBuy(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*HuoBiPro) LimitSell

func (hbpro *HuoBiPro) LimitSell(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*HuoBiPro) MarketBuy

func (hbpro *HuoBiPro) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*HuoBiPro) MarketSell

func (hbpro *HuoBiPro) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)

type HuoBiProSymbol

type HuoBiProSymbol struct {
	BaseCurrency    string
	QuoteCurrency   string
	PricePrecision  float64
	AmountPrecision float64
	MinAmount       float64
	MinValue        float64
	SymbolPartition string
	Symbol          string
}

type OrderInfo

type OrderInfo struct {
	Symbol         string  `json:"symbol"`
	ContractType   string  `json:"contract_type"`
	ContractCode   string  `json:"contract_code"`
	Volume         float64 `json:"volume"`
	Price          float64 `json:"price"`
	OrderPriceType string  `json:"order_price_type"`
	Direction      string  `json:"direction"`
	Offset         string  `json:"offset"`
	LeverRate      float64 `json:"lever_rate"`
	OrderId        int64   `json:"order_id"`
	ClientOrderId  int64   `json:"client_order_id"`
	OrderSource    string  `json:"order_source"`
	CreatedAt      int64   `json:"created_at"`
	CreateDate     int64   `json:"create_date"` //for swap contract
	TradeVolume    float64 `json:"trade_volume"`
	TradeTurnover  float64 `json:"trade_turnover"`
	Fee            float64 `json:"fee"`
	TradeAvgPrice  float64 `json:"trade_avg_price"`
	MarginFrozen   float64 `json:"margin_frozen"`
	Status         int     `json:"status"`
}

type SpotWs

type SpotWs struct {
	*WsBuilder
	sync.Once
	// contains filtered or unexported fields
}

func NewSpotWs

func NewSpotWs() *SpotWs

func (*SpotWs) DepthCallback

func (ws *SpotWs) DepthCallback(call func(depth *Depth))

func (*SpotWs) SubscribeDepth

func (ws *SpotWs) SubscribeDepth(pair CurrencyPair) error

func (*SpotWs) SubscribeTicker

func (ws *SpotWs) SubscribeTicker(pair CurrencyPair) error

func (*SpotWs) SubscribeTrade

func (ws *SpotWs) SubscribeTrade(pair CurrencyPair) error

func (*SpotWs) TickerCallback

func (ws *SpotWs) TickerCallback(call func(ticker *Ticker))

func (*SpotWs) TradeCallback

func (ws *SpotWs) TradeCallback(call func(trade *Trade))

type TradeResponse

type TradeResponse struct {
	Id   int64
	Ts   int64
	Data []struct {
		Id        int64
		Amount    float64
		Price     float64
		Direction string
		Ts        int64
	}
}

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(c *APIConfig) *Wallet

func (*Wallet) GetAccount

func (w *Wallet) GetAccount() (*Account, error)

获取钱包资产

func (*Wallet) GetDepositHistory

func (w *Wallet) GetDepositHistory(currency *Currency) ([]DepositWithdrawHistory, error)

func (*Wallet) GetWithDrawHistory

func (w *Wallet) GetWithDrawHistory(currency *Currency) ([]DepositWithdrawHistory, error)

func (*Wallet) Transfer

func (w *Wallet) Transfer(param TransferParameter) error

func (*Wallet) Withdrawal

func (w *Wallet) Withdrawal(param WithdrawParameter) (withdrawId string, err error)

type WsResponse

type WsResponse struct {
	Ch   string
	Ts   int64
	Tick json.RawMessage
}

Jump to

Keyboard shortcuts

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