huobi

package
v0.10.11 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const (
	BTC_USDT = "btcusdt"

	BTC  = "btc"
	USDT = "usdt"
	HT   = "ht"
)
View Source
const (
	OrderTypeBuyMarket  = "buy-market"
	OrderTypeSellMarket = "sell-market"
	OrderTypeBuyLimit   = "buy-limit"
	OrderTypeSellLimit  = "sell-limit"

	// IOC 全名 Immediate or Cancel(立即成交或撤单),
	// 指用户下的限价单,如果在指定价格不能立即成交,则撤销未成交的部分。
	OrderTypeBuyIoc  = "buy-ioc"
	OrderTypeSellIoc = "sell-ioc"

	// buy-limit-maker
	// 当“下单价格”>=“市场最低卖出价”,订单提交后,系统将拒绝接受此订单;
	// 当“下单价格”<“市场最低卖出价”,提交成功后,此订单将被系统接受。
	OrderTypeBuyLimitMaker = "buy-limit-maker"

	// sell-limit-maker
	// 当“下单价格”<=“市场最高买入价”,订单提交后,系统将拒绝接受此订单;
	// 当“下单价格”>“市场最高买入价”,提交成功后,此订单将被系统接受。
	OrderTypeSellLimitMaker = "sell-limit-maker"

	// 用户在下止盈止损订单时,须额外填写触发价 “stop-price” 与触发价运算符“operator”,
	// 并在订单类型 “type” 中指定订单类型 – “buy-stop-limit” 或 “sell-stop-limit”。
	// 其中,触发价运算符为 ”gte” 时,表示当市场最新成交价大于等于此触发价时该止盈止损订单将被触发;
	// 触发价运算符为 ”lte” 时,表示当市场最新成交价小于等于此触发价时该止盈止损订单将被触发。
	// 如果用户设置的触发价及运算符导致下单即被触发,该止盈止损订单将被拒绝接受。
	OrderTypeBuyStopLimit  = "buy-stop-limit"
	OrderTypeSellStopLimit = "sell-stop-limit"

	// - buy-limit-fok(FOK限价买单)
	// - sell-limit-fok(FOK限价卖单)
	// - buy-stop-limit-fok(FOK止盈止损限价买单)
	// - sell-stop-limit-fok(FOK止盈止损限价卖单)
	// 四个订单类型的订单有效期均为FOK(Fill or Kill),
	// 意即 – 如该订单下单后不能立即完全成交,则将被立即全部自动撤销。
	OrderTypeBuyLimitFok      = "buy-limit-fok"
	OrderTypeSellLimitFok     = "sell-limit-fok"
	OrderTypeBuyStopLimitFok  = "buy-stop-limit-fok"
	OrderTypeSellStopLimitFok = "sell-stop-limit-fok"
)
View Source
const (
	Name        = "huobi"
	DefaultHost = "api.huobi.me"
)
View Source
const CandlestickReqMaxLength = 300

Variables

View Source
var (
	PricePrecision = map[string]int32{
		"btcusdt": 2,
	}
	AmountPrecision = map[string]int32{
		"btcusdt": 5,
	}
	MinAmount = map[string]float64{
		"btcusdt": 0.0001,
	}
	MinTotal = map[string]float64{
		"btcusdt": 5,
	}
)

Functions

This section is empty.

Types

type CandleSlice added in v0.7.18

type CandleSlice []hs.Candle

func (CandleSlice) Len added in v0.7.18

func (cs CandleSlice) Len() int

func (CandleSlice) Less added in v0.7.18

func (cs CandleSlice) Less(i, j int) bool

func (CandleSlice) Swap added in v0.7.18

func (cs CandleSlice) Swap(i, j int)

type Client

type Client struct {
	Label     string
	AccessKey string
	SecretKey string
	Host      string

	SpotAccountId int64
}

func New

func New(label, accessKey, secretKey, host string) *Client

func (Client) AmountPrecision added in v0.8.0

func (c Client) AmountPrecision(symbol string) int32

func (*Client) BuyLimit added in v0.10.4

func (c *Client) BuyLimit(symbol, clientOrderId string, price, amount decimal.Decimal) (orderId uint64, err error)

func (*Client) BuyMarket added in v0.10.9

func (c *Client) BuyMarket(symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)

func (*Client) BuyStopLimit added in v0.10.4

func (c *Client) BuyStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)

func (*Client) CancelOrder

func (c *Client) CancelOrder(symbol string, orderId uint64) error

func (*Client) Candle added in v0.10.0

func (c *Client) Candle(symbol string, period time.Duration, size int) (hs.Candle, error)

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo() ([]account.AccountInfo, error)

func (*Client) GetCandle added in v0.7.5

func (c *Client) GetCandle(symbol, clientId, period string, from, to time.Time) (hs.Candle, error)

func (*Client) GetSpotAccountId

func (c *Client) GetSpotAccountId() (int64, error)

func (*Client) GetTimestamp

func (c *Client) GetTimestamp() (int, error)

func (*Client) LastPrice added in v0.10.0

func (c *Client) LastPrice(symbol string) (decimal.Decimal, error)

func (Client) MinAmount added in v0.10.0

func (c Client) MinAmount(symbol string) decimal.Decimal

func (Client) MinTotal added in v0.10.0

func (c Client) MinTotal(symbol string) decimal.Decimal

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(request *postrequest.PlaceOrderRequest) (uint64, error)

func (Client) PricePrecision added in v0.8.0

func (c Client) PricePrecision(symbol string) int32

func (*Client) SellLimit added in v0.10.4

func (c *Client) SellLimit(symbol, clientOrderId string, price, amount decimal.Decimal) (orderId uint64, err error)

func (*Client) SellMarket added in v0.10.9

func (c *Client) SellMarket(symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error)

func (*Client) SellStopLimit added in v0.10.4

func (c *Client) SellStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error)

func (*Client) SpotAvailableBalance added in v0.10.0

func (c *Client) SpotAvailableBalance() (map[string]decimal.Decimal, error)

func (*Client) SpotLimitOrder added in v0.10.4

func (c *Client) SpotLimitOrder(orderType, symbol, clientOrderId string, price, amount decimal.Decimal) (uint64, error)

func (*Client) SpotMarketOrder added in v0.10.9

func (c *Client) SpotMarketOrder(orderType, symbol, clientOrderId string, total decimal.Decimal) (uint64, error)

func (*Client) SpotStopLimitOrder added in v0.10.4

func (c *Client) SpotStopLimitOrder(orderType, symbol, clientOrderId, operator string, price, amount, stopPrice decimal.Decimal) (uint64, error)

func (*Client) SubscribeAccountUpdate

func (c *Client) SubscribeAccountUpdate(ctx context.Context, symbol, clientId string,
	responseHandler websocketclientbase.ResponseHandler) error

func (*Client) SubscribeCandlestick

func (c *Client) SubscribeCandlestick(ctx context.Context, symbol, clientId string, period time.Duration,
	responseHandler websocketclientbase.ResponseHandler)

func (*Client) SubscribeCandlestickWithReq added in v0.7.0

func (c *Client) SubscribeCandlestickWithReq(ctx context.Context, symbol, clientId string, period time.Duration,
	responseHandler websocketclientbase.ResponseHandler)

func (*Client) SubscribeLast24hCandlestick

func (c *Client) SubscribeLast24hCandlestick(ctx context.Context, symbol, clientId string,
	responseHandler websocketclientbase.ResponseHandler) error

func (*Client) SubscribeOrder

func (c *Client) SubscribeOrder(ctx context.Context, symbol, clientId string,
	responseHandler websocketclientbase.ResponseHandler)

func (*Client) SubscribeTradeClear

func (c *Client) SubscribeTradeClear(ctx context.Context, symbol, clientId string,
	responseHandler websocketclientbase.ResponseHandler)

type Trade

type Trade struct {
	Symbol    string
	OrderId   int64
	OrderSide string
	OrderType string
	Aggressor bool

	Id     int64           // trade id
	Time   int64           // trade time
	Price  decimal.Decimal // trade price
	Volume decimal.Decimal // trade volume

	TransactFee       decimal.Decimal
	FeeDeduct         decimal.Decimal
	FeeDeductCurrency string
}

Trade is the Data object in TradeClear websocket response.

Jump to

Keyboard shortcuts

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