Quickstart Tutorial
This quickstart gets one small Rust program working end to end so you can see a full indicator flow in Rust: inputs, returned series, and the first practical constraint that shows up immediately. Indicators need warmup history before every value carries signal.
If your work starts in notebooks or Python scripts, begin with the Python integration guide. This page stays on the Rust path.
1. Create a small Rust project
Start with a clean binary crate. Keep the first run narrow. Skip async networking, CSV parsing, and backtest machinery until the library is wired up correctly.
cargo new my_trading_bot
cd my_trading_bot
Then add the current VectorTA release to Cargo.toml.
[dependencies]
vector-ta = "0.2.7" 2. Paste a complete first example
Replace src/main.rs with a small example that calculates a few indicators over
a fixed price series. The dataset is deliberately tiny because the goal here is to see the
API and the output shape before you benchmark anything.
use vector_ta::indicators::{bollinger_bands, rsi, sma};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let prices = vec![
100.0, 101.2, 100.8, 102.1, 103.4, 102.9, 104.2, 105.0, 104.7, 106.1,
107.3, 106.8, 108.4, 109.1, 108.6, 110.2, 111.0, 110.4, 112.3, 113.1,
112.7, 114.0, 115.2, 114.9, 116.3, 117.0, 116.5, 118.1, 119.4, 118.8,
];
let sma_5 = sma(&prices, 5)?;
let rsi_14 = rsi(&prices, 14)?;
let bands = bollinger_bands(&prices, 20, 2.0)?;
println!("Last close: {:.2}", prices[prices.len() - 1]);
println!("Last SMA(5): {:.2}", sma_5[sma_5.len() - 1]);
println!("Last RSI(14): {:.2}", rsi_14[rsi_14.len() - 1]);
println!("Last upper band: {:.2}", bands.upper[bands.upper.len() - 1]);
println!("Last middle band: {:.2}", bands.middle[bands.middle.len() - 1]);
println!("Last lower band: {:.2}", bands.lower[bands.lower.len() - 1]);
Ok(())
} This is enough for a first pass because it gives you one trend indicator, one momentum indicator, and one volatility envelope without dragging in extra infrastructure.
3. Run it and inspect the output shape
cargo run The exact numbers depend on the input series, but the important thing is what you should notice immediately:
- The output series is aligned to the input series length.
- Indicators with longer windows need more history before their later values stabilize.
- The latest value is often the only one you care about in a signal-driven workflow, but the full series matters for plotting and backtests.
If the result compiles and runs, the integration step is done. The next job is to stop using a toy vector and move to real price data.
4. Move from toy data to a real CSV
Once the API surface is working, switch to a small CSV with a close column and
feed that into the same indicator calls. Keep the file plain and clean enough that you trust
what you loaded.
Sample Data Format
A minimal CSV for early experiments can look like this:
date,open,high,low,close,volume
2024-01-02,187.15,188.44,186.86,187.21,45123000
2024-01-03,187.84,188.63,187.05,188.22,48234000
2024-01-04,188.60,189.12,187.80,188.94,39512000 use std::fs;
fn load_closes_from_csv(path: &str) -> Result<Vec<f64>, Box<dyn std::error::Error>> {
let contents = fs::read_to_string(path)?;
let mut closes = Vec::new();
for line in contents.lines().skip(1) {
let columns: Vec<&str> = line.split(',').collect();
let close = columns[4].parse::<f64>()?;
closes.push(close);
}
Ok(closes)
} That parser is intentionally plain. It is enough for a first local test and easy to audit. You can replace it later with a stronger data pipeline once the indicator workflow is established.
5. Know what to do next
The next page depends on the next question. For indicator meaning, warmup behavior, and signal interpretation, move to Technical Indicators Theory. For signatures, result types, and more examples, go to the API reference and examples page.
If you are about to turn these signals into a strategy, skip optimization for the moment and read Backtesting Fundamentals first. A working indicator call comes well before a credible trading experiment.
Next reads
The most useful follow-ups are Technical Indicators Theory, API Reference, Examples, and Python Integration Guide if another entry point fits your workflow better.