Tevec
Introduction
A crate to provide financial quantitative analysis functions across different backends (currently Vec & Ndarray & Polars). It uses the Rust trait system to facilitate the support of more backends in the future. Currently, it is mainly divided into three categories of functions:
- Rolling functions
- Mapping functions
- Aggregation functions
Installation
add tevec = "0.2" to your Cargo.toml
Aggregation Functions
Most aggregation functions are implemented for structs that satisfy the IntoIterator + Sized traits.
use *;
let data = vec!;
data.titer.mean; // not consume data, return Some(3)
data.mean; // consume data, return Some(3)
let data = vec!;
data.titer.vmean; // valid mean, this will ignore nan, return 2.
// valid function can also be used for Option<T> dtype
let data = vec!;
data.vmean; // return 2.
Using titer returns an Iterator that satisfies TrustedLen, allowing for further method calls. The titer method comes from the Titer trait, which has been implemented for all backends.
Rolling Functions
use *;
let data = vec!;
let mean: = data.ts_mean; // params: window, min_periods
Mapping Functions
use *;
let v = vec!;
let shift_v: = v.titer.vshift.collect_trusted_vec1;
let shfit_abs_v: = v.titer.abs.vshift.collect_trusted_vec1;
Some mapping functions return an Iterator, allowing for chained calls without reallocating memory, and only collecting the iterator when needed.
Feature Flags
pl: For Polars backend
ndarray: For Ndarray backend
agg: Aggregate Functions
map: Mapping Functions
rolling: Rolling Functions
stat: Statistic Functions
time: DateTime and TimeDelta structs