Skip to main content

kunquant_rs/
lib.rs

1//! # KunQuant-rs
2//!
3//! Rust bindings for the KunQuant financial factor computation library.
4//!
5//! KunQuant is an optimizer, code generator and executor for financial expressions
6//! and factors. This crate provides safe Rust bindings to the KunQuant C API.
7//!
8//! ## Features
9//!
10//! - Batch mode computation for historical data analysis
11//! - Stream mode computation for real-time factor calculation
12//! - Thread-safe executors with single-thread and multi-thread support
13//! - Memory-safe buffer management
14//! - Support for both single and double precision floating point data
15//!
16//! ## Example
17//!
18//! ```rust,no_run
19//! use kunquant_rs::{Executor, Library, BufferNameMap, BatchParams, run_graph, Result};
20//!
21//! fn main() -> Result<()> {
22//!     // Create executor and load library
23//!     let executor = Executor::single_thread()?;
24//!     let library = Library::load("path/to/factor_library.so")?;
25//!     let module = library.get_module("my_module")?;
26//!
27//!     // Set up input/output buffers
28//!     let mut buffers = BufferNameMap::new()?;
29//!     let mut input_data = vec![1.0f32; 8 * 100]; // 8 stocks, 100 time points
30//!     let mut output_data = vec![0.0f32; 8 * 100];
31//!
32//!     buffers.set_buffer_slice("input", &mut input_data)?;
33//!     buffers.set_buffer_slice("output", &mut output_data)?;
34//!
35//!     // Run computation
36//!     let params = BatchParams::full_range(8, 100)?;
37//!     run_graph(&executor, &module, &buffers, &params)?;
38//!
39//!     Ok(())
40//! }
41//! ```
42
43pub mod batch;
44pub mod buffer;
45pub mod error;
46pub mod executor;
47pub mod ffi;
48pub mod library;
49pub mod stream;
50
51// Re-export main types for convenience
52pub use batch::{BatchParams, run_graph};
53pub use buffer::BufferNameMap;
54pub use error::{KunQuantError, Result};
55pub use executor::Executor;
56pub use library::{Library, Module};
57pub use stream::StreamContext;