huobi

package
v0.28.7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 25 Imported by: 5

Documentation

Index

Constants

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 CandlestickReqMaxLength = 300
View Source
const (
	DefaultHost = "api.huobi.me"
)

Variables

This section is empty.

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, error)

func (*Client) AllSymbols added in v0.13.0

func (c *Client) AllSymbols(ctx context.Context) (s []exchange.Symbol, err error)

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 exchange.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(_ string, orderId uint64) error

func (*Client) CandleBySize added in v0.10.14

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

func (*Client) CandleFrom added in v0.10.14

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

func (Client) FormatSymbol added in v0.17.0

func (c Client) FormatSymbol(base, quote string) string

func (*Client) GetAccountInfo

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

func (*Client) GetFee added in v0.15.0

func (c *Client) GetFee(symbol string) (fee exchange.Fee, err error)

func (*Client) GetOrderById added in v0.11.0

func (c *Client) GetOrderById(orderId uint64, _ string) (exchange.Order, error)

func (*Client) GetSpotAccountId

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

func (*Client) GetSymbol added in v0.13.0

func (c *Client) GetSymbol(ctx context.Context, symbol string) (s exchange.Symbol, err error)

func (*Client) GetTimestamp

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

func (*Client) IsFullFilled added in v0.22.0

func (c *Client) IsFullFilled(symbol string, orderId uint64) (order exchange.Order, filled bool, err error)

func (*Client) Last24hVolume added in v0.24.0

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

func (*Client) LastPrice added in v0.10.0

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

func (*Client) PlaceOrder

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

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 exchange.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) SpotBalance added in v0.16.0

func (c *Client) SpotBalance() (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(clientId string, responseHandler websocketclientbase.ResponseHandler)

func (*Client) SubscribeCandlestick

func (c *Client) SubscribeCandlestick(symbol, clientId string, period time.Duration,
	responseHandler exchange.ResponseHandler)

func (*Client) SubscribeCandlestickWithReq added in v0.7.0

func (c *Client) SubscribeCandlestickWithReq(symbol, clientId string, period time.Duration,
	responseHandler exchange.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(symbol, clientId string, responseHandler exchange.ResponseHandler)

func (*Client) SubscribeTradeClear

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

func (*Client) UnsubscribeAccountUpdate added in v0.19.0

func (c *Client) UnsubscribeAccountUpdate(clientId string)

func (*Client) UnsubscribeCandlestick added in v0.19.0

func (c *Client) UnsubscribeCandlestick(symbol, clientId string, period time.Duration)

func (*Client) UnsubscribeCandlestickWithReq added in v0.19.0

func (c *Client) UnsubscribeCandlestickWithReq(symbol, clientId string, period time.Duration)

func (*Client) UnsubscribeOrder added in v0.19.0

func (c *Client) UnsubscribeOrder(symbol, clientId string)

func (*Client) UnsubscribeTradeClear added in v0.19.0

func (c *Client) UnsubscribeTradeClear(symbol, clientId string)

Jump to

Keyboard shortcuts

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