Command-line application which can dynamically fetch, analyze and chart multiple blockchains and markets for arbitrage oportunities for liquidity pairs between different exhanges. For example, the Binance chain, looking at BNBBUSD
on ApeSwap and PancakeSwap.
See installation guide below for specifics on setting up your environment.
This proect uses python 3.7 and the following modules:
Built-in modules:
From pip:
Self-authored:
- dextrader.nomics.pairs Market/pair config data
- dextrader.nomics.utils Nomics API utilities
- analysis.py Analysis functionality
- visuals.py Visualization funcationality
Main CLI Application
See installation guide below for specifics on setting up your environment.
/src
with API_KEY = "{YOUR_KEY}"
inside. Also, search for NOMICS-API uncomment
in client.py
and uncomment the line below to use the API key.
You will need Python 3.7 for this application to run. An easy way to install python 3.7 is to download and install Anaconda. After installing anaconda, open a terminal/command-prompt, and setup a python 3.7 environment, and then activate it like so:
# creating a python 3.7 environment
# name can be any friendly name to refer to your environment, eg 'dev'
conda create --name dev python=3.7 anaconda
# activating the environment
conda activate dev
Next, use pip to install the required modules from the list above
# instaling required modules
$ pip install fire
$ pip install questionary
$ etc...
You are now ready to run the program!
First, ensure you've cloned this repo and setup your environment as detailed in the Installation Guide
Next, open a terminal and cd to the src
directory. You will run the client.py
file, and follow the prompts to:
- choose a chain
- choose a pair to analyze
- choose to update (re)fresh data
- run analysis
- run vizualizations
The final screen output will be both a text-based summary of the arbitrage.
# running the application
cd <path_to_repo>/src/
# launch the app and follow the cli
python client.py
You can ensure your setup is working by running any of the _tests.py files from within src.
from dextrader.nomics.utils import get_candles, format_query_as_dataframe, get_recent_trades
Nomics utils has the functions for scraping nomics data via their api, please see the nomics_test.py file for examples.
There is a bug where if you try and re-use old-csv data from before today, the filter may not pick it up and you will get an empty analysis or crash. If so, just be sure to refresh data for your selected pair, and re-run. If you have existing csv data from earlier today, everything will work. Will be fixed in next version.
Nomics candle data for 1 minute intervals was used for a 24 hr period to simplify the arbitrage analysis between two markets.
Both an optimistic analysis, using the closed prices for each candle minute, as well as a more conservative / worst-case analysis that was done to try and increase the likelihood of having a profitable arbitrage trade opportunity. Examples below
Any new chains, markets, pairs can be entered into the pairs config module and will be dynamically fetched based on user choice with the application.
The arbitrage tool is able to update and analyze market pair data across multiple exchanges on a given chain. For each selected pair, the arbitrage opportunities are calculated across the combinations of all exchanges available. Then, both a textual summary and a set of three plots, an interactive Arbitrage Spread
, a 1-min Candle
, and Trade Volume
views are presented to the user.
Below is an example of the summary and three plots, for an analysis on the Avalanche
chain for AVAXUSDT
pair. You can see that each exchange pair indeed yeilds different levels of arbitrage potential.
Chain / Pair | Exchanges | Profitable Opportunties (worst case) | Profitable Opportunties (closing prices) |
---|---|---|---|
Avalanche / AVAXUSDT | pangolin v sushiswap_avalanche | 7 | 12 |
Avalanche / AVAXUSDT | pangolin v traderjoe | 0 | 5 |
Avalanche / AVAXUSDT | sushiswap v traderjoe | 3 | 23 |
Profitable Trades Summary (textual): AVAXUSDT Summary (Pangolin v Sushiswap)
Spread Plot -- (note opportunities above red threshold line)
Peter Morales
Shivangi Gupta
Jaime Aranda
David Lopez
MIT