Documentation ¶
Index ¶
- type AccountInfo
- type AccountInfoResult
- type ApiParameter
- type CancelData
- type CancelError
- type CancelResult
- type Client
- func (c *Client) Cancel(contractCode string, orderID int64, clientOrderID int64) (result CancelResult, err error)
- func (c *Client) GetAccountInfo(contractCode string) (result AccountInfoResult, err error)
- func (c *Client) GetHisOrders(contractCode string, tradeType int, _type int, status int, createDate int, ...) (result HisOrdersResult, err error)
- func (c *Client) GetKLine(symbol string, period string, size int, from int64, to int64) (result KLineResult, err error)
- func (c *Client) GetMarketDepth(contractCode string, _type string) (result MarketDepthResult, err error)
- func (c *Client) GetOpenOrders(contractCode string, pageIndex int, pageSize int) (result OpenOrdersResult, err error)
- func (c *Client) GetPositionInfo(contractCode string) (result PositionInfoResult, err error)
- func (c *Client) Heartbeat() (result HeartbeatResult, err error)
- func (c *Client) Order(contractCode string, clientOrderID int64, price float64, volume float64, ...) (result OrderResult, err error)
- func (c *Client) OrderInfo(contractCode string, orderID int64, clientOrderID int64) (result OrderInfoResult, err error)
- type Heartbeat
- type HeartbeatResult
- type HisOrdersData
- type HisOrdersResult
- type KLine
- type KLineResult
- type MarketDepthResult
- type NWS
- func (ws *NWS) Login() error
- func (ws *NWS) SetAccountsCallback(callback func(accounts *WSAccounts))
- func (ws *NWS) SetLiquidationOrdersCallback(callback func(liquidationOrders *WSLiquidationOrders))
- func (ws *NWS) SetOrdersCallback(callback func(order *WSOrder))
- func (ws *NWS) SetPositionsCallback(callback func(positions *WSPositions))
- func (ws *NWS) SetProxy(proxyURL string) (err error)
- func (ws *NWS) Start()
- func (ws *NWS) Subscribe(id string, ch map[string]interface{}) error
- func (ws *NWS) SubscribeAccounts(id string, symbol string)
- func (ws *NWS) SubscribeLiquidationOrders(id string, symbol string)
- func (ws *NWS) SubscribeOrders(id string, symbol string)
- func (ws *NWS) SubscribePositions(id string, symbol string)
- func (ws *NWS) SubscribeTopic(id string, topic string)
- func (ws *NWS) Unsubscribe(id string) error
- type OpenOrdersData
- type OpenOrdersResult
- type Order
- type OrderData
- type OrderInfoResult
- type OrderResult
- type Position
- type PositionInfoResult
- type Tick
- type WS
- func (ws *WS) SetDepthCallback(callback func(depth *WSDepth))
- func (ws *WS) SetDepthHFCallback(callback func(depth *WSDepthHF))
- func (ws *WS) SetProxy(proxyURL string) (err error)
- func (ws *WS) SetTickerCallback(callback func(ticker *WSTicker))
- func (ws *WS) SetTradeCallback(callback func(trade *WSTrade))
- func (ws *WS) Start()
- func (ws *WS) Subscribe(id string, ch map[string]interface{}) error
- func (ws *WS) SubscribeDepth(id string, symbol string)
- func (ws *WS) SubscribeDepthHF(id string, symbol string, size int, dateType string)
- func (ws *WS) SubscribeTicker(id string, symbol string)
- func (ws *WS) SubscribeTrade(id string, symbol string)
- func (ws *WS) Unsubscribe(id string) error
- type WSAccountData
- type WSAccounts
- type WSDepth
- type WSDepthHF
- type WSLiquidationOrderData
- type WSLiquidationOrders
- type WSMyTrade
- type WSOrder
- type WSPositionData
- type WSPositions
- type WSTick
- type WSTickHF
- type WSTicker
- type WSTickerTick
- type WSTrade
- type WSTradeItem
- type WSTradeTick
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountInfo ¶
type AccountInfo struct { Symbol string `json:"symbol"` MarginBalance float64 `json:"margin_balance"` MarginPosition float64 `json:"margin_position"` MarginFrozen float64 `json:"margin_frozen"` MarginAvailable float64 `json:"margin_available"` ProfitReal float64 `json:"profit_real"` ProfitUnreal float64 `json:"profit_unreal"` RiskRate float64 `json:"risk_rate"` //*interface{} WithdrawAvailable float64 `json:"withdraw_available"` LiquidationPrice float64 `json:"liquidation_price"` //*interface{} LeverRate float64 `json:"lever_rate"` AdjustFactor float64 `json:"adjust_factor"` MarginStatic float64 `json:"margin_static"` ContractCode string `json:"contract_code"` }
type AccountInfoResult ¶
type AccountInfoResult struct { Status string `json:"status"` // "ok" , "error" ErrCode int `json:"err_code"` ErrMsg string `json:"err_msg"` Data []AccountInfo `json:"data"` Ts int64 `json:"ts"` }
type ApiParameter ¶
type CancelData ¶
type CancelData struct { Errors []CancelError `json:"errors"` Successes string `json:"successes"` }
type CancelError ¶
type CancelResult ¶
type CancelResult struct { Status string `json:"status"` ErrCode int `json:"err_code"` ErrMsg string `json:"err_msg"` Data CancelData `json:"data"` Ts int64 `json:"ts"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(params *ApiParameter) *Client
func (*Client) Cancel ¶
func (c *Client) Cancel(contractCode string, orderID int64, clientOrderID int64) (result CancelResult, err error)
* Cancel 撤销订单
func (*Client) GetAccountInfo ¶
func (c *Client) GetAccountInfo(contractCode string) (result AccountInfoResult, err error)
GetAccountInfo 获取用户账户信息
func (*Client) GetHisOrders ¶
func (c *Client) GetHisOrders(contractCode string, tradeType int, _type int, status int, createDate int, pageIndex int, pageSize int) (result HisOrdersResult, err error)
GetHisOrders 获取合约历史委托
func (*Client) GetMarketDepth ¶
func (c *Client) GetMarketDepth(contractCode string, _type string) (result MarketDepthResult, err error)
GetMarketDepth 获取行情深度数据 step0-150档 step6-20档 (150档数据) step0, step1, step2, step3, step4, step5(合并深度1-5);step0时,不合并深度, (20档数据) step6, step7, step8, step9, step10, step11(合并深度7-11);step6时,不合并深度
func (*Client) GetOpenOrders ¶
func (c *Client) GetOpenOrders(contractCode string, pageIndex int, pageSize int) (result OpenOrdersResult, err error)
GetOpenOrders 获取合约当前未成交委托单 page_index: 1,2,3...
func (*Client) GetPositionInfo ¶
func (c *Client) GetPositionInfo(contractCode string) (result PositionInfoResult, err error)
GetPositionInfo 用户持仓信息
func (*Client) Heartbeat ¶
func (c *Client) Heartbeat() (result HeartbeatResult, err error)
func (*Client) Order ¶
func (c *Client) Order(contractCode string, clientOrderID int64, price float64, volume float64, direction string, offset string, leverRate int, orderPriceType string) (result OrderResult, err error)
Order 合约下单
contract_code: BTC-USD direction: "buy":买 "sell":卖 offset string true "open":开 "close":平 orderPriceType: 订单报价类型 "limit":限价 "opponent":对手价 "post_only":只做maker单,post only下单只受用户持仓数量限制,optimal_5:最优5档、optimal_10:最优10档、optimal_20:最优20档,"fok":FOK订单,"ioc":IOC订单, opponent_ioc": 对手价-IOC下单,"optimal_5_ioc":最优5档-IOC下单,"optimal_10_ioc":最优10档-IOC下单,"optimal_20_ioc":最优20档-IOC下单,"opponent_fok": 对手价-FOK下单,"optimal_5_fok":最优5档-FOK下单,"optimal_10_fok":最优10档-FOK下单,"optimal_20_fok":最优20档-FOK下单
type HeartbeatResult ¶
type HisOrdersData ¶
type HisOrdersResult ¶
type HisOrdersResult struct { Status string `json:"status"` ErrCode int `json:"err_code"` ErrMsg string `json:"err_msg"` Data HisOrdersData `json:"data"` Ts int64 `json:"ts"` }
type KLineResult ¶
type MarketDepthResult ¶
type NWS ¶
NWS WebSocket 订单和用户数据接口
func NewNWS ¶
NewNWS 创建 NWS wsURL: 正式地址 wss://api.hbdm.com/swap-notification 开发地址 wss://api.btcgateway.pro/swap-notification
func (*NWS) SetAccountsCallback ¶
func (ws *NWS) SetAccountsCallback(callback func(accounts *WSAccounts))
func (*NWS) SetLiquidationOrdersCallback ¶
func (ws *NWS) SetLiquidationOrdersCallback(callback func(liquidationOrders *WSLiquidationOrders))
func (*NWS) SetOrdersCallback ¶
func (*NWS) SetPositionsCallback ¶
func (ws *NWS) SetPositionsCallback(callback func(positions *WSPositions))
func (*NWS) SetProxy ¶
SetProxy 设置代理地址 porxyURL: socks5://127.0.0.1:1080 https://127.0.0.1:1080
func (*NWS) SubscribeAccounts ¶
SubscribeAccounts 订阅资产变动数据 symbol: BTC-USD
func (*NWS) SubscribeLiquidationOrders ¶
SubscribeLiquidationOrders 订阅强平订单数据 symbol: BTC-USD
func (*NWS) SubscribeOrders ¶
SubscribeOrders 订阅订单成交数据 symbol: BTC-USD
func (*NWS) SubscribePositions ¶
SubscribePositions 订阅持仓变动更新数据 symbol: BTC-USD
func (*NWS) SubscribeTopic ¶
SubscribeTopic 订阅
type OpenOrdersData ¶
type OpenOrdersResult ¶
type OpenOrdersResult struct { Status string `json:"status"` ErrCode int `json:"err_code"` ErrMsg string `json:"err_msg"` Data OpenOrdersData `json:"data"` Ts int64 `json:"ts"` }
type Order ¶
type Order struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` Volume float64 `json:"volume"` Price float64 `json:"price"` OrderPriceTypeRaw sjson.RawMessage `json:"order_price_type"` // 1限价单,3对手价,4闪电平仓,5计划委托,6post_only OrderType int `json:"order_type"` Direction string `json:"direction"` Offset string `json:"offset"` LeverRate int `json:"lever_rate"` OrderID int64 `json:"order_id"` ClientOrderID string `json:"client_order_id"` CreatedAt int64 `json:"created_at"` TradeVolume float64 `json:"trade_volume"` TradeTurnover float64 `json:"trade_turnover"` Fee float64 `json:"fee"` TradeAvgPrice float64 `json:"trade_avg_price"` MarginFrozen float64 `json:"margin_frozen"` Profit float64 `json:"profit"` Status int `json:"status"` OrderSource string `json:"order_source"` OrderIDStr string `json:"order_id_str"` FeeAsset string `json:"fee_asset"` }
func (*Order) OrderPriceType ¶
type OrderInfoResult ¶
type OrderResult ¶
type Position ¶
type Position struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` Volume float64 `json:"volume"` Available float64 `json:"available"` Frozen float64 `json:"frozen"` CostOpen float64 `json:"cost_open"` CostHold float64 `json:"cost_hold"` ProfitUnreal float64 `json:"profit_unreal"` ProfitRate float64 `json:"profit_rate"` Profit float64 `json:"profit"` PositionMargin float64 `json:"position_margin"` LeverRate int `json:"lever_rate"` Direction string `json:"direction"` // "buy":买 "sell":卖 LastPrice float64 `json:"last_price"` }
type PositionInfoResult ¶
type WS ¶
WS WebSocket 市场行情接口
func NewWS ¶
NewWS 创建 WS wsURL: 正式地址 wss://api.hbdm.com/swap-ws 开发地址 wss://api.btcgateway.pro/swap-ws
func (*WS) SetDepthCallback ¶
func (*WS) SetDepthHFCallback ¶
func (*WS) SetProxy ¶
SetProxy 设置代理地址 porxyURL: socks5://127.0.0.1:1080 https://127.0.0.1:1080
func (*WS) SetTickerCallback ¶
func (*WS) SetTradeCallback ¶
func (*WS) SubscribeDepth ¶
SubscribeDepth 订阅 Market Depth 数据 id: 订阅的编号 symbol: BTC_CQ
func (*WS) SubscribeDepthHF ¶
SubscribeDepthHF 订阅增量深度 size: 20/150 档位数,20:表示20档不合并的深度,150:表示150档不合并的深度 dateType: 数据类型,不填默认为全量数据,"incremental":增量数据,"snapshot":全量数据
func (*WS) SubscribeTicker ¶
SubscribeTicker 订阅 Market Ticker 数据 id: 订阅的编号 symbol: BTC_CQ
func (*WS) SubscribeTrade ¶
SubscribeTrade 订阅 Market Trade 数据 id: 订阅的编号 symbol: BTC_CQ
func (*WS) Unsubscribe ¶
type WSAccountData ¶
type WSAccountData struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` MarginBalance float64 `json:"margin_balance"` MarginStatic float64 `json:"margin_static"` MarginPosition float64 `json:"margin_position"` MarginFrozen float64 `json:"margin_frozen"` MarginAvailable float64 `json:"margin_available"` ProfitReal float64 `json:"profit_real"` ProfitUnreal float64 `json:"profit_unreal"` WithdrawAvailable float64 `json:"withdraw_available"` RiskRate float64 `json:"risk_rate"` LiquidationPrice float64 `json:"liquidation_price"` LeverRate float64 `json:"lever_rate"` AdjustFactor float64 `json:"adjust_factor"` }
type WSAccounts ¶
type WSAccounts struct { Op string `json:"op"` Topic string `json:"topic"` Ts int64 `json:"ts"` Event string `json:"event"` Data []WSAccountData `json:"data"` }
type WSLiquidationOrderData ¶
type WSLiquidationOrders ¶
type WSLiquidationOrders struct { Op string `json:"op"` Topic string `json:"topic"` Ts int64 `json:"ts"` Data []WSLiquidationOrderData `json:"data"` }
type WSMyTrade ¶
type WSMyTrade struct { TradeID int64 `json:"trade_id"` ID string `json:"id"` TradeVolume float64 `json:"trade_volume"` TradePrice float64 `json:"trade_price"` TradeFee float64 `json:"trade_fee"` FeeAsset string `json:"fee_asset"` TradeTurnover float64 `json:"trade_turnover"` CreatedAt int64 `json:"created_at"` Role string `json:"role"` }
type WSOrder ¶
type WSOrder struct { Op string `json:"op"` Topic string `json:"topic"` Ts int64 `json:"ts"` 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 float64 `json:"lever_rate"` OrderID int64 `json:"order_id"` OrderIDStr string `json:"order_id_str"` ClientOrderID int64 `json:"client_order_id"` OrderSource string `json:"order_source"` OrderType int `json:"order_type"` CreatedAt int64 `json:"created_at"` TradeVolume float64 `json:"trade_volume"` TradeTurnover float64 `json:"trade_turnover"` Fee float64 `json:"fee"` TradeAvgPrice float64 `json:"trade_avg_price"` MarginFrozen float64 `json:"margin_frozen"` Profit float64 `json:"profit"` Trade []WSMyTrade `json:"trade"` }
type WSPositionData ¶
type WSPositionData struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` Volume float64 `json:"volume"` Available float64 `json:"available"` Frozen float64 `json:"frozen"` CostOpen float64 `json:"cost_open"` CostHold float64 `json:"cost_hold"` ProfitUnreal float64 `json:"profit_unreal"` ProfitRate float64 `json:"profit_rate"` Profit float64 `json:"profit"` PositionMargin float64 `json:"position_margin"` LeverRate float64 `json:"lever_rate"` Direction string `json:"direction"` LastPrice float64 `json:"last_price"` }
type WSPositions ¶
type WSPositions struct { Op string `json:"op"` Topic string `json:"topic"` Ts int64 `json:"ts"` Event string `json:"event"` Data []WSPositionData `json:"data"` }
type WSTicker ¶
type WSTicker struct { Ch string `json:"ch"` Ts int64 `json:"ts"` Tick WSTickerTick `json:"tick"` }
type WSTickerTick ¶
type WSTrade ¶
type WSTrade struct { Ch string `json:"ch"` Ts int64 `json:"ts"` Tick WSTradeTick `json:"tick"` }
type WSTradeItem ¶
type WSTradeTick ¶
type WSTradeTick struct { ID int64 `json:"id"` Ts int64 `json:"ts"` Data []WSTradeItem `json:"data"` }