nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
1.71k stars 402 forks source link

Nautilus CLI #1602

Closed filipmacek closed 2 months ago

filipmacek commented 2 months ago

Pull Request

Demo

Screenshot 2024-04-21 at 12 36 16

Steps to reproduce and try

Services

You can use docker-compose.yml file located in .docker directory to bootstrap the Nautilus working environment. This will start the following services:

docker-compose up -d

If you only want specific services running (like postgres for example), you can start them with command:

docker-compose up -d postgres

Used services are:

Note: Please use this as development environment only. For production, use a proper and more secure setup. After the services has been started, you must login with psql cli to create nautilus Postgres database. To do that you can run, and type POSTGRES_PASSWORD from docker service setup

psql -h localhost -p 5432 -U postgres

After you have long as postgres administrator, run CREATE DATABASE command with target name( we use nautilus):

psql (16.2, server 15.2 (Debian 15.2-1.pgdg110+1))
Type "help" for help.
postgres=# CREATE DATABASE nautilus;
CREATE DATABASE

Nautilus CLI Developer Guide

Introduction

The Nautilus CLI is a command-line interface tool designed to interact with the Nautilus Trader ecosystem. It provides commands for managing the Postgres database and other trading operations.

Note: The Nautilus CLI command is only supported on UNIX-like systems.

Install

You can install nautilus cli command with from Make file target, which will use cargo install under the hood. And this command will install nautilus bin executable in your path if Rust cargo is properly configured.

make install-cli

Commands

You can run nautilus --help to inspect structure of CLI and groups of commands:

Database

These are commands related to the bootstrapping the Postgres database. For that you work, you need to supply right connection configuration. You can do that through command line arguments or .env file in the root directory or where the commands is being run.

Example of .env file

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USERNAME=postgres
POSTGRES_DATABASE=nautilus
POSTGRES_PASSWORD=pass

List of commands are:

  1. nautilus database init - it will bootstrap schema, roles and all sql files located in schema root directory (like tables.sql)
  2. nautilus database drop - it will drop all tables, role and data in target Postgres database
cjdsellers commented 2 months ago

Awesome stuff :rocket:.