Skip to content
All library documents

Cross-Exchange Spot Arbitrage with Inventory Rebalancing

Article Strategy library · Author: ianzeng123

Summary

This script describes a two-exchange spot arbitrage process for the same asset. It compares executable bid and ask prices across venues, estimates available depth, and places paired buy and sell orders when the spread exceeds a threshold that includes configured fees and a minimum profit margin. Trade size is limited by available balances, order-book quantity, minimum size, and a safety cap.

A separate balance check tracks aggregate asset holdings against an initial baseline and attempts to correct inventory drift when it exceeds a tolerance. The script also calculates profit from account balances and asset holdings, and displays balances, order-book data, latency, and returns in a status table. The published configuration names Binance and OKX, while comments and labels in the source refer to Huobi and Binance, so venue settings are inconsistent. The latency and missing-data safeguards are commented out, and the excerpt gives no verified results; fees, execution risk, inventory assumptions, and operational behavior need careful review.

Key ideas

  • The strategy seeks cross-venue price spreads large enough to cover configured fees and a minimum profit threshold.
  • It sizes paired trades using account balances and visible order-book depth, subject to minimum and maximum limits.
  • A balance routine attempts to keep combined asset holdings near their initial level.
  • Profit is estimated from account balances and changes in aggregate asset holdings.
  • The configured venues conflict with source comments, and key latency and data checks are disabled.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.