Install Backtest in your editor
Extension RahulChaube.blyx-backtest · 0.1.0
The extension includes a runnable Blyx example, function completions and the framework source. For the modular project, extract the starter, open its folder and run blyxc native-run main.blyx with the native toolchain installed.
Create an empty .blyx file, type blyx-backtest-demo and accept the completion. Choose Blyx: Run File to run the example.
For an offline installation, choose Extensions: Install from VSIX for Blyx Language first, then for Backtest.
Download the companion Blyx Language VSIXInstall with Conda
Create an environment containing Backtest 0.1.1, its Blyx source and a runnable example. Run the second command with Blyx 0.2.1, Rust and a host linker installed.
conda create -y --prefix ./blyx-env --override-channels -c https://rahulchaube1.github.io/blyx-packages blyx-backtest=0.1.1=0 blyxc native-run ./blyx-env/share/blyx/backtest/main.blyx
To use this package in your application, copy share/blyx/backtest/vendor/backtest from the environment into your project's vendor directory.
Import into a Blyx project
Install Blyx 0.2.1, Rust 1.85 or newer and a host linker. From the directory containing your entry file, clone this tagged release.
git clone --depth 1 --branch v0.1.1 https://github.com/Rahulchaube1/blyx-backtest.git vendor/backtest
Save this as main.blyx beside vendor and run blyxc native-run main.blyx.
use vendor::backtest::backtest;
fn main() {
let demand = [10, 20, 30, 40, 50, 60, 70, 80];
let baselines = bt_baselines(demand, 3, 2, 1, 2);
println!(at(baselines, 0));
println!(at(baselines, 1));
println!(at(baselines, 2));
let model = bt_score(demand, [45, 55, 65, 75], 3, 2, 1);
println!(at(model, 1));
}Expected output
4 25 30 5
API and input requirements
Choose an initial training history, a positive horizon and a nonnegative gap. A zero training window expands the history. A positive window caps its length. The final incomplete test horizon is omitted.
| API | Use |
|---|---|
bt_fold_count(n, initial, horizon, gap), bt_fold(n, initial, horizon, gap, window, fold) | Plan training and test windows with zero-based, exclusive end indices. |
bt_baselines(series, initial, horizon, gap, window) | Score a last-value and training-mean baseline on identical observations. |
bt_score(series, forecasts, initial, horizon, gap) | Calculate mean absolute and signed error of submitted forecasts. |
Develop and contribute
Open the tagged source to read the implementation and examples. Include the smallest reproducible Blyx program, compiler version and expected result when reporting an issue.
