Documentation ¶
Index ¶
- Constants
- Variables
- type BalanceMsg
- type BalancesSnapshot
- type Configuration
- type Env
- type ErrHandler
- type ExecInst
- type ExecType
- type Granularity
- type HeartbeatMsg
- type L2Msg
- type L3Msg
- type Level
- type MsgType
- type NewOrderSingleMsg
- type Order
- type OrderSide
- type OrderStatus
- type OrderType
- type PricesMsg
- type RejectMsg
- type SubscriptionError
- type Symbol
- type SymbolMsg
- type SymbolsSnapshot
- type TickerMsg
- type TimeInForce
- type TradesMsg
- type TradingMsg
- type TradingReject
- type TradingSnapshot
- type TradingUpdated
- type WebSocketClient
- func (ws *WebSocketClient) Authenticate(token string) error
- func (ws *WebSocketClient) Balances() chan BalancesSnapshot
- func (ws *WebSocketClient) BulkCancel(symbol *Symbol) error
- func (ws *WebSocketClient) CancelOrder(orderID string) error
- func (ws *WebSocketClient) Errors() chan error
- func (ws *WebSocketClient) Heartbeats() chan HeartbeatMsg
- func (ws *WebSocketClient) L2Quotes() chan L2Msg
- func (ws *WebSocketClient) L3Quotes() chan L3Msg
- func (ws *WebSocketClient) NewOrderSingleMessage(order NewOrderSingleMsg) error
- func (ws *WebSocketClient) Prices() chan PricesMsg
- func (ws *WebSocketClient) Start(authenticate bool) error
- func (ws *WebSocketClient) Stop() error
- func (ws *WebSocketClient) SubscribeHeartbeat() error
- func (ws *WebSocketClient) SubscribeToBalances() error
- func (ws *WebSocketClient) SubscribeToL2(symbol Symbol) error
- func (ws *WebSocketClient) SubscribeToL3(symbol Symbol) error
- func (ws *WebSocketClient) SubscribeToPrices(symbol Symbol, granularity Granularity) error
- func (ws *WebSocketClient) SubscribeToSymbols() error
- func (ws *WebSocketClient) SubscribeToTicker(symbol Symbol) error
- func (ws *WebSocketClient) SubscribeToTrades(symbol Symbol) error
- func (ws *WebSocketClient) SubscribeToTrading() error
- func (ws *WebSocketClient) Symbols() chan SymbolMsg
- func (ws *WebSocketClient) Ticker() chan TickerMsg
- func (ws *WebSocketClient) Trades() chan TradesMsg
- func (ws *WebSocketClient) Trading() chan TradingMsg
- func (ws *WebSocketClient) WsL2Serve(symbol string, handler WsL2MsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func (ws *WebSocketClient) WsL2ServeCombined(symbols []string, handler WsL2MsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func (ws *WebSocketClient) WsL3Serve(symbol string, handler WsL3MsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func (ws *WebSocketClient) WsPriceServe(symbol string, granularity Granularity, handler WsPriceMsgHandler, ...) (doneC, stopC chan struct{}, err error)
- func (ws *WebSocketClient) WsTickerServe(symbol string, handler WsTickerMsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- type WsHandler
- type WsL2MsgHandler
- type WsL3MsgHandler
- type WsPriceMsgHandler
- type WsTickerMsgHandler
Constants ¶
View Source
const ( WsEndpoint = "wss://ws.blockchain.info/mercury-gateway/v1/ws" WsTestEndpoint = "wss://ws.staging.blockchain.info/mercury-gateway/v1/ws" )
Endpoints
View Source
const ( Granularity60 Granularity = 60 Granularity300 Granularity = 300 Granularity900 Granularity = 900 Granularity3600 Granularity = 3600 Granularity21600 Granularity = 21600 Granularity86400 Granularity = 86400 GTC TimeInForce = "GTC" // Good Till Cancel. The order will rest on the order book until it is cancelled or filled GTD TimeInForce = "GTD" // Good Till Date. The order will reset on the order book until it is cancelled, filled, or expired FOK TimeInForce = "FOK" // Fill or Kill. The order is either completely filled or cancelled. No Partial Fills are permitted. IOC TimeInForce = "IOC" // Immediate or Cancel. The order is either a) completely filled, b) partially filled and the remaining quantity canceled, or c) the order is canceled. LIMIT OrderType = "limit" // order which has a price limit MARKET OrderType = "market" // order that will match at any price available in the market, starting from the best prices and filling up to the available balance STOP OrderType = "stop" // order which has a stop/trigger price, and when that price is reached, it triggers a market order STOP_LIMIT OrderType = "stopLimit" // order which has a stop price and limit price, and when the stop price is reached, it triggers a limit order at the limit price ORDER_STATUS_PENDING OrderStatus = "pending" // is pending acceptance. Only applicable to stop and stop-limit orders ORDER_STATUS_OPEN OrderStatus = "open" // has been accepted ORDER_STATUS_REJECTED OrderStatus = "rejected" // has been rejected Limit and market orders can get rejected if you have no balance to fill the order even partially. ORDER_STATUS_CANCELLED OrderStatus = "cancelled" // has been cancelled A market order might get in state cancelled if you don’t have enough balance to fill it at market price. Both market orders and limit orders with IOC can have ordStatus ‘cancelled’ if there is no market for them, even without the user requesting the cancellation. ORDER_STATUS_FILLED OrderStatus = "filled" // has been filled A limit order get in state cancelled after the user requested a cancellation. ORDER_STATUS_PARTIAL OrderStatus = "partial" // has been partially filled ORDER_STATUS_EXPIRED OrderStatus = "expired" // has been expired BUY OrderSide = "buy" SELL OrderSide = "sell" ALO ExecInst = "ALO" ExecutionReport MsgType = "8" OrderCancelRejected MsgType = "9" EXEC_TYPE_NEW ExecType = "0" EXEC_TYPE_CANCELLED ExecType = "4" EXEC_TYPE_EXPIRED ExecType = "C" EXEC_TYPE_REJECTED ExecType = "8" EXEC_TYPE_PARTIAL_FILL ExecType = "F" EXEC_TYPE_PENDING ExecType = "A" EXEC_TYPE_TRADE_BREAK ExecType = "H" EXEC_TYPE_ORDER_STATUS ExecType = "I" )
Variables ¶
View Source
var ( WsHeaders = http.Header{ "Origin": {"https://exchange.blockchain.com"}, } PingFrequency = time.Second * 5 )
View Source
var ( ErrAlreadySubscribed = errors.New("already subscribed") ErrInvalidRequest = errors.New("invalid request") )
View Source
var UseTestnet = false
UseTestnet switch all the API endpoints from production to the testnet
Functions ¶
This section is empty.
Types ¶
type BalanceMsg ¶
type BalancesSnapshot ¶
type Configuration ¶
type Granularity ¶
type Granularity int
type HeartbeatMsg ¶
type NewOrderSingleMsg ¶
type NewOrderSingleMsg struct { ClOrdID string `json:"clOrdID"` Symbol Symbol `json:"symbol"` OrdType OrderType `json:"ordType"` TimeInForce TimeInForce `json:"timeInForce"` Side OrderSide `json:"side"` OrderQty float64 `json:"orderQty"` Price float64 `json:"price"` ExecInst ExecInst `json:"execInst"` }
type Order ¶
type Order struct { OrderID string `json:"orderID"` ClOrdID string `json:"clOrdID"` Symbol string `json:"symbol"` Side string `json:"side"` OrdType string `json:"ordType"` OrderQty float64 `json:"orderQty"` LeavesQty float64 `json:"leavesQty"` CumQty float64 `json:"cumQty"` AvgPx float64 `json:"avgPx"` OrdStatus string `json:"ordStatus"` TimeInForce string `json:"timeInForce"` Text string `json:"text"` ExecType string `json:"execType"` ExecID string `json:"execID"` TransactTime time.Time `json:"transactTime"` MsgType int `json:"msgType"` LastPx float64 `json:"lastPx"` TradeID string `json:"tradeId"` Price float64 `json:"price"` }
type OrderStatus ¶
type OrderStatus string
type SubscriptionError ¶
type SymbolMsg ¶
type SymbolMsg struct { Name Symbol `json:"name"` BaseCurrency string `json:"base_currency"` BaseCurrencyScale int `json:"base_currency_scale"` CounterCurrency string `json:"counter_currency"` CounterCurrencyScale int `json:"counter_currency_scale"` MinPriceIncrement int `json:"min_price_increment"` MinPriceIncrementScale int `json:"min_price_increment_scale"` MinOrderSize int `json:"min_order_size"` MinOrderSizeScale int `json:"min_order_size_scale"` MaxOrderSize int `json:"max_order_size"` MaxOrderSizeScale int `json:"max_order_size_scale"` LotSize int `json:"lot_size"` LotSizeScale int `json:"lot_size_scale"` Status string `json:"status"` ID int `json:"id"` AuctionPrice float64 `json:"auction_price"` AuctionSize float64 `json:"auction_size"` AuctionTime string `json:"auction_time"` Imbalance float64 `json:"imbalance"` }
type SymbolsSnapshot ¶
type TimeInForce ¶
type TimeInForce string
type TradingMsg ¶
type TradingReject ¶
type TradingReject struct { Seqnum int `json:"seqnum"` Event string `json:"event"` Channel string `json:"channel"` Text string `json:"text"` ClOrdID string `json:"clOrdID"` OrdStatus string `json:"ordStatus"` Action string `json:"action"` }
func (*TradingReject) IsReject ¶
func (t *TradingReject) IsReject() bool
func (*TradingReject) IsSnapshot ¶
func (t *TradingReject) IsSnapshot() bool
func (*TradingReject) IsUpdate ¶
func (t *TradingReject) IsUpdate() bool
type TradingSnapshot ¶
type TradingSnapshot struct { Seqnum int `json:"seqnum"` Event string `json:"event"` Channel string `json:"channel"` Orders []Order `json:"orders"` }
func (*TradingSnapshot) IsReject ¶
func (t *TradingSnapshot) IsReject() bool
func (*TradingSnapshot) IsSnapshot ¶
func (t *TradingSnapshot) IsSnapshot() bool
func (*TradingSnapshot) IsUpdate ¶
func (t *TradingSnapshot) IsUpdate() bool
type TradingUpdated ¶
type TradingUpdated struct { Seqnum int `json:"seqnum"` Event string `json:"event"` Channel string `json:"channel"` OrderID string `json:"orderID"` ClOrdID string `json:"clOrdID"` Symbol string `json:"symbol"` Side string `json:"side"` OrdType string `json:"ordType"` OrderQty float64 `json:"orderQty"` LeavesQty float64 `json:"leavesQty"` CumQty float64 `json:"cumQty"` AvgPx float64 `json:"avgPx"` OrdStatus string `json:"ordStatus"` TimeInForce string `json:"timeInForce"` Text string `json:"text"` ExecType string `json:"execType"` ExecID string `json:"execID"` TransactTime time.Time `json:"transactTime"` MsgType int `json:"msgType"` LastPx float64 `json:"lastPx"` TradeID string `json:"tradeId"` Price float64 `json:"price"` }
func (*TradingUpdated) IsReject ¶
func (t *TradingUpdated) IsReject() bool
func (*TradingUpdated) IsSnapshot ¶
func (t *TradingUpdated) IsSnapshot() bool
func (*TradingUpdated) IsUpdate ¶
func (t *TradingUpdated) IsUpdate() bool
type WebSocketClient ¶
type WebSocketClient struct {
// contains filtered or unexported fields
}
func NewWebSocketClient ¶
func NewWebSocketClient(configuration Configuration) *WebSocketClient
func (*WebSocketClient) Authenticate ¶
func (ws *WebSocketClient) Authenticate(token string) error
func (*WebSocketClient) Balances ¶
func (ws *WebSocketClient) Balances() chan BalancesSnapshot
func (*WebSocketClient) BulkCancel ¶
func (ws *WebSocketClient) BulkCancel(symbol *Symbol) error
func (*WebSocketClient) CancelOrder ¶
func (ws *WebSocketClient) CancelOrder(orderID string) error
func (*WebSocketClient) Errors ¶
func (ws *WebSocketClient) Errors() chan error
func (*WebSocketClient) Heartbeats ¶
func (ws *WebSocketClient) Heartbeats() chan HeartbeatMsg
func (*WebSocketClient) L2Quotes ¶
func (ws *WebSocketClient) L2Quotes() chan L2Msg
func (*WebSocketClient) L3Quotes ¶
func (ws *WebSocketClient) L3Quotes() chan L3Msg
func (*WebSocketClient) NewOrderSingleMessage ¶
func (ws *WebSocketClient) NewOrderSingleMessage(order NewOrderSingleMsg) error
func (*WebSocketClient) Prices ¶
func (ws *WebSocketClient) Prices() chan PricesMsg
func (*WebSocketClient) Start ¶
func (ws *WebSocketClient) Start(authenticate bool) error
func (*WebSocketClient) Stop ¶
func (ws *WebSocketClient) Stop() error
func (*WebSocketClient) SubscribeHeartbeat ¶
func (ws *WebSocketClient) SubscribeHeartbeat() error
func (*WebSocketClient) SubscribeToBalances ¶
func (ws *WebSocketClient) SubscribeToBalances() error
func (*WebSocketClient) SubscribeToL2 ¶
func (ws *WebSocketClient) SubscribeToL2(symbol Symbol) error
func (*WebSocketClient) SubscribeToL3 ¶
func (ws *WebSocketClient) SubscribeToL3(symbol Symbol) error
func (*WebSocketClient) SubscribeToPrices ¶
func (ws *WebSocketClient) SubscribeToPrices(symbol Symbol, granularity Granularity) error
func (*WebSocketClient) SubscribeToSymbols ¶
func (ws *WebSocketClient) SubscribeToSymbols() error
func (*WebSocketClient) SubscribeToTicker ¶
func (ws *WebSocketClient) SubscribeToTicker(symbol Symbol) error
func (*WebSocketClient) SubscribeToTrades ¶
func (ws *WebSocketClient) SubscribeToTrades(symbol Symbol) error
func (*WebSocketClient) SubscribeToTrading ¶
func (ws *WebSocketClient) SubscribeToTrading() error
func (*WebSocketClient) Symbols ¶
func (ws *WebSocketClient) Symbols() chan SymbolMsg
func (*WebSocketClient) Ticker ¶
func (ws *WebSocketClient) Ticker() chan TickerMsg
func (*WebSocketClient) Trades ¶
func (ws *WebSocketClient) Trades() chan TradesMsg
func (*WebSocketClient) Trading ¶
func (ws *WebSocketClient) Trading() chan TradingMsg
func (*WebSocketClient) WsL2Serve ¶
func (ws *WebSocketClient) WsL2Serve(symbol string, handler WsL2MsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsL2Serve serve websocket l2 handler with a symbol
func (*WebSocketClient) WsL2ServeCombined ¶
func (ws *WebSocketClient) WsL2ServeCombined(symbols []string, handler WsL2MsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsL2ServeCombined serve websocket l2 handler for a list of symbols
func (*WebSocketClient) WsL3Serve ¶
func (ws *WebSocketClient) WsL3Serve(symbol string, handler WsL3MsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsL3Serve serve websocket l3 handler with a symbol
func (*WebSocketClient) WsPriceServe ¶
func (ws *WebSocketClient) WsPriceServe(symbol string, granularity Granularity, handler WsPriceMsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsPriceServe serve websocket ticker handler with a symbol
func (*WebSocketClient) WsTickerServe ¶
func (ws *WebSocketClient) WsTickerServe(symbol string, handler WsTickerMsgHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsTickerServe serve websocket ticker handler with a symbol
type WsL2MsgHandler ¶
type WsL2MsgHandler func(event *L2Msg)
WsL2MsgHandler handle websocket l2 event
type WsL3MsgHandler ¶
type WsL3MsgHandler func(event *L3Msg)
WsL2MsgHandler handle websocket l3 event
type WsPriceMsgHandler ¶
type WsPriceMsgHandler func(event *PricesMsg)
WsPriceMsgHandler handle websocket price event
type WsTickerMsgHandler ¶
type WsTickerMsgHandler func(event *TickerMsg)
WsTickerMsgHandler handle websocket ticker event
Click to show internal directories.
Click to hide internal directories.