Skip to main content

ohlcv_ctl/
lib.rs

1#![allow(clippy::doc_markdown, clippy::multiple_crate_versions)]
2//! # ohlcv-ctl
3//!
4//! ## Status
5//!
6//! ![Build Status](https://img.shields.io/github/actions/workflow/status/typedduck/ohlcv/rust.yml)
7//! [![Crates.io](https://img.shields.io/crates/v/ohlcv-ctl)](https://crates.io/crates/ohlcv-ctl)
8//! [![Crates.io](https://img.shields.io/crates/d/ohlcv-ctl)](https://crates.io/crates/ohlcv-ctl)
9//!     
10//! - [x] Initialize the database schema, command `init`.
11//! - [x] Drop the database schema, command `drop`.
12//! - [ ] Download historical OHLCV data, command `fetch`.
13//! - [ ] Export the data to a CSV or JSON file, command `export`.
14//! - [ ] Import the data from a CSV or JSON file, command `import`.
15//!
16//! ## Overview
17//!
18//! `ohlcv-ctl` is a command line tool to interact with the ohlcv library. It
19//! provides the following functionality:
20//!
21//! - Download historical OHLCV data from various cryptocurrency exchanges.
22//! - Export the data to a CSV file.
23//! - Initialize the database schema.
24//! - Drop the database schema.
25//!
26//! The `fetch` command is used to download historical OHLCV data from various
27//! cryptocurrency exchanges. The data is downloaded in a 5-minute interval of
28//! the previous day, resulting in 288 candles per day. The candles are
29//! aggregated in the database to form larger candles, such as 15-minute,
30//! 1-hour, 4-hour, and 1-day candles.
31//!
32//! The data can be downloaded for multiple trading pairs and multiple exchanges
33//! at the same time. The data is downloaded in parallel to speed up the
34//! process. Care is taken to avoid rate limiting and to handle errors
35//! gracefully.
36//!
37//! To get a consistent time-series of the data, the command line tool must be
38//! run at least once a day. The tool will download the data for the previous
39//! day and aggregate it in the database. If the tool is run more than once a
40//! day, it will only download the missing trading pairs. All times are in UTC
41//! only.
42//!
43//! The `init` command is used to initialize the database schema. The schema
44//! includes tables for the candles of the trading pairs.
45//!
46//! The `drop` command is used to drop the database schema. This will remove the
47//! tables and data from the database of the defined trading pairs. If the
48//! `--all` option is used, all tables for all coins will be removed.
49//!
50//! ## Configuration
51//!
52//! The command line interface uses a configuration file to specify the database
53//! and exchange settings. The configuration file is in TOML format and has the
54//! following structure:
55//!
56//! ```toml
57//! # If user_agent is not set, the default user agent `ohlcv-ctl/<version>`
58//! # will be used.
59//! user_agent = "<optional user-agent>"
60//!
61//! [database]
62//! type = "mysql"
63//! address = "localhost"
64//! database = "ohlcv"
65//! username = "<ohlcv user>"
66//! password = "<secret password>"
67//!
68//! [[coins]]
69//! name = "Bitcoin"
70//! symbol = "BTC"
71//! currency = "USD"
72//! exchanges = { "Binance" = "BTCUSDC" }
73//! ```
74//!
75//! See the implementation of the database configuration for more details about
76//! the fields in the `OHLCV` crate.
77
78mod cli;
79pub use cli::{clargs, command};
80
81pub mod config;
82
83mod error;
84pub use error::Error;