Documentation
¶
Index ¶
- Constants
- Variables
- func Init(ctx context.Context) error
- func IsTradeDetailChanel(ch string) bool
- func NewMBPChannel(sym exchange.Symbol, size int) exchange.Channel
- func ParseDepth(ch string, ts int64, tick json.RawMessage) (interface{}, error)
- func ParseOrder(data json.RawMessage) (interface{}, error)
- func ParseOrderStatus(state string) (exchange.OrderStatus, error)
- func ParseOrderType(oType string) (exchange.OrderSide, exchange.OrderType, error)
- func ParseSymbol(symbol string) (exchange.SpotSymbol, error)
- func ParseTradeTick(ch string, ts int64, raw json.RawMessage) ([]*exchange.Trade, error)
- func TradeDetailSymbol(ch string) string
- type Account
- type AccountHistoryData
- type AccountHistoryReq
- func (ar *AccountHistoryReq) AddTime(ts time.Time) *AccountHistoryReq
- func (ar *AccountHistoryReq) Currency(cy string) *AccountHistoryReq
- func (ar *AccountHistoryReq) EndTime(ts time.Time) *AccountHistoryReq
- func (ar *AccountHistoryReq) FromID(id int) *AccountHistoryReq
- func (ar *AccountHistoryReq) Size(size int) *AccountHistoryReq
- func (ar *AccountHistoryReq) Sort(sort string) *AccountHistoryReq
- func (ar *AccountHistoryReq) TransactTypes(types ...string) *AccountHistoryReq
- type AccountHistoryResp
- type AccountLedgerData
- type AccountLedgerReq
- func (ar *AccountLedgerReq) Currency(cy string) *AccountLedgerReq
- func (ar *AccountLedgerReq) EndTime(et time.Time) *AccountLedgerReq
- func (ar *AccountLedgerReq) FromID(id int) *AccountLedgerReq
- func (ar *AccountLedgerReq) Limit(limit int) *AccountLedgerReq
- func (ar *AccountLedgerReq) Sort(s string) *AccountLedgerReq
- func (ar *AccountLedgerReq) StartTime(st time.Time) *AccountLedgerReq
- func (ar *AccountLedgerReq) TransactTypes(typ string) *AccountLedgerReq
- type AccountLedgerResp
- type Balance
- type BalanceReq
- type BalanceResp
- type CodeC
- type DepositWithdrawlRecord
- type DepositWithdrawlReq
- type Depth
- type Direct
- type MBPChannel
- type MBPDepthDS
- type MBPFullReq
- type MBPFullResp
- type MatchResult
- type MatchResultReq
- type OrderData
- type OrdersChannel
- type OrdersReq
- type OrdersResp
- type OrdersRespDetail
- type PlaceReq
- func (pr *PlaceReq) ClientOrderID(coi string) *PlaceReq
- func (pr *PlaceReq) Operator(op string) *PlaceReq
- func (pr *PlaceReq) Price(price string) *PlaceReq
- func (pr *PlaceReq) Serialize() ([]byte, error)
- func (pr *PlaceReq) Source(source string) *PlaceReq
- func (pr *PlaceReq) StopPrice(sp string) *PlaceReq
- type PlaceResp
- type PrivateCodeC
- type PrivateWSClient
- type PrivateWSReq
- type PrivateWSResp
- type RestClient
- func (rc *RestClient) AccountHistory(ctx context.Context, req *AccountHistoryReq) (*AccountHistoryResp, error)
- func (rc *RestClient) AccountLedger(ctx context.Context, req *AccountLedgerReq) (*AccountLedgerResp, error)
- func (rc *RestClient) Accounts(ctx context.Context) ([]Account, error)
- func (rc *RestClient) Balance(ctx context.Context, req *BalanceReq) (*BalanceResp, error)
- func (cl *RestClient) DepositWitdrawl(ctx context.Context, req *DepositWithdrawlReq) ([]DepositWithdrawlRecord, error)
- func (rc *RestClient) FeeRate(ctx context.Context, symbols []exchange.Symbol) ([]*exchange.TradeFee, error)
- func (rc *RestClient) FetchBalance(ctx context.Context, currencies ...string) (*exchange.Balances, error)
- func (rc *RestClient) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (rc *RestClient) FetchSymbols(ctx context.Context) ([]Symbol, error)
- func (rc *RestClient) Init(ctx context.Context) error
- func (rc *RestClient) MatchResult(ctx context.Context, req *MatchResultReq) ([]MatchResult, error)
- func (rc *RestClient) MatchResults(ctx context.Context, symbol string, types []string, st int64, et int64, ...) ([]MatchResult, error)
- func (rc *RestClient) Orders(ctx context.Context, req *OrdersReq) (*OrdersResp, error)
- func (rc *RestClient) Place(ctx context.Context, req *PlaceReq) (*PlaceResp, error)
- func (rc *RestClient) SubUserAccount(ctx context.Context, req *SubUserAccountReq) ([]BalanceResp, error)
- func (rc *RestClient) SubUserList(ctx context.Context, req *SubUserListReq) (*SubUserListResp, error)
- func (rc *RestClient) SubmitCancel(ctx context.Context, req *SubmitCancelReq) (*PlaceResp, error)
- func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.SpotSymbol, error)
- func (rc *RestClient) Trades(ctx context.Context, req *exchange.TradeReqParam) ([]exchange.Trade, error)
- func (rc *RestClient) TransactFeeRate(ctx context.Context, symbols []string) ([]TransactFeeRate, error)
- type SpotSymbol
- type SubUserAccountReq
- type SubUserData
- type SubUserListReq
- type SubUserListResp
- type SubmitCancelReq
- type Symbol
- type SymbolResp
- type TradeDetail
- type TradeDetailChannel
- type TradeDetailData
- type TransactFeeRate
- type WSClient
Constants ¶
View Source
const ( AccountsEndPoint = "/v1/account/accounts" AccountHistoryEndPoint = "/v1/account/history" AccountLedgerEndPoint = "/v2/account/ledger" TypeFrozen = "frozen" TypeTrade = "trade" )
View Source
const ( ActionPing = "ping" ActionPong = "pong" ActionReq = "req" ActionSub = "sub" ActionPush = "push" )
View Source
const ( DirectNone Direct = "" DirectPrev Direct = "forward" DirectNext Direct = "next" MatchResutEndPoint = "/v1/order/matchresults" MatchRoleMaker = "maker" MatchRoleTaker = "taker" )
View Source
const ( MBPAddr = "wss://api-aws.huobi.pro/feed" WSAddr = "wss://api.huobi.pro/ws" )
View Source
const (
DepositWitdrawlEndPoint = "/v1/query/deposit-withdraw"
)
View Source
const (
PlaceOrderEndPoint = "/v1/order/orders/place"
)
View Source
const (
PrivateWSClientAddr = "wss://api.huobi.pro/ws/v2"
)
View Source
const (
SpotHost = "api.huobi.pro"
)
View Source
const (
SubUserListEndPoint = "/v2/sub-user/user-list"
)
View Source
const (
TransactFeeRateEndPoint = "/v2/reference/transact-fee-rate"
)
Variables ¶
View Source
var ( HuobiSide2ExchangeSide map[string]exchange.OrderSide = map[string]exchange.OrderSide{ "buy": exchange.OrderSideBuy, "sell": exchange.OrderSideSell, } )
Functions ¶
func IsTradeDetailChanel ¶ added in v0.5.8
func NewMBPChannel ¶ added in v0.5.0
func ParseDepth ¶ added in v0.5.0
func ParseDepth(ch string, ts int64, tick json.RawMessage) (interface{}, error)
func ParseOrder ¶ added in v0.5.0
func ParseOrder(data json.RawMessage) (interface{}, error)
func ParseOrderStatus ¶ added in v0.5.0
func ParseOrderStatus(state string) (exchange.OrderStatus, error)
func ParseOrderType ¶ added in v0.5.0
func ParseSymbol ¶ added in v0.3.0
func ParseSymbol(symbol string) (exchange.SpotSymbol, error)
func ParseTradeTick ¶ added in v0.5.8
func TradeDetailSymbol ¶ added in v0.5.8
Types ¶
type AccountHistoryData ¶ added in v0.5.4
type AccountHistoryData struct {
AccountID int `json:"account-id"`
Currency string `json:"currency"`
RecordID int `json:"record-id"`
TransactAmt string `json:"transact-amt"`
TransactType string `json:"transact-type"`
AvailBalance string `json:"avail-balance"`
AcctBalance string `json:"acct-balance"`
TransactTime int `json:"transact-time"`
}
type AccountHistoryReq ¶ added in v0.5.4
func NewAccountHistoryReq ¶ added in v0.5.4
func NewAccountHistoryReq(uid int) *AccountHistoryReq
func (*AccountHistoryReq) AddTime ¶ added in v0.5.4
func (ar *AccountHistoryReq) AddTime(ts time.Time) *AccountHistoryReq
func (*AccountHistoryReq) Currency ¶ added in v0.5.4
func (ar *AccountHistoryReq) Currency(cy string) *AccountHistoryReq
func (*AccountHistoryReq) EndTime ¶ added in v0.5.4
func (ar *AccountHistoryReq) EndTime(ts time.Time) *AccountHistoryReq
func (*AccountHistoryReq) FromID ¶ added in v0.5.4
func (ar *AccountHistoryReq) FromID(id int) *AccountHistoryReq
func (*AccountHistoryReq) Size ¶ added in v0.5.4
func (ar *AccountHistoryReq) Size(size int) *AccountHistoryReq
func (*AccountHistoryReq) Sort ¶ added in v0.5.4
func (ar *AccountHistoryReq) Sort(sort string) *AccountHistoryReq
func (*AccountHistoryReq) TransactTypes ¶ added in v0.5.4
func (ar *AccountHistoryReq) TransactTypes(types ...string) *AccountHistoryReq
type AccountHistoryResp ¶ added in v0.5.4
type AccountHistoryResp struct {
Status string `json:"status"`
NextID int `json:"next-id"`
ErrMsg string `json:"err-msg"`
ErrCode string `json:"err-code"`
Data []AccountHistoryData `json:"data"`
}
type AccountLedgerData ¶ added in v0.5.4
type AccountLedgerData 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"`
}
type AccountLedgerReq ¶ added in v0.5.4
func NewAccountLedgerReq ¶ added in v0.5.4
func NewAccountLedgerReq(uid int) *AccountLedgerReq
func (*AccountLedgerReq) Currency ¶ added in v0.5.4
func (ar *AccountLedgerReq) Currency(cy string) *AccountLedgerReq
func (*AccountLedgerReq) EndTime ¶ added in v0.5.4
func (ar *AccountLedgerReq) EndTime(et time.Time) *AccountLedgerReq
func (*AccountLedgerReq) FromID ¶ added in v0.5.4
func (ar *AccountLedgerReq) FromID(id int) *AccountLedgerReq
func (*AccountLedgerReq) Limit ¶ added in v0.5.4
func (ar *AccountLedgerReq) Limit(limit int) *AccountLedgerReq
func (*AccountLedgerReq) Sort ¶ added in v0.5.4
func (ar *AccountLedgerReq) Sort(s string) *AccountLedgerReq
func (*AccountLedgerReq) StartTime ¶ added in v0.5.4
func (ar *AccountLedgerReq) StartTime(st time.Time) *AccountLedgerReq
func (*AccountLedgerReq) TransactTypes ¶ added in v0.5.4
func (ar *AccountLedgerReq) TransactTypes(typ string) *AccountLedgerReq
type AccountLedgerResp ¶ added in v0.5.4
type AccountLedgerResp struct {
Code int `json:"code"`
Message string `json:"message"`
NextID int `json:"nextId"`
OK bool `json:"ok"`
Data []AccountLedgerData `json:"data"`
}
type BalanceReq ¶ added in v0.5.2
type BalanceReq struct {
AccountID int
}
type BalanceResp ¶ added in v0.5.2
type DepositWithdrawlRecord ¶ added in v0.5.4
type DepositWithdrawlRecord struct {
ID int `json:"id"`
Type string `json:"type"`
Currency string `json:"currency"`
TxHash string `json:"tx-hash"`
Chain string `json:"chain"`
Amount float64 `json:"amount"`
Address string `json:"address"`
AddressTag string `json:"address-tag"`
Fee float64 `json:"fee"`
State string `json:"state"`
CreatedAt int64 `json:"created-at"`
UpdatedAt int64 `json:"updated-at"`
ErrorCode string `json:"error-code"`
ErrorMsg string `json:"error-msg"`
}
type DepositWithdrawlReq ¶ added in v0.5.4
func NewDepositWithdrawlReq ¶ added in v0.5.4
func NewDepositWithdrawlReq(typ string) *DepositWithdrawlReq
func (*DepositWithdrawlReq) Direct ¶ added in v0.5.4
func (dr *DepositWithdrawlReq) Direct(d string) *DepositWithdrawlReq
func (*DepositWithdrawlReq) Type ¶ added in v0.5.4
func (dr *DepositWithdrawlReq) Type(typ string) *DepositWithdrawlReq
type MBPChannel ¶ added in v0.5.0
type MBPChannel struct {
// contains filtered or unexported fields
}
func (*MBPChannel) String ¶ added in v0.5.0
func (mc *MBPChannel) String() string
type MBPDepthDS ¶ added in v0.5.0
type MBPDepthDS struct {
// contains filtered or unexported fields
}
MBPDepthDS build depth according incremental updates and refresh message the ds is inited which means the refresh message has been push int ods
func NewMBPDepthDS ¶ added in v0.5.0
func NewMBPDepthDS(symbol exchange.Symbol) *MBPDepthDS
func (*MBPDepthDS) AddRefresh ¶ added in v0.5.0
func (ds *MBPDepthDS) AddRefresh(d *Depth)
type MBPFullReq ¶ added in v0.5.0
func NewMBPFullReq ¶ added in v0.5.0
func NewMBPFullReq(symbol exchange.Symbol, size int) *MBPFullReq
type MBPFullResp ¶ added in v0.5.0
type MatchResult ¶ added in v0.3.0
type MatchResult struct {
ID int64 `json:"id"`
MatchID int64 `json:"match-id"`
OrderID int64 `json:"order-id"`
TradeID int64 `json:"trade-id"`
CreatedAt int64 `json:"created-at"`
FilledAmount decimal.Decimal `json:"filled-amount"`
FilledFees decimal.Decimal `json:"filled-fees"`
FilledPoints decimal.Decimal `json:"filled-points"`
FeeCurrency string `json:"fee-currency"`
Price decimal.Decimal `json:"price"`
Source string `json:"source"`
Symbol string `json:"symbol"`
Type string `json:"type"`
Role string `json:"role"`
FeeDeductCurrency string `json:"fee-deduct-currency"`
FeeDeductState string `json:"fee-deduct-state"`
}
type MatchResultReq ¶ added in v0.5.0
type MatchResultReq OrdersReq
func NewMatchResultReq ¶ added in v0.5.0
func NewMatchResultReq(orderID string) *MatchResultReq
type OrderData ¶ added in v0.5.0
type OrderData struct {
EventType string `json:"eventType"`
Symbol string `json:"symbol"`
AccountID int64 `json:"accountId"`
OrderID int64 `json:"orderId"`
ClientOrderID string `json:"clientOrderId"`
OrderStatus string `json:"orderStatus"`
OrderPrice string `json:"orderPrice"`
OrderSize string `json:"orderSize"`
OrderValue string `json:"orderValue"`
Type string `json:"type"`
OrderCreateTime int64 `json:"orderCreateTime"`
OrderSource string `json:"orderSource"`
TradePrice string `json:"tradePrice"`
TradeVolume string `json:"tradeVolume"`
TradeID int64 `json:"tradeId"`
TradeTime int64 `json:"tradeTime"`
Aggressor bool `json:"aggressor"`
RemainAmt string `json:"remainAmt"`
ExecAmt string `json:"execAmt"`
LastActTime int64 `json:"lastActTime"`
}
type OrdersChannel ¶ added in v0.5.0
type OrdersChannel struct {
// contains filtered or unexported fields
}
func NewOrdersChannel ¶ added in v0.5.0
func NewOrdersChannel(sym string) *OrdersChannel
func (*OrdersChannel) String ¶ added in v0.5.0
func (oc *OrdersChannel) String() string
type OrdersReq ¶ added in v0.5.0
type OrdersReq struct {
OrderID string
}
func NewOrdersReq ¶ added in v0.5.0
type OrdersResp ¶ added in v0.5.0
type OrdersResp struct {
Data OrdersRespDetail `json:"data"`
}
type OrdersRespDetail ¶ added in v0.5.0
type OrdersRespDetail struct {
ID int64 `json:"id"`
Symbol string `json:"symbol"`
AccountID int64 `json:"account-id"`
Amount string `json:"amount"`
Price string `json:"price"`
CreatedAt int64 `json:"created-at"`
Type string `json:"type"`
FilledAmount string `json:"filled-amount"`
FilledCashAmount string `json:"filled-cash-amount"`
FilledFees string `json:"filled-fees"`
FinishedAt int64 `json:"finished-at"`
UserID int64 `json:"user-id"`
Source string `json:"source"`
State string `json:"state"`
CanceledAt int64 `json:"canceled-at"`
}
type PlaceReq ¶ added in v0.5.0
type PlaceReq struct {
// contains filtered or unexported fields
}
func NewPlaceReq ¶ added in v0.5.0
func (*PlaceReq) ClientOrderID ¶ added in v0.5.0
type PrivateCodeC ¶ added in v0.5.0
type PrivateCodeC struct {
}
func NewPrivateCodeC ¶ added in v0.5.0
func NewPrivateCodeC() *PrivateCodeC
type PrivateWSClient ¶ added in v0.5.0
func NewPrivateWSClient ¶ added in v0.5.0
func NewPrivateWSClient(key, secret string, data chan interface{}) *PrivateWSClient
func (*PrivateWSClient) Auth ¶ added in v0.5.0
func (pws *PrivateWSClient) Auth(ctx context.Context) error
func (*PrivateWSClient) Handle ¶ added in v0.5.0
func (pws *PrivateWSClient) Handle(ctx context.Context, n *rpc.Notify)
type PrivateWSReq ¶ added in v0.5.0
type PrivateWSResp ¶ added in v0.5.0
type PrivateWSResp struct {
Action string `json:"action"`
Code int `json:"code"`
Ch string `json:"ch"`
Data json.RawMessage `json:"data"`
}
type RestClient ¶
type RestClient struct {
*huobi.RestClient
// contains filtered or unexported fields
}
func NewRestClient ¶
func NewRestClient(key, secret string) *RestClient
func (*RestClient) AccountHistory ¶ added in v0.5.4
func (rc *RestClient) AccountHistory(ctx context.Context, req *AccountHistoryReq) (*AccountHistoryResp, error)
func (*RestClient) AccountLedger ¶ added in v0.5.4
func (rc *RestClient) AccountLedger(ctx context.Context, req *AccountLedgerReq) (*AccountLedgerResp, error)
func (*RestClient) Accounts ¶ added in v0.5.0
func (rc *RestClient) Accounts(ctx context.Context) ([]Account, error)
func (*RestClient) Balance ¶ added in v0.5.2
func (rc *RestClient) Balance(ctx context.Context, req *BalanceReq) (*BalanceResp, error)
func (*RestClient) DepositWitdrawl ¶ added in v0.5.4
func (cl *RestClient) DepositWitdrawl(ctx context.Context, req *DepositWithdrawlReq) ([]DepositWithdrawlRecord, error)
func (*RestClient) FetchBalance ¶ added in v0.5.2
func (*RestClient) FetchOrder ¶ added in v0.5.0
func (*RestClient) FetchSymbols ¶ added in v0.3.0
func (rc *RestClient) FetchSymbols(ctx context.Context) ([]Symbol, error)
func (*RestClient) Init ¶
func (rc *RestClient) Init(ctx context.Context) error
Init spot account id for Balance request
func (*RestClient) MatchResult ¶ added in v0.5.0
func (rc *RestClient) MatchResult(ctx context.Context, req *MatchResultReq) ([]MatchResult, error)
func (*RestClient) MatchResults ¶ added in v0.3.0
func (*RestClient) Orders ¶ added in v0.5.0
func (rc *RestClient) Orders(ctx context.Context, req *OrdersReq) (*OrdersResp, error)
func (*RestClient) SubUserAccount ¶ added in v0.5.4
func (rc *RestClient) SubUserAccount(ctx context.Context, req *SubUserAccountReq) ([]BalanceResp, error)
func (*RestClient) SubUserList ¶ added in v0.5.4
func (rc *RestClient) SubUserList(ctx context.Context, req *SubUserListReq) (*SubUserListResp, error)
func (*RestClient) SubmitCancel ¶ added in v0.5.0
func (rc *RestClient) SubmitCancel(ctx context.Context, req *SubmitCancelReq) (*PlaceResp, error)
func (*RestClient) Symbols ¶ added in v0.3.0
func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.SpotSymbol, error)
func (*RestClient) Trades ¶ added in v0.3.0
func (rc *RestClient) Trades(ctx context.Context, req *exchange.TradeReqParam) ([]exchange.Trade, error)
func (*RestClient) TransactFeeRate ¶ added in v0.3.0
func (rc *RestClient) TransactFeeRate(ctx context.Context, symbols []string) ([]TransactFeeRate, error)
type SpotSymbol ¶
type SpotSymbol struct {
*exchange.BaseSpotSymbol
Symbol string
}
func (*SpotSymbol) String ¶
func (ss *SpotSymbol) String() string
type SubUserAccountReq ¶ added in v0.5.4
type SubUserAccountReq struct {
// contains filtered or unexported fields
}
func NewSubUserAccountReq ¶ added in v0.5.4
func NewSubUserAccountReq(uid int) *SubUserAccountReq
type SubUserData ¶ added in v0.5.4
type SubUserListReq ¶ added in v0.5.4
func NewSubUserListReq ¶ added in v0.5.4
func NewSubUserListReq() *SubUserListReq
func (*SubUserListReq) FromID ¶ added in v0.5.4
func (sr *SubUserListReq) FromID(id int) *SubUserListReq
type SubUserListResp ¶ added in v0.5.4
type SubUserListResp struct {
Code int `json:"code"`
Message string `json:"message"`
NextID int `json:"nextId"`
Data []SubUserData `json:"data"`
}
type SubmitCancelReq ¶ added in v0.5.0
type SubmitCancelReq OrdersReq
func NewSubmitCancelReq ¶ added in v0.5.0
func NewSubmitCancelReq(orderID string) *SubmitCancelReq
type Symbol ¶
type Symbol struct {
BaseCurrency string `json:"base-currency"`
QuoteCurreny string `json:"quote-currency"`
Symbol string `json:"symbol"`
MinOrderAmt float64 `json:"min-order-amt"`
MaxOrderAmt float64 `json:"max-order-amt"`
MinOrderValue float64 `json:"min-order-value"`
PricePrecision int `json:"price-precision"`
AmountPrecision int `json:"amount-precision"`
ValuePrecision int `json:"value-precision"`
}
TODO add precision
type SymbolResp ¶
type TradeDetail ¶ added in v0.5.8
type TradeDetail struct {
ID int64 `json:"id"`
TS int64 `json:"ts"`
Data []TradeDetailData `json:"data"`
}
type TradeDetailChannel ¶ added in v0.5.8
type TradeDetailChannel struct {
// contains filtered or unexported fields
}
func NewTradeDetailChannel ¶ added in v0.5.8
func NewTradeDetailChannel(sym string) *TradeDetailChannel
func (*TradeDetailChannel) String ¶ added in v0.5.8
func (tdc *TradeDetailChannel) String() string
type TradeDetailData ¶ added in v0.5.8
type TransactFeeRate ¶
type WSClient ¶ added in v0.5.0
func NewMBPWSClient ¶ added in v0.5.0
func NewMBPWSClient(data chan interface{}) *WSClient
func NewWSClient ¶ added in v0.5.8
func NewWSClient(data chan interface{}) *WSClient
Click to show internal directories.
Click to hide internal directories.