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

pip install almanak

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

    almanak strat new
    
  2. Start the Gateway and Test

    # Terminal 1: Start gateway
    almanak gateway
    
    # Terminal 2: Run strategy
    cd my_strategy
    almanak strat run --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 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.2.1-py3-none-win_amd64.whl (46.2 MB view details)

Uploaded Python 3Windows x86-64

almanak-2.2.1-py3-none-manylinux_2_17_x86_64.whl (44.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

almanak-2.2.1-py3-none-manylinux_2_17_aarch64.whl (43.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

almanak-2.2.1-py3-none-macosx_11_0_x86_64.whl (29.7 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

almanak-2.2.1-py3-none-macosx_11_0_arm64.whl (27.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for almanak-2.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 df4dc74581aee053232c87462677749a157a64be824a9ddd53ce304f2951d6de
MD5 9184d1f3c05ff7242e64cb248f45796a
BLAKE2b-256 27657bbcc5eda9f8015985367ec5bca6f6aa90658cbf2b31369f420316add9de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for almanak-2.2.1-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0965329bcd1ed362af2e10979290a56657f470ffba0a4ba0ff598ee6ce1ccf79
MD5 05b8922abee0b30efd03c3720395a88f
BLAKE2b-256 f527dda4cceabaf318dd65b254d9c40174d84a74aefa6d71a6630e53c16ff398

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for almanak-2.2.1-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 5b4f57ed2f1edb165b33c38ac8d098e8c804e4f0d72bfeeff8adab3c762ad5c6
MD5 a611a0264b2bb4c3020b2db3f024109c
BLAKE2b-256 6bf0ad11af6c5ff2945f253dab09b86103f310e419c43270ca0415c4af1837b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for almanak-2.2.1-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 69fb181ae7422e8fd63cdf576e6ef009981b8bf9af614ab2fb57d86a7168362e
MD5 47fb4aebaa40f54d7cd2e4ea3d9f8833
BLAKE2b-256 5bb62534e367474942760dce460a5c71f0ac5cff9f1098432167cc37328a170b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for almanak-2.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3bd4b66c2268f51f6d1938f1eb3496eb023409ab8c0d0f59b5f0e7513cd0a7d3
MD5 b73376d086464a94a9d451986360e7a2
BLAKE2b-256 c06808b62a87dcf6029aaac7d476bd8caffac88231a150a9b3dcea8cba16c2ab

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