Documentation ¶
Index ¶
- Constants
- Variables
- func GetClients(bTest bool) (clts map[string]*Bitmex)
- func GetHMAC(hashType int, input, key []byte) []byte
- func IsOrderCanceled(o *Order) bool
- func IsOrderFilled(o *Order) bool
- func IsOrderLong(o *Order) bool
- func TransCandle(binSize string, v *models.TradeBin) (candle *Candle)
- type Announcement
- type Bitmex
- func GetClientByName(name string, bTest bool) (bm *Bitmex)
- func GetClientByViperName(cfg *viper.Viper, name string, bTest bool) (bm *Bitmex)
- func GetDefaultClient() *Bitmex
- func NewBitmex(key, secret string) (b *Bitmex)
- func NewBitmexFromCfg(key, secret, baseURL string, cfg *apiclient.TransportConfig) *Bitmex
- func NewBitmexTest(key, secret string) (b *Bitmex)
- func (b *Bitmex) Buy(price float64, amount float64) (ret *Order, err error)
- func (b *Bitmex) CancelAllOrders() (orders []*Order, err error)
- func (b *Bitmex) CancelOrder(oid string) (newOrder *Order, err error)
- func (b *Bitmex) Clone() (ret *Bitmex)
- func (b *Bitmex) CloseLong(price float64, amount float64) (ret *Order, err error)
- func (b *Bitmex) CloseLongMarket(amount float64) (ret *Order, err error)
- func (b *Bitmex) CloseShort(price float64, amount float64) (ret *Order, err error)
- func (b *Bitmex) CloseShortMarket(amount float64) (ret *Order, err error)
- func (b *Bitmex) ContractBalances() (balances map[Contract]Balance, err error)
- func (b *Bitmex) Contracts() (contracts []Contract, err error)
- func (b *Bitmex) CreateOrder(price float64, amount int32, symbol, side, orderType, comment string, ...) (newOrder *models.Order, err error)
- func (b *Bitmex) Depth(d int) (depth Orderbook, err error)
- func (b *Bitmex) GetDepth(d int) (depth Orderbook, err error)
- func (b *Bitmex) GetFunding(start, end time.Time) (funds []*models.Funding, err error)
- func (b *Bitmex) GetInsurance(start, end time.Time) (ins []*models.Insurance, err error)
- func (b *Bitmex) GetLever() (lever float64, err error)
- func (b *Bitmex) GetTicker() (ticker Ticker, err error)
- func (b *Bitmex) Kline(start, end time.Time, nLimit int, bSize string) (klines []*Candle, err error)
- func (b *Bitmex) KlineChan(start, end time.Time, bSize string) (klines chan []interface{}, err chan error)
- func (b *Bitmex) KlineRecent(nCount int32, bSize string) (klines []*Candle, err error)
- func (b *Bitmex) OpenLong(price float64, amount float64) (ret *Order, err error)
- func (b *Bitmex) OpenLongMarket(amount float64) (ret *Order, err error)
- func (b *Bitmex) OpenShort(price float64, amount float64) (ret *Order, err error)
- func (b *Bitmex) OpenShortMarket(amount float64) (ret *Order, err error)
- func (b *Bitmex) Order(oid string) (newOrder *Order, err error)
- func (b *Bitmex) Orders() (orders []*Order, err error)
- func (b *Bitmex) Positions() (positions []Position, err error)
- func (b *Bitmex) Price() (price float64, err error)
- func (b *Bitmex) Sell(price float64, amount float64) (ret *Order, err error)
- func (b *Bitmex) SetContract(contract string) (err error)
- func (b *Bitmex) SetDebug(bDebug bool)
- func (b *Bitmex) SetDepthChan(depthChan chan Depth)
- func (b *Bitmex) SetLever(lever float64) (err error)
- func (b *Bitmex) SetMaxLocalDepth(nMaxDepth int)
- func (b *Bitmex) SetPostOnly(postOnly bool)
- func (b *Bitmex) SetProxy(proxy string) (err error)
- func (b *Bitmex) SetSymbol(symbol string) (err error)
- func (b *Bitmex) SetTradeChan(tradeChan chan Trade)
- func (b *Bitmex) StartWS() (err error)
- func (b *Bitmex) StopLoseBuy(stopPrice, price, amount float64) (ret *Order, err error)
- func (b *Bitmex) StopLoseBuyMarket(price, amount float64) (ret *Order, err error)
- func (b *Bitmex) StopLoseSell(stopPrice, price, amount float64) (ret *Order, err error)
- func (b *Bitmex) StopLoseSellMarket(price, amount float64) (ret *Order, err error)
- func (b *Bitmex) Ticker() (ticker Ticker, err error)
- func (b *Bitmex) Trades(start, end time.Time) (trades []Trade, err error)
- func (b *Bitmex) TradesChan(start, end time.Time) (trades chan []interface{}, err chan error)
- func (b *Bitmex) User() (user *models.User, err error)
- func (b *Bitmex) WS() *BitmexWS
- type BitmexWS
- func (bw *BitmexWS) AddSubscribe(subcribeInfo SubscribeInfo) (err error)
- func (bw *BitmexWS) Connect() (err error)
- func (bw *BitmexWS) GetLastDepth() (depth Depth)
- func (bw *BitmexWS) GetLastOrders() (orders []Order)
- func (bw *BitmexWS) GetLastPos() (poses []Position)
- func (bw *BitmexWS) GetLastTrade() (trade Trade)
- func (bw *BitmexWS) SetBalanceChan(b chan Balance) (err error)
- func (bw *BitmexWS) SetDepthChan(depthChan chan Depth)
- func (bw *BitmexWS) SetHandle(tbl string, handle func(tbl string, msg *Resp))
- func (bw *BitmexWS) SetKlineChan(binSize string, klineChan chan *Candle) (err error)
- func (bw *BitmexWS) SetLastDepth(depth Depth)
- func (bw *BitmexWS) SetLastOrders(orders []Order)
- func (bw *BitmexWS) SetLastPos(pos []Position)
- func (bw *BitmexWS) SetLastTrade(trade Trade)
- func (bw *BitmexWS) SetOrderChan(orderChan chan []Order) (err error)
- func (bw *BitmexWS) SetPositionChan(posChan chan []Position) (err error)
- func (bw *BitmexWS) SetProxy(proxy string)
- func (bw *BitmexWS) SetSubscribe(subcribeTypes []SubscribeInfo)
- func (bw *BitmexWS) SetSymbol(symbol string) (err error)
- func (bw *BitmexWS) SetTradeChan(tradeChan chan Trade)
- type ErrorResponse
- type MainResponse
- type OrderBookData
- type OrderBookL2
- type OrderBookMap
- type OrderMap
- type PositionMap
- type RequestBuffer
- func (r *RequestBuffer) GetBody() []byte
- func (r *RequestBuffer) GetBodyParam() interface{}
- func (r *RequestBuffer) GetFileParam() map[string][]runtime.NamedReadCloser
- func (r *RequestBuffer) GetFormParams() url.Values
- func (r *RequestBuffer) GetHeaderParams() http.Header
- func (r *RequestBuffer) GetMethod() string
- func (r *RequestBuffer) GetPath() string
- func (r *RequestBuffer) GetQueryParams() url.Values
- func (r *RequestBuffer) SetBodyParam(payload interface{}) error
- func (r *RequestBuffer) SetFileParam(name string, files ...runtime.NamedReadCloser) error
- func (r *RequestBuffer) SetFormParam(name string, values ...string) error
- func (r *RequestBuffer) SetHeaderParam(name string, values ...string) error
- func (r *RequestBuffer) SetPathParam(name string, value string) error
- func (r *RequestBuffer) SetQueryParam(name string, values ...string) error
- func (r *RequestBuffer) SetTimeout(timeout time.Duration) error
- type Resp
- func (r *Resp) Decode(buf []byte) (err error)
- func (r *Resp) GetMargins() (margins []*models.Margin)
- func (r *Resp) GetOrder() (orders []*models.Order)
- func (r *Resp) GetOrderbookL2() (orderbook OrderBookData)
- func (r *Resp) GetPostions() (positions []*models.Position)
- func (r *Resp) GetTradeBin() (klines []*models.TradeBin)
- func (r *Resp) GetTradeData() (trades []*models.Trade)
- func (r *Resp) GetWallets() (wallets []*models.Wallet)
- func (r *Resp) HasStatus() bool
- func (r *Resp) HasSuccess() bool
- func (r *Resp) HasTable() bool
- type Shutdown
- type SubscribeInfo
- type SubscribeResp
- type TradeBitmex
- type Transport
- type WSCmd
- type Welcome
Constants ¶
const ( BaseURL = "www.bitmex.com" TestBaseURL = "testnet.bitmex.com" )
const ( MaxTableLen = 200 // Bitmex websocket op BitmexWSOrderbookL2 = "orderBookL2" // Full level 2 orderBook BitmexWSOrderbookL2_25 = "orderBookL2_25" // Full level 2 orderBook BitmexWSOrderbookL10 = "orderBook10" // Top 10 levels using traditional full book push BitmexWSTrade = "trade" // Live trades BitmexWSTradeBin1m = "tradeBin1m" // 1-minute trade bins BitmexWSTradeBin5m = "tradeBin5m" // 5-minute trade bins BitmexWSTradeBin1h = "tradeBin1h" // 1-hour trade bins BitmexWSTradeBin1d = "tradeBin1d" // 1-day trade bins BitmexWSAnnouncement = "announcement" // Site announcements BitmexWSLiquidation = "liquidation" // Liquidation orders as they're entered into the book BitmexWSQuote = "quote" // Top level of the book BitmexWSQuoteBin1m = "quoteBin1m" // 1-minute quote bins BitmexWSQuoteBin5m = "quoteBin5m" // 5-minute quote bins BitmexWSQuoteBin1h = "quoteBin1h" // 1-hour quote bins BitmexWSQuoteBin1d = "quoteBin1d" // 1-day quote bins // Bitmex websocket private op BitmexWSExecution = "execution" // Individual executions; can be multiple per order BitmexWSOrder = "order" // Live updates on your orders BitmexWSMargin = "margin" // Updates on your current account balance and margin requirements BitmexWSPosition = "position" // Updates on your positions BitmexWSWallet = "wallet" // wallet update WSTimeOut = 5 * time.Second )
const ( HashSHA1 = iota HashSHA256 HashSHA512 HashSHA512_384 HashMD5 )
const ( OrderBuy = "Buy" OrderSell = "Sell" OrderTypeLimit = "Limit" OrderTypeMarket = "Market" OrderTypeStop = "Stop" // stop lose with market price, must set stopPx OrderTypeStopLimit = "StopLimit" // stop lose with limit price, must set stopPx PostOnly = "ParticipateDoNotInitiate" ReduceOnly = "ReduceOnly" )
Variables ¶
var (
NoOrderFound = errors.New("no such order")
)
Functions ¶
func GetClients ¶
func IsOrderCanceled ¶ added in v1.0.1
func IsOrderCanceled(o *Order) bool
func IsOrderFilled ¶ added in v1.0.1
func IsOrderFilled(o *Order) bool
func IsOrderLong ¶ added in v1.0.1
func IsOrderLong(o *Order) bool
func TransCandle ¶ added in v1.0.3
Types ¶
type Announcement ¶
type Announcement struct { Content string `json:"content"` Date string `json:"date"` ID int32 `json:"id"` Link string `json:"link"` Title string `json:"title"` }
Announcement General Announcements
type Bitmex ¶
func GetClientByName ¶
func GetClientByViperName ¶ added in v1.0.5
func GetDefaultClient ¶
func GetDefaultClient() *Bitmex
func NewBitmexFromCfg ¶
func NewBitmexFromCfg(key, secret, baseURL string, cfg *apiclient.TransportConfig) *Bitmex
func NewBitmexFromCfg(key, secret, baseURL string, cfg *apiclient.Configuration) *Bitmex {
func NewBitmexTest ¶
func (*Bitmex) CancelAllOrders ¶
CancelAllOrders cancel all not filled orders
func (*Bitmex) CancelOrder ¶
CancelOrder with oid
func (*Bitmex) CloseLongMarket ¶
CloseLongarket close long with market price
func (*Bitmex) CloseShort ¶
CloseShort close short with price
func (*Bitmex) CloseShortMarket ¶
CloseShortMarket close short with market price
func (*Bitmex) ContractBalances ¶
ContractBalances get balances of each contract
func (*Bitmex) Contracts ¶
Contracts get all support contracts Fixme: "parse error", may be the swagger code wrong
func (*Bitmex) CreateOrder ¶ added in v1.0.6
func (b *Bitmex) CreateOrder(price float64, amount int32, symbol, side, orderType, comment string, execInsts ...string) (newOrder *models.Order, err error)
CreteOrder create bitmex order,return bitmex model information
func (*Bitmex) GetFunding ¶ added in v1.0.5
GetFunding get insurance
func (*Bitmex) GetInsurance ¶ added in v1.0.5
GetInsurance get insurance
func (*Bitmex) Kline ¶
func (b *Bitmex) Kline(start, end time.Time, nLimit int, bSize string) (klines []*Candle, err error)
Kline Timestamp of kline is the end of the binSize
func (*Bitmex) KlineRecent ¶
KlineRecent get recent nCount klines
func (*Bitmex) OpenLongMarket ¶
OpenLongMarket open long with market price
func (*Bitmex) OpenShortMarket ¶
OpenShortMarket open short with market price
func (*Bitmex) SetContract ¶
func (*Bitmex) SetDepthChan ¶
func (b *Bitmex) SetDepthChan(depthChan chan Depth)
func (*Bitmex) SetMaxLocalDepth ¶
SetMaxLocalDepth set max local depth cache len
func (*Bitmex) SetPostOnly ¶ added in v1.0.4
func (*Bitmex) SetProxy ¶
SetProxy set proxy of websocket example: socks5://127.0.0.1:1080
http://127.0.0.1:1080
func (*Bitmex) SetTradeChan ¶
func (b *Bitmex) SetTradeChan(tradeChan chan Trade)
func (*Bitmex) StopLoseBuy ¶
StopLoseBuy when marketPrice>=stopPrice, create buy order with price and amount
func (*Bitmex) StopLoseBuyMarket ¶
StopLoseSell when marketPrice>=stopPrice, create buy order with marketPrice and amount
func (*Bitmex) StopLoseSell ¶
StopLoseSell when marketPrice<=stopPrice, create sell order with price and amount
func (*Bitmex) StopLoseSellMarket ¶
StopLoseSell when marketPrice<=stopPrice, create buy order with marketPrice and amount
func (*Bitmex) TradesChan ¶
type BitmexWS ¶
type BitmexWS struct { TableLen int // contains filtered or unexported fields }
func NewBitmexWS ¶
func NewBitmexWSTest ¶
func NewBitmexWSWithURL ¶
func (*BitmexWS) AddSubscribe ¶
func (bw *BitmexWS) AddSubscribe(subcribeInfo SubscribeInfo) (err error)
AddSubscribe add subcribe
func (*BitmexWS) GetLastDepth ¶
func (bw *BitmexWS) GetLastDepth() (depth Depth)
GetLastDepth get last depths
func (*BitmexWS) GetLastOrders ¶ added in v1.0.1
func (bw *BitmexWS) GetLastOrders() (orders []Order)
func (*BitmexWS) GetLastPos ¶
func (bw *BitmexWS) GetLastPos() (poses []Position)
func (*BitmexWS) GetLastTrade ¶
func (bw *BitmexWS) GetLastTrade() (trade Trade)
GetLastDepth get last depths
func (*BitmexWS) SetBalanceChan ¶ added in v1.0.8
func (*BitmexWS) SetDepthChan ¶
func (bw *BitmexWS) SetDepthChan(depthChan chan Depth)
func (*BitmexWS) SetKlineChan ¶
func (*BitmexWS) SetLastDepth ¶
func (bw *BitmexWS) SetLastDepth(depth Depth)
SetLastDepth set depth data,call by websocket message handler
func (*BitmexWS) SetLastOrders ¶ added in v1.0.1
func (bw *BitmexWS) SetLastOrders(orders []Order)
func (*BitmexWS) SetLastPos ¶
func (bw *BitmexWS) SetLastPos(pos []Position)
func (*BitmexWS) SetLastTrade ¶
func (bw *BitmexWS) SetLastTrade(trade Trade)
SetLastTrade set depth data,call by websocket message handler
func (*BitmexWS) SetOrderChan ¶ added in v1.0.1
func (*BitmexWS) SetPositionChan ¶ added in v1.0.1
func (*BitmexWS) SetSubscribe ¶
func (bw *BitmexWS) SetSubscribe(subcribeTypes []SubscribeInfo)
func (*BitmexWS) SetTradeChan ¶
func (bw *BitmexWS) SetTradeChan(tradeChan chan Trade)
type ErrorResponse ¶
type MainResponse ¶
type MainResponse struct { Table string `json:"table"` Keys []string `json:"keys"` Types struct { ID string `json:"id"` Price string `json:"price"` Side string `json:"side"` Size string `json:"size"` Symbol string `json:"symbol"` } `json:"types"` ForeignKeys struct { Side string `json:"side"` Symbol string `json:"symbol"` } `json:"foreignKeys"` Attributes struct { ID string `json:"id"` Symbol string `json:"symbol"` } `json:"Attributes"` }
type OrderBookData ¶
type OrderBookData []*OrderBookL2
func (*OrderBookData) GetDataToMap ¶
func (od *OrderBookData) GetDataToMap(ret OrderBookMap)
func (*OrderBookData) GetMap ¶
func (od *OrderBookData) GetMap() (ret OrderBookMap)
type OrderBookL2 ¶
type OrderBookL2 struct { ID int64 `json:"id"` Price float64 `json:"price"` Side string `json:"side"` Size int64 `json:"size"` Symbol string `json:"symbol"` }
OrderBookL2 contains order book l2
func (*OrderBookL2) Key ¶
func (o *OrderBookL2) Key() string
type OrderBookMap ¶
type OrderBookMap map[string]*OrderBookL2
func NewOrderBookMap ¶
func NewOrderBookMap() (o OrderBookMap)
func (OrderBookMap) GetDepth ¶
func (o OrderBookMap) GetDepth() (depth Depth)
type OrderMap ¶ added in v1.0.1
func NewOrderMap ¶ added in v1.0.1
func NewOrderMap() OrderMap
type PositionMap ¶
func NewPositionMap ¶
func NewPositionMap() (o PositionMap)
func (PositionMap) Pos ¶
func (o PositionMap) Pos() (poses []Position)
func (PositionMap) Update ¶
func (o PositionMap) Update(pos []*models.Position)
type RequestBuffer ¶
type RequestBuffer struct {
// contains filtered or unexported fields
}
func NewRequestBuffer ¶
func NewRequestBuffer() (r *RequestBuffer)
func (*RequestBuffer) GetBody ¶
func (r *RequestBuffer) GetBody() []byte
func (*RequestBuffer) GetBodyParam ¶
func (r *RequestBuffer) GetBodyParam() interface{}
func (*RequestBuffer) GetFileParam ¶
func (r *RequestBuffer) GetFileParam() map[string][]runtime.NamedReadCloser
func (*RequestBuffer) GetFormParams ¶
func (r *RequestBuffer) GetFormParams() url.Values
func (*RequestBuffer) GetHeaderParams ¶ added in v1.0.1
func (r *RequestBuffer) GetHeaderParams() http.Header
func (*RequestBuffer) GetMethod ¶
func (r *RequestBuffer) GetMethod() string
func (*RequestBuffer) GetPath ¶
func (r *RequestBuffer) GetPath() string
func (*RequestBuffer) GetQueryParams ¶
func (r *RequestBuffer) GetQueryParams() url.Values
func (*RequestBuffer) SetBodyParam ¶
func (r *RequestBuffer) SetBodyParam(payload interface{}) error
func (*RequestBuffer) SetFileParam ¶
func (r *RequestBuffer) SetFileParam(name string, files ...runtime.NamedReadCloser) error
func (*RequestBuffer) SetFormParam ¶
func (r *RequestBuffer) SetFormParam(name string, values ...string) error
func (*RequestBuffer) SetHeaderParam ¶
func (r *RequestBuffer) SetHeaderParam(name string, values ...string) error
func (*RequestBuffer) SetPathParam ¶
func (r *RequestBuffer) SetPathParam(name string, value string) error
func (*RequestBuffer) SetQueryParam ¶
func (r *RequestBuffer) SetQueryParam(name string, values ...string) error
func (*RequestBuffer) SetTimeout ¶
func (r *RequestBuffer) SetTimeout(timeout time.Duration) error
type Resp ¶
type Resp struct { Request WSCmd `json:"request"` SubscribeResp ErrorResponse MainResponse Action string // contains filtered or unexported fields }
func (*Resp) GetMargins ¶ added in v1.0.8
func (*Resp) GetOrderbookL2 ¶
func (r *Resp) GetOrderbookL2() (orderbook OrderBookData)
func (*Resp) GetPostions ¶
func (*Resp) GetTradeBin ¶
func (*Resp) GetTradeData ¶
func (*Resp) GetWallets ¶ added in v1.0.8
func (*Resp) HasSuccess ¶
type Shutdown ¶
type Shutdown struct {
// contains filtered or unexported fields
}
Shutdown to monitor and shut down routines package specific
func NewRoutineManagement ¶
func NewRoutineManagement() *Shutdown
NewRoutineManagement returns an new initial routine management system
func (*Shutdown) SignalShutdown ¶
func (r *Shutdown) SignalShutdown()
SignalShutdown signals a shutdown across routines
type SubscribeInfo ¶
type SubscribeResp ¶
type TradeBitmex ¶
type Transport ¶
type Transport struct { *httptransport.Runtime Key string Secret string }