Categorygithub.com/Hongssd/mybybitapi
modulepackage
0.1.4
Repository: https://github.com/hongssd/mybybitapi.git
Documentation: pkg.go.dev

# README

mybybitapi

Go 1.19.0 Contributor Victor License: MIT

Table of Contents

Require

require (
	github.com/json-iterator/go v1.1.12
	github.com/shopspring/decimal v1.4.0
	github.com/sirupsen/logrus v1.9.3
)

Installation

go get github.com/Hongssd/mybybitapi

Public Rest Examples

Kline

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PublicRestClient()
res, err := client.NewMarketKline().Category("spot").Interval("1").Symbol("BTCUSDT").Limit(10).Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

OrderBook

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PublicRestClient()
res, err := client.NewMarketOrderBook().Category("spot").Symbol("BTCUSDT").Limit(20).Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Private Rest Examples

Wallet Balance

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PrivateRestClient()
res, err := client.NewAccountWalletBalance().AccountType("UNIFIED").Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Order Create

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PrivateRestClient()
res, err := client.NewOrderCreate().
	Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("10000").
	Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Batch Order Create

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY").PrivateRestClient()
res, err := client.NewOrderCreateBatch().
        AddNewOrderCreateReq(client.NewOrderCreate().
			Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("10000")).
        AddNewOrderCreateReq(client.NewOrderCreate().
			Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("11000")).
        Do()
if err != nil {
    panic(err)
}
fmt.Println(res)

Public Websocket Examples

Subscribe Kline

wsclient := mybybitapi.NewPublicSpotWsStreamClient()
//Open Websocket Connect
err := wsclient.OpenConn()
if err != nil {
    panic(err)
}
//Subscribe Kline
sub, err := wsclient.SubscribeKlineMultiple([]string{"BTCUSDT", "ETHUSDT"}, []string{"1", "5", "30"})
if err != nil {
    panic(err)
}


//Listen for klines 
for {
    select {
    case err := <-sub.ErrChan():
        panic(err)
    case result := <-sub.ResultChan():
        fmt.Println(result)
    case <-sub.CloseChan():
        fmt.Println("subscribe closed")
    }
}

Private Websocket Examples

Subscribe Order

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY")
wsclient := mybybitapi.NewPrivateWsStreamClient()

//Open Websocket Connect
err := wsclient.OpenConn()
if err != nil {
    panic(err)
}

//Auth To Bybit
err = wsclient.Auth(client)
if err != nil {
    panic(err)
}


//Subscribe All-In-One Topic: order
sub, err := wsclient.SubscribeOrder("all")
if err != nil {
    panic(err)
}


//Listen for orders 
for {
    select {
    case err := <-sub.ErrChan():
        panic(err)
    case result := <-sub.ResultChan():
        fmt.Println(result)
    case <-sub.CloseChan():
        fmt.Println("subscribe closed")
    }
}

Trade Websocket Examples

Create Order

client := mybybitapi.NewRestClient("YOUR_API_KEY","YOUR_API_KEY")
privateClient := client.PrivateRestClient()
wsclient := mybybitapi.NewTradeWsStreamClient()
//Open Websocket Connect
err := wsclient.OpenConn()
if err != nil {
    panic(err)
}

//Auth To Bybit
err = wsclient.Auth(client)
if err != nil {
    panic(err)
}

//Websocket order create
orderCreateRes, err := wsclient.CreateOrder(
    privateClient.NewOrderCreate().
    Category("linear").Symbol("BTCUSDT").Side("Buy").OrderType("Limit").Qty("0.1").Price("10000"))
if err != nil {
    panic(err)
}
fmt.Println(orderCreateRes)

# Functions

No description provided by the author
捕获下单/撤单/查单结果.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Request 发送请求.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

查詢手續費率.
查詢帳戶信息.
設置保證金模式(帳戶).
升級至UTA Pro.
查詢錢包餘額.
CONTRACT合約帳戶 SPOT現貨帳戶 OPTION USDC合約帳戶 FUND資金帳戶 UNIFIED統一帳戶.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
查詢延遲提幣凍結金額.
劃轉 (單帳號內).
查詢帳戶單個幣種餘額.
查詢賬戶所有幣種余額.
查詢劃轉紀錄 (單帳號內).
帳戶類型間可劃轉的幣種.
鉴权.
No description provided by the author
No description provided by the author
test.
test.
test.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
私有频道.
反向合约公共频道.
合约公共频道.
期权公共频道.
现货公共频道.
ws下单交易频道.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
查詢可交易產品的規格信息.
查詢市場價格K線數據.
Order Book (深度).
查詢平台最近成交歷史.
查詢最新行情信息.
Bybit服務器時間.
撤单.
批量撤单.
下单.
修改委託單.
批量修改委託單.
撤銷委託單.
撤銷所有訂單.
批量撤銷委託單.
創建委託單.
批量創建委託單.
查詢成交紀錄 (2年).
查詢歷史訂單 (2年).
查詢實時委託單.
查詢持倉 (實時).
設置槓桿.
切換全倉/逐倉保證金(交易對).
切換持倉模式.
POST
No description provided by the author
No description provided by the author
No description provided by the author
全倉槓桿設置用戶最大槓桿倍數.
查詢統一帳戶下槓桿交易的開關狀態和槓桿倍數.
订阅.
No description provided by the author
取消订阅.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
订阅间隔.
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
setMarginMode true string ISOLATED_MARGIN(逐倉保證金模式), REGULAR_MARGIN(全倉保證金模式)PORTFOLIO_MARGIN(組合保證金模式)默認常規,傳常規則返回設置成功.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
AssetTithdrawWithdrawableAmount: PrivateRest接口 //GET 查詢延遲提幣凍結金額.
AssetTithdrawWithdrawableAmount: PrivateRest接口 //GET 查詢延遲提幣凍結金額.
No description provided by the author
AssetTransferInterTransfer: PrivateRest接口 //POST 劃轉 (單帳號內).
AssetTransferInterTransfer: PrivateRest接口 //POST 劃轉 (單帳號內).
No description provided by the author
AssetTransferQueryAccountCoinBalance: PrivateRest接口 //GET 查詢帳戶單個幣種餘額.
AssetTransferQueryAccountCoinBalance: PrivateRest接口 //GET 查詢帳戶單個幣種餘額.
No description provided by the author
AssetTransferQueryAccountCoinsBalance: PrivateRest接口 //GET 查詢賬戶所有幣種餘額.
AssetTransferQueryAccountCoinsBalance: PrivateRest接口 //GET 查詢賬戶所有幣種餘額.
No description provided by the author
AssetTransferQueryInterTransferList: PrivateRest接口 //GET 查詢劃轉紀錄 (單帳號內).
AssetTransferQueryInterTransferList: PrivateRest接口 //GET 查詢劃轉紀錄 (單帳號內).
No description provided by the author
No description provided by the author
AssetTransferQueryTransferCoinList: PrivateRest接口 //GET 帳戶類型間可劃轉的幣種.
AssetTransferQueryTransferCoinList: PrivateRest接口 //GET 帳戶類型間可劃轉的幣種.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LinearDetails.
No description provided by the author
No description provided by the author
category true string 产品类型.
No description provided by the author
No description provided by the author
No description provided by the author
category false string 產品類型.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
linear 独特参数.
option 独特参数.
category true string 產品類型.
No description provided by the author
No description provided by the author
spot 独特参数.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
OptionsDetails.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
下單時需確保帳戶內有足夠的資金。一旦下單,根據訂單所需資金,您的帳戶資金將在訂單生命週期內凍結相應額度,被凍結的資金額度取決於訂單屬性。 每個請求包含的訂單數最大是: 20筆(期权), 10筆(期貨), 10筆(現貨),返回的數據列表中分成兩個list,訂單創建的列表和創建結果的信息返回,兩個list的訂單的序列是完全保持一致的。.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SpotDetails.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
spotLeverage string 槓桿倍數.
数据流订阅标准结构体.
No description provided by the author
登陆及订阅返回结果.
授权请求参数.
登陆请求相关.
单独授权接口返回结果.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
id string 消息id topic string Topic名 creationTime number 消息數據創建時間 data array Object > category string 產品類型 統一帳戶: spot, linear, iverse, option 經典帳戶: spot, linear, inverse.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ws下单/撤单/改单请求参数.
No description provided by the author
ws下单/撤单/改单单次请求.
No description provided by the author
No description provided by the author
下单/撤单/改单返回结果.
No description provided by the author
No description provided by the author
数据流订阅基础客户端.
订阅请求相关.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
spot 現貨 linear USDT永續, USDC永續, USDC交割 inverse 反向合約,包含反向永續, 反向交割 option 期權.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author