Almanak SDK
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
-
Create a New Strategy (scaffolds a self-contained Python project with
pyproject.toml,.venv/,uv.lock)almanak strat new
-
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| almanak-2.29.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| almanak-2.29.0-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| almanak-2.29.0-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| almanak-2.29.0-py3-none-macosx_11_0_x86_64.whl | Python 3 | none | macOS 11.0+ x86-64 | Details |
| almanak-2.29.0-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.0-py3-none-win_amd64.whl
| Download URL | almanak-2.29.0-py3-none-win_amd64.whl |
|---|---|
| Size | 51.8 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0b6a5703f13df3fb34cd4703083f3398727eb9c3b15da152ff9b3356143353c5
|
|
BLAKE2b-256 checksum How to use checksums |
57e8cd3e395ef00148df6b2e7a96b977106ccf6556cf51481928081c5c0331e6
|
| 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.0-py3-none-manylinux_2_17_x86_64.whl
| Download URL | almanak-2.29.0-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 |
21df7a4f6fbcb6d7a6e4d86eace88210c6aa4d833a1ea53795f5ec6d6476fe19
|
|
BLAKE2b-256 checksum How to use checksums |
8176357a9a96cf2286aefdee5e09793c55b231acc0c93a70ca48ea43002ed4a4
|
| 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.0-py3-none-manylinux_2_17_aarch64.whl
| Download URL | almanak-2.29.0-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 |
6ab08e0604c9beb7ae3882a6442e5abaacde12da7cf8c1cee2f92d378c107573
|
|
BLAKE2b-256 checksum How to use checksums |
84a88b9614ca650010bf5cff403be203308922fc7912ba0691568f95f53c8753
|
| 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.0-py3-none-macosx_11_0_x86_64.whl
| Download URL | almanak-2.29.0-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 |
f9523ab3c51db73aa638af9db3f37586a73667b9067cce46ea07c521bc79a60d
|
|
BLAKE2b-256 checksum How to use checksums |
dcfbf7103b25842fd84b8b4987030b1118d7c3b95894c956f7b59c58a7c43dc4
|
| 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.0-py3-none-macosx_11_0_arm64.whl
| Download URL | almanak-2.29.0-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 |
e0a2fdbf2746079bb2cd525a1e669b1584a9fa030159597ea1b1e76f92b8272d
|
|
BLAKE2b-256 checksum How to use checksums |
4bc20379c5c10de9a03a6f0158bc4e56f13986c32ef9e44d4afc089987842f24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.14
|