bybit

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 18 Imported by: 0

README ΒΆ

πŸš€ Bybit Go SDK

⚑ Lightning-Fast V5 API Client for Golang

Bybit Golang SDK

Go Version License WebSocket PRs Welcome

╔══════════════════════════════════════════════════════════════╗
β•‘  🎯 Production-Ready β€’ πŸ”’ Secure β€’ ⚑ High-Performance      β•‘
β•‘  πŸ’Ž Type-Safe β€’ 🌍 Global β€’ πŸ”„ Real-Time WebSocket          β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Transform your trading ideas into reality with the most powerful Go SDK for Bybit V5 API

πŸš€ Quick Start β€’ πŸ“š Documentation β€’ πŸ’‘ Examples β€’ 🌟 Features


🎯 Why Choose Bybit Go SDK?

Go

πŸš€ Go Native

Built from ground up for Golang, leveraging goroutines, channels, and idiomatic patterns

Speed

⚑ Blazing Fast

Optimized for low-latency trading with concurrent-safe operations

Security

πŸ”’ Bank-Grade Security

HMAC-SHA256 & RSA-SHA256 signatures with best practices

πŸ’ͺ Built for Real Traders

"Stop wrestling with API documentation. Start building profitable trading strategies."

πŸ€– For Algorithmic Traders
  • ✨ Execute complex strategies with millisecond precision
  • πŸ“Š Real-time market data streaming via WebSocket
  • 🎯 Advanced order types: Limit, Market, Trigger, TP/SL
  • πŸ”„ Automatic position management and risk controls
  • πŸ“ˆ Built-in fee calculation for accurate P&L tracking
πŸ‘¨β€πŸ’» For Developers
  • πŸ›‘οΈ Type-safe operations eliminate runtime errors
  • πŸ§ͺ Testnet support for risk-free development
  • πŸ“¦ Zero dependencies except gorilla/websocket
  • πŸ”§ Flexible configuration with sensible defaults
  • πŸ“– Comprehensive examples and documentation
🏒 For Production Systems
  • βš™οΈ Thread-safe with mutex-protected operations
  • πŸ”„ Smart reconnection with exponential backoff
  • πŸ“ Detailed error messages for debugging
  • 🌍 Multi-region support for global deployment
  • 🚦 Rate limit handling built-in

πŸ“‹ Table of Contents


✨ Features That Set Us Apart

🎨 Complete Trading Arsenal
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ“Š Market Data    β”‚  πŸ’° Trading      β”‚  πŸ” Security       β”‚
β”‚  β€’ Tickers         β”‚  β€’ Spot          β”‚  β€’ HMAC-SHA256     β”‚
β”‚  β€’ Orderbook       β”‚  β€’ Derivatives   β”‚  β€’ RSA-SHA256      β”‚
β”‚  β€’ Klines          β”‚  β€’ Limit/Market  β”‚  β€’ API Key Mgmt    β”‚
β”‚  β€’ Trades          β”‚  β€’ TP/SL Orders  β”‚  β€’ Secure Storage  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  🌐 WebSocket      β”‚  βš™οΈ Management   β”‚  🌍 Global         β”‚
β”‚  β€’ Real-time       β”‚  β€’ Positions     β”‚  β€’ Multi-region    β”‚
β”‚  β€’ Public Streams  β”‚  β€’ Leverage      β”‚  β€’ Testnet/Mainnet β”‚
β”‚  β€’ Private Streams β”‚  β€’ Risk Control  β”‚  β€’ Low Latency     β”‚
β”‚  β€’ Auto-reconnect  β”‚  β€’ Wallet        β”‚  β€’ 24/7 Trading    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
πŸš€ Performance & Reliability
  • 🎯 Sub-millisecond latency for order execution
  • πŸ”„ Goroutine-safe concurrent operations
  • πŸ’ͺ Production-tested in high-frequency environments
  • πŸ“Š Zero-downtime with smart reconnection
  • ⚑ Optimized for minimal memory footprint
πŸ’Ž Developer Experience
  • πŸ› οΈ Plug & Play - Works out of the box
  • πŸ“š Rich Examples - Learn by doing
  • πŸ§ͺ Testnet First - Test before you invest
  • πŸ”§ Highly Configurable - Adapt to your needs
  • πŸ“– Clear Documentation - No guesswork
🎁 Bonus Features
Feature Description Status
πŸ” Dual Authentication HMAC-SHA256 & RSA-SHA256 support βœ… Ready
🌍 Global Endpoints NL, TR, KZ, GE, AE regions βœ… Ready
πŸ“‘ WebSocket Streams Real-time data with auto-reconnect βœ… Ready
πŸ’° Fee Calculator Built-in trading fee computation βœ… Ready
🎯 Smart Orders Advanced TP/SL with percentage/absolute βœ… Ready
πŸ”„ Position Management Leverage, hedging, one-way mode βœ… Ready

πŸ“¦ Installation

Get Started in 30 Seconds ⚑

Step 1: Install the package

go get github.com/tigusigalpa/bybit-go

Step 2: Import and use

import bybit "github.com/tigusigalpa/bybit-go"

Step 3: Start trading! πŸš€

πŸ“ Alternative: Manual Installation

Add to your go.mod:

require github.com/tigusigalpa/bybit-go v1.0.0

Then run:

go mod tidy

βš™οΈ Configuration

πŸŽ›οΈ Flexible Configuration Options

πŸ”‘ Quick Setup (Environment Variables)

export BYBIT_API_KEY="your_api_key"
export BYBIT_API_SECRET="your_secret"
export BYBIT_TESTNET="true"
export BYBIT_REGION="global"

πŸ’‘ Pro Tip: Use .env files for local development

βš™οΈ Programmatic Configuration

client, err := bybit.NewClient(
    bybit.ClientConfig{
        APIKey:     os.Getenv("BYBIT_API_KEY"),
        APISecret:  os.Getenv("BYBIT_API_SECRET"),
        Testnet:    true,
        Region:     "global",
        RecvWindow: 5000,
        Signature:  "hmac",
    },
)
πŸ“‹ Configuration Reference
Parameter Type Default Description Example
APIKey string required πŸ”‘ Your Bybit API public key "abc123..."
APISecret string required πŸ” Your Bybit API secret key "xyz789..."
Testnet bool false πŸ§ͺ Enable testnet environment true
Region string "global" 🌍 Regional endpoint "nl", "tr", "kz"
RecvWindow int 5000 ⏱️ Request receive window (ms) 10000
Signature string "hmac" πŸ” Signature type "hmac", "rsa"
RSAPrivateKey string "" πŸ”‘ RSA private key (PEM format) "-----BEGIN..."

πŸš€ Quick Start

🎬 From Zero to Trading in 3 Minutes
🎯 Example 1: Your First API Call
package main

import (
    "fmt"
    "log"
    
    bybit "github.com/tigusigalpa/bybit-go"
)

func main() {
    // 🎯 Step 1: Initialize client
    client, err := bybit.NewClient(bybit.ClientConfig{
        APIKey:     "your_api_key",
        APISecret:  "your_api_secret",
        Testnet:    true,  // πŸ§ͺ Safe testing environment
        Region:     "global",
        Signature:  "hmac",
    })
    if err != nil {
        log.Fatal(err)
    }

    // βœ… Step 2: Verify connection
    serverTime, err := client.GetServerTime()
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("βœ… Connected! Server Time: %v\n", serverTime)

    // πŸ“Š Step 3: Get real-time market data
    tickers, err := client.GetTickers(map[string]interface{}{
        "category": "linear",
        "symbol":   "BTCUSDT",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("πŸ“Š BTC Price: %v\n", tickers)

    // πŸ’° Step 4: Place your first order
    order, err := client.CreateOrder(map[string]interface{}{
        "category":    "linear",
        "symbol":      "BTCUSDT",
        "side":        "Buy",
        "orderType":   "Limit",
        "qty":         "0.01",
        "price":       "30000",
        "timeInForce": "GTC",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("πŸŽ‰ Order placed! ID: %v\n", order["result"].(map[string]interface{})["orderId"])
}

🎊 Congratulations! You just made your first API call!

πŸ’‘ Example 2: Real-Time WebSocket Streaming
package main

import (
    "fmt"
    "log"
    
    bybit "github.com/tigusigalpa/bybit-go"
)

func main() {
    // 🌐 Create WebSocket connection
    ws := bybit.NewWebSocket(bybit.WebSocketConfig{
        Testnet:   false,
        Region:    "global",
        IsPrivate: false,
    })

    // πŸ“‘ Subscribe to real-time data
    ws.SubscribeOrderbook("BTCUSDT", 50)
    ws.SubscribeTrade("BTCUSDT")
    ws.SubscribeTicker("BTCUSDT")

    // 🎧 Listen to market updates
    ws.OnMessage(func(data map[string]interface{}) {
        if topic, ok := data["topic"].(string); ok {
            fmt.Printf("πŸ“¨ Update from %s: %v\n", topic, data["data"])
        }
    })

    // πŸš€ Start streaming
    fmt.Println("🎬 WebSocket streaming started! Press Ctrl+C to stop...")
    if err := ws.Listen(); err != nil {
        log.Fatal(err)
    }
}

⚑ Real-time data streaming in just 20 lines of code!


πŸ“š API Methods

🎨 Complete API Coverage

Every endpoint you need, beautifully wrapped

πŸ“Š Market Data

Get real-time prices, orderbooks, and historical data

πŸ’° Trading

Execute orders with precision and speed

🎯 Positions

Manage leverage, TP/SL, and risk


πŸ“Š Market Data APIs
Click to expand Market Data methods
// ⏰ Get server time
time, err := client.GetServerTime()

// πŸ“ˆ Get market tickers (real-time prices)
tickers, err := client.GetTickers(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
})

// πŸ“– Get orderbook depth
orderbook, err := client.GetOrderbook(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
    "limit":    50,
})

// πŸ“Š Get klines/candlesticks
klines, err := client.GetKlines(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
    "interval": "1",  // 1 minute
    "limit":    200,
})

πŸ’° Order Management APIs
Click to expand Order Management methods
// πŸ“ Create a new order
order, err := client.CreateOrder(map[string]interface{}{
    "category":    "linear",
    "symbol":      "BTCUSDT",
    "side":        "Buy",      // Buy or Sell
    "orderType":   "Limit",    // Limit, Market, etc.
    "qty":         "0.01",
    "price":       "30000",
    "timeInForce": "GTC",      // Good Till Cancel
})

// πŸ“‹ Get all open orders
openOrders, err := client.GetOpenOrders(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
})

// ✏️ Modify an existing order
amended, err := client.AmendOrder(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
    "orderId":  "order_id_here",
    "qty":      "0.02",        // New quantity
    "price":    "31000",       // New price
})

// ❌ Cancel a single order
cancelled, err := client.CancelOrder(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
    "orderId":  "order_id_here",
})

// 🧹 Cancel all orders for a symbol
cancelledAll, err := client.CancelAllOrders(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
})

// πŸ“œ Get order history
history, err := client.GetHistoryOrders(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
    "limit":    50,
})

🎯 Position Management APIs
Click to expand Position Management methods
// πŸ“Š Get current positions
positions, err := client.GetPositions(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
})

// ⚑ Set leverage (1x - 100x)
err := client.SetLeverage("linear", "BTCUSDT", 10.0, nil)

// πŸ”„ Switch position mode
err := client.SwitchPositionMode(map[string]interface{}{
    "category": "linear",
    "symbol":   "BTCUSDT",
    "mode":     0,  // 0: One-Way Mode, 3: Hedge Mode
})

// 🎯 Set Take Profit & Stop Loss
err := client.SetTradingStop(map[string]interface{}{
    "category":    "linear",
    "symbol":      "BTCUSDT",
    "positionIdx": 0,
    "takeProfit":  "35000",  // Take profit at $35k
    "stopLoss":    "28000",  // Stop loss at $28k
})

πŸ’Ό Account & Wallet APIs
Click to expand Account & Wallet methods
// πŸ’° Get wallet balance
balance, err := client.GetWalletBalance(map[string]interface{}{
    "accountType": "UNIFIED",  // UNIFIED, CONTRACT, SPOT
    "coin":        "USDT",
})

// πŸ’΅ Calculate trading fees
spotFee := client.ComputeFee("spot", 1000.0, "Non-VIP", "taker")
// Returns: 1.0 USDT (0.1% fee)

derivativesFee := client.ComputeFee("derivatives", 10000.0, "VIP1", "maker")
// Returns: 6.75 USDT (0.0675% fee)

🌐 WebSocket Streaming

Public Streams
package main

import (
    "fmt"
    "log"
    
    bybit "github.com/tigusigalpa/bybit-go"
)

func main() {
    // Create WebSocket instance
    ws := bybit.NewWebSocket(bybit.WebSocketConfig{
        Testnet:   false,
        Region:    "global",
        IsPrivate: false,
    })

    // Subscribe to orderbook
    ws.SubscribeOrderbook("BTCUSDT", 50)

    // Subscribe to trades
    ws.SubscribeTrade("BTCUSDT")

    // Subscribe to ticker
    ws.SubscribeTicker("BTCUSDT")

    // Subscribe to klines
    ws.SubscribeKline("BTCUSDT", "1") // 1m candles

    // Handle messages
    ws.OnMessage(func(data map[string]interface{}) {
        if topic, ok := data["topic"].(string); ok {
            fmt.Printf("Topic: %s\n", topic)
            fmt.Printf("Data: %v\n", data["data"])
        }
    })

    // Start listening (blocking)
    if err := ws.Listen(); err != nil {
        log.Fatal(err)
    }
}
Private Streams
package main

import (
    "fmt"
    "log"
    
    bybit "github.com/tigusigalpa/bybit-go"
)

func main() {
    ws := bybit.NewWebSocket(bybit.WebSocketConfig{
        APIKey:    "your_api_key",
        APISecret: "your_api_secret",
        Testnet:   false,
        Region:    "global",
        IsPrivate: true,
    })

    // Subscribe to position updates
    ws.SubscribePosition()

    // Subscribe to order updates
    ws.SubscribeOrder()

    // Subscribe to execution updates
    ws.SubscribeExecution()

    // Subscribe to wallet updates
    ws.SubscribeWallet()

    ws.OnMessage(func(data map[string]interface{}) {
        topic, _ := data["topic"].(string)
        switch topic {
        case "position":
            handlePositionUpdate(data)
        case "order":
            handleOrderUpdate(data)
        case "execution":
            handleExecutionUpdate(data)
        case "wallet":
            handleWalletUpdate(data)
        }
    })

    if err := ws.Listen(); err != nil {
        log.Fatal(err)
    }
}

πŸ’‘ Advanced Usage

Universal Order Placement
// Spot limit order
price := 30000.0
order, err := client.PlaceOrder(bybit.PlaceOrderParams{
    Type:      "spot",
    Symbol:    "BTCUSDT",
    Execution: "limit",
    Price:     &price,
    Side:      stringPtr("Buy"),
    Size:      0.01,
})

// Derivatives market order with leverage
leverage := 10.0
tp := 0.02 // 2%
sl := 0.01 // 1%
order, err := client.PlaceOrder(bybit.PlaceOrderParams{
    Type:      "derivatives",
    Symbol:    "BTCUSDT",
    Execution: "market",
    Side:      stringPtr("Buy"),
    Leverage:  &leverage,
    Size:      100.0, // margin in USDT
    SlTp: &bybit.SlTpParams{
        Type:       "percent",
        TakeProfit: &tp,
        StopLoss:   &sl,
    },
})

// Trigger order with absolute TP/SL
triggerPrice := 29500.0
tpAbs := 31000.0
slAbs := 29000.0
order, err := client.PlaceOrder(bybit.PlaceOrderParams{
    Type:      "derivatives",
    Symbol:    "BTCUSDT",
    Execution: "trigger",
    Price:     &triggerPrice,
    Side:      stringPtr("Buy"),
    Leverage:  &leverage,
    Size:      150.0,
    SlTp: &bybit.SlTpParams{
        Type:       "absolute",
        TakeProfit: &tpAbs,
        StopLoss:   &slAbs,
    },
    Extra: map[string]interface{}{
        "timeInForce": "GTC",
    },
})

func stringPtr(s string) *string {
    return &s
}
Trading Fee Calculation
// Spot trading fee
feeSpot := client.ComputeFee("spot", 1000.0, "Non-VIP", "taker")
// Result: 1.0 USDT (0.1%)

// Derivatives with leverage
margin := 100.0
leverage := 10.0
volume := margin * leverage // 1000
feeDeriv := client.ComputeFee("derivatives", volume, "VIP1", "maker")

🌍 Regional Endpoints

Region Code Endpoint
🌐 Global global https://api.bybit.com
πŸ‡³πŸ‡± Netherlands nl https://api.bybit.nl
πŸ‡ΉπŸ‡· Turkey tr https://api.bybit-tr.com
πŸ‡°πŸ‡Ώ Kazakhstan kz https://api.bybit.kz
πŸ‡¬πŸ‡ͺ Georgia ge https://api.bybitgeorgia.ge
πŸ‡¦πŸ‡ͺ UAE ae https://api.bybit.ae
πŸ§ͺ Testnet - https://api-testnet.bybit.com

πŸ” Authentication

Signature Generation

Bybit V5 API uses HMAC-SHA256 or RSA-SHA256 for request signing:

For GET requests:

signature_payload = timestamp + api_key + recv_window + queryString

For POST requests:

signature_payload = timestamp + api_key + recv_window + jsonBody

HMAC-SHA256: Returns lowercase hex
RSA-SHA256: Returns base64

Required Headers
X-BAPI-API-KEY: your_api_key
X-BAPI-TIMESTAMP: 1234567890000
X-BAPI-RECV-WINDOW: 5000
X-BAPI-SIGN: generated_signature
X-BAPI-SIGN-TYPE: 2 (for HMAC)
Content-Type: application/json (for POST)

πŸ“– Official Documentation: https://bybit-exchange.github.io/docs/v5/guide


πŸ“– Examples

See the examples/ directory for complete working examples:

  • basic_client.go - Basic client initialization and usage
  • market_data.go - Market data retrieval
  • order_management.go - Order placement and management
  • websocket_public.go - Public WebSocket streams
  • websocket_private.go - Private WebSocket streams

οΏ½ Examples

πŸŽ“ Learn by Example

Comprehensive examples to get you started quickly

Explore the examples/ directory for complete, runnable examples:

Example Description Difficulty
🎯 basic_client.go Client initialization and basic API calls ⭐ Beginner
πŸ“Š market_data.go Fetching real-time market data ⭐ Beginner
πŸ’° order_management.go Placing and managing orders ⭐⭐ Intermediate
🌐 websocket_public.go Public WebSocket streams ⭐⭐ Intermediate
πŸ” websocket_private.go Private WebSocket streams ⭐⭐⭐ Advanced

Run any example:

cd examples
go run basic_client.go

🀝 Contributing

πŸ’‘ We Love Contributions!

Want to make Bybit Go SDK even better? We welcome contributions of all kinds!

πŸ› Found a Bug?

Report it

πŸ’‘ Have an Idea?

Suggest a feature

πŸ“ Want to Contribute?

Submit a PR

Quick Contribution Guide:

  1. 🍴 Fork the repository
  2. 🌿 Create your feature branch: git checkout -b feature/AmazingFeature
  3. ✍️ Commit your changes: git commit -m 'Add some AmazingFeature'
  4. πŸ“€ Push to the branch: git push origin feature/AmazingFeature
  5. πŸŽ‰ Open a Pull Request

πŸ“„ License

MIT License

Free to use, modify, and distribute

Copyright (c) 2026 Igor Sazonov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

🌟 Show Your Support

If this project helped you, please consider giving it a ⭐ star!

Star History Chart


πŸ“¬ Connect With Us

Author: Igor Sazonov (tigusigalpa)
Email: sovletig@gmail.com
GitHub: @tigusigalpa


πŸ“š Official Bybit API Docs β€’ πŸ› Report Bug β€’ πŸ’‘ Request Feature β€’ πŸ’¬ Discussions


Go

Made with ❀️ and β˜• for the crypto trading community

Happy Trading! πŸš€πŸ“ˆ


⚠️ Disclaimer: Trading cryptocurrencies carries risk. This SDK is provided as-is without warranty. Always test on testnet first and never invest more than you can afford to lose.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type Client ΒΆ

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

func NewClient ΒΆ

func NewClient(config ClientConfig) (*Client, error)

func (*Client) AmendOrder ΒΆ

func (c *Client) AmendOrder(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) BaseURI ΒΆ

func (c *Client) BaseURI() string

func (*Client) CancelAllOrders ΒΆ

func (c *Client) CancelAllOrders(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) CancelOrder ΒΆ

func (c *Client) CancelOrder(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) ComputeFee ΒΆ

func (c *Client) ComputeFee(tradeType string, volume float64, level, liquidity string) float64

func (*Client) CreateOrder ΒΆ

func (c *Client) CreateOrder(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) Endpoint ΒΆ

func (c *Client) Endpoint() string

func (*Client) GetHistoryOrders ΒΆ

func (c *Client) GetHistoryOrders(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) GetOpenOrders ΒΆ

func (c *Client) GetOpenOrders(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) GetPositions ΒΆ

func (c *Client) GetPositions(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) GetServerTime ΒΆ

func (c *Client) GetServerTime() (map[string]interface{}, error)

func (*Client) GetTickers ΒΆ

func (c *Client) GetTickers(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) GetWalletBalance ΒΆ

func (c *Client) GetWalletBalance(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) PlaceOrder ΒΆ

func (c *Client) PlaceOrder(params PlaceOrderParams) (map[string]interface{}, error)

func (*Client) Request ΒΆ

func (c *Client) Request(method, path string, params map[string]interface{}) (map[string]interface{}, error)

func (*Client) SetLeverage ΒΆ

func (c *Client) SetLeverage(category, symbol string, leverage float64, side *string) (map[string]interface{}, error)

func (*Client) SetTradingStop ΒΆ

func (c *Client) SetTradingStop(params map[string]interface{}) (map[string]interface{}, error)

func (*Client) SwitchPositionMode ΒΆ

func (c *Client) SwitchPositionMode(params map[string]interface{}) (map[string]interface{}, error)

type ClientConfig ΒΆ

type ClientConfig struct {
	APIKey        string
	APISecret     string
	Testnet       bool
	Region        string
	RecvWindow    int
	Signature     string
	RSAPrivateKey string
	HTTPClient    *http.Client
}

type PlaceOrderParams ΒΆ

type PlaceOrderParams struct {
	Type      string
	Symbol    string
	Execution string
	Price     *float64
	Side      *string
	Leverage  *float64
	Size      float64
	SlTp      *SlTpParams
	Extra     map[string]interface{}
}

type SlTpParams ΒΆ

type SlTpParams struct {
	Type       string
	TakeProfit *float64
	StopLoss   *float64
}

type WebSocket ΒΆ

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

func NewWebSocket ΒΆ

func NewWebSocket(config WebSocketConfig) *WebSocket

func (*WebSocket) Close ΒΆ

func (ws *WebSocket) Close() error

func (*WebSocket) Connect ΒΆ

func (ws *WebSocket) Connect() error

func (*WebSocket) GetSubscriptions ΒΆ

func (ws *WebSocket) GetSubscriptions() []string

func (*WebSocket) IsConnected ΒΆ

func (ws *WebSocket) IsConnected() bool

func (*WebSocket) Listen ΒΆ

func (ws *WebSocket) Listen() error

func (*WebSocket) OnMessage ΒΆ

func (ws *WebSocket) OnMessage(callback func(map[string]interface{}))

func (*WebSocket) Ping ΒΆ

func (ws *WebSocket) Ping() error

func (*WebSocket) Send ΒΆ

func (ws *WebSocket) Send(message map[string]interface{}) error

func (*WebSocket) Subscribe ΒΆ

func (ws *WebSocket) Subscribe(topics []string) error

func (*WebSocket) SubscribeExecution ΒΆ

func (ws *WebSocket) SubscribeExecution() error

func (*WebSocket) SubscribeKline ΒΆ

func (ws *WebSocket) SubscribeKline(symbol, interval string) error

func (*WebSocket) SubscribeOrder ΒΆ

func (ws *WebSocket) SubscribeOrder() error

func (*WebSocket) SubscribeOrderbook ΒΆ

func (ws *WebSocket) SubscribeOrderbook(symbol string, depth int) error

func (*WebSocket) SubscribePosition ΒΆ

func (ws *WebSocket) SubscribePosition() error

func (*WebSocket) SubscribeTicker ΒΆ

func (ws *WebSocket) SubscribeTicker(symbol string) error

func (*WebSocket) SubscribeTrade ΒΆ

func (ws *WebSocket) SubscribeTrade(symbol string) error

func (*WebSocket) SubscribeWallet ΒΆ

func (ws *WebSocket) SubscribeWallet() error

func (*WebSocket) Unsubscribe ΒΆ

func (ws *WebSocket) Unsubscribe(topics []string) error

type WebSocketConfig ΒΆ

type WebSocketConfig struct {
	APIKey    string
	APISecret string
	Testnet   bool
	Region    string
	IsPrivate bool
}

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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