bybit_connector

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 19 Imported by: 0

README

bybit-go-api

GO 1.21.0 Contributor Victor

Table of Contents

About

The Official Go Lang API connector for Bybit's HTTP and WebSocket APIs.

Dive into a plethora of functionalities:

  • Market Data Retrieval
  • Trade Execution
  • Position Management
  • Account and Asset Info Retrieval
  • User and Upgrade Management
  • Public Websocket Streaming
  • Private Websocket Streaming
  • Lending Institution and Client
  • Broker Earning Data

bybit-go-api provides an official, robust, and high-performance go connector to Bybit's trading APIs.

Initially conceptualized by go developer Victor, this module is now maintained by Bybit's in-house go experts.

Your contributions are most welcome!

Development

bybit-go-api is under active development with the latest features and updates from Bybit's API implemented promptly. The module utilizes minimal external libraries to provide a lightweight and efficient experience. If you've made enhancements or fixed bugs, please submit a pull request.

Installation

Ensure you have go 1.21.0 or higher. And use dependencies as below

require (
	github.com/google/uuid v1.4.0
	github.com/gorilla/websocket v1.5.1
	github.com/stretchr/testify v1.8.4
)

To import my package you need just to put the link to your go mode file github.com/buurzx/bybit.go.api

Usage

Note: Replace placeholders (like YOUR_API_KEY, links, or other details) with the actual information. You can also customize this template to better fit the actual state and details of your Java API.

Rest API
  • Place an order by Map
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "linear", "symbol": "BTCUSDT", "side": "Buy", "positionIdx": 0, "orderType": "Limit", "qty": "0.001", "price": "10000", "timeInForce": "GTC"}
orderResult, err := client.NewTradeService(params).PlaceOrder(context.Background())
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(bybit.PrettyPrint(orderResult))
  • Place an order by Trade Class
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
orderResult, err := client.NewPlaceOrderService("linear", "XRPUSDT", "Buy", "Market", "10").Do(context.Background())
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(bybit.PrettyPrint(orderResult))
  • Place batch order
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "option",
	"request": []map[string]interface{}{
		{
			"category":    "option",
			"symbol":      "BTC-10FEB23-24000-C",
			"orderType":   "Limit",
			"side":        "Buy",
			"qty":         "0.1",
			"price":       "5",
			"orderIv":     "0.1",
			"timeInForce": "GTC",
			"orderLinkId": "9b381bb1-401",
			"mmp":         false,
			"reduceOnly":  false,
		},
		{
			"category":    "option",
			"symbol":      "BTC-10FEB23-24000-C",
			"orderType":   "Limit",
			"side":        "Buy",
			"qty":         "0.1",
			"price":       "5",
			"orderIv":     "0.1",
			"timeInForce": "GTC",
			"orderLinkId": "82ee86dd-001",
			"mmp":         false,
			"reduceOnly":  false,
		},
	},
}
orderResult, err := client.NewTradeService(params).PlaceBatchOrder(context.Background())
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(bybit.PrettyPrint(orderResult))
  • Get Position
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "linear", "settleCoin": "USDT", "limit": 10}
orderResult, err := client.NewPositionService(params).GetPositionList(context.Background())
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(bybit.PrettyPrint(orderResult))
  • Get Transaction Log
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"accountType": "UNIFIED", "category": "linear"}
accountResult, err := client.NewAccountService(params).GetTransactionLog(context.Background())
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(bybit.PrettyPrint(accountResult))
Websocket public channel
  • Order book Subscribe
ws := bybit.NewBybitPublicWebSocket("wss://stream.bybit.com/v5/public/spot", func(message string) error {
fmt.Println("Received:", message)
return nil
})
_ = ws.Connect([]string{"orderbook.1.BTCUSDT"})
select {}
Websocket private channel
ws := bybit.NewBybitPrivateWebSocket("wss://stream-testnet.bybit.com/v5/private", "YOUR_API_KEY", "YOUR_API_SECRET", func(message string) error {
	fmt.Println("Received:", message)
	return nil
})
_ = ws.Connect([]string{"order"})
select {}

Contact

For support, join our Bybit API community on Telegram.

Contributors

List of other contributors


Victor

💻 📖

Documentation

Index

Constants

View Source
const (
	Name    = "bybit.api.go"
	Version = "1.0.0"
	// 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 FormatTimestamp

func FormatTimestamp(t time.Time) int64

FormatTimestamp formats a time into Unix timestamp in milliseconds, as requested by Binance.

func GetCurrentTime

func GetCurrentTime() int64

func Ping

func Ping(b *WebSocket)

func PrettyPrint

func PrettyPrint(i interface{}) string

Types

type AccountClient

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

func (*AccountClient) GetAccountInfo

func (s *AccountClient) GetAccountInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetAccountWallet

func (s *AccountClient) GetAccountWallet(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetBorrowHistory

func (s *AccountClient) GetBorrowHistory(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetCoinGreeks

func (s *AccountClient) GetCoinGreeks(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetCollateralInfo

func (s *AccountClient) GetCollateralInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetFeeRates

func (s *AccountClient) GetFeeRates(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetMMPState

func (s *AccountClient) GetMMPState(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) GetTransactionLog

func (s *AccountClient) GetTransactionLog(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) ResetMarketMakerProtection

func (s *AccountClient) ResetMarketMakerProtection(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) SetCollateralCoin

func (s *AccountClient) SetCollateralCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) SetMarginMode

func (s *AccountClient) SetMarginMode(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) SetMarketMakerProtection

func (s *AccountClient) SetMarketMakerProtection(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AccountClient) UpgradeToUTA

func (s *AccountClient) UpgradeToUTA(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type AssetClient

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

func (*AssetClient) CancelWithdrawAsset

func (s *AssetClient) CancelWithdrawAsset(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) CreateInternalTransfer

func (s *AssetClient) CreateInternalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) CreateUniversalTransfer

func (s *AssetClient) CreateUniversalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetAllCoinsBalance

func (s *AssetClient) GetAllCoinsBalance(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetAllowedDepositCoin

func (s *AssetClient) GetAllowedDepositCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetAssetInfo

func (s *AssetClient) GetAssetInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetAssetOrderRecord

func (s *AssetClient) GetAssetOrderRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetCoinInfo

func (s *AssetClient) GetCoinInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetDeliveryRecord

func (s *AssetClient) GetDeliveryRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetDepositRecords

func (s *AssetClient) GetDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetInternalDepositRecords

func (s *AssetClient) GetInternalDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetInternalTransfer

func (s *AssetClient) GetInternalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetMasterDepositAddress

func (s *AssetClient) GetMasterDepositAddress(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetSingleCoinsBalance

func (s *AssetClient) GetSingleCoinsBalance(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetSubDepositAddress

func (s *AssetClient) GetSubDepositAddress(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetSubDepositRecords

func (s *AssetClient) GetSubDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetSubUids

func (s *AssetClient) GetSubUids(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetTransferableCoin

func (s *AssetClient) GetTransferableCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetUniversalTransfer

func (s *AssetClient) GetUniversalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetUsdcSettlement

func (s *AssetClient) GetUsdcSettlement(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetWithdrawalAmount

func (s *AssetClient) GetWithdrawalAmount(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) GetWithdrawalRecords

func (s *AssetClient) GetWithdrawalRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) SetDepositAccount

func (s *AssetClient) SetDepositAccount(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*AssetClient) WithdrawAsset

func (s *AssetClient) WithdrawAsset(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type BrokerServiceClient

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

func (*BrokerServiceClient) GetBrokerEarning

func (s *BrokerServiceClient) GetBrokerEarning(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type Client

type Client struct {
	APIKey     string
	APISecret  string
	BaseURL    string
	HTTPClient *http.Client
	Debug      bool
	Logger     *log.Logger
	// contains filtered or unexported fields
}

Client define API client

func NewBybitHttpClient

func NewBybitHttpClient(apiKey string, APISecret string, options ...ClientOption) *Client

NewBybitHttpClient NewClient Create client function for initialising new Bybit client

func (*Client) NewAccountService

func (c *Client) NewAccountService(params map[string]interface{}) *AccountClient

func (*Client) NewAccountServiceNoParams

func (c *Client) NewAccountServiceNoParams() *AccountClient

func (*Client) NewAssetService

func (c *Client) NewAssetService(params map[string]interface{}) *AssetClient

func (*Client) NewBrokerService

func (c *Client) NewBrokerService(params map[string]interface{}) *BrokerServiceClient

func (*Client) NewLendingService

func (c *Client) NewLendingService(params map[string]interface{}) *LendingServiceClient

func (*Client) NewLendingServiceNoParams

func (c *Client) NewLendingServiceNoParams() *LendingServiceClient

func (*Client) NewMarketInfoService

func (c *Client) NewMarketInfoService(params map[string]interface{}) *MarketClient

func (*Client) NewMarketInfoServiceNoParams

func (c *Client) NewMarketInfoServiceNoParams() *MarketClient

func (*Client) NewMarketKLinesService

func (c *Client) NewMarketKLinesService(klineType string, params map[string]interface{}) *MarketClient

func (*Client) NewMarketKlineService

func (c *Client) NewMarketKlineService(klineType, category, symbol, interval string) *Klines

NewMarketKlineService Market Endpoints

func (*Client) NewPlaceOrderService

func (c *Client) NewPlaceOrderService(category, symbol, side, orderType, qty string) *Order

NewPlaceOrderService Trade Endpoints

func (*Client) NewPositionService

func (c *Client) NewPositionService(params map[string]interface{}) *PositionClient

func (*Client) NewPreUpgradeService

func (c *Client) NewPreUpgradeService(params map[string]interface{}) *PreUpgradeClient

func (*Client) NewSpotLeverageService

func (c *Client) NewSpotLeverageService(params map[string]interface{}) *SpotLeverageClient

func (*Client) NewSpotMarginDataService

func (c *Client) NewSpotMarginDataService(params map[string]interface{}, isUta bool) *SpotMarginClient

func (*Client) NewTradeService

func (c *Client) NewTradeService(params map[string]interface{}) *TradeClient

func (*Client) NewUserService

func (c *Client) NewUserService(params map[string]interface{}) *UserServiceClient

type ClientOption

type ClientOption func(*Client)

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL is a client option to set the base URL of the Bybit HTTP client.

func WithDebug

func WithDebug(debug bool) ClientOption

type Klines

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

Klines Market Kline (GET /v5/market/kline)

func (*Klines) Do

func (s *Klines) Do(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*Klines) End

func (s *Klines) End(endTime uint64) *Klines

End set endTime

func (*Klines) Limit

func (s *Klines) Limit(limit int) *Klines

Limit set limit

func (*Klines) Start

func (s *Klines) Start(startTime uint64) *Klines

Start set startTime

type LendingServiceClient

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

func (*LendingServiceClient) C2cCancelRedeemFunds

func (s *LendingServiceClient) C2cCancelRedeemFunds(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) C2cDepositFunds

func (s *LendingServiceClient) C2cDepositFunds(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) C2cRedeemFunds

func (s *LendingServiceClient) C2cRedeemFunds(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetC2cLendingAccountInfo

func (s *LendingServiceClient) GetC2cLendingAccountInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetC2cLendingCoinInfo

func (s *LendingServiceClient) GetC2cLendingCoinInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetC2cLendingOrders

func (s *LendingServiceClient) GetC2cLendingOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetInsLoanInfo

func (s *LendingServiceClient) GetInsLoanInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetInsLoanOrders

func (s *LendingServiceClient) GetInsLoanOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetInsLoanToValue

func (s *LendingServiceClient) GetInsLoanToValue(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetInsMarginCoinInfo

func (s *LendingServiceClient) GetInsMarginCoinInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*LendingServiceClient) GetInsRepayOrders

func (s *LendingServiceClient) GetInsRepayOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type MarketClient

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

func (*MarketClient) GetDeliveryPrice

func (s *MarketClient) GetDeliveryPrice(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetFundingRates

func (s *MarketClient) GetFundingRates(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetHistoricalVolatility

func (s *MarketClient) GetHistoricalVolatility(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetInstrumentInfo

func (s *MarketClient) GetInstrumentInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetInsuranceInfo

func (s *MarketClient) GetInsuranceInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetMarketKline

func (s *MarketClient) GetMarketKline(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetMarketLSRatio

func (s *MarketClient) GetMarketLSRatio(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetMarketTickers

func (s *MarketClient) GetMarketTickers(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetOpenInterests

func (s *MarketClient) GetOpenInterests(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetOrderBookInfo

func (s *MarketClient) GetOrderBookInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetPublicRecentTrades

func (s *MarketClient) GetPublicRecentTrades(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetRiskLimit

func (s *MarketClient) GetRiskLimit(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*MarketClient) GetServerTime

func (s *MarketClient) GetServerTime(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type MessageHandler

type MessageHandler func(message string) error

type Order

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

func (*Order) CloseOnTrigger

func (order *Order) CloseOnTrigger(close bool) *Order

func (*Order) Do

func (order *Order) Do(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*Order) IsLeverage

func (order *Order) IsLeverage(isLeverage int) *Order

func (*Order) Mmp

func (order *Order) Mmp(mmp bool) *Order

func (*Order) OrderFilter

func (order *Order) OrderFilter(filter string) *Order

func (*Order) OrderIv

func (order *Order) OrderIv(iv string) *Order

func (*Order) OrderLinkId

func (order *Order) OrderLinkId(orderLinkId string) *Order

func (*Order) PositionIdx

func (order *Order) PositionIdx(idx int) *Order

func (*Order) Price

func (order *Order) Price(price string) *Order

func (*Order) ReduceOnly

func (order *Order) ReduceOnly(reduce bool) *Order

func (*Order) SlLimitPrice

func (order *Order) SlLimitPrice(price string) *Order

func (*Order) SlOrderType

func (order *Order) SlOrderType(orderType string) *Order

func (*Order) SlTriggerBy

func (order *Order) SlTriggerBy(triggerBy string) *Order

func (*Order) SmpType

func (order *Order) SmpType(smp string) *Order

func (*Order) StopLoss

func (order *Order) StopLoss(loss string) *Order

func (*Order) TakeProfit

func (order *Order) TakeProfit(profit string) *Order

func (*Order) TimeInForce

func (order *Order) TimeInForce(tif string) *Order

func (*Order) TpLimitPrice

func (order *Order) TpLimitPrice(price string) *Order

func (*Order) TpOrderType

func (order *Order) TpOrderType(orderType string) *Order

func (*Order) TpTriggerBy

func (order *Order) TpTriggerBy(triggerBy string) *Order

func (*Order) TpslMode

func (order *Order) TpslMode(mode string) *Order

func (*Order) TriggerBy

func (order *Order) TriggerBy(triggerBy string) *Order

func (*Order) TriggerDirection

func (order *Order) TriggerDirection(direction int) *Order

func (*Order) TriggerPrice

func (order *Order) TriggerPrice(triggerPrice string) *Order

type PositionClient

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

func (*PositionClient) ConfirmPositionRiskLimit

func (s *PositionClient) ConfirmPositionRiskLimit(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) GetClosePnl

func (s *PositionClient) GetClosePnl(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) GetExecutionList

func (s *PositionClient) GetExecutionList(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) GetPositionList

func (s *PositionClient) GetPositionList(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SetPositionAutoMargin

func (s *PositionClient) SetPositionAutoMargin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SetPositionLeverage

func (s *PositionClient) SetPositionLeverage(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SetPositionRiskLimit

func (s *PositionClient) SetPositionRiskLimit(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SetPositionTpslMode

func (s *PositionClient) SetPositionTpslMode(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SetPositionTradingStop

func (s *PositionClient) SetPositionTradingStop(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SwitchPositionMargin

func (s *PositionClient) SwitchPositionMargin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) SwitchPositionMode

func (s *PositionClient) SwitchPositionMode(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PositionClient) UpdatePositionMargin

func (s *PositionClient) UpdatePositionMargin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type PreUpgradeClient

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

func (*PreUpgradeClient) GetPreUpgradeClosedPnl

func (s *PreUpgradeClient) GetPreUpgradeClosedPnl(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PreUpgradeClient) GetPreUpgradeExecutionList

func (s *PreUpgradeClient) GetPreUpgradeExecutionList(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PreUpgradeClient) GetPreUpgradeOptionDeliveryRecord

func (s *PreUpgradeClient) GetPreUpgradeOptionDeliveryRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PreUpgradeClient) GetPreUpgradeOrderHistory

func (s *PreUpgradeClient) GetPreUpgradeOrderHistory(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PreUpgradeClient) GetPreUpgradeTransactionLog

func (s *PreUpgradeClient) GetPreUpgradeTransactionLog(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*PreUpgradeClient) GetPreUpgradeUsdcSettlement

func (s *PreUpgradeClient) GetPreUpgradeUsdcSettlement(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type RequestOption

type RequestOption func(*request)

RequestOption define option type for request

func WithRecvWindow

func WithRecvWindow(recvWindow string) RequestOption

WithRecvWindow Append `WithRecvWindow(insert_recvWindow)` to request to modify the default recvWindow value

type ServerResponse

type ServerResponse struct {
	RetCode    int         `json:"retCode"`
	RetMsg     string      `json:"retMsg"`
	Result     interface{} `json:"result"`
	RetExtInfo struct{}    `json:"retExtInfo"`
	Time       int64       `json:"time"`
}

type SpotLeverageClient

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

func (*SpotLeverageClient) GetLeverageTokenInfo

func (s *SpotLeverageClient) GetLeverageTokenInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotLeverageClient) GetLeverageTokenMarket

func (s *SpotLeverageClient) GetLeverageTokenMarket(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotLeverageClient) GetLeverageTokenOrders

func (s *SpotLeverageClient) GetLeverageTokenOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotLeverageClient) PurchaseLeverageToken

func (s *SpotLeverageClient) PurchaseLeverageToken(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotLeverageClient) RedeemLeverageToken

func (s *SpotLeverageClient) RedeemLeverageToken(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type SpotMarginClient

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

func (*SpotMarginClient) BorrowSpotMarginLoan

func (s *SpotMarginClient) BorrowSpotMarginLoan(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginBorrowCoin

func (s *SpotMarginClient) GetSpotMarginBorrowCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginBorrowOrders

func (s *SpotMarginClient) GetSpotMarginBorrowOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginCoin

func (s *SpotMarginClient) GetSpotMarginCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginData

func (s *SpotMarginClient) GetSpotMarginData(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginInterests

func (s *SpotMarginClient) GetSpotMarginInterests(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginLoanAccountInfo

func (s *SpotMarginClient) GetSpotMarginLoanAccountInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginRepaymentOrders

func (s *SpotMarginClient) GetSpotMarginRepaymentOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) GetSpotMarginState

func (s *SpotMarginClient) GetSpotMarginState(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) RepaySpotMarginLoan

func (s *SpotMarginClient) RepaySpotMarginLoan(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) SetSpotMarginLeverage

func (s *SpotMarginClient) SetSpotMarginLeverage(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*SpotMarginClient) ToggleSpotMarginTrade

func (s *SpotMarginClient) ToggleSpotMarginTrade(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type TradeClient

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

func (*TradeClient) AmendBatchOrder

func (s *TradeClient) AmendBatchOrder(ctx context.Context, opts ...RequestOption) (res *models.BatchOrderServerResponse, err error)

func (*TradeClient) AmendOrder

func (s *TradeClient) AmendOrder(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) CancelAllOrders

func (s *TradeClient) CancelAllOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) CancelBatchOrder

func (s *TradeClient) CancelBatchOrder(ctx context.Context, opts ...RequestOption) (res *models.BatchOrderServerResponse, err error)

func (*TradeClient) CancelOrder

func (s *TradeClient) CancelOrder(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) GetOpenOrders

func (s *TradeClient) GetOpenOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) GetOrderHistory

func (s *TradeClient) GetOrderHistory(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) GetSpotBorrowQuota

func (s *TradeClient) GetSpotBorrowQuota(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) PlaceBatchOrder

func (s *TradeClient) PlaceBatchOrder(ctx context.Context, opts ...RequestOption) (res *models.BatchOrderServerResponse, err error)

func (*TradeClient) PlaceOrder

func (s *TradeClient) PlaceOrder(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*TradeClient) SetDisconnectCancelAll

func (s *TradeClient) SetDisconnectCancelAll(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type UserServiceClient

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

func (*UserServiceClient) CreateSubApiKey

func (s *UserServiceClient) CreateSubApiKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) CreateSubMember

func (s *UserServiceClient) CreateSubMember(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) DeleteMasterAPIKey

func (s *UserServiceClient) DeleteMasterAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) DeleteSubAPIKey

func (s *UserServiceClient) DeleteSubAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) DeleteSubUID

func (s *UserServiceClient) DeleteSubUID(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) FreezeSubUID

func (s *UserServiceClient) FreezeSubUID(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) GetAPIKeyInfo

func (s *UserServiceClient) GetAPIKeyInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) GetAffiliateUserInfo

func (s *UserServiceClient) GetAffiliateUserInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) GetSubUidList

func (s *UserServiceClient) GetSubUidList(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) GetUidWalletType

func (s *UserServiceClient) GetUidWalletType(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) ModifyMasterAPIKey

func (s *UserServiceClient) ModifyMasterAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

func (*UserServiceClient) ModifySubAPIKey

func (s *UserServiceClient) ModifySubAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error)

type WebSocket

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

func NewBybitPrivateWebSocket

func NewBybitPrivateWebSocket(url, apiKey, apiSecret string, handler MessageHandler) (*WebSocket, chan struct{})

func NewBybitPublicWebSocket

func NewBybitPublicWebSocket(url string, handler MessageHandler) *WebSocket

func (*WebSocket) Connect

func (b *WebSocket) Connect(args []string) error

func (*WebSocket) Disconnect

func (b *WebSocket) Disconnect() error

func (*WebSocket) Send

func (b *WebSocket) Send(message string) error

func (*WebSocket) SendAsJson

func (b *WebSocket) SendAsJson(v interface{}) error

func (*WebSocket) SetMessageHandler

func (b *WebSocket) SetMessageHandler(handler MessageHandler)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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