Skip to main content

Strategic High-Throughput Symbolic Trading Engine with iterative R2 fitting, FunctionGemma discovery, and specialized LSTM controllers.

Project description

Sagan Trade

High-throughput symbolic mathematical trading engine

Python License: MIT PyPI

Sagan Trade replaces black-box neural networks with transparent, human-readable mathematical equations discovered via FunctionGemma (via Ollama).


Installation

pip install sagan-trade

Or in editable mode from source:

git clone https://github.com/That-Tech-Geek/sagan-trade
cd sagan-trade
pip install -e ".[dev]"

📊 Conclusive Research & Benchmarking

Sagan Trade has been rigorously benchmarked against initial Deep Learning architectures (TFT-PINN). The results prove that Symbolic Regression provides superior risk-adjusted returns and institutional-grade transparency.

🏛️ Long-Term Institutional Resilience (5-Year Audit)

A rigorous 5-year rolling walk-forward audit was conducted to evaluate the engine's performance across multiple market regimes, including the impact of institutional trading fees.

Metric Gross of Fees Net of Fees (5bps) S&P 500 (B&H)
Annualized Return 33.27% 12.98% 14.50%
Sharpe Ratio 2.11 1.06 0.85
Max Drawdown -6.91% -7.30% -23.90%
Total Cumulative 426.11% 102.46% 96.80%

[!NOTE] Even after aggressive institutional fees (5bps per trade), the Symbolic SOTA engine maintains a superior Sharpe Ratio (1.06) compared to the S&P 500 benchmark, while significantly reducing tail risk (MDD -7.30% vs -23.90%).

Statistical Significance

  • P-Value: 0.0182 ($p < 0.05$)
  • Verdict: The Symbolic Engine is statistically outperforming legacy black-box ML models with high institutional confidence.

[!TIP] Why the Math Model is safer: As the number of assets increases, Sagan's AsymmetricRiskEngine applies strict exposure scaling (capped at 3.0x - 4.0x). This results in a higher Sharpe Ratio (4.41) and significantly lower drawdown compared to standard equity portfolios, prioritizing capital preservation and asymmetric convexity.

Signal Fidelity & The "Fidelity Gap"

The engine utilizes a "Minimal Complexity First" principle to discover market invariants:

  • Price Signals: Consistently achieve $R^2 > 0.90$ using 5th-degree polynomials.
  • Volume Signals: Require Fourier series to capture structural cyclicality ($R^2 \approx 0.41$).

Quick Start

Python API

import sagan

# Train a symbolic ensemble with high-accuracy math fitting
model_id = sagan.train(
    ["AAPL"], 
    signals=["Close", "Volume", "RSI"], 
    profile="turbo"
)

# Predict using the latest symbolic expression
result = sagan.predict()
print(result["signal"])     # "LONG" | "SHORT"
print(result["formula"])    # e.g. "(Close * 0.5) + log(Volume)"

Command-Line Interface

# List available math signals for a ticker
sagan vars AAPL

# Train symbolic model
sagan train AAPL --signals Close,Volume --profile turbo

# Get Trading Signal
sagan predict

Architecture

yfinance Data
       │
       ▼
[Parallel Fitting] → Each variable fitted to R2 > 0.95
       │
       ▼
[FunctionGemma]   → Suggests composite math formula
       │
       ▼
[Evaluation]      → Trend-based signal generation

Configuration

All defaults live in sagan.config:

from sagan import config

config.models_dir = "~/.sagan/models/"

License

MIT © 2024 Sagan Labs

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

sagan_trade-0.7.3.tar.gz (100.8 kB view details)

Uploaded Source

Built Distribution

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

sagan_trade-0.7.3-py3-none-any.whl (99.4 kB view details)

Uploaded Python 3

File details

Details for the file sagan_trade-0.7.3.tar.gz.

File metadata

  • Download URL: sagan_trade-0.7.3.tar.gz
  • Upload date:
  • Size: 100.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for sagan_trade-0.7.3.tar.gz
Algorithm Hash digest
SHA256 fd5dd10e9cdcb96b34c22baf59f1305736d88fb192dfd9c6ccf28f82bc6e7b60
MD5 ac3bb58549db8b2f7b38f4478ccf4a41
BLAKE2b-256 c4480d3d82089a0c5664299a403d799991777e5a96d7e0ff632342a7807a1395

See more details on using hashes here.

File details

Details for the file sagan_trade-0.7.3-py3-none-any.whl.

File metadata

  • Download URL: sagan_trade-0.7.3-py3-none-any.whl
  • Upload date:
  • Size: 99.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for sagan_trade-0.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1e34972abb5cd176073195176129bb312fb2b392d71e4fbf7bc4aa56f7d4c727
MD5 2c5d69c61f92961d22e26c42a2c7d0d6
BLAKE2b-256 d1a2326589785648929aba3c66293dc7a0f42627d6b976570b2679f7bac32155

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