Binance Connector
A Rust-based connector for interacting with the Binance API, designed to facilitate trading operations and data retrieval for cryptocurrency markets.
Table of Contents
About
Binance Connector is a Rust library that provides a simple interface for interacting with the Binance cryptocurrency exchange's REST API. It aims to simplify the process of executing trades, querying market data, and managing accounts on Binance through a Rust application.
Features
- Support for Binance REST API (e.g., market data, account management, and trading operations).
- Lightweight and fast with idiomatic Rust design.
- Easy-to-use abstractions for complex API interactions.
- Examples included to help you get started quickly.
Note: As of the current version, this project only supports creating orders for the BTCUSDT pair on Binance Futures.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
-
Rust (stable version, use rustup to manage your Rust version)
-
Cargo, Rust's package manager
-
Tokio runtime for asynchronous programming
-
A
.envfile in the root of your project with your Binance API credentials:# BINANCE # Your Binance API Key BINANCE_API_KEY='type your api key here' # Your Binance API Secret BINANCE_API_SECRET='type your api secret here'
Installing
-
Clone the repo:
-
Navigate to the project directory:
-
Build and run the project:
Add dependencies to Cargo.toml
To use the Binance Connector library, you'll need to add the required dependencies to your Cargo.toml file. Below is the required configuration:
[]
= "0.1.0" # Replace with the latest version
= { = "1", = ["full"] }
= "0.15" # For loading environment variables from .env
Basic Usage
The following example demonstrates how to create a futures limit order on Binance using the Binance Connector library.
⚠️ Important: This example is specifically for Binance Futures. Ensure you have Futures permissions enabled for your API Key.
use create_order;
use Error as StdError;
async