Two-Exchange Spread Hedging with Inventory Rebalancing
Summary
This JavaScript strategy monitors order books on two exchanges for the same currency. It compares the best bid on one venue with the best ask on the other in both directions, then opens a paired short and long when the corresponding spread meets its configurable minimum. Trade size is capped by a maximum amount, displayed liquidity, available inventory, and available balance. A loop interval controls polling, and the spread thresholds can be adjusted while running.
After a paired trade, the script cancels outstanding orders and later checks combined account stocks and balances against their starting levels. If holdings have drifted beyond a minimum amount, it attempts to rebalance across the venues, then reports profit and inventory offsets. This is an execution-oriented cross-venue arbitrage design, not evidence that the spread is profitable after fees. It depends on both legs filling, accurate account updates, adequate liquidity, and compatible exchange behavior; the document provides no backtest or live results and flags the source as research use only.
Key ideas
- The strategy compares cross-exchange bid-ask spreads in both trading directions.
- It places a paired sale and purchase when a configured spread threshold is reached.
- Position size is limited by order-book liquidity, balances, inventory, and a maximum amount.
- Periodic account checks cancel orders and attempt to rebalance accumulated inventory differences.
- Execution risk, fees, and fill quality are not evaluated with results in the document.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.