Skip to main content

Synthetic alternative-history generation for backtest overfitting detection

Project description

sablier-flow

sablier-flow

Stop shipping overfit backtests.
Run your strategy on N alternative versions of history that share your data's statistical fingerprint.

PyPI Python versions License Docs


What it is

sablier-flow is a Python SDK that learns the joint dynamics of your market data — cross-asset correlations, vol clustering, regime structure — and generates synthetic alternative histories that share those statistics but produce different specific paths.

Run your existing backtest on N alternative versions of the same data and turn a single P&L number into a distribution. If your strategy only works on the one history that happened, that's overfit — now measurable.

Install

pip install sablier-flow

Sign up at sablier.ai for an API key (free starter credits cover the entire getting-started notebook).

Quickstart

import sablier_flow as sf
import numpy as np

# 1. Auth (one-time device flow; sets ~/.sablier/credentials)
sf.login()

# 2. Your backtest. Takes a price DataFrame, returns dict[str, float].
def my_backtest(prices):
    rets = prices['SPY'].pct_change().dropna()
    return {'sharpe': float(rets.mean() / rets.std() * np.sqrt(252))} if rets.std() > 0 else {'sharpe': 0.0}

# 3. Load data — bundled demo or your own DataFrame.
df = sf.demo_data()                          # SPY/QQQ/IWM/TLT + 3 macro features, 2010-2023
backtest_window = df.iloc[-252:]             # the slice you'll evaluate

# 4. Train + generate synthetic alternative versions of the backtest window.
fit   = sf.fit(df, features=list(df.columns), data_types=df.attrs['data_types'], horizon=252)
paths = sf.generate(fit.model_id, n_paths=200, like=backtest_window)

# 5. Run your backtest on each synth path and score robustness.
real_result   = my_backtest(backtest_window)
synth_results = [my_backtest(p) for p in paths.as_dataframes()]
report = sf.robustness(real_result, synth_results, primary_metric='sharpe')

print(report.summary())

Examples

Live empirical demos with executed outputs baked in — open them on GitHub and see the numbers immediately:

Notebook What it proves
📓 Backtest Robustness At the 0.7 overfit_score threshold: flags 29 of 30 selection-biased lucky strategies (top 30 of a 500-strategy pure-noise search; max honest = 0.725, min lucky = 0.695) vs 1 of 12 false positives on a designed honest family
📓 TSTR Predictive Rank Spearman ρ = +0.74, 95% CI [+0.55, +0.83], p ≈ 4e-5 — synth ranks predict real OOS ranks
📓 Memorization Audit NN-distance ratio R = 0.9309 vs replay-floor R = 0.0161 — 57.8× separation, synth is genuinely new
📓 Getting Started End-to-end SDK tour: login → fit → validate → generate → robustness

Why use it

  • One call trains a model that handles cross-asset dependence, regime structure, and tail behavior — no hand-rolled copulas, no block-length tuning
  • Per-strategy overfit detection that classical CSCV-PBO can't surface (selection bias from parameter searches)
  • Train on synth, deploy on realsf.predictive_rank_score proves the ranking carries forward, so you don't have to burn real OOS data on strategy selection
  • Engine-agnostic: works with pandas, backtrader, vectorbt; LEAN CSV export adapter included

Docs

License

Apache 2.0 (code) · CC BY 4.0 (docs)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sablier_flow-1.0.15.tar.gz (599.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sablier_flow-1.0.15-py3-none-any.whl (607.6 kB view details)

Uploaded Python 3

File details

Details for the file sablier_flow-1.0.15.tar.gz.

File metadata

  • Download URL: sablier_flow-1.0.15.tar.gz
  • Upload date:
  • Size: 599.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for sablier_flow-1.0.15.tar.gz
Algorithm Hash digest
SHA256 467623143f4093e89e9e21e9326420d63bada53d1e69e819846245316b3da61a
MD5 3564bf31a248f6810c6e6c525f808016
BLAKE2b-256 0f3474489f170ba61893a7c3a226f48e9f1cbc6544cd60651959d0f6d660c3d5

See more details on using hashes here.

File details

Details for the file sablier_flow-1.0.15-py3-none-any.whl.

File metadata

  • Download URL: sablier_flow-1.0.15-py3-none-any.whl
  • Upload date:
  • Size: 607.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for sablier_flow-1.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 ad5cbd7e2e4b55321429540b90caec738210acaf08e5bc3ecd4ae720805090fd
MD5 3107bab94b14c0ec1fb087a60962fd9e
BLAKE2b-256 f792c87f30964e819e584159a996e8272feb735e5a3a674cdbfbdf837898c9a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page