Bybit API v5 client in Rust
This is simply a bybit V5 api connector using binance-rs implementation, Some parts of the api have not been completed yet...Anyone is welcome to branch/fork the repository and add their own upgrades, see Development section for details.
[!CAUTION] This is a personal project, use at your own risk. Neither the original author, nor any of the contributors of this software shall ever be held responsible for your investment losses. Cryptocurrency investment is subject to high market risk.
Table of Contents
Features
Some part of the project is still under development. Please regularly take a look at this README for updates.
- REST API:
- Market Data: Access to K-line, tickers, order book, and more. See
tests/market_test.rs - Trade: Functionality for placing, amending, and canceling orders. See
tests/trade_test.rs- Order Management: Place, amend, cancel orders (single and batch)
- Order History: Query open, closed, and historical orders
- Trade History: Get execution records
- Pre-check Orders: Calculate margin impact before placement
- Borrow Quota: Check available balance for spot and margin trading
- Disconnection Protection (DCP): Configure automatic order cancellation on disconnection
- Advanced Order Features: Slippage tolerance, BBO (Best Bid/Offer) settings, TP/SL modes
- Position: Manage your trading positions. See
tests/position_test.rs - Account & Asset: These sections are currently under active development. See
tests/account_test.rsfor progress
- Market Data: Access to K-line, tickers, order book, and more. See
- Websocket API:
- Support for subscribing to real-time public and private data streams. See
tests/ws_test.rs
- Support for subscribing to real-time public and private data streams. See
Development
If you want to contribubute please make sure to follow this setup. Install the precommit tool if you don't have it installed already and make sure to install the pre-commit hooks
Precommit
Install the pre-commit CLI tool and in this repo install the hooks.
Install tool
Install hooks
Usage
This crate can be installed by adding the following to your Cargo.toml:
[]
= "*"
Take a look at tests for usage.
New Trade Methods Examples
The library now includes comprehensive support for Bybit's V5 trade API. Here are examples of the newly implemented features:
1. Pre-check Order (Margin Calculation)
let pre_check_request = custom;
let response = trader.pre_check_order.await?;
println!;
println!;
2. Get Borrow Quota (Spot Trading)
let borrow_request = new;
let response = trader.get_borrow_quota_spot.await?;
println!;
println!;
3. Configure Disconnection Protection (DCP)
let dcp_request = new;
let response = trader.set_dcp_options.await?;
println!;
4. Advanced Order Features
let order = OrderRequest ;
For complete examples, see examples/new_trade_methods.rs.
Contact
if you have any issues contact me on X (twitter) @unkuseni
Acknowledgments
Credit
I like the project design of binance-rs and decided to use it. You might stumble upon some changes where both projects differ.
Special thanks
A special thank you to Sajjon for all of his many contributions.
Also thanks to enseed for the contributions.