ohlcv-ctl

Crates.ioohlcv-ctl
lib.rsohlcv-ctl
version0.0.3
sourcesrc
created_at2024-08-27 08:47:05.51364
updated_at2024-08-27 12:44:10.789384
descriptionData collector library for fetching, analyzing, predicting and charting time series data (OHLC) of cryptocurrencies from various exchanges
homepagehttps://github.com/typedduck/ohlcv
repositoryhttps://github.com/typedduck/ohlcv
max_upload_size
id1353062
size95,630
Marc H. Göldner (typedduck)

documentation

README

OHLCV Command Line Interface

Build Status Crates.io Crates.io

The OHLCV command line interface is a tool for downloading historical OHLCV (Open, High, Low, Close, Volume) data from various cryptocurrency exchanges.

The functionality provided by the command line interface is implemented in the OHLCV library.

Status

This project is in the early stages of development and is not yet ready for production use.

  • Initialize the database schema, command init.
  • Drop the database schema, command drop.
  • Download historical OHLCV data, command fetch.
  • Export the data to a CSV or JSON file, command export.
  • Import the data from a CSV or JSON file, command import.

Command Line Interface

The command line interface provides the following functionality:

  • Download historical OHLCV data from various cryptocurrency exchanges.
  • Export the data to a CSV file.
  • Initialize the database schema.
  • Drop the database schema.
Usage: ohlcv-ctl [COMMAND]

Commands:
  init   Initialize the database tables
  drop   Remove the database tables
  fetch  Fetch data from the origin
  help   Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

The fetch command is used to download historical OHLCV data from various cryptocurrency exchanges. The data is downloaded in a 5-minute interval of the previous day, resulting in 288 candles per day. The candles are aggregated in the database to form larger candles, such as 15-minute, 1-hour, 4-hour, and 1-day candles.

The data can be downloaded for multiple trading pairs and multiple exchanges at the same time. The data is downloaded in parallel to speed up the process. Care is taken to avoid rate limiting and to handle errors gracefully.

To get a consistent time-series of the data, the command line tool must be run at least once a day. The tool will download the data for the previous day and aggregate it in the database. If the tool is run more than once a day, it will only download the missing trading pairs. All times are in UTC only.

Usage: ohlcv-ctl fetch [OPTIONS]

Options:
  -c, --config <FILE>  optional path to the configuration file
  -h, --help           Print help

The init command is used to initialize the database schema. The schema includes tables for the candles of the trading pairs.

Usage: ohlcv-ctl init [OPTIONS]

Options:
  -c, --config <FILE>  optional path to the configuration file
  -h, --help           Print help

The drop command is used to drop the database schema. This will remove the tables and data from the database of the defined trading pairs. If the --all option is used, all tables for all coins will be removed.

Usage: ohlcv-ctl drop [OPTIONS]

Options:
  -a, --all            remove tables for all coins
  -c, --config <FILE>  optional path to the configuration file
  -h, --help           Print help

Configuration

The command line interface uses a configuration file to specify the database and exchange settings. The configuration file is in TOML format and has the following structure:

# If user_agent is not set, the default user agent `ohlcv-ctl/<version>` will be
# used.
user_agent = "<optional user-agent>"

[database]
# The type of the database. Supported types are `mysql`, `postgres` and
# `sqlite`. Which are available depends on the features enabled during
# compilation.
type = "mysql"
host = "localhost"
database = "ohlcv"
username = "<ohlcv user>"
password = "<secret password>"

[[coins]]
name = "Bitcoin"
symbol = "BTC"
currency = "USD"
exchanges = { "Binance" = "BTCUSDC" }

See the implementation of the database configuration for more details about the fields in the OHLCV crate.

Commit count: 0

cargo fmt