agent0.core.test_utils

Test fixtures for agent0

Submodules

Classes

CycleTradesPolicy

A agent that simply cycles through all trades.

Functions

assert_never(→ NoReturn)

Helper function for exhaustive matching on ENUMS.

cycle_trade_policy(→ Type[CycleTradesPolicy])

Test fixture to build a policy that cycles through all trades.

Package Contents

agent0.core.test_utils.assert_never(arg: NoReturn) NoReturn

Helper function for exhaustive matching on ENUMS.

Note

This ensures that all ENUM values are checked, via an exhaustive match: https://github.com/microsoft/pyright/issues/2569

Parameters:

arg (NoReturn) – The enum value.

class agent0.core.test_utils.CycleTradesPolicy(policy_config: Config)

Bases: agent0.core.hyperdrive.policies.HyperdriveBasePolicy

A agent that simply cycles through all trades.

class Config

Bases: agent0.core.hyperdrive.policies.HyperdriveBasePolicy.Config

Custom config arguments for this policy.

max_trades: int | None = None

The maximum amount of trades to make before this policy is done trading.

counter = 0
max_trades
action(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) tuple[list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]], bool]

This agent simply opens all trades for a fixed amount and closes them after, one at a time

Parameters:
Returns:

A tuple where the first element is a list of actions, and the second element defines if the agent is done trading

Return type:

tuple[list[MarketAction], bool]

agent0.core.test_utils.cycle_trade_policy() Type[CycleTradesPolicy]

Test fixture to build a policy that cycles through all trades.

Returns:

A policy that cycles through all trades.

Return type:

CycleTradesPolicy