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

Total release size: 227.4 MB

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

Download URL almanak-2.29.1-py3-none-win_amd64.whl
Size 51.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
00e3ef46bddf102bc7c53770f0140295503423fe7d63e4a4b2de2764eaaf9221
BLAKE2b-256 checksum
How to use checksums
6334c8501fea942223d3cc67dff6702aa9502a1130ff8b87c9e16ba603974dbd
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.29.1-py3-none-manylinux_2_17_x86_64.whl

Download URL almanak-2.29.1-py3-none-manylinux_2_17_x86_64.whl
Size 48.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f0d118efd22e287e891808061dce6d85c51dba62d068c8c92bbe14286bf3cec3
BLAKE2b-256 checksum
How to use checksums
e56227d3b3cb9d371b54b970543f01d4350defecad35e653458f6a0f4ee855b6
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.29.1-py3-none-manylinux_2_17_aarch64.whl

Download URL almanak-2.29.1-py3-none-manylinux_2_17_aarch64.whl
Size 48.6 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
6cd818f375727689c36e9cbfcbf9f84394ef50f12e901779865eefe4743675b4
BLAKE2b-256 checksum
How to use checksums
6d0066212407f0c9cc253d1bdb1e09e3d47a39111e78d6a9fad2490f69f0ee13
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.29.1-py3-none-macosx_11_0_x86_64.whl

Download URL almanak-2.29.1-py3-none-macosx_11_0_x86_64.whl
Size 40.5 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
749b62737e90226be768910523f856b8d85e8a3eb5a7c0fcfa3621111ea76d42
BLAKE2b-256 checksum
How to use checksums
b3c0f963bae1b3cd5846e50347a0b0cf92f845a5c29de18c1c9a452c5b5b0d07
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.29.1-py3-none-macosx_11_0_arm64.whl

Download URL almanak-2.29.1-py3-none-macosx_11_0_arm64.whl
Size 37.8 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f693a04de3bf3eaea58323d06d7db74c6c5c644721c0e75b2b99fa563af73630
BLAKE2b-256 checksum
How to use checksums
f04045ce25e781e384546e0e1d9e2e97de7407d4d0b73e5a3189f825f840d393
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

This release

2.29.1 This release

5 release files

2.29.0

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