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

# README

GoCryptoTrader package Binance

Build Status Software License GoDoc Coverage Status Go Report Card

This binance 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

Binance 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() == "Binance" {
		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

GetRateLimits returns the rate limit for the exchange.

# Constants

withdrawals status codes description.
withdrawals status codes description.
withdrawals status codes description.
withdrawals status codes description.
withdrawals status codes description.
withdrawals status codes description.
withdrawals status codes description.

# Variables

BinanceRequestParamsOrderLimit Limit order.
BinanceRequestParamsOrderLimitMarker LIMIT_MAKER.
BinanceRequestParamsOrderMarket Market order.
BinanceRequestParamsOrderStopLoss STOP_LOSS.
BinanceRequestParamsOrderStopLossLimit STOP_LOSS_LIMIT.
BinanceRequestParamsOrderTakeProfit TAKE_PROFIT.
BinanceRequestParamsOrderTakeProfitLimit TAKE_PROFIT_LIMIT.
BinanceRequestParamsTimeFOK FOK.
BinanceRequestParamsTimeGTC GTC.
BinanceRequestParamsTimeIOC IOC.
WithdrawalFees the large list of predefined withdrawal fees Prone to change.

# Structs

Account holds the account data.
ADLEstimateData stores data for ADL estimates.
AggregatedTrade holds aggregated trade information.
AggregatedTradeRequestParams holds request params.
AllLiquidationOrders gets all liquidation orders.
AutoCancelAllOrdersData gives data of auto cancelling all open orders.
AveragePrice holds current average symbol price.
Balance holds query order data.
BatchCancelOrderData stores batch cancel order data.
BestPrice holds best price data.
Binance is the overarching type across the Binance package.
CancelOrderResponse is the return structured response from the exchange.
CandleStick holds kline data.
CExchangeInfo stores exchange info for cfutures.
CoinInfo stores information about all supported coins.
CollateralAssetData stores collateral asset data.
CollateralAssetItem stores collateral asset item data.
CollateralRepayRate stores collateral repayment rate data.
CompressedTradesData stores futures trades data in a compressed format.
CrossMarginInterestData stores cross margin data for borrowing.
CryptoLoanAdjustLTV stores crypto loan LTV adjustment data.
CryptoLoanBorrow stores crypto loan borrow data.
CryptoLoanLTVAdjustmentHistory stores crypto loan LTV adjustment history data.
CryptoLoanLTVAdjustmentItem stores crypto loan LTV adjustment item data.
CryptoLoanOngoingOrder stores crypto loan ongoing order data.
CryptoLoanOngoingOrderItem stores crypto loan ongoing order item data.
CryptoLoanRepay stores crypto loan repayment data.
CryptoLoanRepayHistory stores crypto loan repayment history data.
CryptoLoanRepayHistoryItem stores crypto loan repayment history item data.
CryptoLoansIncomeHistory stores crypto loan income history data.
CustomiseMarginCall stores customise margin call data.
CustomiseMarginCallItem stores customise margin call item data.
DepositAddress stores the deposit address info.
DepositHistory stores deposit history info.
ExchangeInfo holds the full exchange information type.
FlexibleCollateralAssetsData stores flexible collateral asset data.
FlexibleCollateralAssetsDataItem stores a flexible collateral asset data item.
FlexibleLoanAdjustLTV stores a flexible loan LTV adjustment.
FlexibleLoanAssetsData stores flexible loan asset data.
FlexibleLoanAssetsDataItem stores a flexible loan asset data item.
FlexibleLoanBorrow stores a flexible loan borrow.
FlexibleLoanBorrowHistory stores flexible loan borrow history.
FlexibleLoanBorrowHistoryItem stores a flexible loan borrow history item.
FlexibleLoanLTVAdjustmentHistory stores flexible loan LTV adjustment history.
FlexibleLoanLTVAdjustmentHistoryItem stores a flexible loan LTV adjustment history item.
FlexibleLoanOngoingOrder stores flexible loan ongoing orders.
FlexibleLoanOngoingOrderItem stores a flexible loan ongoing order item.
FlexibleLoanRepay stores a flexible loan repayment.
FlexibleLoanRepayHistory stores flexible loan repayment history.
FlexibleLoanRepayHistoryItem stores a flexible loan repayment history item.
ForcedOrdersData stores forced orders data.
FundingRateData stores funding rates data.
FundingRateHistory stores funding rate history.
FundingRateInfoResponse stores funding rate info.
FuturesAccountAsset holds account asset information.
FuturesAccountBalanceData stores account balance data for futures.
FuturesAccountInformation stores account information for futures account.
FuturesAccountInformationPosition holds account position data.
FuturesAccountTradeList stores account trade list data.
FuturesBasisData gets futures basis data.
FuturesCandleStick holds kline data.
FuturesIncomeHistoryData stores futures income history data.
FuturesLeverageData stores leverage data for futures.
FuturesMarginUpdatedResponse stores margin update response data.
FuturesNewOrderRequest stores all the data needed to submit a delivery/coin-margined-futures order.
FuturesOrderData stores order data for futures.
FuturesOrderGetData stores futures order data for get requests.
FuturesOrderPlaceData stores futures order data.
FuturesPositionInformation stores futures position info.
FuturesPublicTradesData stores recent public trades for futures.
GenericAuthResponse is a general data response for a post auth request.
GetPositionMarginChangeHistoryData gets margin change history for positions.
GlobalLongShortRatio stores ratio data of all longs vs shorts.
HistoricalTrade holds recent trade data.
IndexMarkPrice stores data for index and mark prices.
InterestHistoryData gets interest history data.
KlinesRequestParams represents Klines request data.
KlineStream holds the kline stream data.
KlineStreamData defines kline streaming data.
LevelDetail stores level detail data.
LoanableAssetItem stores loanable asset item data.
LoanableAssetsData stores loanable assets data.
LoanBorrowHistory stores loan borrow history data.
LoanBorrowHistoryItem stores loan borrow history item data.
MarginAccount holds the margin account data.
MarginAccountAsset holds each individual margin account asset.
MarginInfoData stores margin info data.
MarkPriceData stores mark price data for futures.
ModifyIsolatedMarginData stores margin modification data.
NewOrderRequest request type.
NewOrderResponse is the return structured response from the exchange.
NotionalBracketData stores notional bracket data.
OpenInterestData stores open interest data.
OpenInterestStats stores stats for open interest data.
OrderBook actual structured data that can be used for orderbook.
OrderbookData stores ob data for umargined and cmargined futures.
OrderBookData is resp data from orderbook endpoint.
OrderBookDataRequestParams represents Klines request data.
OrderbookItem stores an individual orderbook item.
OrderVars stores side, status and type for any order/trade.
PerpsExchangeInfo stores data for perps.
PlaceBatchOrderData stores batch order data for placing.
PriceChangeStats contains statistics for the last 24 hours trade.
QueryOrderData holds query order data.
RecentTrade holds recent trade data.
RecentTradeRequestParams represents Klines request data.
Response holds basic binance api response data.
SymbolOrderBookTicker stores orderbook ticker data.
SymbolPrice holds basic symbol price.
SymbolPriceTicker stores ticker price stats.
SymbolsData stores perp futures' symbols.
TakerBuySellVolume stores taker buy sell volume.
TickerStream holds the ticker stream data.
TopTraderAccountRatio stores account ratio data for top traders.
TopTraderPositionRatio stores position ratio for top trader accounts.
TradeStream holds the trade stream data.
U24HrPriceChangeStats stores price change stats data.
UAccountBalanceV2Data stores account balance data for ufutures.
UAccountIncomeHistory stores income history data.
UAccountInformationV2Data stores account info for ufutures.
UAccountTradeHistory stores trade data for the users account.
UAsset holds account asset information.
UChangeInitialLeverage stores leverage change data.
UCompositeIndexInfoData stores composite index data for usdt margined futures.
UCompressedTradeData stores compressed trade data.
UForceOrdersData stores liquidation orders data for the account.
UFuturesExchangeInfo stores exchange info for ufutures.
UFuturesNewOrderRequest stores order data for placing.
UFuturesOrderData stores order data for ufutures.
UFuturesSymbolInfo contains details of a currency symbol for a usdt margined future contract.
ULiquidationOrdersData stores liquidation orders data.
ULongShortRatio stores top trader accounts' or positions' or global long/short ratio data.
UMarkPrice stores mark price data.
UModifyIsolatedPosMargin stores modified isolated margin positions' data.
UNotionalLeverageAndBrakcetsData stores notional and leverage brackets data for the account.
UOpenInterestData stores open interest data.
UOpenInterestStats stores open interest stats data.
UOrderData stores order data.
UPosition holds account position information.
UPositionADLEstimationData stores ADL estimation data for a position.
UPositionInformationV2 stores positions data.
UPositionMarginChangeHistoryData gets position margin change history data.
UPublicTradesData stores trade data.
UserAccountStream contains a key to maintain an authorised websocket connection.
UserMarginInterestHistory user margin interest history row.
UserMarginInterestHistoryResponse user margin interest history response.
USymbolOrderbookTicker stores symbol orderbook ticker data.
USymbolPriceTicker stores symbol price ticker data.
UTakerVolumeData stores volume data on buy/sell side from takers.
WebsocketDepthStream is the difference for the update depth stream.
WithdrawResponse contains status of withdrawal request.
WithdrawStatusResponse defines a withdrawal status response.
WsAccountInfoData defines websocket account info data.
WsAccountPositionData defines websocket account position data.
WsBalanceUpdateData defines websocket account balance data.
WsListStatusData defines websocket account listing status data.
WsOrderUpdateData defines websocket account order update data.
WsPayload defines the payload through the websocket connection.

# Type aliases

DepthUpdateParams is used as an embedded type for WebsocketDepthStream.
RequestParamsOrderType trade order type.
RequestParamsTimeForceType Time in force.