Skip to main content

A powerful Python SDK for developing and deploying autonomous DeFi agents. Features agent-based modeling, state machine architecture, and non-custodial execution through Safe smart accounts

Project description

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, Polymarket, 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, Balancer
  • Lending: Aave V3, Morpho Blue, Compound V3, Spark
  • Liquid Staking: Lido, Ethena
  • Yield: Pendle
  • Perpetuals: GMX V2, Hyperliquid
  • Prediction Markets: Polymarket
  • CEX Integration: Kraken
  • Aggregators: Enso, LiFi

Contributing

See the Contributing Guide to get started.

Documentation

For detailed documentation, visit sdk.docs.almanak.co

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

almanak-2.19.0-py3-none-win_amd64.whl (47.9 MB view details)

Uploaded Python 3Windows x86-64

almanak-2.19.0-py3-none-manylinux_2_17_x86_64.whl (45.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

almanak-2.19.0-py3-none-manylinux_2_17_aarch64.whl (45.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

almanak-2.19.0-py3-none-macosx_11_0_x86_64.whl (36.0 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

almanak-2.19.0-py3-none-macosx_11_0_arm64.whl (33.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file almanak-2.19.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: almanak-2.19.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 47.9 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.13

File hashes

Hashes for almanak-2.19.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 489bb12cf975f0af84601fed7bd3ffbcd43da52e468a96caec161793de8dd7d5
MD5 f12340a829c8d44c2b816f23f3741dbe
BLAKE2b-256 7c4e960478832de4d7130f5f9e2d01d6921043e616696fa6449bbeccc3efc1ef

See more details on using hashes here.

File details

Details for the file almanak-2.19.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for almanak-2.19.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ee1d8fe9a99691e02341d2afcd86aeee0e7daf6b60128d4f692e2c49da3bca7a
MD5 064792c4855d9fee16f9f0dd251a377f
BLAKE2b-256 db732b8c62280ee863bc08658b4f488e0daa84760d4e4a243bf439f596401c39

See more details on using hashes here.

File details

Details for the file almanak-2.19.0-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for almanak-2.19.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 6aabf4041b76d91a776a750bac7d062062cb56a75e126296c8277bd63356d28d
MD5 7047a6e293efc42d394b42de9f55c99f
BLAKE2b-256 eda03c03991a711d16a143ecfdcad661d9259b53bcb3eb0f007728ae035b2a9d

See more details on using hashes here.

File details

Details for the file almanak-2.19.0-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for almanak-2.19.0-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 0708a7c7b521ebd0beff7074ae5e3c26d32e52f860c8db7fe18d0a2e4533dbda
MD5 799412df45ee681646d981a16ee51333
BLAKE2b-256 5c2868ac2f8a12a6166769a9083eb46830d637528ea4992e2300fd94eb6d1fda

See more details on using hashes here.

File details

Details for the file almanak-2.19.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for almanak-2.19.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e64c0d9d4a7e933906a1f462dff89b3d5bacc5fd9d45b12b958092a674bc283
MD5 029cd737bc40990bd22df225b106a7f7
BLAKE2b-256 f74d65c883581628697b379d7d3d3dce49b22f77f2c990d625848b2e2a987bc5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page