Metadata-Version: 2.4
Name: statementkit
Version: 0.3.0
Summary: Parse brokerage statement content into actionable numbers. Independent tool. Not affiliated with or endorsed by Interactive Brokers LLC.
Author: heshiming
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/heshiming/statementkit
Project-URL: Repository, https://github.com/heshiming/statementkit
Keywords: brokerage,statements,parsing,finance
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# statementkit

Parse brokerage statement content into actionable knowledge and numbers.
A library for upper applications: a pure Rust core, a stable C ABI, and
thin bindings for other languages on top.

Independent tool. Not affiliated with or endorsed by Interactive Brokers
LLC.

## Status

Version `0.3.0`: exact-decimal numerics, a streaming session over 35
named statement targets with optional ticker selection, and measure
targets (risk ratios, tail-risk, economics) parameterized by
caller-declared knobs (`"risk-ratios?rf=0.03"`). Output fields are
standardized. The full stack
is live: Rust core → Rust tests → C ABI → header → linked C consumer →
published Python, Node, and Java bindings. Expect additive APIs at
`0.x`.

## Layout

```
crates/statementkit      core: pure functions, no I/O, no FFI types
crates/statementkit-c    C ABI: status codes, out-params, panic-proofed
  include/statementkit.h hand-kept header; discriminants contractual
bindings/python          ctypes shim over the C ABI (pyo3 wheels later)
bindings/node            raw-WASM npm package, TypeScript types included
bindings/java            Panama FFM, JDK 22+, no JNI; Maven
                         io.github.heshiming:statementkit (natives embedded)
bindings/go              cgo over the static lib, plain `go test ./...`
tests/vectors/           shared ground-truth vectors every binding runs
scripts/c-smoke.sh       links tests/smoke.c against the static lib, runs it
scripts/bindings-test.sh builds all targets, runs every binding suite
scripts/docs.sh          builds the mdBook site (docs/); serve to preview
docs/                    mdBook site; src is the source of truth, docs/book/
                         is build output (deployed via .github/workflows/docs.yml)
```

All parsing logic lives in the core crate only. A binding that
re-implements logic, or behaves differently from another binding, is a bug.

## Quickstart

```sh
cargo test --workspace        # core unit + integration + FFI tests
scripts/c-smoke.sh            # builds release static lib, compiles and runs C smoke
scripts/bindings-test.sh      # python + go + node + java suites vs shared vectors
```

C usage — stream a CSV statement through a session:

```c
#include "statementkit.h"
#include <stdio.h>
#include <stdlib.h>

const char *names[] = {"income", "trades"};
SkSession *s;
char err[256];
if (sk_session_open(&s, names, 2, NULL, 0, err, sizeof err) != SK_OK) { return 1; }

FILE *f = fopen("statement.csv", "rb");
unsigned char chunk[65536];
size_t n;
while ((n = fread(chunk, 1, sizeof chunk, f)) > 0) sk_session_feed(s, chunk, n);
fclose(f);
sk_session_end_file(s);

size_t len; sk_session_report_len(s, &len);
char *out = malloc(len + 1); sk_session_report(s, out, len + 1);
puts(out);                    /* compact JSON, numeric literals unquoted */
free(out);
sk_session_close(s);
```

## Guarantees

- No network I/O, no credentials, no telemetry — checkable in a network
  namespace.
- No Rust panic ever crosses the FFI boundary (`catch_unwind` at every
  entry point; `SK_PANIC` as the last-resort status).
- All test fixtures are synthetic. The library has never seen a real
  statement and ships none.
- Money is exact decimal (`Dec`); binary float never carries a money
  value.

## License

Apache-2.0. See [LICENSE](LICENSE).
