Skip to content

Instantly share code, notes, and snippets.

@bludnic
Last active August 30, 2024 20:44
Show Gist options
  • Save bludnic/ff7382161eba157f9057d95ebaa5566f to your computer and use it in GitHub Desktop.
Save bludnic/ff7382161eba157f9057d95ebaa5566f to your computer and use it in GitHub Desktop.
OpenTrader Bot Architecture Overview

OpenTrader Bot Architecture Overview

Base Packages

These packages can be imported everywhere

  • types: Defines types and interfaces used in the whole project.
  • db, prisma: Manages the database schema, migrations, and custom Prisma models.
  • logger: Provides a logger instance.
  • tools: Includes utilities for grid calculations, price/balance formatting, and candlestick analysis.

Bot Functionality Packages

  • bot-templates: Contains strategies logic. Each strategy is a separate file. Includes predefined strategies like GRID strategy and RSI strategy.
  • bot-processor: It’s a strategy runner, which is responsible for executing a strategy and handling commands such as placing and canceling orders.
  • bot-backtesting: Offers functionality for backtesting a strategy.

Service packages

There are independent packages that may be later published on NPM

  • exchanges: Contains exchange connectors with an unified API. It uses CCXT under the hood.
  • indicators: Calculates technical analysis (TA) indicators. Currently supports only RSI indicator.

Application Logic Packages

  • bot-store: Global state manager for storing market data such as candles, order books, and public trades, which are used later to feed a strategy.
  • event-bus: Event emitter for bot lifecycle (created, started, stopped)
  • processing: Handles trade execution, including placing orders, refreshing statuses, and canceling orders.
  • trpc: Provides API endpoints for managing bots and exchange accounts.
  • bot, daemon: Bootstraps the bot, subscribes to public and private channels via WebSockets. Starts a web server to expose tRPC endpoints. Subscribes to the EventBus for reacting to events like bot creation, bot started, and bot stopped.

High-Order Packages

  • apps/cli: Provides CLI commands for managing the bot
  • frontend: Contains the UI for managing multiple bots.

Currently, the frontend resides in a private repo until I decide on the license and funding strategy. For early adopters, I will offer lifetime access to the frontend for free.

Everything is bundled toghether and published on NPM as opentrader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment