20min
Price Arbitrage Bot
Overview
- The bot in this repository is designed to perform price arbitrage between RageTrade's decentralized perpetual market and perpetual futures of centralized exchanges.
- Currently, the bot will perform price arbitrage between RageTrade's ETH perp and Binance's ETH-PERP future markets. It can be extended to accommodate more centralized exchanges or pairs with minor changes.
- RageTrade will be initially deployed on arbitrum, so some ETH is required to run the bot for paying network gas fees.
Strategy
- The bot will perform simple price arbitrage, i.e if there is sufficient price difference between Binance and RageTrade, the bot would take a long position on the leg where the price is lower and short on the other leg.
- The Bot will only consider taking a position if the spread is high enough to cover for fees of placing orders on RageTrade & Binance.
- Then, after estimating trade size, if the expected profit is greater than network transaction fees + minimum profit threshold (config parameter), the bot will execute in the equal and opposite direction on both legs. If any of the legs fail to execute a trade, the bot will reverse the position on the opposite leg to neutralize.
- The bot can be configured to allow to take new trades only up to a certain margin ratio (leverage) to reduce the risk of liquidation and exposure, if the margin ratio threshold, the bot will notify to add more margin into account and will not take further trade (unless it decreases post-trade margin ratio)
Strategy Parameters:
Text
|
Rage-Trade functions
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
Binance functions
- The functions below are of an older FTX arb bot. Updated code snippets coming soon....
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
TypeScript
|
Setup
- Create a sub-account on Binance, obtain credentials, and add collateral. Do not take any position manually from this sub-account. Add credentials into the config.ts file in the root directory.
- create an account on RageTrade and deposit some margin in USDC (can be done via UI) and add RPC URL, private key & rage account number in the config file.
- modify PRE_FLIGHT_CHECK checks according to your requirements of margin and minimum balance threshold.
- Edit ARB_BOT_WEBHOOK_URL in config to receive notifications for events in the discord channel.
- run yarn clean && yarn build & follow docker-compose.yml to build and deploy the container.
Precautions
- Do not use the same Binance subaccount to open/close positions manually (unless you want to withdraw completely and stop the bot). Only deposit USD as collateral.
- Do not use the same RageTrade account open/close positions manually (unless you want to withdraw completely and stop the bot).
- Use cloud service to deploy containers instead of the local environment.