| Crates.io | tktax-burst |
| lib.rs | tktax-burst |
| version | 0.2.2 |
| created_at | 2025-02-01 04:11:44.269451+00 |
| updated_at | 2025-02-01 04:11:44.269451+00 |
| description | A Rust library for identifying and printing heavy bursts of financial transactions in a sliding date window. |
| homepage | |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538104 |
| size | 100,724 |
tktax-burst provides robust, production-grade routines for analyzing transaction flows over contiguous time spans, ensuring that financial or operational data can be processed quickly and accurately to reveal peak transaction intensities.
tktax-burst is a Rust library for detecting and displaying “heavy bursts” of transaction activity within a specified rolling time window. It computes daily aggregates from a collection of financial transactions, enumerates all possible windows, then ranks these windows by total transaction volume. Overlapping or consecutive windows are merged to provide a consolidated view of high-intensity activity intervals.
[day, day + (window_size - 1)] using chrono’s NaiveDate.use tktax_burst::FindHeavyTransactionBursts;
use tktax_account::Account;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Assume `account` is already populated with transaction data.
let account = Account::new(/* ... */);
// Print the top 5 heaviest bursts, each spanning 7 days.
account.print_heavy_bursts(5, 7);
Ok(())
}
In this example:
collect_daily_totals: Aggregates transaction amounts by date.build_date_windows: Constructs rolling date windows of configurable length.merge_overlapping_burst_windows: Merges overlapping/adjacent date windows.print_merged_bursts: Outputs consolidated intervals and their total amounts.print_transaction_lines: Displays individual transactions within each interval.FindHeavyTransactionBursts: Core trait for enumerating, merging, and displaying high-volume windows.A comprehensive suite of tests is included under #[cfg(test)]. Run them with:
cargo test
This ensures correctness of daily totals, window merging, descending sort, and final burst-printing logic.
This crate can be licensed or distributed according to your project’s needs. Update the [package] section in your Cargo.toml accordingly.
Please open an issue or submit a pull request to contribute improvements or bug fixes. Testing additions and suggestions for optimization of the interval-merging algorithm are especially welcome.