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
Metadata
Release files for almanak 2.29.2
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.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| almanak-2.29.2-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| almanak-2.29.2-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| almanak-2.29.2-py3-none-macosx_11_0_x86_64.whl | Python 3 | none | macOS 11.0+ x86-64 | Details |
| almanak-2.29.2-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
Total release size: 228.0 MB
Release files / almanak-2.29.2-py3-none-win_amd64.whl
| Download URL | almanak-2.29.2-py3-none-win_amd64.whl |
|---|---|
| Size | 51.9 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9d7269fc77b06c2e875805936ec0e2420304c8bf21edf771317af6c8f44bf504
|
|
BLAKE2b-256 checksum How to use checksums |
339d197bcb7c8b682b5832981e58e1d76d1bc293a1a22a28661634cea2a0ea60
|
| 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.2-py3-none-manylinux_2_17_x86_64.whl
| Download URL | almanak-2.29.2-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 48.8 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
73b81e50f22fcd1b2ceed017fb3f56012cb39b77ebe7b9f3e2b9c5a3d80285b5
|
|
BLAKE2b-256 checksum How to use checksums |
36a929b78dd18d1969681cc492addd0d7c0cd03624423877efcd3ad4c6a21fdd
|
| 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.2-py3-none-manylinux_2_17_aarch64.whl
| Download URL | almanak-2.29.2-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 |
874f92f00f04c8a02d93e9b8f31e7775335ef7c667e5d0989706aeae27c65ebe
|
|
BLAKE2b-256 checksum How to use checksums |
b655d00cdda4286920fba06d5225a9d8114270202405515d1159259320e5aa2a
|
| 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.2-py3-none-macosx_11_0_x86_64.whl
| Download URL | almanak-2.29.2-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 |
cb94f337c179e0741f596515f3f49bc8e629dd3903f87d7b8873d98d15551a80
|
|
BLAKE2b-256 checksum How to use checksums |
6935253f7e48001c984745cba4d6dcc7b9517fb74cb26a355648fa2fe4bfb246
|
| 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.2-py3-none-macosx_11_0_arm64.whl
| Download URL | almanak-2.29.2-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 37.9 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0e5a9e1be0bb0c331371b145e43101a60378b5d8b3fe74223d7bc01c10695b66
|
|
BLAKE2b-256 checksum How to use checksums |
60465b5c2e6a80e91a2c495266fb614ed5dc33d1f0b88249f5c3ae5cd4c6c174
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.14
|