diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6cb43b2..806e910f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Requirements ```bash -# NodeJS v18 or higher +# NodeJS v20 or higher $ node -v # `pnpm` must be installed @@ -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 @@ -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) diff --git a/README.md b/README.md index 78d24b2d..3147f827 100644 --- a/README.md +++ b/README.md @@ -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 ``` -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. @@ -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 --from --to -t ` +Command: `opentrader backtest --from --to -t ` 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 ` +Command: `opentrader trade ` 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 contact@opentrader.pro - -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