Skip to main content

A framework for creating trading bots

Project description

Investing Algorithm Framework

Create trading strategies. Compare them side by side. Pick the best one and Deploy ๐Ÿš€

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

Investing Algorithm Framework โ€” features overview

Join our Discord

Proudly sponsored by
Finterion

Introduction

Investing Algorithm Framework is a Python framework for creating, backtesting, and deploying trading strategies.

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 is actually better.

This framework is built around the full loop: create strategies โ†’ vector backtest for signals analysis โ†’ compare them in a single report โ†’ event backtest the most promising strategies โ†’ deploy the winner. It generates a self-contained HTML dashboard that lets you rank, filter, and visually compare every strategy you've tested โ€” all in one view, no notebooks required.

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.
  • ๐ŸŒ Load External Data โ€” Fetch CSV, JSON, or Parquet from any URL with caching and auto-refresh
  • ๏ฟฝ Record Custom Variables โ€” Track any indicator or metric during backtests with context.record()
  • ๏ฟฝ๐Ÿš€ Build โ†’ Backtest โ†’ Deploy โ€” Local dev, cloud deploy (AWS / Azure), or monetize on Finterion
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 โ€” all before committing to a full event-driven simulation.

Vector backtest engine โ€” run thousands of strategies in parallel

๐Ÿƒ Event-Driven Backtesting โ€” Bar-by-bar realism

Once you've narrowed down promising strategies, run them through a full event-driven simulation. Pluggable slippage and fill models, partial fills, and a complete simulation blotter โ€” using the same code path you'll deploy live.

Event-driven backtest engine โ€” bar-by-bar realism with order fills

Backtest Analysis & Dashboard

Every backtest produces a self-contained HTML dashboard โ€” open it in any browser, share with teammates, archive it. No server, no Jupyter, no dependencies. Compare strategies side-by-side, drill into trades, and capture your reasoning as you go.

Backtest analysis dashboard with MCP server and notes

  • Self-contained HTML reports โ€” equity curves, drawdowns, trade lists, monthly returns, side-by-side strategy comparison
  • Built-in MCP server โ€” let Copilot, Claude, or any MCP-compatible agent query your backtests, rank strategies, and reason over trades through investing-algorithm-framework mcp
  • Notes keeping โ€” annotate every backtest with hypotheses, observations and conclusions; notes travel with the report so your research is never lost

โ†’ Backtest dashboard docs ยท MCP server docs

Live Trading

Once a strategy proves itself in backtests, deploy it with the same code path you backtested. Connect to any exchange โ€” use the built-in CCXT integration, or plug in your own OrderExecutor for brokers, FIX gateways, or any custom venue. Run locally, in Docker, or deploy serverless to AWS Lambda or Azure Functions. Built-in portfolio tracking, position management, order persistence, and automatic state recovery.

Live trading & deployment โ€” AWS Lambda and Azure Functions

  • No code rewrites โ€” your TradingStrategy runs identically in backtest, paper trading and live
  • Cloud deploy โ€” investing-algorithm-framework init --type aws_lambda / --type azure_function
  • Multiple exchanges & venues โ€” CCXT integration out of the box (Binance, Bitvavo, Coinbase, Kraken โ€ฆ), or plug in your own OrderExecutor for any broker / FIX / custom venue
  • Portfolio persistence โ€” trades, orders and positions survive restarts

โ†’ Live trading & deployment docs

Marketplace Integration

Publish your winning strategies to the Finterion marketplace and monetize them. Investors subscribe to your bot, you earn a recurring revenue share โ€” the framework handles the technical integration.

Marketplace integration โ€” featuring Finterion

โ†’ Finterion plugin

Usage and Installation

To get started, install the framework and scaffold a new project:

pip install investing-algorithm-framework

# Generate project structure
investing-algorithm-framework init

# Or for cloud deployment
investing-algorithm-framework init --type aws_lambda
investing-algorithm-framework init --type azure_function

The documentation provides guides and API reference. The quick start will walk you through your first strategy.

Creating a Strategy

The framework is designed around the TradingStrategy class. You define what data your strategy needs and when to buy or sell โ€” the framework handles execution, position management, and reporting.

from typing import Dict, Any

import pandas as pd
from pyindicators import ema, rsi, crossover, crossunder

from investing_algorithm_framework import (
    TradingStrategy, DataSource, TimeUnit, DataType,
    PositionSize, ScalingRule, StopLossRule,
)


class RSIEMACrossoverStrategy(TradingStrategy):
    """
    EMA crossover + RSI filter strategy with position scaling and stop losses.

    Buy when RSI is oversold AND a recent EMA crossover occurred.
    Sell when RSI is overbought AND a recent EMA crossunder occurred.
    Scale into winners, trail a stop loss, and let the framework handle the rest.
    """
    time_unit = TimeUnit.HOUR
    interval = 2
    symbols = ["BTC", "ETH"]
    data_sources = [
        DataSource(
            identifier="BTC_ohlcv", symbol="BTC/EUR",
            data_type=DataType.OHLCV, time_frame="2h",
            market="BITVAVO", pandas=True, warmup_window=100,
        ),
        DataSource(
            identifier="ETH_ohlcv", symbol="ETH/EUR",
            data_type=DataType.OHLCV, time_frame="2h",
            market="BITVAVO", pandas=True, warmup_window=100,
        ),
    ]

    # Risk management
    position_sizes = [
        PositionSize(symbol="BTC", percentage_of_portfolio=20),
        PositionSize(symbol="ETH", percentage_of_portfolio=20),
    ]
    scaling_rules = [
        ScalingRule(
            symbol="BTC", max_entries=3,
            scale_in_percentage=[50, 25], cooldown_in_bars=5,
        ),
        ScalingRule(
            symbol="ETH", max_entries=3,
            scale_in_percentage=[50, 25], cooldown_in_bars=5,
        ),
    ]
    stop_losses = [
        StopLossRule(
            symbol="BTC", percentage_threshold=5,
            sell_percentage=100, trailing=True,
        ),
        StopLossRule(
            symbol="ETH", percentage_threshold=5,
            sell_percentage=100, trailing=True,
        ),
    ]

    def generate_buy_signals(
        self, data: Dict[str, Any]
    ) -> Dict[str, pd.Series]:
        signals = {}

        for symbol in self.symbols:
            df = data[f"{symbol}_ohlcv"]
            ema_short = ema(df, period=12, source_column="Close",
                           result_column="ema_short")
            ema_long = ema(ema_short, period=26, source_column="Close",
                          result_column="ema_long")
            ema_cross = crossover(ema_long,
                                  first_column="ema_short",
                                  second_column="ema_long",
                                  result_column="ema_crossover")
            rsi_data = rsi(df, period=14, source_column="Close",
                          result_column="rsi")

            rsi_oversold = rsi_data["rsi"] < 30
            recent_crossover = (
                ema_cross["ema_crossover"].rolling(window=10).max() > 0
            )
            signals[symbol] = (rsi_oversold & recent_crossover).fillna(False)

        return signals

    def generate_sell_signals(
        self, data: Dict[str, Any]
    ) -> Dict[str, pd.Series]:
        signals = {}

        for symbol in self.symbols:
            df = data[f"{symbol}_ohlcv"]
            ema_short = ema(df, period=12, source_column="Close",
                           result_column="ema_short")
            ema_long = ema(ema_short, period=26, source_column="Close",
                          result_column="ema_long")
            ema_cross = crossunder(ema_long,
                                   first_column="ema_short",
                                   second_column="ema_long",
                                   result_column="ema_crossunder")
            rsi_data = rsi(df, period=14, source_column="Close",
                          result_column="rsi")

            rsi_overbought = rsi_data["rsi"] >= 70
            recent_crossunder = (
                ema_cross["ema_crossunder"].rolling(window=10).max() > 0
            )
            signals[symbol] = (rsi_overbought & recent_crossunder).fillna(False)

        return signals

Create as many strategy variants as you want โ€” different parameters, different indicators, different symbols โ€” then backtest them all and compare in a single report.

Backtest Report Dashboard

Every backtest produces a single HTML file you can open in any browser, share with teammates, or archive. No server, no dependencies, no Jupyter required.

Self-contained HTML backtest dashboard

from investing_algorithm_framework import BacktestReport

# After running backtests
report = BacktestReport(backtest)
report.show()  # Opens dashboard in your browser

# Or load previously saved backtests from disk
report = BacktestReport.open(directory_path="path/to/backtests")
report.show()

# Compare multiple strategies side by side
report = BacktestReport.open(backtests=[backtest_a, backtest_b, backtest_c])
report.show()

# Save as a self-contained HTML file
report.save("my_report.html")

Overview page โ€” KPI cards, key metrics ranking table, trading activity, return scenarios, equity curves, metric bar charts, monthly returns heatmap, return distributions, and window coverage matrix.

Strategy pages โ€” Deep dive into each strategy with per-run equity curves, rolling Sharpe, drawdown, monthly/yearly returns, and portfolio summary.

Capabilities
Backtest Report Dashboard Self-contained HTML report with ranking tables, equity curves, metric charts, heatmaps, and strategy comparison
Event-Driven Backtesting Realistic, order-by-order simulation
Vectorized Backtesting Fast signal research and prototyping
Cross-Sectional Pipelines Compute factors across many symbols at once โ€” rank, filter and score universes per iteration
50+ Metrics CAGR, Sharpe, Sortino, max drawdown, win rate, profit factor, recovery factor, volatility, and more
Live Trading Connect to exchanges via CCXT for real-time execution
Portfolio Management Position tracking, trade management, persistence
Cloud Deployment Deploy to AWS Lambda, Azure Functions, or run as a web service
Market Data Providers Built-in providers for CCXT, Yahoo Finance, Alpha Vantage, and Polygon โ€” or build your own
Load External Data Fetch CSV, JSON, or Parquet from any URL with caching, date parsing, and pre/post-processing
Record Custom Variables Track any indicator or metric during backtests with context.record()
Strategies OHLCV, tickers, custom data โ€” Polars and Pandas native
Extensible Custom data providers, order executors, and strategy classes
Plugins
Plugin Description
PyIndicators Technical analysis indicators (EMA, RSI, MACD, etc.)
Finterion Plugin Share and monetize strategies on Finterion's marketplace

Development & Contributing

We welcome contributions! Open an issue, pick one up, or send a PR.

git clone https://github.com/coding-kitties/investing-algorithm-framework.git
cd investing-algorithm-framework
poetry install

# Run all tests
python -m unittest discover -s tests

Resources

Risk Disclaimer

If you use this framework for real trading, do not risk money you are afraid to lose. Test thoroughly with backtesting first. Start small. We assume no responsibility for your investment results.

Acknowledgements

We want to thank all contributors to this project. A full list can be found in AUTHORS.md.

Sponsor

Finterion

Finterion โ€” Marketplace for trading bots. Monetize your strategies by publishing them on Finterion.

Project details


Release history Release notifications | RSS feed

This version

8.7.0

Download files

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

Source Distribution

investing_algorithm_framework-8.7.0.tar.gz (884.7 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file investing_algorithm_framework-8.7.0.tar.gz.

File metadata

  • Download URL: investing_algorithm_framework-8.7.0.tar.gz
  • Upload date:
  • Size: 884.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.13 Linux/6.17.0-1010-azure

File hashes

Hashes for investing_algorithm_framework-8.7.0.tar.gz
Algorithm Hash digest
SHA256 47703144540aeed10a2a9c45fc214db54671943e1421ccb14c52be447f92bc92
MD5 536e1b12bb22501fe66b260339e91eb5
BLAKE2b-256 ef2cf719ef6c5788eb3c91c404d171c00cc87799731f7e5232e501513541aa81

See more details on using hashes here.

File details

Details for the file investing_algorithm_framework-8.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for investing_algorithm_framework-8.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a08ba904ccb59124efb2c7b7f8f0efa5dba1e8e2882d5060d4b69d18b21a8a5
MD5 fcf51f39592f9225b47c20479e2ac264
BLAKE2b-256 cb570ae752031823cc79d7cd567d443476d8f0d1c92c6656f9724416915f4fe3

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