Skip to main content
    ___          ____  ____
   /   |  _____ / __ \/ __/
  / /| | / ___// / / / /_
 / ___ |(__  )/ /_/ / __/
/_/  |_/____/ \____/_/

AsOf

Point-in-time market intelligence, cited filings, and paper research — zero look-ahead, zero broker.

AsOf (PyPI: asof-research, formerly FinGPT Trader) replays market data and issuer documents strictly as they became available, preserves verbatim source citations, and simulates paper portfolios with exact Decimal accounting. Individual books use their listing currency, and portfolio studies combine separately funded books in one base currency. Python 3.11+ runs the core research CLI with the standard library.

# Install the CLI tool (stdlib-only core, or add [filings] for PDF parsing):
pip install asof-research
uv tool install 'asof-research[filings]'
asof --help

Architecture

Research ingestion, point-in-time storage, and paper simulation are strictly separated from live broker execution. Deterministic rules run first; hosted Gemini fallback is invoked only when a filing candidate misses a core field, and every claim requires a verbatim source quote.

flowchart TB
    subgraph Sources["1. External Sources (Raw)"]
        PDF["Issuer PDFs (Results, AGMs, Notices)"]
        PL["NSE Daily Price Lists (PDF / CSV)"]
        CRYPTO["Binance Public Spot REST"]
        FX["FX & Borrow Schedules"]
    end

    subgraph Ingest["2. Offline Ingestion & Verification"]
        FE["filing-extract (pypdf + pypdfium2 + rules)"]
        LLM["Optional Gemini Fallback (Vertex AI, uncertainty-routed)"]
        NSE_IMP["nse-import (PDF parser + scanned-PDF guard)"]
        BIN_AD["binance-spot-daily (stdlib REST adapter)"]
        FE -.->|"missing core field only"| LLM
    end

    subgraph Store["3. Point-in-Time Store (No Look-Ahead)"]
        CAT["Corporate Actions Catalog (actions + catalog-add)"]
        MKT["Raw OHLCV / VWAP Datasets (sessions + prices)"]
        FEAT["Timestamped Features (observed_at + latency)"]
    end

    subgraph Engine["4. Paper Research & Risk Engine"]
        PAPER["PaperEngine (Decimal fills, fees, dividends, borrow)"]
        PORT["Portfolio & Risk (FX marks, drawdown, exposures)"]
        COMP["Walk-Forward Comparisons (baseline vs stressed costs)"]
    end

    PDF --> FE
    PL --> NSE_IMP
    CRYPTO --> BIN_AD
    FE -->|"reviewed promotion"| CAT
    NSE_IMP --> MKT
    BIN_AD --> MKT
    FX --> PORT

    CAT --> PAPER
    MKT --> PAPER
    FEAT --> PAPER
    PAPER --> PORT
    PAPER --> COMP

Try the replay

python3 main.py
python3 main.py replay --dataset nse --as-of 2025-01-08T15:00:00+03:00
python3 main.py evidence --dataset nse --as-of 2025-01-09T15:00:00+03:00
python3 main.py paper --dataset nse --policy buy_hold
python3 main.py compare --dataset nse
python3 main.py evaluate --dataset nse

The default replay contains 12 captured Binance BTC/USDT daily bars. The NSE example contains 13 fictional KES sessions, an issuer statement, two versions of one dividend notice, a court filing, a decision and a news report. Try the two January cutoffs above. At the January 8 close the original dividend is KES 1.00. The correction to KES 1.20 arrives after that close. The example calendar, fees, prices, liquidity and labels are teaching inputs. The bundled cases exercise the software and provide no estimate of investment performance.

Import local data

Copy a sample dataset and pass its directory to --dataset. Keep privately licensed source files locally. One manifest identifies the stable listing, issuer, currency, venue, lot size, adapter, source, capture time and calendar version. Use raw prices with separately recorded dividends and split/bonus corporate actions. A single-listing report uses its listing currency. The portfolio command translates the funded books using dated FX observations.

File Contents
sessions.csv Versioned session dates and explicit timezone-aware opens and closes. Supply the applicable exchange calendar, including holidays and exceptional sessions.
prices.csv One row per session with raw OHLCV, availability time and trading status. Suspended sessions carry an explicit valuation mark.
documents.json Immutable document IDs, source references, issuer, attributed document kind, publication and ingestion times, and an array of page texts. Optional fields include the financial period, predecessor document ID and curated dividend terms.
labels.json Optional field references for evaluation, including expected text, page and supporting span. Maintain these independently for a real study.
klines.json For the Binance spot adapter, use a frozen UTC daily REST kline response with millisecond timestamps and its capture time in the manifest.

Replay reconstructs public availability. Ingestion time separately records when the snapshot was collected. A date-only publication becomes eligible at the next listed session open. For bulk-imported history, the output describes what public evidence supports, rather than the arrival history of an actual trading feed. Extracted pages must preserve source page order. The rules extractor abstains on ambiguous matches. A filing preserves the claimant's attribution and a judgment preserves the court's attribution.

Paper portfolios and comparisons

Paper is the only execution mode of the research CLI. The default paper policy holds cash. A producer emits a timestamped research signal with its version, horizon and evidence. Portfolio sizing converts it to a long-only target and approves a quantity. A pending quantity can fill on a later tradable raw close, capped by participation, available cash, lot size and exposure. Fee and slippage assumptions apply to each fill. The closing-price approximation is suited to daily-bar research. A dividend becomes a receivable using the holding before its ex-date and becomes cash on the first session on or after payment. Only curated corporate action terms can post to the ledger.

python3 main.py paper --dataset nse --policy price --fee-bps 15 --slippage-bps 8 --participation 0.005
python3 main.py paper --dataset /data/initial-snapshot --policy price --follow

In follow mode, a local publisher writes the directory of each completed snapshot to standard input, one per line. Standard output emits a JSON portfolio report for each extension. Repeated snapshots are idempotent. Publish each snapshot atomically, append corrections as new documents, and retain the snapshot sequence for recovery. A changed historical bar or backdated source requires a fresh historical replay.

The comparison reads the fixed test start, one-session horizon and fold length from the manifest. Earlier prices warm up the factor. The book carries through consecutive test folds. Cash, buy-and-hold including dividends, and one-session price momentum use the same costs and liquidity rules. A second scenario doubles fee and slippage and halves participation. Reports include drawdown, turnover, exposure, fees and net returns. The historical comparison uses long-only policies. For a borrow or cross-currency study, use the portfolio command below.

Cross-currency and borrow studies

python3 main.py replay --dataset nse-public-sample
python3 main.py portfolio --spec examples/kes-portfolio.json

The public sample is a single Safaricom observation checked against the NSE price list dated September 2, 2026. Its opening price is unknown. Its VWAP can value a holding but cannot execute a paper order. The captured document gives the dividend amount and book closure. Posting a payment requires separately verified entitlement terms.

The example study pre-funds two books in KES and USDT. FX is quoted as base currency per unit of listing currency. Each translation uses a rate available at the valuation time. Missing rates, stale rates and stale held-position marks stop the study. Weights must total one. Optional study fields enable periodic cross-sleeve cash rebalancing ("rebalance": "daily" | "weekly" | "monthly"), single-name concentration caps ("max_single_weight"), and passive benchmark attribution ("benchmark"), reporting Sharpe, Sortino, HHI concentration, per-sleeve days_to_exit, tracking error, information ratio, and beta.

Cross-sectional factor research & local web workstation

Evaluate strictly point-in-time cross-sectional factors (momentum_20d, momentum_60d, liquidity_adv20, dividend_yield, earnings_yield) with Spearman Rank-IC, IC-IR, hit rate, and quantile spreads across a multi-ticker NSE universe:

python3 -m asof factors --universe ./local-data/universe --catalog ./local-data/catalog --horizons 1,5,20 --min-adv 100000

Launch the local, paper-only web workstation (pure Python stdlib, loopback-only by default) with Filing Workbench, As-Of Explorer, Multi-Ticker Market & Liquidity Board, and Paper Risk Lab:

python3 -m asof serve --port 8765
# Enable one-click catalog promotion and the multi-ticker NSE Board:
python3 -m asof serve --port 8765 --catalog ./local-data/catalog --universe ./local-data/universe

A short sale requires explicit dated loan inventory. A schedule sets maximum outstanding units, an annual rate, expiry and a buy-in premium. Loan fees accrue ACT/365 on the preceding mark, including weekends. A reduction in the allowed outstanding quantity or an expiry triggers a buy-in subject to tradable volume. The last known loan rate continues on overdue units. Short holders owe any eligible dividend. For a single book pass paper --policy short_hold --borrow loan.json, with instrument and a records array using the example's borrow fields. The included FX and borrowing terms are synthetic scenario assumptions.

Historical dividend research

Query dated issuer disclosures with python3 -m asof actions --as-of 2026-06-30 --status approved. Add --symbol EQTY --history to inspect a single issuer over time. The offline catalog covers nine Kenyan issuers. Each field retains its supporting source, and inference runs separately. Disclosure clocks, corpus and model comparisons

Optional model experiments

Supply a hosted Gemini project (--vertex-project) or a locally merged GGUF (--gguf, install .[model]) for optional model experiments. The evaluator compares models against the deterministic parser with field accuracy, citation precision, abstentions, elapsed time and token counts.

python3 main.py evaluate --dataset nse --gguf /models/fingpt.gguf --structured
python3 main.py evaluate --corpus asof/fixtures/issuer-excerpts --gguf /models/fingpt.gguf --structured
python3 main.py features --dataset nse --gguf /models/fingpt.gguf --structured --model-available-at 2024-12-01T00:00:00Z --latency-seconds 60 > features.json
python3 main.py compare --dataset nse --features features.json

Use the actual model availability date and a defensible inference delay in an experiment. The example arguments illustrate the format. The additional policy applies the same price factor with a sentiment filter on its first eligible observation. Treat generated sentiment as a hypothesis. Assess its incremental value on a separately frozen, reviewed sample before drawing conclusions.

Local model evaluation and provider design

Full-filing PDF extraction and NSE price lists

Extract cited dividend events directly from complete issuer PDFs, promote reviewed outputs into a local corporate-actions catalog, and import standard NSE Daily Equity Price List PDFs or CSVs into nse-daily datasets:

python3 -m pip install -e '.[filings]'
python3 -m asof filing-extract --pdf scbk-fy24.pdf --symbol SCBK --source "$ISSUER_URL" > scbk.json
python3 -m asof financials-extract --pdf scbk-fy24.pdf --symbol SCBK --source "$ISSUER_URL"
python3 -m asof filing-extract --pdf scbk-fy24.pdf --symbol SCBK --source "$ISSUER_URL" --vertex-project YOUR_PROJECT
python3 -m asof catalog-add --report scbk.json --notice-date 2025-03-19 --catalog ./my-catalog
python3 -m asof actions --as-of 2025-03-20 --symbol SCBK --catalog ./my-catalog
python3 -m asof nse-import --input ./nse-daily-lists --symbol SCOM --out ./datasets/scom
python3 -m asof replay --dataset ./datasets/scom

Deterministic rules run first. When --vertex-project (hosted Gemini) or --gguf is supplied, the model is invoked only as a fallback for candidates missing a core field. See Full-filing PDF extraction and NSE price lists and Working with real NSE data for bulk --universe CSV import, persisted financials --as-of catalogs, and scanned-PDF handling.

Development

python3 -m pip install -e '.[dev,filings]'
python3 -m pytest -q tests

New read-only adapters can be supplied to load_dataset(..., adapters={...}). Custom signal producers can be passed to PaperEngine and receive the listing, current bar, previous tradable bar and available features. The legacy async crypto bot was archived at git tag v0.1-legacy-crypto.

License

Apache License 2.0 — see LICENSE.md and NOTICE for details.

Acknowledgements

This project builds on the foundation of several open-source projects and research:

  • FinGPT Research: Financial NLP concepts inspired by the FinGPT paper.
  • pypdf & pypdfium2: Offline layout text extraction and dual-decoder PDF coverage verification.
  • llama.cpp & Vertex AI: Optional local GGUF and hosted Gemini structured-output backends.
  • Binance Public Spot REST API: Secondary crypto market data adapter demonstrating asset-agnostic replay.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure to follow the code style and include tests for new features. See CONTRIBUTING.md for more details.

Metadata

Release files for asof-research 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asof-research 0.5.0
File Size Uploaded Provenance Actions
asof_research-0.5.0.tar.gz 109.2 kB With provenance Details for asof_research-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for asof-research 0.5.0
File Interpreter ABI Platform Actions
asof_research-0.5.0-py3-none-any.whl Python 3 none any Details for asof_research-0.5.0-py3-none-any.whl

Total release size: 206.6 kB

Release files / asof_research-0.5.0.tar.gz

Download URL asof_research-0.5.0.tar.gz
Size 109.2 kB
Tags Source
SHA-256 checksum
How to use checksums
68e61e2a96be0a016e2f45010d2123ca464f4e92c5ee129addbb54dee97dc9cd
BLAKE2b-256 checksum
How to use checksums
00aa67986e8d6becad84aaa2517177d7bfd5fee00d005205adecdf29a58399a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / asof_research-0.5.0-py3-none-any.whl

Download URL asof_research-0.5.0-py3-none-any.whl
Size 97.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f1d697ec0064051c59c84f73caf50f50925ed548313d438a5cdeffc37ad9e24
BLAKE2b-256 checksum
How to use checksums
576c54837db31eae572fee6975360433b5b6b4c9a69eae53c1e52b4f7bb7e24b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for asof-research 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for asof_research-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page