diff --git a/CHANGELOG.md b/CHANGELOG.md index 593e6cb3..4e0db7eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,10 +39,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Community health files: `CONTRIBUTING.md`, `SECURITY.md`, `CODE_OF_CONDUCT.md`, issue / pull-request templates, `CODEOWNERS`, and a Dependabot configuration. -- Seven example OHLCV datasets under `crates/wickra/examples/data/`, one per - timeframe (1m / 5m / 15m / 1h / 12h / 1d / 1month), holding real BTCUSDT - spot klines, alongside the `fetch_btcusdt` example that regenerates them - from the Binance REST API. +- Seven example OHLCV datasets under `examples/data/`, one per timeframe + (1m / 5m / 15m / 1h / 12h / 1d / 1month), holding real BTCUSDT spot klines, + alongside the `fetch_btcusdt` example that regenerates them from the + Binance REST API. - `Timeframe::minutes`, `Timeframe::hours` and `Timeframe::days` convenience constructors, each building on seconds with a checked-multiplication overflow guard. diff --git a/bindings/node/examples/backtest.js b/bindings/node/examples/backtest.js index 0cd192a5..18a09a2b 100644 --- a/bindings/node/examples/backtest.js +++ b/bindings/node/examples/backtest.js @@ -26,15 +26,13 @@ const wickra = require('..'); // every one of them (any extra columns are ignored). const REQUIRED_COLUMNS = ['timestamp', 'open', 'high', 'low', 'close', 'volume']; -// Default dataset: the checked-in BTCUSDT daily candles under -// crates/wickra/examples/data/, resolved relative to this file. +// Default dataset: the checked-in BTCUSDT daily candles under the workspace +// `examples/data/` directory, resolved relative to this file. const DEFAULT_CSV = path.join( __dirname, '..', '..', '..', - 'crates', - 'wickra', 'examples', 'data', 'btcusdt-1d.csv', diff --git a/crates/wickra/benches/indicators.rs b/crates/wickra/benches/indicators.rs index 2d4ff904..748ed93b 100644 --- a/crates/wickra/benches/indicators.rs +++ b/crates/wickra/benches/indicators.rs @@ -6,14 +6,14 @@ //! ``` //! //! Each benchmark feeds real BTCUSDT 1-minute candles — read from the -//! checked-in dataset `examples/data/btcusdt-1m.csv` — through both the -//! streaming (`update` loop) and batch APIs of an indicator. Sizes cover -//! small (1 000), medium (10 000), and large (50 000) workloads, taken as -//! prefixes of that dataset. +//! checked-in dataset at the workspace `examples/data/btcusdt-1m.csv` — +//! through both the streaming (`update` loop) and batch APIs of an +//! indicator. Sizes cover small (1 000), medium (10 000), and large +//! (50 000) workloads, taken as prefixes of that dataset. //! //! Regenerate the dataset with: //! ```text -//! cargo run -p wickra --example fetch_btcusdt +//! cargo run -p wickra-examples --bin fetch_btcusdt //! ``` use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; @@ -26,13 +26,17 @@ use wickra_data::csv::CandleReader; /// Workload sizes, in candles. Each is taken as a prefix of the dataset. const SIZES: &[usize] = &[1_000, 10_000, 50_000]; -/// Load the checked-in BTCUSDT 1-minute candle dataset. +/// Load the checked-in BTCUSDT 1-minute candle dataset from the workspace +/// `examples/data/` directory. fn load_candles() -> Vec { - let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/data/btcusdt-1m.csv"); + let path = concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../examples/data/btcusdt-1m.csv" + ); let mut reader = CandleReader::open(path).unwrap_or_else(|e| { panic!( "could not open the benchmark dataset {path}: {e}\n\ - generate it with `cargo run -p wickra --example fetch_btcusdt`" + generate it with `cargo run -p wickra-examples --bin fetch_btcusdt`" ) }); reader diff --git a/crates/wickra/examples/fetch_btcusdt.rs b/crates/wickra/examples/fetch_btcusdt.rs index c3a968dd..c6224f2d 100644 --- a/crates/wickra/examples/fetch_btcusdt.rs +++ b/crates/wickra/examples/fetch_btcusdt.rs @@ -2,8 +2,9 @@ //! and write them as CSV datasets under `examples/data/`. //! //! These are the datasets the indicator benchmarks (`benches/indicators.rs`) -//! and the `example_data` integration test run against. Re-run this example -//! to refresh them with the latest market history: +//! and the `example_data` integration test run against. They live at the +//! workspace `examples/data/` directory. Re-run this example to refresh +//! them with the latest market history: //! //! ```text //! cargo run -p wickra --example fetch_btcusdt @@ -96,6 +97,8 @@ fn main() -> Result<(), Box> { .map_err(|_| "system clock is beyond the i64 millisecond range")?; let data_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("..") + .join("..") .join("examples") .join("data"); std::fs::create_dir_all(&data_dir)?; diff --git a/crates/wickra/tests/example_data.rs b/crates/wickra/tests/example_data.rs index 624a2d9d..67e5012b 100644 --- a/crates/wickra/tests/example_data.rs +++ b/crates/wickra/tests/example_data.rs @@ -2,11 +2,11 @@ //! hold enough rows, and carry strictly increasing — and, for the fixed //! timeframes, evenly spaced — timestamps. //! -//! The datasets live in `examples/data/` and are produced by the -//! `fetch_btcusdt` example. Regenerate them with: +//! The datasets live in the workspace `examples/data/` directory and are +//! produced by the `fetch_btcusdt` example. Regenerate them with: //! //! ```text -//! cargo run -p wickra --example fetch_btcusdt +//! cargo run -p wickra-examples --bin fetch_btcusdt //! ``` use wickra_data::csv::CandleReader; @@ -26,7 +26,7 @@ const DATASETS: &[(&str, usize, Option)] = &[ ]; fn dataset_path(file: &str) -> String { - format!("{}/examples/data/{file}", env!("CARGO_MANIFEST_DIR")) + format!("{}/../../examples/data/{file}", env!("CARGO_MANIFEST_DIR")) } #[test] diff --git a/docs/wiki/Data-Layer.md b/docs/wiki/Data-Layer.md index 15cf878f..9bf7833f 100644 --- a/docs/wiki/Data-Layer.md +++ b/docs/wiki/Data-Layer.md @@ -159,10 +159,9 @@ cargo run -p wickra-data --example live_binance --features live-binance ## Example datasets The repository ships seven ready-to-use OHLCV datasets under -`crates/wickra/examples/data/`, one per timeframe, holding real Binance -**BTCUSDT** spot candles in the standard `timestamp,open,high,low,close,volume` -layout the `CandleReader` reads. The timestamp is each candle's open time in -milliseconds. +`examples/data/`, one per timeframe, holding real Binance **BTCUSDT** spot +candles in the standard `timestamp,open,high,low,close,volume` layout the +`CandleReader` reads. The timestamp is each candle's open time in milliseconds. | File | Timeframe | Rows | | --- | --- | --- | diff --git a/examples/README.md b/examples/README.md index 5f71f0d6..aac43387 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,7 +10,7 @@ live here under [`python/`](python/). | Example | What it does | Run | | --- | --- | --- | | `backtest.rs` | Compute a basket of indicators over an OHLCV CSV and print a summary. | `cargo run -p wickra --example backtest -- ` | -| `fetch_btcusdt.rs` | Download real BTCUSDT klines from the Binance REST API into `crates/wickra/examples/data/`. | `cargo run -p wickra --example fetch_btcusdt` | +| `fetch_btcusdt.rs` | Download real BTCUSDT klines from the Binance REST API into `examples/data/`. | `cargo run -p wickra --example fetch_btcusdt` | | `live_binance.rs` | Stream live Binance klines through an indicator over a resilient WebSocket. | `cargo run -p wickra-data --example live_binance --features live-binance` | ## Python — `examples/python/` @@ -42,7 +42,7 @@ Build the native module first: `cd bindings/node && npm install && npx napi buil ## Example datasets -`crates/wickra/examples/data/` holds seven real BTCUSDT OHLCV datasets, one +`examples/data/` holds seven real BTCUSDT OHLCV datasets, one per timeframe (1m, 5m, 15m, 1h, 12h, 1d, 1month), in the standard `timestamp,open,high,low,close,volume` layout. The Rust and Node backtest examples and the indicator benchmarks run against them. Regenerate them with diff --git a/crates/wickra/examples/data/btcusdt-12h.csv b/examples/data/btcusdt-12h.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-12h.csv rename to examples/data/btcusdt-12h.csv diff --git a/crates/wickra/examples/data/btcusdt-15m.csv b/examples/data/btcusdt-15m.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-15m.csv rename to examples/data/btcusdt-15m.csv diff --git a/crates/wickra/examples/data/btcusdt-1d.csv b/examples/data/btcusdt-1d.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-1d.csv rename to examples/data/btcusdt-1d.csv diff --git a/crates/wickra/examples/data/btcusdt-1h.csv b/examples/data/btcusdt-1h.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-1h.csv rename to examples/data/btcusdt-1h.csv diff --git a/crates/wickra/examples/data/btcusdt-1m.csv b/examples/data/btcusdt-1m.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-1m.csv rename to examples/data/btcusdt-1m.csv diff --git a/crates/wickra/examples/data/btcusdt-1month.csv b/examples/data/btcusdt-1month.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-1month.csv rename to examples/data/btcusdt-1month.csv diff --git a/crates/wickra/examples/data/btcusdt-5m.csv b/examples/data/btcusdt-5m.csv similarity index 100% rename from crates/wickra/examples/data/btcusdt-5m.csv rename to examples/data/btcusdt-5m.csv