BatchParams

Struct BatchParams 

Source
pub struct BatchParams {
    pub num_stocks: usize,
    pub total_time: usize,
    pub cur_time: usize,
    pub length: usize,
}
Expand description

Parameters for batch computation of factor values over time series data.

BatchParams defines the dimensions and time window for batch factor computation. It specifies how many stocks to process, the total time series length, and which subset of time points to compute.

§Data Layout

KunQuant expects data in time-series format where:

  • Rows represent time points (e.g., trading days)
  • Columns represent stocks
  • Data is stored in row-major order: [t0_s0, t0_s1, ..., t0_sN, t1_s0, ...]

§SIMD Requirements

In STs memory layout, num_stocks must be a multiple of 8 to enable SIMD (Single Instruction, Multiple Data) vectorization.

Fields§

§num_stocks: usize

Number of stocks to process (must be multiple of 8 for STs, can be any positive integer for TS)

§total_time: usize

Total number of time points in the input data arrays

§cur_time: usize

Starting time index for computation (0-based)

§length: usize

Number of consecutive time points to compute

Implementations§

Source§

impl BatchParams

Source

pub fn new( num_stocks: usize, total_time: usize, cur_time: usize, length: usize, ) -> Result<Self>

Creates new batch computation parameters with validation.

This constructor validates that the stock count meets SIMD requirements and that the time window parameters are consistent.

§Arguments
  • num_stocks - Number of stocks to process
  • total_time - Total number of time points in input data
  • cur_time - Starting time index for computation (0-based)
  • length - Number of consecutive time points to compute
§Returns

Returns Ok(BatchParams) on success, or an error if:

  • cur_time + length > total_time (time window exceeds data bounds)
  • Any parameter is invalid
§Examples
use kunquant_rs::BatchParams;

// Process 16 stocks over 100 time points, computing all points
let params = BatchParams::new(16, 100, 0, 100)?;

// Process 8 stocks, compute only the last 20 time points
let params = BatchParams::new(8, 252, 232, 20)?;
Source

pub fn full_range(num_stocks: usize, total_time: usize) -> Result<Self>

Creates parameters for computing the entire time range.

This is a convenience method that creates batch parameters to process all time points in the dataset, equivalent to calling BatchParams::new(num_stocks, total_time, 0, total_time).

§Arguments
  • num_stocks - Number of stocks to process
  • total_time - Total number of time points in the data
§Returns

Returns Ok(BatchParams) configured to process the entire time range,

§Examples
use kunquant_rs::BatchParams;

// Process all 252 trading days for 16 stocks
let params = BatchParams::full_range(16, 252)?;

// Equivalent to:
// let params = BatchParams::new(16, 252, 0, 252)?;
§Use Cases
  • Historical backtesting over complete datasets
  • Factor computation for entire time series
  • Initial factor validation and testing
  • Scenarios where memory constraints are not a concern

Trait Implementations§

Source§

impl Clone for BatchParams

Source§

fn clone(&self) -> BatchParams

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BatchParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.