| Crates.io | tesser-ledger |
| lib.rs | tesser-ledger |
| version | 0.9.3 |
| created_at | 2025-11-29 16:21:23.012748+00 |
| updated_at | 2025-12-04 04:50:12.934179+00 |
| description | Ledger primitives for Tesser accounting |
| homepage | |
| repository | https://github.com/tesserspace/tesser |
| max_upload_size | |
| id | 1956925 |
| size | 87,294 |
tesser-ledger contains the accounting primitives that keep Tesser's balances, realized PnL, and adjustments auditable. It defines the canonical LedgerEntry structure plus repositories that write to SQLite or Apache Parquet, so the same APIs cover low-latency disk storage and analytics exports.
SqliteLedgerRepository for on-disk durability and ParquetLedgerRepository for analytical pipelines.entries_from_fill converts tesser_core::Fill events into the correct ledger lines for spot or perpetual instruments, including realized PnL and fees.use rust_decimal::Decimal;
use tesser_core::{AssetId, ExchangeId};
use tesser_ledger::{LedgerEntry, LedgerRepository, LedgerType, LedgerSequencer, SqliteLedgerRepository};
let repo = SqliteLedgerRepository::new("ledger.db").expect("open sqlite");
let mut sequencer = LedgerSequencer::new(repo.latest_sequence()?.unwrap_or(0));
let entry = LedgerEntry::new(
ExchangeId::from("paper"),
AssetId::from("paper:USDT"),
Decimal::new(1_000, 0),
LedgerType::TransferIn,
"initial_funding",
)
.with_sequence(sequencer.next());
repo.append(&entry).expect("persist ledger line");
To export the same data for downstream analytics, instantiate ParquetLedgerRepository and call append_batch with the same LedgerEntry values. The schema aligns with Arrow so you can load the files directly into Python/Polars.
LedgerQuery lets you filter the repository by exchange, asset, ledger type, or sequence range. This makes it easy to:
use tesser_core::AssetId;
use tesser_ledger::LedgerQuery;
let entries = repo.query(LedgerQuery::default().with_asset(AssetId::from("binance:USDT")))?;
append_batch to commit all adjustments derived from a fill atomically.entries_from_fill and FillLedgerContext ensure derivative vs. spot products produce the correct cash movements and metadata.no_std-friendly aside from the storage backends; you can depend on just the types if you disable the repositories or gate them behind features in your own crate.