bludnic / opentrader

Open-source crypto trading bot
https://opentrader.dev
Apache License 2.0
3 stars 2 forks source link
bot cryptocurrency custom-strategy dca-bot grid-bot rsi-strategy technical-indicators

OpenTrader logo

GitHub Actions Workflow Status GitHub commit activity Static Badge

OpenTrader is an advanced cryptocurrency trading bot offering high-frequency, cross-exchange arbitrage and event-based strategies, including technical analysis with indicators. Features a user-friendly management UI, robust backtesting capabilities, and support for 100+ exchanges via CCXT.

Strategies:

Supported exchanges: OKX, BYBIT, BINANCE, KRAKEN, COINBASE, GATEIO

Quick start

Requirements

# NodeJS v18 or higher
$ node -v

# `pnpm` must be installed
$ pnpm -v

# Install Turborepo globally
$ pnpm install turbo --global

# Docker (optional)
$ docker -v

Environment variables

The project uses a single .env file in the root directory. Frameworks such as Next.js require the .env file to be located directly in the project directory. To address this, some apps/packages might include a symlink pointing to the root .env file.

  1. Create environment file .env in the root directory
$ cp .env.example .env
  1. Replace the DATABASE_URL if your URL is different from the actual one.

Installation

  1. Install dependencies
$ pnpm install
  1. Build /packages/**
$ turbo run build --filter='./packages/*'
  1. Run db migrations
$ turbo run prisma:migrate
  1. Seed the database
$ turbo run prisma:seed

⚠️ Note: Since the packages do not have a dev server, running the build command is mandatory on the first run.

Basic usage

Connect an exchange

Copy the exchanges.default.json5 file to exchanges.dev.json5 and add your API keys.

Supported exchanges: OKX, BYBIT, BINANCE, KRAKEN, COINBASE, GATEIO

Choose a strategy

Create the strategy configuration file config.dev.json5. We will use the grid strategy as an example.

{
  // Grid strategy params
  settings: {
    highPrice: 70000, // upper price of the grid
    lowPrice: 60000, // lower price of the grid
    gridLevels: 20, // number of grid levels
    quantityPerGrid: 0.0001, // quantity in base currency per each grid
  },
  pair: "BTC/USDT",
  exchange: "DEFAULT",
}

Currently supported strategies: grid, rsi

Run a backtest

Command: pnpm opentrader backtest <strategy> --from <date> --to <date> -t <timeframe>

Example running a grid strategy on 1h timeframe.

$ pnpm opentrader backtest grid --from 2024-03-01 --to 2024-06-01 -t 1h

To get more accurate results, use a smaller timeframe, e.g. 1m, however, it will take more time to download OHLC data from the exchange.

Live trading

Command: pnpm opentrader trade <strategy>

Example running a live trading with grid strategy.

$ pnpm opentrader trade grid

After Ctrl+C, the orders created by the bot will remain on the exchange. To cancel them, use the pnpm opentrader stop command.

UI

The user interface allows managing multiple bots and strategies, viewing backtest results, and monitoring live trading.

UI Preview

Currently, the UI is under development. For early access, please email me at contact@opentrader.pro

After getting the access, run the following command to pull the UI into monorepo:

$ git submodule update --init

Run frontend app:

$ pnpm i
$ turbo run build --filter='./packages/*'
$ turbo run dev

Project structure

🪪 License

Licensed under the Apache 2.0 License. See the LICENSE file for more information.