{"id":25046150,"url":"https://github.com/herniqeu/graph-arbitrage","last_synced_at":"2026-02-06T02:32:33.477Z","repository":{"id":274250255,"uuid":"874364773","full_name":"herniqeu/graph-arbitrage","owner":"herniqeu","description":"arbitrage in crypto with graphs","archived":false,"fork":false,"pushed_at":"2025-01-26T01:17:06.000Z","size":188,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-20T14:37:39.906Z","etag":null,"topics":["algorithm","arbitrage","crypto","graph","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/herniqeu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T17:38:25.000Z","updated_at":"2025-07-08T10:18:49.000Z","dependencies_parsed_at":"2025-01-26T02:28:23.974Z","dependency_job_id":"a776817f-5f25-436c-8e12-5001a2717d37","html_url":"https://github.com/herniqeu/graph-arbitrage","commit_stats":null,"previous_names":["herniqeu/graph-arbitrage"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/herniqeu/graph-arbitrage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herniqeu%2Fgraph-arbitrage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herniqeu%2Fgraph-arbitrage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herniqeu%2Fgraph-arbitrage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herniqeu%2Fgraph-arbitrage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/herniqeu","download_url":"https://codeload.github.com/herniqeu/graph-arbitrage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herniqeu%2Fgraph-arbitrage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29145861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T01:13:33.096Z","status":"online","status_checked_at":"2026-02-06T02:00:08.092Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","arbitrage","crypto","graph","python"],"created_at":"2025-02-06T06:35:57.502Z","updated_at":"2026-02-06T02:32:33.458Z","avatar_url":"https://github.com/herniqeu.png","language":"Python","readme":"# Crypto Arbitrage Bot\n\n## Overview\n\nThis project implements a real-time cryptocurrency arbitrage detection and execution system. It monitors multiple cryptocurrency exchanges, identifies profitable arbitrage opportunities, and simulates their execution. The system uses websocket connections to receive live market data and employs graph theory algorithms to detect arbitrage cycles.\n\n## Features\n\n- Real-time market data collection via WebSocket\n- Arbitrage opportunity detection using the Bellman-Ford algorithm\n- Simulated arbitrage execution\n- Live dashboard for monitoring arbitrage opportunities and portfolio value\n\n## Math and Algorithms\n\n### Arbitrage Detection\n\nWe use a modified version of the Bellman-Ford algorithm to detect negative cycles in a graph representation of exchange rates. \n\n1. **Graph Representation**: Each cryptocurrency is a node, and exchange rates are weighted edges.\n\n2. **Edge Weight Calculation**: \n   For an exchange rate `r` from currency A to B, the edge weight `w` is:\n   w = -log(r)\n   This transformation allows us to use addition instead of multiplication when calculating arbitrage profits.\n\n3. **Bellman-Ford Algorithm**: We run V-1 iterations (where V is the number of vertices) of the following relaxation step:\n\n```\nfor each edge (u, v) with weight w:\n  if distance[u] + w \u003c distance[v]:\n    distance[v] = distance[v] + w\n```\n\nIf after these iterations we can still relax an edge, we have found a negative cycle, which represents an arbitrage opportunity.\n\n4. **Profit Calculation**: For a cycle `c` of currencies `[c₁, c₂, ..., cₙ, c₁]`, the profit `p` is:\n\np = (r₁₂ * r₂₃ * ... * rₙ₁) - 1\n\nwhere `rᵢⱼ` is the exchange rate from currency `i` to `j`.\n\n### Arbitrage Execution Simulation\n\nThe simulation assumes instant execution and no transaction fees. For each arbitrage opportunity:\n\n1. Calculate the profit percentage `p`.\n2. Update the simulated balance `B`:\nB_new = B * (1 + p)\n\n## Setup and Running\n\n1. Clone the repository\n2. Install dependencies: `pip install -r requirements.txt`\n3. Set up your `.env` file with necessary configurations\n4. Run the application: `python app/main.py`\n\n## Configuration\n\nKey configuration options in `.env`:\n\n- `INITIAL_BALANCE`: Starting balance for simulation\n- `MAX_ARBITRAGE_PROFIT`: Maximum allowed profit for an arbitrage opportunity\n- `ARBITRAGE_CHECK_INTERVAL`: Time between arbitrage checks\n- `BINANCE_API_KEY` and `BINANCE_API_SECRET`: Your Binance API credentials\n\n## Dashboard\n\nThe dashboard displays:\n- Current simulated balance\n- Portfolio value over time\n- Top 5 current arbitrage opportunities\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fherniqeu%2Fgraph-arbitrage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fherniqeu%2Fgraph-arbitrage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fherniqeu%2Fgraph-arbitrage/lists"}