Skip to main content

SignalFlow: modular framework for trading signal generation, validation and execution

Project description

SignalFlow

Real-time-first framework for trading signal research and execution

Version Python 3.12+ License: MIT Code style: ruff


SignalFlow V5 is a Polars-backed framework for algorithmic trading research that takes a strategy from idea to backtest to live with one object you can save and ship. The public surface is six nouns:

Noun What it is
Dataset One lazy, immutable market-data container. sf.data(...) builds it; the same object feeds backtest, paper, and live.
Transform A column-producing step - features (RSI, Returns, ZScore) and detectors (ThresholdDetector) share one contract.
Models ForecastModel (trainable predictor → probability column) plus validator combinators.
Flow The central, deployable, tradeable unit: forecasts → detectors → validator → strategy → risk.
Engine The decision/execution loop and brokers (SimBroker, ExchangeBroker).
Run The result of executing a Flow - equity curve, fills, and a standard .scorecard().

Install

pip install signalflow-trading
Extra Installs For
signalflow-trading[ta] (signalflow-ta plugin) 189+ technical indicators
signalflow-trading[rl] stable-baselines3, gymnasium, torch RL strategy models (Flow.env)
signalflow-trading[live] mlflow, huggingface_hub model artifact tracking / deploy
signalflow-trading[llm] anthropic, pydantic LLM-assisted flow authoring
signalflow-trading[dev] pytest, ruff, mypy development

Idea → first backtest

import signalflow as sf

ds = sf.data("memory", pairs=["BTCUSDT"], start="2023-01-01", interval="1h")

model = sf.ForecastModel(target=sf.FixedHorizon(bars=12),
                         features=sf.FeaturePipe(sf.SMA(10), sf.SMA(20), sf.SMA(50)))
model.fit(ds)                                          # train tier-1 forecaster

flow = sf.Flow(name="sma_rise",
               forecasts={"rise": model},
               detectors=[sf.ThresholdDetector(forecast="rise", p_min=0.6)],
               strategy=sf.RulesStrategy())
run = flow.backtest(ds, capital=50_000)
print(run.scorecard())                                 # total_return, sharpe, max_drawdown, ...

CLI

sf list                 # registry snapshot grouped by type
sf list transform       # one type, with one-line summaries
sf run flow.yaml --source memory --pairs BTCUSDT --start 2023-01-01 --interval 1h --capital 50000
sf promote flow.yaml --to shadow   # validate + show the registry op (real promotion: sf-prod)
sf version

Three invariants worth knowing

WoE/IV encoding is the default. Features flow through Weight-of-Evidence encoding against the target, and IVSelector keeps only columns whose Information Value clears a threshold. Encoding is monotone, leak-aware, and fit out-of-fold.

A Flow is inference-only. Every forecast slot (and the optional validator slot) must hold a trained model. Constructing a Flow around an unfitted model raises UntrainedModelError - you cannot accidentally deploy something untrained. The same Flow object runs backtest, paper, and live over the same Dataset; only the mode flag changes.

Deploy is data. flow.save(path) serializes the whole stack (config + trained artifacts) to YAML plus a model directory; sf.Flow.load(path) brings it back byte-for-byte. There is no code to redeploy - promoting a strategy is moving a file. Model artifacts can live on the local filesystem, MLflow, or the Hugging Face Hub (model.save("mlflow://..."), model.save("hf://...")).

flow.save("flows/rsi_rise.yaml")
same = sf.Flow.load("flows/rsi_rise.yaml")
assert same.backtest(ds, capital=50_000).final_equity == run.final_equity

Registry

Every core class registers under a name - that name is what flow.yaml serializes and sf list enumerates. Seven ComponentTypes: SOURCE, TRANSFORM, MODEL, STRATEGY, SAMPLER, BROKER, METRIC.

sf.registry.snapshot()                          # {type: [names]}
sf.registry.list(sf.ComponentType.TRANSFORM)    # ['atr', 'bbands', 'ema', ...]

Ecosystem

Package Description
signalflow-ta Technical-indicator plugin ([ta] extra)
sf-prod Promotion, shadow/live rollout, monitoring

License: MIT  ·  Author: pathway2nothing  ·  Docs: signalflow-trading.com

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

signalflow_trading-0.8.0.tar.gz (100.7 kB view details)

Uploaded Source

Built Distribution

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

signalflow_trading-0.8.0-py3-none-any.whl (134.9 kB view details)

Uploaded Python 3

File details

Details for the file signalflow_trading-0.8.0.tar.gz.

File metadata

  • Download URL: signalflow_trading-0.8.0.tar.gz
  • Upload date:
  • Size: 100.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for signalflow_trading-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3507cfc882cd09242c877427262155a69337a41d0f90a44f709b4a39ee184f57
MD5 4f27b250a90af671aa0e5ed65f9d671f
BLAKE2b-256 32f7a7db989f1d23696ced929691bf4616e9250c1ec82381326400cebb876435

See more details on using hashes here.

File details

Details for the file signalflow_trading-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for signalflow_trading-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3115972dd69ca1f4c95ede74d7da3a6272f81384dc50c8482f390741540f740d
MD5 c96ded66d8cddc39f6956c9dd044b24a
BLAKE2b-256 014e8103c2036c15850933141ade2a37fb207f82289752b736814ae21a39da68

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