swap

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransferEndPoint    = "/v2/account/transfer"
	TransferSpotAccount = "spot"
	TransferSwapAccount = "swap"
)
View Source
const (
	SwapHost    = "api.hbdm.com"
	SwapProHost = "api.huobi.pro"
)
View Source
const (
	SwapOrderEndPoint  = "/swap-api/v1/swap_order"
	SwapCancelEndPoint = "/swap-api/v1/swap_cancel"

	OrderDirectionBuy  = "buy"
	OrderDirectionSell = "sell"
	OrderOffsetOpen    = "open"
	OrderOffsetClose   = "close"

	OrderPriceLimit  = "limit"
	OrderPriceMarket = "opponent"
)
View Source
const (
	ContractEndPoint = "/swap-api/v1/swap_contract_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 Init added in v0.5.0

func Init(ctx context.Context) error

func NewDepthHighFreq added in v0.5.0

func NewDepthHighFreq(symbol string, size DepthSize) exchange.Channel

func NewOrdersChannel added in v0.5.0

func NewOrdersChannel(symbol string) exchange.Channel

func ParseDepth added in v0.5.0

func ParseDepth(raw json.RawMessage) (interface{}, error)

func ParseOrder added in v0.5.0

func ParseOrder(raw []byte) (*exchange.Order, error)

func ParseSymbol added in v0.5.0

func ParseSymbol(sym string) (exchange.SwapSymbol, error)

Types

type AuthResponse added in v0.5.0

type AuthResponse struct {
	Op      string `json:"op"`
	ErrCode int    `json:"err-code"`
	TS      int64  `json:"ts"`
	ErrMsg  string `json:"err-msg"`
}

type CodeC

type CodeC struct {
	*huobi.CodeC
}

func NewCodeC

func NewCodeC() *CodeC

func (*CodeC) Decode

func (cc *CodeC) Decode(raw []byte) (rpc.Response, error)

type ContractInfo

type ContractInfo struct {
	Status string `json:"status"`
	TS     int    `json:"ts"`
	Data   []Data `json:"data"`
}

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 Depth added in v0.5.0

type Depth struct {
	Asks    [][2]float64
	Bids    [][2]float64
	Ch      string
	Event   string
	ID      int64
	MrID    int64
	TS      int64
	Version int
}

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 DepthSize added in v0.5.0

type DepthSize int
const (
	DepthSize20  DepthSize = 20
	DepthSize150 DepthSize = 150
)

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   int     `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"`
}

type OrderReq added in v0.5.0

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

func NewOrderReq added in v0.5.0

func NewOrderReq(contractCode string, volume int, direction string, offset string, lever int, orderPriceType string) *OrderReq

func (*OrderReq) Price added in v0.5.0

func (or *OrderReq) Price(price float64) *OrderReq

func (*OrderReq) Serialize added in v0.5.0

func (or *OrderReq) Serialize() ([]byte, error)

type OrderResp added in v0.5.0

type OrderResp struct {
	OrderID    int64  `json:"order_id"`
	OrderIDStr string `json:"order_id_str"`
}

type PingResponse added in v0.5.0

type PingResponse struct {
	Op string `json:"op"`
	TS string `json:"ts"`
}

type PrivateCodeC added in v0.5.0

type PrivateCodeC struct {
	*huobi.CodeC
}

func NewPrivateCodeC added in v0.5.0

func NewPrivateCodeC() *PrivateCodeC

func (*PrivateCodeC) Decode added in v0.5.0

func (pcc *PrivateCodeC) Decode(raw []byte) (rpc.Response, error)

func (*PrivateCodeC) Encode added in v0.5.0

func (pcc *PrivateCodeC) Encode(req rpc.Request) ([]byte, error)

type PrivateWSClient added in v0.5.0

type PrivateWSClient struct {
	*exchange.WSClient
	// contains filtered or unexported fields
}

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)

func (*PrivateWSClient) Run added in v0.5.0

func (ws *PrivateWSClient) Run(ctx context.Context) error

func (*PrivateWSClient) Subscribe added in v0.5.0

func (ws *PrivateWSClient) Subscribe(ctx context.Context, channels ...exchange.Channel) error

type Response added in v0.5.0

type Response struct {
	Op string `json:"op"`
}

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) PrivatePostReq added in v0.5.0

func (rc *RestClient) PrivatePostReq(ctx context.Context, endPoint string, sr Serializer, dst interface{}) error

func (*RestClient) SwapCancel added in v0.5.0

func (rc *RestClient) SwapCancel(ctx context.Context, req *SwapCancelReq) (*SwapCancelResp, error)

func (*RestClient) SwapOrder added in v0.5.0

func (rc *RestClient) SwapOrder(ctx context.Context, req *OrderReq) (*OrderResp, 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 Serializer interface {
	Serialize() ([]byte, error)
}

type SwapCancelError added in v0.5.0

type SwapCancelError struct {
	OrderID string `json:"order_id"`
	ErrCode int    `json:"err_code"`
	ErrMsg  string `json:"err_msg"`
}

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 Symbol

type Symbol struct {
	*exchange.BaseSwapSymbol
}

func (*Symbol) String

func (s *Symbol) String() string

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

func (*TransferReq) Serialize added in v0.5.0

func (tr *TransferReq) Serialize() ([]byte, error)

type TransferResp added in v0.5.0

type TransferResp struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"string"`
	Success bool        `json:"success"`
}

type WSClient

type WSClient struct {
	*future.WSClientDeriv
}

func NewWSClient

func NewWSClient(data chan interface{}) *WSClient

func (*WSClient) Subscribe

func (ws *WSClient) Subscribe(ctx context.Context, cs ...exchange.Channel) error

Jump to

Keyboard shortcuts

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