https://github.com/afnanenayet/forex-arbitrage
Detect arbitrage opportunities with FOREX pricing data. Written in Rust.
https://github.com/afnanenayet/forex-arbitrage
arbitrage forex pricing rust
Last synced: 4 months ago
JSON representation
Detect arbitrage opportunities with FOREX pricing data. Written in Rust.
- Host: GitHub
- URL: https://github.com/afnanenayet/forex-arbitrage
- Owner: afnanenayet
- License: bsd-2-clause
- Created: 2019-05-05T05:58:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-21T22:11:35.000Z (almost 3 years ago)
- Last Synced: 2025-08-04T00:24:11.228Z (10 months ago)
- Topics: arbitrage, forex, pricing, rust
- Language: Rust
- Homepage:
- Size: 142 KB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: docs/README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# forex arbitrage
## Summary
This program is a proof of concept showing how you can detect arbitrage
opportunities using forex pricing data. It uses pricing data from
exchangeratesapi.io (free) to acquire the pricing data.
The data is taken and converted into a graph, with the weights being the
negative logarithm of the pricing data. The negative log is taken because I am
using the Bellman-Ford algorithm to detect arbitrage opportunities. The
Bellman-Ford algorithm detects negative cycles, but we want a situation where
the pricing data leads to a _positive_ cycle of prices, such that we can start
at some currency X, and perform some set of currency conversions such that we
end up at currency X, but with more money than we started from.
Because the Bellman-Ford algorithm adds weights, we need to figure out some
transformation that allows us to use addition to find a positive weight cycle.
We know that `log(a) + log(b) = log(a * b)`, which takes care of the addition
problem. Using `-log(x)` lets us turn positive cycles into negative ones, which
means that we can detect arbitrage opportunities by finding a negative cycle in
a graph.
## Usage
The program saves the generated conversion rate graph as a json file. You can
change the name of the json file from the default naming scheme using the `-o`
flag. You can also elect to load pricing data from a json file using the `-i`
flag, if you're just messing around or debugging and don't need the most recent
data.
## Development
Compile this program with:
```sh
cargo build
# or
cargo build --release
```
All files are formatted using `rustfmt`.