Skip to content

vedanthnyk25/triangle_arbitrage

Repository files navigation

TRIB APEX ENGINE ⚡

Trib Apex Dashboard

Distributed High-Frequency Triangular Arbitrage System

Go Next.js Redis Docker

📖 Overview

TRIB APEX is a high-performance, event-driven trading engine designed to identify and exploit market inefficiencies in the cryptocurrency market. It models currency pairs as a directed weighted graph and utilizes a modified Bellman-Ford algorithm to detect negative cycles (arbitrage opportunities) in real-time.

Unlike simple bots, TRIB functions as a distributed system. It decouples high-throughput data ingestion from analysis and execution using Redis as an atomic message broker, ensuring the UI remains responsive without adding latency to the trading engine.

🚀 Key Features

🧠 The Core Engine (Golang)

  • Graph Theory Implementation: Models 20+ currency pairs (USDT, BTC, ETH, SOL, BNB, etc.) as nodes in a dynamic graph.
  • O(V·E) Algo: Runs concurrent Bellman-Ford algorithms to detect profit loops (e.g., USDT -> SOL -> BTC -> USDT) in sub-millisecond time.
  • Smart Math: Converts exchange rates to negative logarithms (-log(price)) to transform the "maximize product" problem into a "shortest path" problem.
  • Fee Awareness: Automatically deducts exchange fees (0.1%) during path calculation to prevent slippage losses.

⚡ Real-Time Infrastructure

  • Atomic Pipeline: Uses Redis Lists and Pub/Sub to handle state management, ensuring thread-safe operations between the Engine and the API.
  • WebSocket Ingestion: Consumes raw @bookTicker streams from Binance for the absolute latest bid/ask data.
  • Fault Tolerance: Dockerized microservices with strict healthcheck dependencies ensure the system self-recovers.

📊 Mission Control (Next.js 14)

  • Live Visualizer: Custom SVG components animated with Framer Motion to visualize the active search path and return rates.
  • Zero-Latency Feed: Uses optimized polling hooks to display trade executions the millisecond they are processed by the engine.
  • Cyberpunk UI: A sleek, "Linear-style" dark mode interface built with TailwindCSS and Shadcn/UI.

🛠 Tech Stack

Component Technology Description
Engine Go (Golang) High-concurrency processing, WebSocket handling, Graph algos.
API Go (Fiber) Fast HTTP layer to expose Redis data to the frontend.
Database Redis (Alpine) In-memory message broker, state store, and atomic locking.
Frontend Next.js 14 App Router, TypeScript, Server Components.
Styling TailwindCSS With clsx, tailwind-merge, and Shadcn/UI components.
Animation Framer Motion Complex SVG path animations and layout transitions.
DevOps Docker Compose Multi-container orchestration with health checks.

📐 System Architecture

graph TD
    WS[Binance WebSocket] -->|Ticks| GE[Go Engine]
    GE -->|Update Weights| Graph[In-Memory Graph]
    Graph -->|Bellman-Ford| Detect{Negative Cycle?}
    Detect -->|Yes| Exec[Execute Trade]
    Exec -->|Push Data| Redis[(Redis)]
    
    Redis -->|Read State| API[Go Fiber API]
    API -->|JSON| Client[Next.js Dashboard]


##     
Loading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published