Documentation ¶
Index ¶
- Constants
- func GetCurrentTime() int64
- func ParseCurrencyPair(symbol string) gocoinex.CurrencyPair
- type Bybit
- func (g *Bybit) CancelOrder(orderId string, currencyPair CurrencyPair) (bool, error)
- func (g *Bybit) GetAccount() (*Account, error)
- func (g *Bybit) GetBestTicker(currencyPair CurrencyPair) (*BestTicker, error)
- func (g *Bybit) GetCurrencyPairs() ([]CurrencyPair, error)
- func (g *Bybit) GetDepth(size int, currencyPair CurrencyPair) (*Depth, error)
- func (g *Bybit) GetExchangeName() string
- func (g *Bybit) GetKlineRecords(currencyPair CurrencyPair, period KlinePeriod, size int, ...) ([]Kline, error)
- func (g *Bybit) GetOneOrder(orderId string, currencyPair CurrencyPair) (*Order, error)
- func (g *Bybit) GetOrderHistorys(currencyPair CurrencyPair, optional ...OptionalParameter) ([]Order, error)
- func (g *Bybit) GetSubAccount(coin Currency) (*SubAccount, error)
- func (g *Bybit) GetTicker(currencyPair CurrencyPair) (*Ticker, error)
- func (g *Bybit) GetTradeFee(currencyPair CurrencyPair) (*TradeFee, error)
- func (g *Bybit) GetTrades(currencyPair CurrencyPair, size int64) ([]Trade, error)
- func (g *Bybit) GetUnfinishOrders(currencyPair CurrencyPair) ([]Order, error)
- func (p *Bybit) LimitBuy(amount, price string, currencyPair CurrencyPair, ...) (*Order, error)
- func (p *Bybit) LimitSell(amount, price string, currencyPair CurrencyPair, ...) (*Order, error)
- func (p *Bybit) MarketBuy(amount, price string, currencyPair CurrencyPair) (*Order, error)
- func (p *Bybit) MarketSell(amount, price string, currencyPair CurrencyPair) (*Order, error)
- func (g *Bybit) PlaceOrder(amount, price string, currencyPair CurrencyPair, orderType, orderSide string) (*Order, error)
- type Category
- type CoinInfo
- type FeeRateItem
- type FeeRatesInfo
- type Instrument
- type InstrumentInfoResponse
- type LeverageFilter
- type LotSizeFilter
- type MarketKlineResponse
- type MarketTickers
- type OrderBookInfo
- type OrderInfo
- type OrderInfoResponse
- type OrderStatus
- type PriceFilter
- type PublicRecentTradeHistory
- type ServerResponse
- type SpotWs
- func (s *SpotWs) Auth()
- func (s *SpotWs) BestTickerCallback(f func(ticker *gocoinex.BestTicker, exchange string))
- func (s *SpotWs) DepthCallback(f func(depth *gocoinex.Depth, exchange string))
- func (s *SpotWs) HeartbeatData() []byte
- func (s *SpotWs) SubscribeBestTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeDepth(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeTrade(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) SubscribeUserBalance() error
- func (s *SpotWs) SubscribeUserOrder() error
- func (s *SpotWs) TickerCallback(f func(ticker *gocoinex.Ticker, exchange string))
- func (s *SpotWs) TradeCallback(f func(trade *gocoinex.Trade, exchange string))
- func (s *SpotWs) UnSubscribeBestTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeDepth(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeTicker(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeTrade(pair gocoinex.CurrencyPair) error
- func (s *SpotWs) UnSubscribeUserBalance() error
- func (s *SpotWs) UnSubscribeUserOrder() error
- func (s *SpotWs) UserBalanceCallback(f func(trade *gocoinex.SubAccount, exchange string))
- func (s *SpotWs) UserOrderCallback(f func(trade *gocoinex.Order, exchange string))
- type SymbolStatus
- type TickerInfo
- type TimeInForce
- type TradeInfo
- type WalletAccountInfo
- type WalletBalanceInfo
Constants ¶
View Source
const ( Subscribe = "subscribe" UnSubscribe = "unsubscribe" )
View Source
const ( Name = "bybit.api.go" Version = "1.0.2" // Https MAINNET = "https://api.bybit.com" MAINNET_BACKT = "https://api.bytick.com" TESTNET = "https://api-testnet.bybit.com" // WebSocket public channel - Mainnet SPOT_MAINNET = "wss://stream.bybit.com/v5/public/spot" LINEAR_MAINNET = "wss://stream.bybit.com/v5/public/linear" INVERSE_MAINNET = "wss://stream.bybit.com/v5/public/inverse" OPTION_MAINNET = "wss://stream.bybit.com/v5/public/option" // WebSocket public channel - Testnet SPOT_TESTNET = "wss://stream-testnet.bybit.com/v5/public/spot" LINEAR_TESTNET = "wss://stream-testnet.bybit.com/v5/public/linear" INVERSE_TESTNET = "wss://stream-testnet.bybit.com/v5/public/inverse" OPTION_TESTNET = "wss://stream-testnet.bybit.com/v5/public/option" // WebSocket private channel WEBSOCKET_PRIVATE_MAINNET = "wss://stream.bybit.com/v5/private" WEBSOCKET_PRIVATE_TESTNET = "wss://stream-testnet.bybit.com/v5/private" // V3 V3_CONTRACT_PRIVATE = "wss://stream.bybit.com/contract/private/v3" V3_UNIFIED_PRIVATE = "wss://stream.bybit.com/unified/private/v3" V3_SPOT_PRIVATE = "wss://stream.bybit.com/spot/private/v3" )
Variables ¶
This section is empty.
Functions ¶
func GetCurrentTime ¶
func GetCurrentTime() int64
func ParseCurrencyPair ¶
func ParseCurrencyPair(symbol string) gocoinex.CurrencyPair
Types ¶
type Bybit ¶
type Bybit struct {
// contains filtered or unexported fields
}
func (*Bybit) CancelOrder ¶
func (*Bybit) GetAccount ¶
func (*Bybit) GetBestTicker ¶
func (*Bybit) GetExchangeName ¶
func (*Bybit) GetKlineRecords ¶
func (*Bybit) GetOneOrder ¶
优先在在挂订单中查询,查找不到时去查询历史订单
func (*Bybit) GetOrderHistorys ¶
func (*Bybit) GetSubAccount ¶
func (*Bybit) GetTradeFee ¶
私有权限
func (*Bybit) GetUnfinishOrders ¶
查询指定交易对所有挂单
func (*Bybit) LimitBuy ¶
func (p *Bybit) LimitBuy(amount, price string, currencyPair CurrencyPair, optional ...LimitOrderOptionalParameter) (*Order, error)
限价买单
func (*Bybit) MarketSell ¶
type Category ¶
type Category string
const ( CategorySpot Category = "spot" CategoryLinear Category = "linear" //Unified Account: USDT perpetual, and USDC contract, including USDC perp, USDC futures; Classic Account: USDT perp CategoryInverse Category = "inverse" // Inverse contract, including Inverse perp, Inverse futures CategoryOption Category = "option" )
type CoinInfo ¶
type CoinInfo struct { Coin string `json:"coin"` Equity string `json:"equity"` UsdValue string `json:"usdValue"` WalletBalance string `json:"walletBalance"` Free string `json:"free"` Locked string `json:"locked"` BorrowAmount string `json:"borrowAmount"` AvailableToBorrow string `json:"availableToBorrow"` AvailableToWithdraw string `json:"availableToWithdraw"` AccruedInterest string `json:"accruedInterest"` TotalOrderIM string `json:"totalOrderIM"` TotalPositionIM string `json:"totalPositionIM"` TotalPositionMM string `json:"totalPositionMM"` UnrealisedPnl string `json:"unrealisedPnl"` CumRealisedPnl string `json:"cumRealisedPnl"` Bonus string `json:"bonus"` CollateralSwitch bool `json:"collateralSwitch"` MarginCollateral bool `json:"marginCollateral"` }
type FeeRateItem ¶
type FeeRatesInfo ¶
type FeeRatesInfo struct { Category string `json:"category"` List []FeeRateItem `json:"list"` }
交易手续费相关
type Instrument ¶
type Instrument struct { Symbol string `json:"symbol"` ContractType string `json:"contractType"` OptionType string `json:"optionType"` Innovation string `json:"innovation"` Status SymbolStatus `json:"status"` BaseCoin string `json:"baseCoin"` QuoteCoin string `json:"quoteCoin"` LaunchTime string `json:"launchTime"` DeliveryTime string `json:"deliveryTime"` DeliveryFeeRate string `json:"deliveryFeeRate"` PriceScale string `json:"priceScale"` MarginTrading string `json:"marginTrading"` LeverageFilter LeverageFilter `json:"leverageFilter"` PriceFilter PriceFilter `json:"priceFilter"` LotSizeFilter LotSizeFilter `json:"lotSizeFilter"` UnifiedMarginTrade bool `json:"unifiedMarginTrade"` FundingInterval int `json:"fundingInterval"` SettleCoin string `json:"settleCoin"` CopyTrading string `json:"copyTrading"` }
type InstrumentInfoResponse ¶
type InstrumentInfoResponse struct { Category Category `json:"category"` NextPageCursor string `json:"nextPageCursor"` List []Instrument `json:"list"` }
交易对信息相关 struct
type LeverageFilter ¶
type LotSizeFilter ¶
type LotSizeFilter struct { MaxOrderQty string `json:"maxOrderQty"` MinOrderQty string `json:"minOrderQty"` QtyStep string `json:"qtyStep"` PostOnlyMaxOrderQty string `json:"postOnlyMaxOrderQty"` BasePrecision string `json:"basePrecision"` QuotePrecision string `json:"quotePrecision"` MaxOrderAmt string `json:"maxOrderAmt"` MinOrderAmt string `jsoN:"minOrderAmt"` }
type MarketKlineResponse ¶
type MarketKlineResponse struct { Category Category `json:"category"` Symbol string `json:"symbol"` List [][]string `json:"list"` }
Kline 相关
type MarketTickers ¶
type MarketTickers struct { Category string `json:"category"` List []*TickerInfo `json:"list"` }
ticker相关
type OrderBookInfo ¶
type OrderBookInfo struct { Symbol string `json:"s"` Bids [][]string `json:"b"` Asks [][]string `json:"a"` Timestamp int64 `json:"ts"` UpdateID int64 `json:"u"` }
深度相关
type OrderInfo ¶
type OrderInfo struct { OrderId string `json:"orderId"` OrderLinkId string `json:"orderLinkId"` BlockTradeId string `json:"blockTradeId"` Symbol string `json:"symbol"` Price string `json:"price"` Qty string `json:"qty"` Side string `json:"side"` IsLeverage string `json:"isLeverage"` PositionIdx int `json:"positionIdx"` OrderStatus OrderStatus `json:"orderStatus"` CancelType string `json:"cancelType"` RejectReason string `json:"rejectReason"` AvgPrice string `json:"avgPrice"` LeavesQty string `json:"leavesQty"` LeavesValue string `json:"leavesValue"` CumExecQty string `json:"cumExecQty"` CumExecValue string `json:"cumExecValue"` CumExecFee string `json:"cumExecFee"` TimeInForce string `json:"timeInForce"` OrderType string `json:"orderType"` StopOrderType string `json:"stopOrderType"` OrderIv string `json:"orderIv"` TriggerPrice string `json:"triggerPrice"` TakeProfit string `json:"takeProfit"` StopLoss string `json:"stopLoss"` TpslMode string `json:"tpslMode"` OcoTriggerType string `json:"ocoTriggerType"` TpLimitPrice string `json:"tpLimitPrice"` SlLimitPrice string `json:"slLimitPrice"` TpTriggerBy string `json:"tpTriggerBy"` SlTriggerBy string `json:"slTriggerBy"` TriggerDirection int `json:"triggerDirection"` TriggerBy string `json:"triggerBy"` LastPriceOnCreated string `json:"lastPriceOnCreated"` ReduceOnly bool `json:"reduceOnly"` CloseOnTrigger bool `json:"closeOnTrigger"` PlaceType string `json:"placeType"` SmpType string `json:"smpType"` SmpGroup int `json:"smpGroup"` SmpOrderId string `json:"smpOrderId"` CreatedTime string `json:"createdTime"` UpdatedTime string `json:"updatedTime"` }
订单相关
type OrderInfoResponse ¶
type OrderStatus ¶
type OrderStatus string
const ( OrderStatusCreated OrderStatus = "Created" // order has been accepted by the system but not yet put through the matching engine OrderStatusNew OrderStatus = "New" // order has been placed successfully OrderStatusRejected OrderStatus = "Rejected" OrderStatusPartiallyFilled OrderStatus = "PartiallyFilled" OrderStatusPartiallyFilledCanceled OrderStatus = "PartiallyFilledCanceled" //Only spot has this order status OrderStatusFilled OrderStatus = "Filled" OrderStatusCancelled OrderStatus = "Cancelled" // In derivatives, orders with this status may have an executed qty OrderStatusUntriggered OrderStatus = "Untriggered" OrderStatusTriggered OrderStatus = "Triggered" OrderStatusDeactivated OrderStatus = "Deactivated" // UTA: Spot tp/sl order, conditional order, OCO order are cancelled before they are triggered )
type PriceFilter ¶
type PublicRecentTradeHistory ¶
type PublicRecentTradeHistory struct { Category string `json:"category"` List []TradeInfo `json:"list"` }
交易trade相关
type ServerResponse ¶
type ServerResponse struct { RetCode int `json:"retCode"` RetMsg string `json:"retMsg"` Result json.RawMessage `json:"result"` RetExtInfo struct{} `json:"retExtInfo"` Time int64 `json:"time"` }
api server response
type SpotWs ¶
type SpotWs struct {
// contains filtered or unexported fields
}
func (*SpotWs) BestTickerCallback ¶
func (s *SpotWs) BestTickerCallback(f func(ticker *gocoinex.BestTicker, exchange string))
func (*SpotWs) DepthCallback ¶
func (*SpotWs) HeartbeatData ¶
func (*SpotWs) SubscribeBestTicker ¶
func (s *SpotWs) SubscribeBestTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeDepth ¶
func (s *SpotWs) SubscribeDepth(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeTicker ¶
func (s *SpotWs) SubscribeTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeTrade ¶
func (s *SpotWs) SubscribeTrade(pair gocoinex.CurrencyPair) error
func (*SpotWs) SubscribeUserBalance ¶
func (*SpotWs) SubscribeUserOrder ¶
func (*SpotWs) TickerCallback ¶
func (*SpotWs) TradeCallback ¶
func (*SpotWs) UnSubscribeBestTicker ¶
func (s *SpotWs) UnSubscribeBestTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeDepth ¶
func (s *SpotWs) UnSubscribeDepth(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeTicker ¶
func (s *SpotWs) UnSubscribeTicker(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeTrade ¶
func (s *SpotWs) UnSubscribeTrade(pair gocoinex.CurrencyPair) error
func (*SpotWs) UnSubscribeUserBalance ¶
func (*SpotWs) UnSubscribeUserOrder ¶
func (*SpotWs) UserBalanceCallback ¶
func (s *SpotWs) UserBalanceCallback(f func(trade *gocoinex.SubAccount, exchange string))
type SymbolStatus ¶
type SymbolStatus string
const ( SymbolStatusPreLaunch SymbolStatus = "PreLaunch" SymbolStatusTrading SymbolStatus = "Trading" SymbolStatusSettling SymbolStatus = "Settling" SymbolStatusDelivering SymbolStatus = "Delivering" SymbolStatusClosed SymbolStatus = "Closed" )
type TickerInfo ¶
type TickerInfo struct { Symbol string `json:"symbol"` LastPrice string `json:"lastPrice"` IndexPrice string `json:"indexPrice"` MarkPrice string `json:"markPrice"` PrevPrice24h string `json:"prevPrice24h"` Price24hPcnt string `json:"price24hPcnt"` HighPrice24h string `json:"highPrice24h"` LowPrice24h string `json:"lowPrice24h"` PrevPrice1h string `json:"prevPrice1h"` OpenInterest string `json:"openInterest"` OpenInterestValue string `json:"openInterestValue"` Turnover24h string `json:"turnover24h"` Volume24h string `json:"volume24h"` FundingRate string `json:"fundingRate"` NextFundingTime string `json:"nextFundingTime"` PredictedDeliveryPrice string `json:"predictedDeliveryPrice"` BasisRate string `json:"basisRate"` Basis string `json:"basis"` DeliveryFeeRate string `json:"deliveryFeeRate"` DeliveryTime string `json:"deliveryTime"` Ask1Size string `json:"ask1Size"` Bid1Price string `json:"bid1Price"` Ask1Price string `json:"ask1Price"` Bid1Size string `json:"bid1Size"` Ask1Iv string `json:"ask1Iv"` Bid1Iv string `json:"bid1Iv"` MarkIv string `json:"markIv"` UnderlyingPrice string `json:"underlyingPrice"` TotalVolume string `json:"totalVolume"` TotalTurnover string `json:"totalTurnover"` Change24h string `json:"change24h"` UsdIndexPrice string `json:"usdIndexPrice"` }
type TimeInForce ¶
type TimeInForce string
const ( TimeInForceGTC TimeInForce = "GTC" //GoodTillCancel TimeInForceIOC TimeInForce = "IOC" //ImmediateOrCancel TimeInForceFOK TimeInForce = "FOK" //FillOrKill TimeInForcePostOnly TimeInForce = "PostOnly" )
type WalletAccountInfo ¶
type WalletAccountInfo struct { AccountType string `json:"accountType"` AccountLTV string `json:"accountLTV"` AccountIMRate string `json:"accountIMRate"` AccountMMRate string `json:"accountMMRate"` TotalEquity string `json:"totalEquity"` TotalWalletBalance string `json:"totalWalletBalance"` TotalMarginBalance string `json:"totalMarginBalance"` TotalAvailableBalance string `json:"totalAvailableBalance"` TotalPerpUPL string `json:"totalPerpUPL"` TotalInitialMargin string `json:"totalInitialMargin"` TotalMaintenanceMargin string `json:"totalMaintenanceMargin"` Coins []CoinInfo `json:"coin"` }
type WalletBalanceInfo ¶
type WalletBalanceInfo struct {
List []WalletAccountInfo `json:"list"`
}
钱包帐户相关
Click to show internal directories.
Click to hide internal directories.