Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WolffunService/bingx-go

Repository files navigation

BingX Go Client

This repository contains a Go client library for interacting with the BingX API. It provides a convenient way to access various trading functionalities, including spot trading and swap trading, using Go programming language.

Features

  • Spot Trading:

    • Retrieve account balance
    • Create, cancel, and retrieve orders
    • Manage open orders and view order history
  • Swap Trading:

    • Create orders with detailed parameters

Installation

To use this library in your project, you can simply import it into your Go application. Ensure you have Go installed and set up on your machine.

go get github.com/WolffunService/bingx-go

Usage

Initialization

First, create a new client instance using your API key and secret key:

import "github.com/yourusername/bingx-go"

client := bingxgo.NewClient("your_api_key", "your_secret_key")

Spot Trading

Get Account Balance

spotClient := bingxgo.SpotClient{client: client}
balances, err := spotClient.GetBalance()
if err != nil {
    log.Fatal(err)
}
fmt.Println(balances)

Create Order

order := bingxgo.SpotOrderRequest{
    Symbol:   "BTCUSDT",
    Side:     "BUY",
    Type:     "LIMIT",
    Quantity: 1.0,
    Price:    50000.0,
}

orderResponse, err := spotClient.CreateOrder(order)
if err != nil {
    log.Fatal(err)
}
fmt.Println(orderResponse)

Cancel Order

err := spotClient.CancelOrder("BTCUSDT", "order_id")
if err != nil {
    log.Fatal(err)
}

Swap Trading

Create Order

tradeClient := bingxgo.TradeClient{client: client}
swapOrder := bingxgo.OrderRequest{
    Symbol:       "BTCUSDT",
    Side:         "BUY",
    PositionSide: "LONG",
    Type:         "LIMIT",
    Quantity:     1.0,
    Price:        50000.0,
}

swapOrderResponse, err := tradeClient.CreateOrder(swapOrder)
if err != nil {
    log.Fatal(err)
}
fmt.Println(swapOrderResponse)

Contributing

We welcome contributions to this project. Please fork the repository and submit a pull request with your changes. Ensure your code follows the existing style and includes tests where applicable.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any questions or issues, please open an issue on the GitHub repository or contact the maintainers directly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages