Metadata-Version: 2.4
Name: rl-pricing
Version: 2.0.0
Summary: A reproducibility lab for trading AI: causal backtests, a live forward-test track and a pre-open decision ledger for RL, LLM and forecasting policies.
Author: Bicheng Wang
License-Expression: MIT
Project-URL: Homepage, https://bichengwang.github.io/RL-pricing/
Project-URL: Source, https://github.com/BichengWang/RL-pricing
Project-URL: Issues, https://github.com/BichengWang/RL-pricing/issues
Project-URL: Changelog, https://github.com/BichengWang/RL-pricing/blob/main/CHANGELOG.md
Project-URL: Leaderboard, https://bichengwang.github.io/RL-pricing/leaderboard/
Project-URL: Paper, https://arxiv.org/abs/2609.31870
Keywords: reinforcement learning,portfolio management,backtesting,benchmark,leaderboard
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: stockstats>=0.6.2
Requires-Dist: yfinance>=0.2.40
Requires-Dist: matplotlib>=3.7
Requires-Dist: gymnasium>=0.29.1
Requires-Dist: stable-baselines3>=2.3.2
Requires-Dist: torch>=2.0
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Provides-Extra: lint
Requires-Dist: ruff>=0.5; extra == "lint"
Provides-Extra: agents
Requires-Dist: anthropic>=0.40; extra == "agents"
Dynamic: license-file

# RL-pricing

A reproducibility lab for trading AI. RL-pricing re-tests published claims
about deep RL agents, LLM trading agents and forecasters under one
pre-registered protocol. This package holds the lab's instruments:

- `rl-pricing bench`: a causal backtesting benchmark. Policies decide at the
  close and fill at the next open with fees; learned policies run over
  several seeds; frozen policies are scored on a live forward-test track; and
  a decision ledger records LLM agents' trades before each US market open.
- `rl-pricing --mode train|backtest|ensemble|lstm`: the share-trading toolkit
  that trains and backtests Stable-Baselines3 agents (A2C, PPO, DDPG, TD3,
  SAC), a rolling ensemble and an LSTM forecaster on daily equity data.

## Score your own policy

A policy maps the history up to today's close to long-only target weights,
which fill at the next open. Put it in a submission directory:

```python
# my-submissions/low-vol/policy.py
import numpy as np

from rl.bench.policy import Policy


class LowVolHalf(Policy):
    """Equal-weight the calmer half of the listed assets."""

    def act(self, view):
        closes = view.history.window(64).close
        vol = np.nanstd(np.diff(np.log(closes), axis=0), axis=0)
        vol = np.where(view.listed & np.isfinite(vol), vol, np.inf)
        keep = np.argsort(vol)[: max(1, view.listed.sum() // 2)]
        weights = np.zeros(len(view.tickers))
        weights[keep] = 1 / len(keep)
        return weights
```

and describe it in `my-submissions/low-vol/submission.json`:

```json
{"name": "Low-vol half", "kind": "other", "policy": "policy.py:LowVolHalf", "trials": 1}
```

A submission can also name a built-in policy, such as
`"policy": "rl.bench.policies.baselines:Momentum"` or
`"policy": "rl.bench.policies.sb3:SB3Policy"` with `"params": {"algo": "ppo"}`.
Then score it against 1/N buy-and-hold:

```bash
pip install rl-pricing
rl-pricing bench tasks
rl-pricing bench run --task synthetic --submission low-vol \
    --submissions-root my-submissions --out-root board
rl-pricing bench leaderboard --out-root board --no-readme
```

`synthetic` runs offline; the real tasks (`us-sectors`, `us-multi-asset`,
`crypto-majors`, …) download their data on first use into `datasets/bench/`,
or `$RL_PRICING_DATA`.

The import package is `rl`, so this distribution can't share an environment
with the unrelated `rl` (GNU Readline bindings) distribution. The policy
interface, the `submission.json` fields, the record formats and the
`rl-pricing` commands follow semantic versioning; see the
[changelog](https://github.com/BichengWang/RL-pricing/blob/main/CHANGELOG.md).

- [Verdicts, findings and leaderboard](https://github.com/BichengWang/RL-pricing#readme)
- [Paper: Wang & Zhang, arXiv:2609.31870](https://arxiv.org/abs/2609.31870)

The training toolkit's environment, preprocessing and training code are
adapted from [FinRL](https://github.com/AI4Finance-Foundation/FinRL), which is
MIT-licensed.
