Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Jul 17, 2024
1 parent d528258 commit ee452aa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 122 deletions.
35 changes: 8 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Requirements

```bash
# NodeJS v18 or higher
# NodeJS v20 or higher
$ node -v

# `pnpm` must be installed
Expand All @@ -26,32 +26,7 @@ To solve this some apps/packages may contain a symlink to the root `.env`.
$ cp .env.example .env
```

2. Replace the `DATABASE_URL` if your URL is different from the actual one.

> 💡 **Tip**: You can run PostgreSQL inside a Docker container with `docker compose up -d database`. See details below.
# Docker (optional)

1. If you want to use PostgreSQL within a Docker container use the following commands:

```bash
$ docker compose up -d database # start service
$ docker compose stop database # stop service
```

2. Or, if you are using WebStorm, just open `docker-compose.yml` and click ▶️ near the service name.

# Processing app (optional)

The `apps/processor` is a separate NodeJS app that synchronizes orders with the Exchange faster by using WebSockets.

Features:

- Sync orders statuses with the Exchange by using WebSockets
- Fallback to REST API by polling every 60s
- Runs the bot template if any order was filled
- Place pending orders on the Exchange
- Async queue (in case two or more orders were filled at the same time)
2. Update the `ADMIN_PASSWORD`. The password is required to authorize later in the Opentrader UI.

# Installation

Expand Down Expand Up @@ -111,3 +86,9 @@ $ pnpm run dev

- Frontend: http://localhost:3000
- Processor: http://localhost:4000

# Project structure

- Strategies dir: [packages/bot-templates](/packages/bot-templates/src/templates)
- Indicators: [packages/indicators](/packages/indicators/src/indicators)
- Exchange connectors: [packages/exchanges](/packages/exchanges/src/exchanges)
123 changes: 28 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,55 @@
- [x] [RSI](packages/bot-templates/src/templates/rsi.ts): A Relative Strength Index (RSI) strategy that buys and sells based on the RSI indicator.
- [ ] `DCA`: Dollar-Cost Averaging (DCA) strategy that buys an asset at regular intervals.

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

# Quick start

## Requirements

```bash
# NodeJS v20 or higher
$ node -v
Get started with OpenTrader in just a few steps. Follow this quick guide to install, configure, and run your crypto trading bot.

# `pnpm` must be installed
$ pnpm -v
## Installation

# Install Turborepo globally
$ pnpm install turbo --global
Install OpenTrader globally using npm:

# Docker (optional)
$ docker -v
```bash
npm install -g opentrader
```

## Environment variables
## Configuration

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
Set an admin password for later accessing the OpenTrader UI:

```bash
$ cp .env.example .env
opentrader set-password <password>
```

2. Replace the `DATABASE_URL` if your URL is different from the actual one.

## Installation
## Running the app

1. Install dependencies
Start the OpenTrader:

```bash
$ pnpm install
opentrader up
```

2. Build packages

```bash
$ turbo run build
```
The app will start the RPC server and listen on port 8000.

3. Run db migrations
> **Tip**: Use `opentrader up -d` to start the app as a daemon. To stop it, run `opentrader down`.
```bash
$ turbo run prisma:migrate
```
# Usage

4. Seed the database
## UI

```bash
$ turbo run prisma:seed
```
The user interface allows managing multiple bots and strategies, viewing backtest results, and monitoring live trading.

> ⚠️ **Note**: Since the packages do not have a dev server, running the `build` command is mandatory on the first run.
You can access the OpenTrader UI on: http://localhost:8000

# Basic usage
## CLI

## Connect an exchange
### Connect an exchange

Copy the `exchanges.sample.json5` file to `exchanges.json5` and add your API keys.

> Supported exchanges: OKX, BYBIT, BINANCE, KRAKEN, COINBASE, GATEIO
> Available exchanges: OKX, BYBIT, BINANCE, KRAKEN, COINBASE, GATEIO
## Choose a strategy
### Choose a strategy

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

Expand All @@ -106,76 +84,31 @@ Create the strategy configuration file `config.json5`. We will use the `grid` st

> Currently supported strategies: `grid`, `rsi`
## Run a backtest
### Run a backtest

Command: `./bin/cli.sh backtest <strategy> --from <date> --to <date> -t <timeframe>`
Command: `opentrader backtest <strategy> --from <date> --to <date> -t <timeframe>`

Example running a `grid` strategy on `1h` timeframe.

```bash
$ bin/cli.sh backtest grid --from 2024-03-01 --to 2024-06-01 -t 1h
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

## Starting the daemon

Before running live trading, you need to start the daemon:

```bash
$ bin/cli.sh up
```

Now the daemon is ready to listen for incoming commands.

> Tip: To run the daemon in the background, use: `bin/cli.sh up -d`
### Live trading

## Running a Live Trading

Command: `bin/cli.sh trade <strategy>`
Command: `opentrader trade <strategy>`

Example running a live trading with `grid` strategy.

```bash
$ bin/cli.sh trade grid
```

> To stop the live trading, run `bin/cli.sh stop`
## Stop the daemon

To stop the daemon, run the following command:

```bash
$ bin/cli.sh down
```

# UI

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

![UI Preview](.github/images/ui.png)

Currently, the UI is under development. For early access, please email me at [email protected]

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

```shell
$ git submodule update --init
```

Run frontend app:

```shell
$ pnpm i
$ turbo run build
$ turbo run dev
$ opentrader trade grid
```

- Frontend: http://localhost:3000
- API: http://localhost:4000
> To stop the live trading, run `opentrader stop`
# Project structure

Expand Down

0 comments on commit ee452aa

Please sign in to comment.