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

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

Total release size: 220.4 MB

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

Download URL almanak-2.26.0-py3-none-win_amd64.whl
Size 50.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
52e945fef6b27a9f328bbacc615aa22a391ea43cd6b23af211b7f169e082f084
BLAKE2b-256 checksum
How to use checksums
2a8b578364aed27611c74b61ae344f47b54af89021d6d897662141a9db422eae
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.0-py3-none-manylinux_2_17_x86_64.whl

Download URL almanak-2.26.0-py3-none-manylinux_2_17_x86_64.whl
Size 47.9 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c4c49a2c25f420d43854fbecc7c72e119a6ef8d0ffe2a72813d67a00dcd105b2
BLAKE2b-256 checksum
How to use checksums
e57f8efbdf84ea76aa7720c8ba0764f2117349528f8be5f196f5d47167ce0d6d
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.0-py3-none-manylinux_2_17_aarch64.whl

Download URL almanak-2.26.0-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
1bcff5e31416c61d16cb723c29cfc715c997a599806cfe4cb237c4b6a3c30121
BLAKE2b-256 checksum
How to use checksums
61f0088d70e5cd00ebfa128fc12730c5156c525189b9233dd7da8fdfd9050ebe
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.0-py3-none-macosx_11_0_x86_64.whl

Download URL almanak-2.26.0-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
92c5203393e09929ffbe88b6a11950e300e8c02174fa31a995061f16cb25b765
BLAKE2b-256 checksum
How to use checksums
f1039aececfa59e12ffd63d3c32a38d108116116f9eb15537c79fb29dee3f7a3
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.0-py3-none-macosx_11_0_arm64.whl

Download URL almanak-2.26.0-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
a4f81551e5ff0fa3708e40ac7719775c32b5e1887193bf3e3097c8df02e696ae
BLAKE2b-256 checksum
How to use checksums
053cbdc8b271bb47b6ba81c2d769530c3f5749b1c5831073a1544d3a8bb8afd6
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

2.26.1

5 release files

This release

2.26.0 This release

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