Triangular arbitrage bot for Binance Spot market with userspace networking
Harjus
Ultra low latency Binance Spot Market triangular arbitrage trading bot utilizing kernel bypass.
Demo
Running v4.0.0 in Binance testnet
Development
Development is done inside a Vagrant VM accessed via VSCode Remote SSH. The VM provides a consistent development environment with all necessary dependencies pre-installed, and an extra network card to dedicate to Harjus.
vagrant up
By default, the VM is allocated 50% of your host's CPU and RAM. You can override this with environment variables:
# Allocate 8 CPUs and 16 GB RAM
VMCPUS=8 VMRAM_GB=16 vagrant up
Requirements
- VirtualBox
- Vagrant
- VSCode with Remote - SSH extension
List available commands
just
Build
# build F-Stack release (only needs to be ran once)
just fstack::release
debug build
just build
release build
just build-release
Test
just test
Run
# create .env following the sample
this is the main configuration
cp .env.sample .env
vim .env
debug build
just run
release build
just run-release
Deployment
Harjus is deployed to the availability zone closest to Binance FIX API Marked Data endpoint in AWS. This ensures the bot has the best conditions to learn about arbitrage opportunities before other participants.
Requirements
- All development requirements
- AWS CLI
- Terraform
- Ansible
- python3-botocore
- python3-boto3
List available deployment commands
just deploy
Preparation
The optimal availability zone differs for each user. Use the latency measurement utility to find out yours. See detailed instructions.
# Measure latency to find optimal availability zone
just deploy::measure-latency
create .env following the sample
this is the main configuration
cp .env.sample .env
vim .env
Deploying
# Build and package release
just build-release <architecture>
for example: just build-release icelake-server
^ this optimizes for the c6in.xlarge instance used in deployment
Package into dist/harjus.tar.gz
just package
Setup Terraform backend (run once)
just deploy::setup-backend
Setup server in the optimal availability zone (use AZ from latency measurement)
just deploy::setup-server <awsavailabilityzone>
for example: just deploy::setup-server ap-northeast-1a
Deploy (requires release package path)
just deploy::deploy <package_path>
for example: just deploy::deploy dist/harjus.tar.gz
Connect to server via SSH
just deploy::connect-server
Cleanup server
just server-cleanup
Cleanup all resources
just deploy::cleanup