Skip to main content

Almanak SDK

PyPI version

The Almanak SDK is a powerful Python library for developing, testing, and deploying autonomous DeFi agents. Built on an intent-based architecture, it provides a comprehensive framework for creating sophisticated trading strategies with minimal boilerplate.

Features

  • Intent-Based Architecture: Express trading logic as high-level intents (Swap, LP, Borrow, etc.) - the framework handles compilation and execution
  • Gateway Security: All external access mediated through secure gRPC gateway
  • Three-Tier State Management: Automatic persistence with HOT/WARM/COLD tiers
  • Comprehensive Backtesting: PnL simulation, paper trading on Anvil forks, and parameter sweeps
  • Multi-Chain Support: Ethereum, Arbitrum, Optimism, Base, Avalanche, Polygon, BSC, Sonic, Blast, Mantle, Berachain
  • Protocol Integration: Uniswap V3, Aave V3, Morpho Blue, GMX V2, Lido, Ethena, Kraken, and more
  • Non-Custodial Design: Full control over your funds through Safe smart accounts

Installation

pipx install almanak

Optional features ship as extras:

pipx install 'almanak[dashboard,backtest]'   # web dashboard + backtest charts/optimization
Extra Enables
dashboard almanak dashboard and the strategy/backtest web dashboards (streamlit, plotly)
backtest backtest chart export and almanak strat backtest optimize (matplotlib, plotly, optuna)
code Python LSP for almanak code (pyright)

Using an AI coding agent? Teach it the SDK in one command:

almanak agent install

Auto-detects your platform (Claude Code, Codex, Cursor, Copilot, and 6 more) and installs the strategy builder skill.

Quick Start

  1. Create a New Strategy (scaffolds a self-contained Python project with pyproject.toml, .venv/, uv.lock)

    almanak strat new
    
  2. Test on a Local Anvil Fork

    cd my_strategy
    uv run almanak strat run --network anvil --once
    

Writing a Strategy

Strategies use an intent-based architecture. Implement the decide() method to return an intent:

from almanak import IntentStrategy, SwapIntent, HoldIntent, MarketSnapshot

class MyStrategy(IntentStrategy):
    def decide(self, market: MarketSnapshot) -> Intent:
        eth_price = market.prices.get("ETH")
        usdc_balance = market.balances.get("USDC")

        if eth_price < 2000 and usdc_balance > 1000:
            return SwapIntent(
                token_in="USDC",
                token_out="ETH",
                amount=1000,
                slippage=0.005,
            )
        return HoldIntent(reason="Waiting for better conditions")

Supported Networks

Ethereum, Arbitrum, Optimism, Base, Avalanche, Polygon, BSC, Sonic, Plasma, Blast, Mantle, Berachain

Supported Protocols

  • DEXs: Uniswap V3, SushiSwap V3, PancakeSwap V3, TraderJoe V2, Aerodrome, Curve
  • Lending: Aave V3, Morpho Blue, Compound V3, Spark
  • Liquid Staking: Lido, Ethena
  • Yield: Pendle
  • Perpetuals: GMX V2, Hyperliquid
  • CEX Integration: Kraken
  • Aggregators: Enso, LiFi

Pending testing: Prediction Markets (Polymarket) and Flash loans are undergoing further validation and are temporarily withheld from the supported matrix (almanak info matrix). Treat them as experimental.

Contributing

See the Contributing Guide to get started.

Documentation

For detailed documentation, visit sdk.docs.almanak.co

Support

Release files for almanak 2.26.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for almanak 2.26.1
File
almanak-2.26.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
almanak-2.26.1-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
almanak-2.26.1-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
almanak-2.26.1-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details
almanak-2.26.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 220.7 MB

Release files / almanak-2.26.1-py3-none-win_amd64.whl

Download URL almanak-2.26.1-py3-none-win_amd64.whl
Size 50.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
0aababf57ecc9287f39e660fb9daccd210afd914c910dee6e1e5965a05425dc5
BLAKE2b-256 checksum
How to use checksums
1df6cabec4b1940c705a0fc394332b417e034e61875f66e6d07cf182301a515a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.13

Release files / almanak-2.26.1-py3-none-manylinux_2_17_x86_64.whl

Download URL almanak-2.26.1-py3-none-manylinux_2_17_x86_64.whl
Size 48.0 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
42fc9ff4f321d02cbb1bb3a90bb3e20cc0d077d8f63cddc924e71fb10d2af4b9
BLAKE2b-256 checksum
How to use checksums
1d0b4c69d7403b1eb88e4b9379a2f7bfb74a65291ad5b494fd48257f5e042a59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.13

Release files / almanak-2.26.1-py3-none-manylinux_2_17_aarch64.whl

Download URL almanak-2.26.1-py3-none-manylinux_2_17_aarch64.whl
Size 47.7 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3e6d92ec535f21686c81bf02ceef7cc019392c1468bc02708b7f89d6018b04e1
BLAKE2b-256 checksum
How to use checksums
aa0c20baa37e9284fc7311d8c8d31850d3201f2ac992939597722b89c014db16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.13

Release files / almanak-2.26.1-py3-none-macosx_11_0_x86_64.whl

Download URL almanak-2.26.1-py3-none-macosx_11_0_x86_64.whl
Size 38.5 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
6f65be4cd619e9cf9b05caeab89b4c0cf4712ff415b8b53005fb43e8c834cfea
BLAKE2b-256 checksum
How to use checksums
be2c7d0cf34d1c9d204df2a3e219ba9612ebdd24179ba916d2c327cfaf7a767e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.13

Release files / almanak-2.26.1-py3-none-macosx_11_0_arm64.whl

Download URL almanak-2.26.1-py3-none-macosx_11_0_arm64.whl
Size 36.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
555fd872b5b2683a0cd792215326a245e9c0d9cb1de045692dc6ecd8788445c3
BLAKE2b-256 checksum
How to use checksums
287cf09ec59c4e5855bd423d317c7e997bc8de7c8a1a22faac5cbc8953847d31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.13

Release history Release notifications | RSS feed

2.29.1

5 release files

2.29.0

5 release files

2.26.2

5 release files

This release

2.26.1 This release

5 release files

2.26.0

5 release files

2.25.1

5 release files

2.25.0

5 release files

2.24.0

5 release files

2.23.0

5 release files

2.22.0

5 release files

2.20.0

5 release files

2.19.1

5 release files

2.19.0

5 release files

2.18.0

5 release files

2.16.0

5 release files

2.15.0

5 release files

2.14.0

5 release files

2.13.0

5 release files

2.12.0

5 release files

2.9.0

5 release files

2.8.1

5 release files

2.8.0

5 release files

2.7.0

5 release files

2.6.4

5 release files

2.6.3

5 release files

2.6.2

5 release files

2.6.1

5 release files

2.6.0

5 release files

2.5.0

5 release files

2.4.0

5 release files

2.3.0

5 release files

2.2.1

5 release files

2.2.0

5 release files

2.1.0

5 release files

2.0.0

5 release files

1.0.9

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page