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

Total release size: 226.5 MB

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

Download URL almanak-2.28.0-py3-none-win_amd64.whl
Size 51.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
2bec525a39cde2a3e929b841b4746180fc339a3bc02f16497a9566f2d2a897c9
BLAKE2b-256 checksum
How to use checksums
3fda036fe1dd17bfd77717b182a793deca3b97b409cb722db23e498c31b98f2d
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.28.0-py3-none-manylinux_2_17_x86_64.whl

Download URL almanak-2.28.0-py3-none-manylinux_2_17_x86_64.whl
Size 48.5 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
86bdaf677312892c734d793642dfb30eb0fce5b1ba9481be6353ae5896bc132b
BLAKE2b-256 checksum
How to use checksums
7891736e0109104972746a418e13207cfbf047ef015052312b4299882227aa1b
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.28.0-py3-none-manylinux_2_17_aarch64.whl

Download URL almanak-2.28.0-py3-none-manylinux_2_17_aarch64.whl
Size 48.4 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
69f39fa954c584a0f3e56a75b6b3d1472f9b8feea2d611a47963ddbe44a49739
BLAKE2b-256 checksum
How to use checksums
131145f0a4307476e2c8a346ff56e21d9a7969edae70b488a5a811cccde915d4
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.28.0-py3-none-macosx_11_0_x86_64.whl

Download URL almanak-2.28.0-py3-none-macosx_11_0_x86_64.whl
Size 40.3 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
34d64b665d6067559651bb0051c3c9d612947c7617e9b5dbdebf270f7e4a652a
BLAKE2b-256 checksum
How to use checksums
129ef1d7771b6aeb4d97ace5c82ecd193213d3632603be6b26e15dadc2934c62
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.28.0-py3-none-macosx_11_0_arm64.whl

Download URL almanak-2.28.0-py3-none-macosx_11_0_arm64.whl
Size 37.6 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1ae36ea80d4e6815e9e4652922228100006204d03c76b1f34c135402e5f566ce
BLAKE2b-256 checksum
How to use checksums
f537c492c3691f65620aeb25b48aec9bca2ecc3ad6ff14e9909de9346290095f
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.28.0 This release

5 release files

2.26.2

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