Futures-Spot-Arbitrage-Binance-V1

Overview

Futures-Spot-Arbitrage-Binance-V1

The project includes arbitrage strategies between Binance futures and spot markets and stablecoin hedging arbitrage strategies.

该项目包括币安期货和现货市场之间的套利策略以及稳定币对冲套利策略。

Features

  • Real-time Price Monitoring: Utilizes Binance API to fetch real-time prices from both Futures and Spot markets.
  • Arbitrage Opportunity Detection: Monitors price differentials between Futures and Spot markets to identify potential arbitrage opportunities.
  • Automated Trading: Execute trades automatically when profitable arbitrage opportunities are detected.
  • Risk Management: Includes risk management measures to mitigate potential losses.
  • Logging and Reporting: Logs trade history and performance metrics for analysis and reporting.

Requirements

  • Rust 1.78.0-nightly
  • Binance API keys with Futures and Spot trading permissions
  • Rust libraries: reqwest, tokio, binance-rs-async, rocksdb, bincode ..

Setup

  1. Clone this repository:

    git clone https://github.com/matrix-tang/Futures-Spot-Arbitrage-Binance-V1.git
    
  2. Obtain API keys from Binance with Futures and Spot trading permissions.

  3. Set up API keys in config.tmol:

     [redis]
     url = "redis://127.0.0.1:6379/"
    
     [mysql]
     url = "mysql://root:123456@localhost:3306/arbitrage"
    
     [rocksdb]
     path = "_path_for_rocksdb_storage"
    
     [binance_api_config]
     api_key = ""
     secret_key = ""
    
     [log]
     pattern = "console" # console/file 控制台/文件
     dir = "logs"
     prefix = "arb.log"
     level = "INFO"

Usage

Run the main script to start monitoring and executing arbitrage opportunities:

  // run arbitrage 
  // 执行期现套利策略
  cargo run --bin arbitrage
  // run stable coin hedging
  // 执行稳定币对冲策略
  cargo run --bin hedging

Configuration

Adjust configuration parameters in config.toml according to your preferences and risk tolerance.

Disclaimer

  • Use at Your Own Risk: Trading involves risks, and past performance is not indicative of future results. Always exercise caution and perform thorough research before engaging in trading activities.
  • Not Financial Advice: This project is for educational and informational purposes only. It does not constitute financial advice, and the authors are not responsible for any losses incurred from using this software.

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests to enhance the project.


Disclaimer: This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.

You might also like...
Provides two APIs for easily cancelling futures, with the option to fallback to a timeout cancellation

tokio-context Provides two different methods for cancelling futures with a provided handle for cancelling all related futures, with a fallback timeout

A high level async Redis client for Rust built on Tokio and Futures.

A high level async Redis client for Rust built on Tokio and Futures.

Adaptors from AsyncRead/AsyncWrite to Stream/Sink using futures.

async-codec-lite Adaptors from AsyncRead/AsyncWrite to Stream/Sink using futures. async-codec-lite Adaptors from AsyncRead/AsyncWrite to Stream/Sink u

Bazaar is a Rust crate for algorithmic futures trading

Bazaar is a Rust crate for algorithmic futures trading

The most fundamental type for async synchronization: an intrusive linked list of futures

wait-list This crate provides WaitList, the most fundamental type for async synchronization. WaitList is implemented as an intrusive linked list of fu

A wrapper around Rust futures that stores the future in space provided by the caller.

StackFuture This crate defines a StackFuture wrapper around futures that stores the wrapped future in space provided by the caller. This can be used t

Crate extending futures stream combinators, that is adding precise rate limiter
Crate extending futures stream combinators, that is adding precise rate limiter

stream-rate-limiter Stream combinator .rate_limiter(opt: RateLimitOptions) Provides way to limit stream element rate with constant intervals. It adds

Comments
  • '期现套利策略表' 是人工手动输入吗?

    '期现套利策略表' 是人工手动输入吗?

    问题1: '期现套利策略表' 是人工手动输入吗?

            Box::pin(service::spot_all_ticker(price_tx.clone())),
            Box::pin(service::futures_all_ticker(price_tx.clone())),
            Box::pin(service::delivery_all_ticker(price_tx.clone())),
    

    这里监控了 所有 binance symbols 的 websocket 的 Individual Symbol Mini Ticker Stream 作为价格输入

    问题2:

    option_amount 是一个order size,还是 max position。应该有一个 持仓上限。 还是说 order size = max position, 最多只持有1个 order size?

    opened by xiandong79 3
  • 建议 以及 帮助

    建议 以及 帮助

    很高兴能看到一个期现套利的Rust代码分享,感谢。

    阅读代码后,我发现一些需要优化的地方,下面提出

    1. 差价比率配置表arb_diff_rate,不应该是手动配置的,应该是有一个爬虫任务来抓取所有(交割合约-现货)组合的价差,自动排序出套利空间最大的组合。另外配置项增加黑名单币种,可以跳过某些垃圾币。
    2. 期现套利策略表arb_strategy,增加字段类似【单币最大持仓USD】以限制一个币种的最大持仓。【最大持仓USD】以限制最大持仓支出。
    3. websocket稳定性相关:缺少ping回应pong; 缺少断线重连机制。

    不知道你是否认同我的提议, 如果认同的话,我想近期提交PR来优化上面列出的问题。(如果你想要一个新手Rust帮手的话)

    opened by lijiachang 3
Owner
Tony Z
Tony Z
Spot coupling by finding out which files are always in the same commit

git moves-together This tells you when files in the repository frequently move together. This lets you identify where the coupling is in the system. C

Billie Thompson 14 Oct 31, 2022
Sub-pixel precision light spot rendering library for astronomy and video tracking applications.

Planetarium Sub-pixel precision light spot rendering library for astronomy and video tracking applications. Example usage use planetarium::{Canvas, Sp

Sergey Kvachonok 5 Mar 27, 2022
Reimplement Simple Arbitrage in Rust

Reimplement Simple Arbitrage in Rust

null 115 Dec 29, 2022
Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust.

Dex Arbitrage - MEV Bot Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust. Before Starting I am a self-taught programmer, a co

null 4 Sep 18, 2023
This is the github repo for the Spot Lite protocol.

spot-contract This is the github repo for the Spot Lite protocol. Set up local Sei Please follow the documentation on the official Sei doc to set up y

nick 3 Nov 8, 2023
Automated Solana tool for quick arbitrage, customizable, with real-time data and wallet integration. Trade responsibly.

Solana Arbitrage Trading Tool The Solana Arbitrage Trading Tool is an automated solution crafted to spot and capitalize on arbitrage opportunities wit

null 43 Mar 12, 2024
A fully asynchronous, futures-based Kafka client library for Rust based on librdkafka

rust-rdkafka A fully asynchronous, futures-enabled Apache Kafka client library for Rust based on librdkafka. The library rust-rdkafka provides a safe

Federico Giraud 1.1k Jan 8, 2023
The gRPC library for Rust built on C Core library and futures

gRPC-rs gRPC-rs is a Rust wrapper of gRPC Core. gRPC is a high performance, open source universal RPC framework that puts mobile and HTTP/2 first. Sta

TiKV Project 1.6k Jan 7, 2023
Futures implementation for JSON-RPC

futures-jsonrpc Futures + JSON-RPC A lightweight remote procedure call protocol. It is designed to be simple! And, with futures, even more flexible! T

Victor Lopes 12 May 19, 2022
Futures-based QUIC implementation in Rust

Pure-rust QUIC protocol implementation Quinn is a pure-rust, future-based implementation of the QUIC transport protocol undergoing standardization by

null 2.6k Jan 8, 2023