package
0.0.0-20250311023717-5c21e974eed8
Repository: https://github.com/thrasher-corp/gocryptotrader.git
Documentation: pkg.go.dev

# README

GoCryptoTrader package Bybit

Build Status Software License GoDoc Coverage Status Go Report Card

This bybit package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on our GoCryptoTrader Kanban board.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Bybit Exchange

Current Features

  • REST Support
  • Websocket Support

How to enable

	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then

How to do REST public/private calls

  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var b exchange.IBotExchange

for i := range bot.Exchanges {
	if bot.Exchanges[i].GetName() == "Bybit" {
		b = bot.Exchanges[i]
	}
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := b.UpdateTicker(...)
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := b.UpdateOrderbook(...)
if err != nil {
	// Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := b.GetAccountInfo()
if err != nil {
	// Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := b.GetTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderBook()
if err != nil {
	// Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := b.GetUserInfo(...)
if err != nil {
	// Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := b.Trade(...)
if err != nil {
	// Handle error
}

How to do Websocket public/private calls

	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then

Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

# Functions

GetRateLimit returns the rate limit for the exchange.
StringToOrderStatus returns order status from string.

# Structs

AccountFee holds account fee information.
AccountInfo represents margin mode account information.
AccountLoanInfo covers: Margin trade (Normal Account).
AddOrReduceMargin represents a add or reduce margin response.
AddOrReduceMarginParam holds manually add or reduce margin for isolated margin position parameters.
AffiliateCustomerInfo represents user information.
AllowedDepositCoinInfo represents coin deposit information.
AmendOrderParams represents a parameter for amending order.
Authenticate stores authentication variables required.
AutoAddMarginParam represents parameters for auto add margin.
BatchAmendOrderParamItem represents a single order amend item in batch amend order.
BatchAmendOrderParams request parameter for batch amend order.
BatchOrderItemParam represents a batch order place parameter.
BatchOrderResponse represents a batch trade order item response.
BatchOrdersList represents a list trade orders.
BindOrUnbindUIDResponse holds uid information after binding/unbinding.
BorrowableCoinInfo represents borrowable coin information.
BorrowHistory represents interest records.
BorrowOrderDetail represents a borrow order detail info.
BorrowQuota represents.
BorrowResponse represents borrow response transaction id.
BrokerEarningItem represents contract-to-contract broker earning item.
Bybit is the overarching type across this package.
C2CLendingCoinInfo represent contract-to-contract lending coin information.
C2CLendingFundResponse represents contract-to-contract deposit funds item.
C2CLendingFundsParams represents deposit funds parameter.
CancelAllOrdersParam request parameters for cancel all orders.
CancelAllResponse represents a cancel all trade orders response.
CancelBatchOrder represents a batch cancel request parameters.
CancelBatchResponseItem represents a batch cancel response item.
CancelOrderParams represents a cancel order parameters.
ClosedProfitAndLossResponse represents list of closed profit and loss records.
CoinBalance represents coin balance for a specific asset type.
CoinBalances represents coin balances for a specific asset type.
CoinExchangeRecords represents a coin exchange records.
CoinGreeks represents current account greeks information.
CoinInfo represents coin info information.
CoinRepaymentResponse represents a coin repayment detail.
CollateralInfo represents collateral information of the current unified margin account.
CreateSubUserParams parameter to create a new sub user id.
DeliveryPrice represents the delivery price information.
DeliveryRecord represents delivery records of USDC futures and Options.
DepositAddresses represents deposit address information.
DepositRecords represents deposit records.
Error defines all error information for each request.
ErrorMessage represents an error message item.
Execution represents execution record.
ExecutionResponse represents users order execution response.
Fee holds fee information.
FeeRate represents maker and taker fee rate information for a symbol.
FundingRate represents a funding rate instance.
FundingRateHistory represents a funding rate history for a category.
GreeksResponse represents changes to your greeks data.
HistoricVolatility represents option historical volatility.
InstitutionalMarginCoinInfo represents margin coin info for institutional lending token and tokens convert information.
InstitutionalProductInfo represents institutional product info.
InstrumentInfo holds all instrument info across spot, linear, option types.
InstrumentInfoItem represents an instrument long short ratio information.
InstrumentsInfo represents a category, page indicator, and list of instrument information.
InsuranceHistory represents an insurance list.
InterestAndQuota represents interest and quota information.
InternalDepositRecords represents internal deposit records response instances.
KlineItem stores an individual kline data item.
KlineResponse represents a kline item list instance as an array of string.
LendArgument represents currency borrow and repay parameter.
LendingAccountInfo represents contract-to-contract lending account info item.
LeveragedTokenMarket represents leverage token market details.
LeverageToken represents a response instance when purchasing a leverage token.
LeverageTokenInfo represents leverage token information.
LoanOrderDetails retrieves institutional loan order detail item.
LTNav represents leveraged token nav stream.
LTVInfo represents institutional lending Loan-to-value(LTV).
MarginCoinInfo represents margin coin information.
MarkPriceKlineResponse represents a kline data item.
MMPRequestParam represents an MMP request parameter.
MMPStates represents an MMP states.
OpenInterest represents open interest of each symbol.
Orderbook stores the orderbook data.
OrderRepayInfo represents repaid information information.
OrderResponse holds newly placed order information.
PermissionsList represents list of sub api permissions.
PingMessage represents a ping message.
PlaceBatchOrderParam represents a parameter for placing batch orders.
PlaceOrderParams represents.
PositionInfo represents a position info item.
PositionInfoList represents a list of positions infos.
PreUpdateOptionDeliveryRecord represents delivery records of Option.
RedeemPurchaseRecord represents a purchase and redeem record instance.
RedeemToken represents leverage redeem token.
RepayResponse represents a repay id.
RestResponse represents a REST response instance.
RiskLimitHistory represents risk limit history of a category.
RiskLimitResponse represents a risk limit response.
ServerTime represents server time.
SetDCPParams represents the set disconnect cancel all parameters.
SetLeverageParams parameters to set the leverage.
SetMarginModeResponse represents a response for setting margin mode.
SetRiskLimitParam represents a risk limit set parameter.
SettlementSession represents a USDC settlement session.
SpotMarginMode represents data about whether spot margin trade is on / off.
StatusResponse represents account information.
SubAccountAPIKeys holds list of sub-account API Keys.
SubscriptionArgument represents a subscription arguments.
SubscriptionResponse represents a subscription response.
SubUID represents a sub-users ID.
SubUIDAPIKeyParam represents a sub-user ID API key creation parameter.
SubUIDAPIKeyUpdateParam represents a sub-user ID API key update parameter.
SubUIDAPIResponse represents sub UID API key response.
SubUserItem represents a sub user response instance.
SwitchPositionModeParams represents a position switch mode parameters.
SwitchTradeModeParams parameters to switch between cross margin and isolated margin trade mode.
TickerData represents a list of ticker detailed information.
TickerItem represents a ticker item detail.
TPSLModeParams parameters for settle Take Profit(TP) or Stop Loss(SL) mode.
TPSLModeResponse represents response for the take profit and stop loss mode change.
TradeOrder represents a trade order details.
TradeOrders represents category and list of trade orders of the category.
TradingHistory represents a trading history list.
TradingHistoryItem represents a trading history item instance.
TradingStopParams take profit, stop loss or trailing stop for the position.
TransactionLog represents a transaction log history.
TransactionLogItem represents a transaction log item information.
TransferableCoins represents list of transferable coins.
TransferParams represents parameters from internal coin transfer.
TransferResponse represents a transfer response.
UnifiedAccountUpgradeResponse represents a response parameter for update to unified account.
VIPMarginData represents VIP margin data.
WalletBalance represents wallet balance.
WalletType represents available wallet types for the master account or sub account.
WebsocketLiquidation represents liquidation stream push data.
WebsocketResponse represents push data response struct.
WebsocketWallet represents a wallet stream to see changes to your wallet in real-time.
WithdrawableAmount represents withdrawable amount information for each currency code.
WithdrawalParam represents asset withdrawal request parameter.
WithdrawalRecords represents a list of withdrawal records.
WsOrderbookDetail represents an orderbook detail information.

# Type aliases

AccountInfos represents account type and account information.
AccountType constants.
LTKlines represents a leverage token kline.
WebsocketPublicTrades represents.
WsExecutions represents execution stream to see your executions in real-time.
WsKlines represents a list of Kline data.
WsOrders represents private order.
WsPositions represents a position information.