Documentation
¶
Index ¶
- Constants
- func Init(ctx context.Context) error
- func NewDepthHighFreq(symbol string, size DepthSize) exchange.Channel
- func NewOrdersChannel(symbol string) exchange.Channel
- func ParseDepth(raw json.RawMessage) (interface{}, error)
- func ParseOrder(raw []byte) (*exchange.Order, error)
- func ParseSymbol(sym string) (exchange.SwapSymbol, error)
- type AuthResponse
- type CodeC
- type ContractInfo
- type Data
- type Depth
- type DepthHighFreqChannel
- type DepthSize
- type FinancialRecord
- type FinancialRecordRequest
- func (frr *FinancialRecordRequest) Direct(direct string) *FinancialRecordRequest
- func (frr *FinancialRecordRequest) EndTime(ts int) *FinancialRecordRequest
- func (frr *FinancialRecordRequest) FromID(fromID int) *FinancialRecordRequest
- func (frr *FinancialRecordRequest) Serialize() ([]byte, error)
- func (frr *FinancialRecordRequest) StartTime(ts int) *FinancialRecordRequest
- func (frr *FinancialRecordRequest) Type(types ...int) *FinancialRecordRequest
- type FinancialRecordResponse
- type FundingRateReq
- type FundingRateResp
- type OrderNotify
- type OrderNotifyTrade
- type OrderReq
- type OrderResp
- type PingResponse
- type Position
- type PositionInfoRequest
- type PrivateCodeC
- type PrivateWSClient
- type Response
- type RestClient
- func (rc *RestClient) FetchBalance(ctx context.Context, currencies ...string) (*exchange.Balances, error)
- func (rc *RestClient) FetchFundingRate(ctx context.Context, symbol exchange.Symbol) (*exchange.FundingRate, error)
- func (rc *RestClient) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (rc *RestClient) Finance(ctx context.Context, params *exchange.FinanceReqParam) ([]exchange.Finance, error)
- func (cl *RestClient) FinancialRecord(ctx context.Context, req *FinancialRecordRequest) (*FinancialRecordResponse, error)
- func (rc *RestClient) PositionInfo(ctx context.Context, req *PositionInfoRequest) ([]Position, error)
- func (rc *RestClient) PrivatePostReq(ctx context.Context, endPoint string, req interface{}, dst interface{}) error
- func (rc *RestClient) SwapAccountInfo(ctx context.Context, req *SwapAccountInfoReq) ([]SwapAccountInfo, error)
- func (rc *RestClient) SwapCancel(ctx context.Context, req *SwapCancelReq) (*SwapCancelResp, error)
- func (rc *RestClient) SwapFee(ctx context.Context, req *SwapFeeReq) ([]SwapFee, error)
- func (rc *RestClient) SwapFundingRate(ctx context.Context, req *FundingRateReq) (*FundingRateResp, error)
- func (rc *RestClient) SwapOrder(ctx context.Context, req *OrderReq) (*OrderResp, error)
- func (rc *RestClient) SwapOrderDetail(ctx context.Context, req *SwapOrderDetailReq) (*SwapOrderDetailResp, error)
- func (rc *RestClient) Transfer(ctx context.Context, req *TransferReq) (*TransferResp, error)
- type Serializer
- type SwapAccountInfo
- type SwapAccountInfoReq
- type SwapCancelError
- type SwapCancelReq
- type SwapCancelResp
- type SwapFee
- type SwapFeeReq
- type SwapOrderDetailReq
- func (sdr *SwapOrderDetailReq) CreatedAt(ts int64) *SwapOrderDetailReq
- func (sdr *SwapOrderDetailReq) OrderType(ot int) *SwapOrderDetailReq
- func (sdr *SwapOrderDetailReq) PageIndex(pi int) *SwapOrderDetailReq
- func (sdr *SwapOrderDetailReq) PageSize(ps int) *SwapOrderDetailReq
- func (sdr *SwapOrderDetailReq) Serialize() ([]byte, error)
- type SwapOrderDetailResp
- type Symbol
- type TransferReq
- type TransferResp
- type WSClient
Constants ¶
View Source
const ( TransferEndPoint = "/v2/account/transfer" TransferSpotAccount = "spot" TransferSwapAccount = "swap" )
View Source
const ( SwapFeeEndPoint = "/swap-api/v1/swap_fee" SwapAccountInfoEndPoint = "/swap-api/v1/swap_account_info" )
View Source
const ( SwapHost = "api.hbdm.com" SwapProHost = "api.huobi.pro" )
View Source
const ( FinancialRecordEndPoint = "/swap-api/v3/swap_financial_record" FinancialRecordTypeFundingIncome = 30 FinancialRecordTypeFundingOutCome = 31 )
View Source
const ( SwapOrderEndPoint = "/swap-api/v1/swap_order" SwapCancelEndPoint = "/swap-api/v1/swap_cancel" SwapOrderDetailEndPoint = "/swap-api/v1/swap_order_detail" OrderDirectionBuy = "buy" OrderDirectionSell = "sell" OrderOffsetOpen = "open" OrderOffsetClose = "close" OrderPriceLimit = "limit" OrderPriceMarket = "opponent" OrderPriceOptimal5 = "optimal_5" )
View Source
const (
ContractEndPoint = "/swap-api/v1/swap_contract_info"
)
View Source
const (
FundingRateEndPoint = "/swap-api/v1/swap_funding_rate"
)
View Source
const (
PositionInfoEndPoint = "/swap-api/v1/swap_position_info"
)
View Source
const (
SwapPrivateAddr = "wss://api.hbdm.com/swap-notification"
)
View Source
const (
SwapWSAddr = "wss://api.hbdm.com/swap-ws"
)
Variables ¶
This section is empty.
Functions ¶
func NewDepthHighFreq ¶ added in v0.5.0
func NewOrdersChannel ¶ added in v0.5.0
func ParseDepth ¶ added in v0.5.0
func ParseDepth(raw json.RawMessage) (interface{}, error)
func ParseSymbol ¶ added in v0.5.0
func ParseSymbol(sym string) (exchange.SwapSymbol, error)
Types ¶
type AuthResponse ¶ added in v0.5.0
type ContractInfo ¶
type Data ¶
type Data struct {
Symbol string `json:"symbol"`
ContractCode string `json:"contract_code"`
ContractSize float64 `json:"contract_size"`
PriceTick float64 `json:"price_tick"`
CreateDate string `json:"create_date"`
ContractStatus int `json:"contract_status"`
SettlementDate string `json:"settlement_date"`
}
type DepthHighFreqChannel ¶ added in v0.5.0
type DepthHighFreqChannel struct {
// contains filtered or unexported fields
}
func (*DepthHighFreqChannel) String ¶ added in v0.5.0
func (ch *DepthHighFreqChannel) String() string
type FinancialRecord ¶ added in v0.5.2
type FinancialRecordRequest ¶ added in v0.5.2
type FinancialRecordRequest struct {
// contains filtered or unexported fields
}
func NewFinancialRecordRequest ¶ added in v0.5.2
func NewFinancialRecordRequest(contractCode string) *FinancialRecordRequest
func (*FinancialRecordRequest) Direct ¶ added in v0.5.7
func (frr *FinancialRecordRequest) Direct(direct string) *FinancialRecordRequest
func (*FinancialRecordRequest) EndTime ¶ added in v0.5.7
func (frr *FinancialRecordRequest) EndTime(ts int) *FinancialRecordRequest
EndTime specific record query end timestamp in milliseconds
func (*FinancialRecordRequest) FromID ¶ added in v0.5.7
func (frr *FinancialRecordRequest) FromID(fromID int) *FinancialRecordRequest
func (*FinancialRecordRequest) Serialize ¶ added in v0.5.2
func (frr *FinancialRecordRequest) Serialize() ([]byte, error)
func (*FinancialRecordRequest) StartTime ¶ added in v0.5.7
func (frr *FinancialRecordRequest) StartTime(ts int) *FinancialRecordRequest
StartTime specific record query start timestamp in milliseconds
func (*FinancialRecordRequest) Type ¶ added in v0.5.2
func (frr *FinancialRecordRequest) Type(types ...int) *FinancialRecordRequest
type FinancialRecordResponse ¶ added in v0.5.2
type FinancialRecordResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
TS int64 `json:"ts"`
Data []FinancialRecord `json:"data"`
}
type FundingRateReq ¶ added in v0.5.4
func NewFundingRateReq ¶ added in v0.5.4
func NewFundingRateReq(cc string) *FundingRateReq
type FundingRateResp ¶ added in v0.5.4
type FundingRateResp struct {
EstimmatedRate decimal.Decimal `json:"estimated_rate"`
FundingRate decimal.Decimal `json:"funding_rate"`
ContractCode string `json:"contract_code"`
Symbol string `json:"symbol"`
FeeAsset string `json:"fee_asset"`
FundingTime string `json:"funding_time"`
NextFundingTime string `json:"next_funding_time"`
}
func (*FundingRateResp) Transfer ¶ added in v0.5.4
func (tr *FundingRateResp) Transfer() (*exchange.FundingRate, error)
type OrderNotify ¶ added in v0.5.0
type OrderNotify struct {
Op string `json:"op"`
Topic string `json:"topic"`
TS int64 `json:"ts"` //ping message and auth message ts field have different type
Symbol string `json:"symbol"`
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"`
Status int `json:"status"`
LeverRate int `json:"lever_rate"`
OrderID int64 `json:"order_id"`
OrderIDStr string `json:"order_id_str"`
ClientOrderID int64 `json:"client_order_id"`
OrderType int `json:"order_type"`
CreatedAt int64 `json:"created_at"`
TradeVolume int `json:"trade_volume"`
TradeTurnOver float64 `json:"trade_turnover"`
Fee float64 `json:"fee"`
FeeAsset string `json:"fee_asset"`
TradeAvgPrice float64 `json:"trade_avg_price"`
CanceledAt int64 `json:"canceled_at"`
RealProfit float64 `json:"real_profit"`
Trades []OrderNotifyTrade `json:"trade"`
}
type OrderNotifyTrade ¶ added in v0.5.0
type OrderNotifyTrade struct {
TradeFee float64 `json:"trade_fee"`
FeeAsset string `json:"fee_asset"`
TradeID int64 `json:"trade_id"`
ID string `json:"id"`
TradeVolume float64 `json:"trade_volume"`
TradePrice float64 `json:"trade_price"`
TradeTurnOver float64 `json:"trade_turnover"`
CreatedAt int64 `json:"created_at"`
Profit float64 `json:"profit"`
RealProfit float64 `json:"real_profit"`
Role string `json:"role"`
}
type OrderReq ¶ added in v0.5.0
type OrderReq struct {
// contains filtered or unexported fields
}
func NewOrderReq ¶ added in v0.5.0
type PingResponse ¶ added in v0.5.0
type Position ¶ added in v0.5.2
type Position struct {
Symbol string `json:"symbol"`
ContractCode string `json:"contract_code"`
Volume decimal.Decimal `json:"volume"`
Available decimal.Decimal `json:"available"`
Frozen decimal.Decimal `json:"frozen"`
CostOpen decimal.Decimal `json:"cost_open"`
CostHold decimal.Decimal `json:"cost_hold"`
ProfitUnreal decimal.Decimal `json:"profit_unreal"`
ProfitRate decimal.Decimal `json:"profit_rate"`
LeverRate int `json:"lever_rate"`
PositionMargin decimal.Decimal `json:"position_margin"`
Direction string `json:"direction"`
Profit decimal.Decimal `json:"profit"`
LastPrice decimal.Decimal `json:"last_price"`
}
type PositionInfoRequest ¶ added in v0.5.2
type PositionInfoRequest struct {
ContractCode string `json:"contract_code"`
}
func NewPositionInfoRequest ¶ added in v0.5.2
func NewPositionInfoRequest(code string) *PositionInfoRequest
func (*PositionInfoRequest) Serialize ¶ added in v0.5.2
func (pir *PositionInfoRequest) Serialize() ([]byte, error)
type PrivateCodeC ¶ added in v0.5.0
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 (ws *PrivateWSClient) Auth(ctx context.Context) error
func (*PrivateWSClient) Handle ¶ added in v0.5.0
func (ws *PrivateWSClient) Handle(ctx context.Context, notify *rpc.Notify)
type RestClient ¶
type RestClient struct {
*huobi.RestClient
}
func NewRestClient ¶
func NewRestClient(key string, secret string) *RestClient
func NewRestClientWithHost ¶ added in v0.5.0
func NewRestClientWithHost(key, secret, host string) *RestClient
func (*RestClient) FetchBalance ¶ added in v0.5.2
func (*RestClient) FetchFundingRate ¶ added in v0.5.4
func (rc *RestClient) FetchFundingRate(ctx context.Context, symbol exchange.Symbol) (*exchange.FundingRate, error)
func (*RestClient) FetchOrder ¶ added in v0.5.1
func (*RestClient) Finance ¶ added in v0.5.2
func (rc *RestClient) Finance(ctx context.Context, params *exchange.FinanceReqParam) ([]exchange.Finance, error)
func (*RestClient) FinancialRecord ¶ added in v0.5.2
func (cl *RestClient) FinancialRecord(ctx context.Context, req *FinancialRecordRequest) (*FinancialRecordResponse, error)
func (*RestClient) PositionInfo ¶ added in v0.5.2
func (rc *RestClient) PositionInfo(ctx context.Context, req *PositionInfoRequest) ([]Position, error)
func (*RestClient) PrivatePostReq ¶ added in v0.5.0
func (rc *RestClient) PrivatePostReq(ctx context.Context, endPoint string, req interface{}, dst interface{}) error
PrivatePostReq send post request to huobi swap api. the request body is generate from req param vai json.Marshal() or Serialize()
func (*RestClient) SwapAccountInfo ¶ added in v0.5.2
func (rc *RestClient) SwapAccountInfo(ctx context.Context, req *SwapAccountInfoReq) ([]SwapAccountInfo, error)
func (*RestClient) SwapCancel ¶ added in v0.5.0
func (rc *RestClient) SwapCancel(ctx context.Context, req *SwapCancelReq) (*SwapCancelResp, error)
func (*RestClient) SwapFee ¶ added in v0.5.1
func (rc *RestClient) SwapFee(ctx context.Context, req *SwapFeeReq) ([]SwapFee, error)
func (*RestClient) SwapFundingRate ¶ added in v0.5.4
func (rc *RestClient) SwapFundingRate(ctx context.Context, req *FundingRateReq) (*FundingRateResp, error)
func (*RestClient) SwapOrderDetail ¶ added in v0.5.1
func (rc *RestClient) SwapOrderDetail(ctx context.Context, req *SwapOrderDetailReq) (*SwapOrderDetailResp, error)
func (*RestClient) Transfer ¶ added in v0.5.0
func (rc *RestClient) Transfer(ctx context.Context, req *TransferReq) (*TransferResp, error)
type Serializer ¶ added in v0.5.0
type SwapAccountInfo ¶ added in v0.5.2
type SwapAccountInfo struct {
Symbol string `json:"symbol"`
ContractCode string `json:"contract_code"`
MarginBalance decimal.Decimal `json:"margin_balance"`
MarginFrozen decimal.Decimal `json:"margin_frozen"`
MarginAvailable decimal.Decimal `json:"margin_available"`
ProfitReal decimal.Decimal `json:"profit_real"`
ProfitUnreal decimal.Decimal `json:"profit_unreal"`
RiskRate decimal.Decimal `json:"risk_rate"`
LiquidationPrice decimal.Decimal `json:"liquidation_price"`
WithdrawAvailable decimal.Decimal `json:"withdraw_available"`
LeverRate decimal.Decimal `json:"lever_rate"`
AdjustFactor decimal.Decimal `json:"adjust_factor"`
}
type SwapAccountInfoReq ¶ added in v0.5.2
type SwapAccountInfoReq struct {
// contains filtered or unexported fields
}
func NewSwapAccountInfoReq ¶ added in v0.5.2
func NewSwapAccountInfoReq() *SwapAccountInfoReq
func (*SwapAccountInfoReq) ContractCode ¶ added in v0.5.2
func (sai *SwapAccountInfoReq) ContractCode(code string) *SwapAccountInfoReq
func (*SwapAccountInfoReq) Serialize ¶ added in v0.5.2
func (sai *SwapAccountInfoReq) Serialize() ([]byte, error)
type SwapCancelError ¶ added in v0.5.0
type SwapCancelReq ¶ added in v0.5.0
type SwapCancelReq struct {
// contains filtered or unexported fields
}
func NewSwapCancelReq ¶ added in v0.5.0
func NewSwapCancelReq(symbol string) *SwapCancelReq
func (*SwapCancelReq) ClientOrderIDs ¶ added in v0.5.0
func (scr *SwapCancelReq) ClientOrderIDs(ids ...string) *SwapCancelReq
func (*SwapCancelReq) Orders ¶ added in v0.5.0
func (scr *SwapCancelReq) Orders(ids ...string) *SwapCancelReq
func (*SwapCancelReq) Serialize ¶ added in v0.5.0
func (scr *SwapCancelReq) Serialize() ([]byte, error)
type SwapCancelResp ¶ added in v0.5.0
type SwapCancelResp struct {
Errors []SwapCancelError `json:"errors"`
Successes string `json:"successes"` //id1,id2,id3 ...
}
type SwapFee ¶ added in v0.5.1
type SwapFee struct {
Symbol string `json:"symbol"`
ContractCode string `json:"contract_code"`
OpenMakerFee string `json:"open_maker_fee"`
OpenTakerFee string `json:"open_taker_fee"`
CloseMakerFee string `json:"close_maker_fee"`
CloseTakerFee string `json:"close_taker_fee"`
FeeAsset string `json:"fee_asset"`
}
type SwapFeeReq ¶ added in v0.5.1
type SwapFeeReq struct {
ContractCode string `json:"contract_code"`
}
func NewSwapFeeReq ¶ added in v0.5.1
func NewSwapFeeReq(symbol string) *SwapFeeReq
type SwapOrderDetailReq ¶ added in v0.5.1
type SwapOrderDetailReq struct {
// contains filtered or unexported fields
}
func NewSwapOrderDetailReq ¶ added in v0.5.1
func NewSwapOrderDetailReq(cc string, id int64) *SwapOrderDetailReq
func (*SwapOrderDetailReq) CreatedAt ¶ added in v0.5.1
func (sdr *SwapOrderDetailReq) CreatedAt(ts int64) *SwapOrderDetailReq
func (*SwapOrderDetailReq) OrderType ¶ added in v0.5.1
func (sdr *SwapOrderDetailReq) OrderType(ot int) *SwapOrderDetailReq
func (*SwapOrderDetailReq) PageIndex ¶ added in v0.5.1
func (sdr *SwapOrderDetailReq) PageIndex(pi int) *SwapOrderDetailReq
func (*SwapOrderDetailReq) PageSize ¶ added in v0.5.1
func (sdr *SwapOrderDetailReq) PageSize(ps int) *SwapOrderDetailReq
func (*SwapOrderDetailReq) Serialize ¶ added in v0.5.1
func (sdr *SwapOrderDetailReq) Serialize() ([]byte, error)
type SwapOrderDetailResp ¶ added in v0.5.1
type SwapOrderDetailResp struct {
Symbol string `json:"symbol"`
ContractCode string `json:"contract_code"`
LeverRate int `json:"lever_rate"`
Direction string `json:"direction"`
Offset string `json:"offset"`
Volume float64 `json:"volume"`
Price float64 `json:"price"`
CreatedAt int64 `json:"created_at"`
CanceledAt int64 `json:"canceled_at"`
OrderSource string `json:"order_source"`
OrderPriceType string `json:"order_price_type"`
MarginFrozen float64 `json:"margin_frozen"`
Profit float64 `json:"profit"`
Trades []OrderNotifyTrade `json:"trades"`
TotalPage int `json:"total_page"`
CurrentPage int `json:"current_page"`
TotalSize int `json:"total_size"`
LiquidationType string `json:"liquidation_type"`
FeeAsset string `json:"fee_asset"`
Fee float64 `json:"fee"`
OrderID int64 `json:"order_id"`
OrderIDStr string `json:"order_id_str"`
ClientOrderID interface{} `json:"client_order_id"`
OrderType string `json:"order_type"`
Status int `json:"status"`
TradeAvgPrice float64 `json:"trade_avg_price"`
TradeTurnOver float64 `json:"trade_turn_over"`
TradeVolume float64 `json:"trade_volume"`
IsTpsl interface{} `json:"is_tpsl"`
RealProfit float64 `json:"real_profit"`
}
type Symbol ¶
type Symbol struct {
*exchange.BaseSwapSymbol
}
type TransferReq ¶ added in v0.5.0
type TransferReq struct {
// contains filtered or unexported fields
}
func NewTransferReq ¶ added in v0.5.0
func NewTransferReq(from, to, currency string, amount float64) *TransferReq
NewTransferReq build swap transfer reqeust amount will truncate 8 decimal places
func (*TransferReq) Serialize ¶ added in v0.5.0
func (tr *TransferReq) Serialize() ([]byte, error)
type TransferResp ¶ added in v0.5.0
Click to show internal directories.
Click to hide internal directories.