This page describes how to install the environment to run the robot. You mainly need to prepare the following parts:
- TimeScaleDB: a high-performance time series database based on postgresql, used to store candles, orders and so on.
- golang: it is recommended to use the latest version
Banbot supports the high-performance indicator library banta out of the box, and you can quickly develop custom indicators based on it.
Install TimeScaleDB database
It is recommended to install the latest stable version according to the official documentation:
- Installation in linux
- Installation in MacOS
- Installation in Windows
- Installation using Docker
Docker installation tips
When executing docker run, please add the
-v /your/data/dir:/home/postgres/pgdata/data
parameter to map the data to the host directory.
Set TimeZone
All timestamps in Banbot are in UTC time zone, and it is also necessary to set them to UTC time zone in Timestampdb.
You can use a text editor to open the configuration file for PostgreSQL:
/var/lib/pgsql/<version>/data/postgresql.conf
/etc/postgresql/<version>/main/postgresql.conf
/usr/local/pgsql/data/postgresql.conf
C:\Program Files\PostgreSQL\<version>\data\postgresql.conf
/usr/local/var/postgres/postgresql.conf
Change the timezone
to UTC
:
timezone = 'UTC'
Restarting PostgreSQL service takes effect:
sudo systemctl restart postgresql
# press Win + R, input: services.msc
# find `postgresql` and restart it
brew services restart postgresql
Initialize the table structure
Download the sql file, unzip it and prepare for execution.
Use the psql
tool to log in to the database
psql -d "postgres://<username>:<password>@<host>:<port>"
Then create the database and execute the SQL file:
CREATE database bantd;
\c bantd -- switch active database
\i /path/to/schema.sql
\i /path/to/schema2.sql
Docker Tips
If you use docker to start TimeScaleDB, please put the two decompressed sql files in the host root directory of -v
. Then execute the following command to open psql
:
docker exec -it timescaledb psql -U postgres -h localhost
The sql file path for -i
should be /home/postgres/pgdata/data/schema.sql
Check if TimestampcaleDB is installed:
\dx
You’ll see a list of installed extensions:
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+---------------------------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | 2.15.1 | public | Enables scalable inserts and complex queries for time-series data (Community Edition)
Install golang
Please download and install from the official golang website (https://go.dev/doc/install)
You can use Visual Studio Code
or GoLand
as the development IDE