Metadata-Version: 2.4
Name: consistency-auditor
Version: 0.2.1
Summary: Audit backtest vs live trading consistency with CSV matching, event-log replay, and CLI reports.
Author: Mohsen Moghaddam
License-Expression: MIT
Project-URL: Homepage, https://github.com/Mohsentinal/consistency-auditor
Project-URL: Repository, https://github.com/Mohsentinal/consistency-auditor
Project-URL: Issues, https://github.com/Mohsentinal/consistency-auditor/issues
Project-URL: Changelog, https://github.com/Mohsentinal/consistency-auditor/blob/main/CHANGELOG.md
Keywords: trading,backtesting,audit,cli,quant
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: snapshot
Requires-Dist: pandas>=2.0; extra == "snapshot"
Requires-Dist: pyarrow>=14.0; extra == "snapshot"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.12; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=6; extra == "dev"
Requires-Dist: pandas>=2.0; extra == "dev"
Requires-Dist: pyarrow>=14.0; extra == "dev"
Dynamic: license-file

# consistency-auditor

Audit backtest vs live trading consistency and generate reports from both CSV trade lists and `ConsistencyRecorder` event logs.

## What it does

- Match backtest vs live trades with exact-ID + fuzzy time matching
- Report missing / extra trades
- Measure entry and exit time/price alignment with full distribution statistics
- Estimate per-trade and cumulative P&L drift
- Replay `DECISION -> ORDER_SENT -> FILL/REJECTED` chains from JSONL logs
- Emit matched / unmatched CSV reports for further analysis

## Install

### From source

```bash
python -m pip install -e ".[dev]"
```

### Quick CLI check

```bash
consistency-auditor --version
```

## Audit CSVs

```bash
consistency-auditor audit   --backtest .\examples\backtest.csv   --live     .\examples\live.csv   --tolerance 120   --price-tolerance 0.0003   --out .\outputs   --out-prefix demo
```

Outputs when `--out` is provided:
- `outputs\matched_demo.csv`
- `outputs\unmatched_demo.csv`

## Replay event log

```bash
consistency-auditor replay   --events .\examples\events.jsonl   --fail-on rejected
```

Expected replay summary includes:
- run info
- total decisions / actionable decisions
- filled / rejected / unexecuted counts
- fill rate
- decision-to-fill latency stats
- rejection details

## Dev setup (Windows)

```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -U pip
python -m pip install -e ".[dev]"
ruff check .
pytest -q
python -m build
```

## CI

GitHub Actions runs Ruff + pytest on push and pull request. The package is ready for build validation and PyPI release after CI is green.

## Files worth reading

- `AUDITOR_SPEC.md` — behavior/specification
- `CHANGELOG.md` — release history
- `CONTRIBUTING.md` — local workflow and release checklist
