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.27.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.27.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| almanak-2.27.0-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| almanak-2.27.0-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| almanak-2.27.0-py3-none-macosx_11_0_x86_64.whl | Python 3 | none | macOS 11.0+ x86-64 | Details |
| almanak-2.27.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
Total release size: 228.2 MB
Release files / almanak-2.27.0-py3-none-win_amd64.whl
| Download URL | almanak-2.27.0-py3-none-win_amd64.whl |
|---|---|
| Size | 52.1 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5150ce29272bf955cbadbc2b207b8ac03b83a6fe4fdc428346e7bf586e9d6613
|
|
BLAKE2b-256 checksum How to use checksums |
eff2ff0d258ee10c746aafb68d2d615c28c89ae0c4478e8f74efca731d051166
|
| 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.27.0-py3-none-manylinux_2_17_x86_64.whl
| Download URL | almanak-2.27.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 |
37d33726d599d1d1e3ba63edd8bc6f86dde85c2d4e5cfb7300dd6dbc77c6f9a1
|
|
BLAKE2b-256 checksum How to use checksums |
7e8c79deba18dff55e90a2dac18a00cafcf5514a4e89cc55113778d7c81d336e
|
| 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.27.0-py3-none-manylinux_2_17_aarch64.whl
| Download URL | almanak-2.27.0-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 |
602856da6209f9849e00ff2cd193c4877db515403fc22fda9799e189ff6f2692
|
|
BLAKE2b-256 checksum How to use checksums |
9e4b0f08f0d5ff9f9baac9f62a502a4077a270012371f171994752179634f0b9
|
| 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.27.0-py3-none-macosx_11_0_x86_64.whl
| Download URL | almanak-2.27.0-py3-none-macosx_11_0_x86_64.whl |
|---|---|
| Size | 40.6 MB |
| Tags | Python 3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
30ae0981fe283ee7ea7c3b2397a5be0fef1ff6dee117d3fda71b34eb1fa62017
|
|
BLAKE2b-256 checksum How to use checksums |
7e70c878e08b75026ff2cbcc7d1f28f825840445f56a2a77bea3b9b879d88adb
|
| 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.27.0-py3-none-macosx_11_0_arm64.whl
| Download URL | almanak-2.27.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 38.0 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5d2ac473c0f10ac287539a8b615c511ce695c06c8ad5c3542414a0d25d0414ae
|
|
BLAKE2b-256 checksum How to use checksums |
c4379142988ecbf94b0bad903d2320f6213ba94c8c4491ba280736a53b57b5e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.14
|