MCPcopy Index your code
hub / github.com/coding-kitties/investing-algorithm-framework

github.com/coding-kitties/investing-algorithm-framework @v8.10.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v8.10.0 ↗ · + Follow
6,068 symbols 27,636 edges 681 files 2,503 documented · 41%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Investing Algorithm Framework

The full quant workflow in one framework: build strategies, vector & event-driven backtest at scale, compare in a single dashboard, and deploy the winner 🚀

linux main macos main windows main pypi downloads license discord reddit stars

<img src="https://github.com/coding-kitties/investing-algorithm-framework/raw/v8.10.0/static/features/hero-dark.svg" alt="Investing Algorithm Framework — features overview" style="max-width: 100%;">

Join our Discord

Proudly sponsored by

Finterion

Introduction

Investing Algorithm Framework is a Python framework that covers the entire quant workflow: define a strategy once, vector-backtest thousands of parameter variants to find promising signals, narrow down with a storage layer that ranks 10k+ results in milliseconds, validate the winners in a realistic event-driven simulation, compare everything in a single interactive HTML dashboard, and deploy the best performer live, all with the same TradingStrategy class, no code rewrites between stages.

Most quant frameworks stop at "here's your backtest result." You get a number, maybe a chart, and then you're on your own figuring out which strategy variant is actually better, whether the result is robust across time windows, and how to go from research to production. This framework closes that gap.

Want to see this in practice? Check out the examples/tutorial/: a series of runnable notebooks that walk you through every stage: defining a strategy, visualizing its signals, sweeping parameters across rolling windows, detecting overfitting with Monte Carlo permutation tests, filtering and ranking with the storage layer, and deploying the winner.

Features

  • 📊 30+ Metrics — CAGR, Sharpe, Sortino, Calmar, VaR, CVaR, Max DD, Recovery & more
  • 🧮 Cross-Sectional Pipelines — Rank, filter and score entire universes of symbols every iteration with a tidy factor table
  • Vector Backtesting for Signal Analysis — Quickly test your strategy logic on historical data to see how signals would have behaved before committing to full event-driven backtests
  • 🏃 Event-Driven Backtesting — Once promising strategies are identified via vector backtests, run full event-driven backtests to simulate realistic execution and portfolio management
  • 🔀 Permutation Testing / Monte Carlo Simulations — Assess the statistical robustness of your strategies by running them across randomized market scenarios to see how often your results could occur by chance
  • 🚀 Deployment — Once the best strategy is identified through backtesting and comparison, deploy it to production locally or in the cloud (AWS Lambda / Azure Functions) to start live trading
  • ⚔️ Multi-Strategy Comparison — Rank, filter & compare strategies in a single interactive report
  • 🪟 Multi-Window Robustness — Test across different time periods with window coverage analysis
  • 📈 Equity & Drawdown Charts — Overlay equity curves, rolling Sharpe, drawdown & return distributions
  • 🗓️ Monthly Heatmaps & Yearly Returns — Calendar heatmap per strategy with return/growth toggles
  • 🎯 Return Scenario Projections — Good, average, bad & very bad year projections from backtest data
  • 📉 Benchmark Comparison — Beat-rate analysis vs Buy & Hold, DCA, risk-free & custom benchmarks
  • 📄 One-Click HTML Report — Self-contained file, no server, dark & light theme, shareable
  • 📦 Custom .iafbt Backtest Bundle Format — An explicit, versioned, compressed, language-portable container (zstd + msgpack with magic-byte header) plus a separate parquet index for fast filtering without loading. ~21× smaller and ~27× fewer files than standard filebased directory layouts, with parallel I/O for fast load/save of large amounts of backtests.
  • 🗄️ Tiered Backtest Storage Layer — Manage thousands of .iafbt bundles with a Tier-1 SQLite index (sub-100 ms ranks/filters over 10k+ backtests), a swappable BacktestStore protocol (LocalDirStore, LocalTieredStore), content-addressed Tier-3 OHLCV deduplication, and a CLI (iaf index / iaf list / iaf rank / iaf migrate-store) that plugs straight into the HTML dashboard.
  • 🌐 Load External Data — Fetch CSV, JSON, or Parquet from any URL with caching and auto-refresh
  • Per-Market Deposit Schedules & Portfolio Sync — Declare recurring or one-shot external cash flows on a market with deposit_schedule= / auto_sync=True. Backtests simulate the deposits; live mode reconciles with the broker — same context.sync_portfolio() API in both modes.
  • 📝 Record Custom Variables — Track any indicator or metric during backtests with context.record()
  • ⏱️ Signal Cooldowns: Throttle whipsaw with declarative CooldownRules: per-symbol or portfolio-wide, side-aware (trigger="sell", blocks="buy"), enforced identically by the vector and event-driven engines
  • 🚀 Build → Backtest → Deploy — Local dev, cloud deploy (AWS / Azure), or monetize on Finterion

Strategy Definition

Declare what data your strategy needs and when to buy or sell as a TradingStrategy subclass — the framework wires up data loading, signal evaluation, order execution, position management, and reporting around it. The same class runs unchanged in vector backtests, event-driven backtests, paper trading and live.

Want strategy ideas to start from? Check out examples/strategies_showcase/: a collection of runnable strategy templates (trend following, mean reversion, cross-sectional momentum, multi-factor, pairs trading, and more).

Risk and execution behaviour are expressed as declarative rule lists rather than ad-hoc code paths, so the engines can enforce them identically across modes:

  • position_sizes: PositionSize per symbol (fixed amount or percentage of portfolio).
  • stop_losses / take_profits: StopLossRule / TakeProfitRule with fixed or trailing thresholds and partial-exit sell_percentage.
  • scaling_rules: ScalingRule for pyramiding (scale_in_percentage=[…], max_entries, per-symbol cooldown_in_bars).
  • cooldowns: CooldownRule to throttle whipsaw — per-symbol or portfolio-wide, side-aware (e.g. trigger="sell", blocks="buy", bars=12). Enforced bar-for-bar in both the vector and event-driven engines.
  • trading_costs: TradingCost per symbol (fees, slippage, fixed costs).
from investing_algorithm_framework import (
    TradingStrategy,
    PositionSize,
    ScalingRule,
    StopLossRule,
    TakeProfitRule,
    CooldownRule,
    TradingCost,
)


class MyStrategy(TradingStrategy):
    symbols = ["BTC", "ETH"]

    position_sizes = [
        PositionSize(symbol="BTC", percentage_of_portfolio=20),
        PositionSize(symbol="ETH", percentage_of_portfolio=20),
    ]

    stop_losses = [
        StopLossRule(symbol="BTC", percentage_threshold=5, trailing=True),
        StopLossRule(symbol="ETH", percentage_threshold=5, trailing=True),
    ]

    take_profits = [
        TakeProfitRule(
            symbol="BTC", percentage_threshold=10, sell_percentage=50,
        ),
        TakeProfitRule(
            symbol="ETH", percentage_threshold=10, sell_percentage=50,
        ),
    ]

    scaling_rules = [
        ScalingRule(
            symbol="BTC", max_entries=3, scale_in_percentage=[50, 25],
        ),
        ScalingRule(
            symbol="ETH", max_entries=3, scale_in_percentage=[50, 25],
        ),
    ]

    cooldowns = [
        CooldownRule(symbol="BTC", trigger="sell", blocks="buy", bars=12),
        CooldownRule(trigger="any", blocks="any", bars=2),
    ]

    trading_costs = [
        TradingCost(symbol="BTC", fee_percentage=0.1),
        TradingCost(symbol="ETH", fee_percentage=0.1),
    ]

    def generate_buy_signals(self, data):
        ...

    def generate_sell_signals(self, data):
        ...

Strategy docs

Backtesting Engines

⚡ Vector Backtesting — Test thousands of strategies, fast

Polars-powered vectorized signal evaluation. Compare thousands of strategies side by side, sweep parameter grids, run multi-window robustness checks, rank by key metrics and surface your top candidates in seconds

Core symbols most depended-on inside this repo

get
called by 546
investing_algorithm_framework/domain/backtesting/bundle.py
n
called by 407
docusaurus/docs/assets/js/main.628f15e7.js
find
called by 290
investing_algorithm_framework/services/repository_service.py
keys
called by 187
investing_algorithm_framework/domain/backtesting/bundle.py
get_amount
called by 171
investing_algorithm_framework/domain/models/order/order.py
exists
called by 165
investing_algorithm_framework/services/backtest_store/base.py
create
called by 164
investing_algorithm_framework/services/repository_service.py
a
called by 161
docusaurus/docs/assets/js/main.628f15e7.js

Shape

Method 3,786
Function 1,426
Class 805
Route 51

Languages

Python85%
TypeScript15%
Rust1%

Modules by API surface

docusaurus/docs/assets/js/main.628f15e7.js372 symbols
investing_algorithm_framework/app/reporting/templates/dashboard.js181 symbols
tests/services/metrics/test_trades.py99 symbols
tests/services/metrics/test_returns.py99 symbols
tests/infrastructure/services/test_backtest_service.py92 symbols
tests/domain/test_blotter.py83 symbols
investing_algorithm_framework/app/context.py76 symbols
investing_algorithm_framework/domain/blotter.py69 symbols
investing_algorithm_framework/app/app.py64 symbols
tests/cli/test_mcp_server.py59 symbols
investing_algorithm_framework/domain/pipeline/factor.py57 symbols
tests/services/metrics/test_profit_factor.py56 symbols

For agents

$ claude mcp add investing-algorithm-framework \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page