https://github.com/robertmartin8/cryptographarb
Using graph algorithms to find arbitrage opportunities
https://github.com/robertmartin8/cryptographarb
arbitrage cryptocurrency graphs trading
Last synced: 4 months ago
JSON representation
Using graph algorithms to find arbitrage opportunities
- Host: GitHub
- URL: https://github.com/robertmartin8/cryptographarb
- Owner: robertmartin8
- License: mit
- Created: 2019-06-26T03:06:18.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-14T15:18:23.000Z (over 6 years ago)
- Last Synced: 2025-08-21T02:43:38.661Z (10 months ago)
- Topics: arbitrage, cryptocurrency, graphs, trading
- Language: Python
- Size: 41 KB
- Stars: 183
- Watchers: 8
- Forks: 52
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# CryptoGraphArb

This is the supporting code for my [post](https://reasonabledeviations.com/2019/04/21/currency-arbitrage-graphs-2/) on using graph theory to discover arbitrage opportunities in a cryptocurrency market.
## Getting started
To run it, first sign up to [CryptoCompare](https://min-api.cryptocompare.com/) to get a free API key. Then, you can either replace it after the equals sign at the top of `cryptocompare_scraper.py`, or create a new text file named `API_KEY.txt` and paste it there directly.
Then, install dependencies with:
```bash
pip install -r requirements.txt
```
Lastly, run the code:
```bash
python cryptocompare_scraper.py
python graph_arbitrage.py
```
## Overview
- `cryptocompare_scraper.py` downloads the raw data, creating `pairs_list.json`, `binance_data/` and `snapshot.csv`.
- `graph_arbitrage.py` processes this data and puts it into a graph, before running Bellman-Ford to find arbitrage opportunities.
## Your turn
Here's a brief list of a few ways that you could extend this project. Some are trivial, some are not!
- Model transaction fees. This is literally one line of code, multiplying the arbitrage value by e.g 0.999 for each element in the path.
- Download data from more exchanges. `graph_arbitrage.py` operates completely independently of the data collection, it just needs an adjacency matrix.
- Automatically run the code at fixed intervals to continuously look for arbitrage.
- Modify the Bellman-Ford so that it doesn't have to recompute everything when some weights change.