A high-performance currency arbitrage detection system that identifies profitable trading opportunities across multiple currency pairs using real-time exchange rates.
- Multi-threaded Processing: Parallel analysis of currency chunks for faster detection
- Real-time Rate Fetching: Live exchange rates from ExchangeRate-API
- Bellman-Ford Algorithm: Efficient cycle detection for arbitrage opportunities
- Dual Implementation: Both C++ and Python versions available
- Configurable Parameters: Adjustable cycle lengths, thresholds, and chunk sizes
- Performance Monitoring: Detailed timing and logging of detection processes
arby/
├── cppversion/ # C++ implementation
│ ├── main.cpp # Main C++ entry point
│ ├── fetcher.cpp # API rate fetching
│ ├── fetcher.hpp # Fetcher header
│ ├── graph.cpp # Graph algorithms
│ ├── graph.hpp # Graph header
│ └── json.hpp # JSON parsing library
├── binarby.py # Python implementation
├── requirements.txt # Python dependencies
├── arbitrage.log # Execution logs
└── arbitrage_log.csv # Results data
- C++ Version: GCC with C++17 support
- Python Version: Python 3.8+ with pip
-
Clone the repository:
git clone <repository-url> cd arby
-
For Python version:
# Create virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt
-
For C++ version:
cd cppversion g++ -std=c++17 main.cpp fetcher.cpp graph.cpp -o arby -lcurl
The system uses the ExchangeRate-API for real-time exchange rates. To use real API calls:
- Get a free API key from ExchangeRate-API
- Update the
API_KEYvariable in both implementations:cppversion/main.cppbinarby.py
Note: The current implementation has a blank API key to prevent real API usage during development.
# Activate virtual environment
source venv/bin/activate
# Run the arbitrage detector
python binarby.pycd cppversion
./arby- Multi-threading: Uses
std::threadfor parallel chunk processing - Graph Algorithms: Custom implementation of Bellman-Ford for cycle detection
- Memory Efficient: Optimized data structures for large currency matrices
- Multiprocessing: Uses
multiprocessing.Poolfor parallel execution - Pandas Integration: Efficient DataFrame operations for rate calculations
- ThreadPoolExecutor: Concurrent API rate fetching
- Rate Fetching: ~sub 1 second for upto 40 currencies
- Cycle Detection: Parallel processing reduces analysis time by ~80%
- Memory Usage: Optimized for handling large currency matrices
- Accuracy: Detects arbitrage opportunities with configurable profit thresholds