Skip to main content

Strategy

Strategies are very tightly connected to Agents. Each agent can get assigned a strategy but its optional.

A strategy encapsulates the behavior of an agent. It instantiates the logic or algorithm that dictates the agent’s actions (or “decisions”). For example, a trader agent can execute trades on a DEX according to a simple rule– the logic of that trading rule is the strategy. A strategy can employ a model (or multiple models) to inform its actions.

The word Strategy is used in the broader sense of the terms and is not limited to a DeFi strategy. Other fields working with agent-based simulation could use wording such as Behaviour or Policy.

Models

One strength of the strategies is its models, it allows you to use a machine learning model (or simpler mathematical models) to make more advanced decisions. Learn more about how models work in the simulator and how to configure them here.

Configuration

Strategies are configured mainly through its own almanak-library.yaml. It doesn't require many options:

name: "Trend Following"
type: "strategy"
version: "1.0.0"
author: "Almanak AG"
description: "Trend Following strategy"
license: "MIT"

settings:
example_setting: "example_value"

models:
- alias: "trading_prediction"
source: "wandb://almanak/model-registry/Uniswap_Trader_Trend-Following:latest"

supported_chains:
- engine: 'evm'
chainId: '1'
dependencies:
protocols:
- "library://almanak/protocols/uniswap-v3:1.0.0"
- engine: 'evm'
chainId: '2'
dependencies:
protocols:
- "library://almanak/protocols/uniswap-v3:1.0.0"
settings:
uniswap_v3_usdc_pool: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"

There are quite a few things that you can add here. One of the big ones is the latest option supported_chains, which is simply an array of objects that you can use to configure dependencies and only allow the agent to work on certain chains because it has unique features to them.

  • engine is the Chain Engine as configured for the environment.
  • chainId is the chain id as configured for the environment.
  • dependencies allow you to set certain dependencies on an environment level, these have to be library items.
  • settings are like any other settings but can overwrite them on an environment level. Useful for contract addresses that are different per chain

There are also settings on a top level. They work the same as the settings at the environment level, the environment level will overwrite the top level!

And models which have to be configured here to be made available in the simulator. Read more about models here.