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

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.2
File
almanak-2.26.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
almanak-2.26.2-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
almanak-2.26.2-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
almanak-2.26.2-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details
almanak-2.26.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 228.4 MB

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

Download URL almanak-2.26.2-py3-none-win_amd64.whl
Size 52.1 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
917a0a81d42461dbb0b4a5b3bbefee2caec3e8be8bccc40c83ef401669692d82
BLAKE2b-256 checksum
How to use checksums
5463d0e0238d722d969fdbfa01e9fc493f2bd7c25ac51983cfa6292ae10fa2aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.14

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

Download URL almanak-2.26.2-py3-none-manylinux_2_17_x86_64.whl
Size 48.8 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
413b9735a3a211133119bf25cb2b80827476e9446cf11507de666848f129954b
BLAKE2b-256 checksum
How to use checksums
860b5c5874c144a2b91d515dca2e1a55ed3a6f914a32025fdeb5bd199b532aa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.14

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

Download URL almanak-2.26.2-py3-none-manylinux_2_17_aarch64.whl
Size 48.7 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
80ba05a1763b596da2647cf89620879b272409eaa26b3daa61dc553a119e8eb1
BLAKE2b-256 checksum
How to use checksums
327a31dde76eb6d4171fa238469ffee7142a052ff6b13c63bd1c2549576150aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.14

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

Download URL almanak-2.26.2-py3-none-macosx_11_0_x86_64.whl
Size 40.7 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
273dc66ad4d13c7aa9ec2f9bbdd64c018bd1abb840b93a134e054c79a0deb2e9
BLAKE2b-256 checksum
How to use checksums
07f6400bf2f99983d160634b02bc085e1142533f8df5ffaeb087a84030d3fe10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.14

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

Download URL almanak-2.26.2-py3-none-macosx_11_0_arm64.whl
Size 38.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
37479af6c54a2b8572b86eca154d51f24df54d6d85c67dc91ede420729c2245c
BLAKE2b-256 checksum
How to use checksums
8cde379b1c07eca76a54d564e022703a3ef96902ffbb33c266e3ea577061589c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.14

Release history Release notifications | RSS feed

2.29.1

5 release files

2.29.0

5 release files

This release

2.26.2 This release

5 release files

2.26.1

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