Skip to main content

Strategic Symbolic Trading Engine with iterative R2 fitting and FunctionGemma discovery.

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).

Component Role
Symbolic Regressor Fits variables to R2 > 0.95 using Polynomial and Fourier basis functions.
FunctionGemma AI architect that suggests optimal mathematical compositions of signals.
Power Hub OS-level optimization for maximum throughput (Eco, Balanced, Turbo).

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]"

📊 Performance & Research

The SymbolicBasis framework achieves high-fidelity trend fitting by decomposing signals into Polynomial and Fourier series.

Asset Discovered Function Fidelity ($R^2$)
AAPL Polynomial (Deg 4) 0.9337
MSFT Polynomial (Deg 5) 0.9370
GOOGL Polynomial (Deg 3) 0.9617
NVDA Polynomial (Deg 3) 0.9211

[!NOTE] Higher $R^2$ values indicate greater trend stability, allowing the PortfolioAllocator to prioritize assets with minimal mathematical uncertainty.


Quick Start

Python API

import sagan

# Train a symbolic ensemble with high-accuracy math fitting
model_id = sagan.train(
    ["AAPL"], 
    signals=["Close", "Volume", "RSI"], 
    target_r2=0.95,
    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 --r2 0.95 --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.3.1.tar.gz (63.6 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.3.1-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sagan_trade-0.3.1.tar.gz
  • Upload date:
  • Size: 63.6 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.3.1.tar.gz
Algorithm Hash digest
SHA256 7a89901e16847c7c1b7c94bd56f06a60b765b2e6d42adae4550aac221a29e48e
MD5 c29f5ddf5665a3515469d319d9bd1037
BLAKE2b-256 8354bfd5f803dd90c25177f191068e5794ccf258399025de1b7b5fe006771540

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sagan_trade-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 44.5 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b29149fbfb1b83201f437444c0515448d99d7e39bf12e55094ce1dbedea9b32
MD5 2792707c86feed5859e78369c8e456bd
BLAKE2b-256 a0ab74cdb5a2a786337c021877eda1b3f895c4836a07b521eebc2dd9778d1086

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