agent0.core.hyperdrive.policies

Policies for expert system trading bots.

Submodules

Classes

HyperdriveBasePolicy

Hyperdrive policy.

PolicyZoo

All policies in agent0.

Package Contents

class agent0.core.hyperdrive.policies.HyperdriveBasePolicy(policy_config: Config)

Bases: agent0.core.base.policies.BasePolicy[agent0.ethpy.hyperdrive.HyperdriveReadInterface, agent0.core.hyperdrive.agent.HyperdriveWallet]

Hyperdrive policy.

close_matured_positions(wallet: agent0.core.hyperdrive.agent.HyperdriveWallet, pool_state: agent0.ethpy.hyperdrive.state.PoolState, minimum_trade_amount: fixedpointmath.FixedPoint = FixedPoint(0)) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]

Generate actions to close longs and shorts that have matured.

Parameters:
  • wallet (HyperdriveWallet) – The agent’s wallet.

  • pool_state (PoolState) – The current state of the Hyperdrive pool.

  • minimum_trade_amount (FixedPoint, optional) – A mimimum amount to trade; if the matured position is smaller than this amount then it will not be closed. Defaults to 0.

Returns:

Is a list of Hyperdrive trade actions for closing matured longs and shorts.

Return type:

list[MarketAction]

abstract action(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.agent.HyperdriveWallet) tuple[list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]], bool]

Return an empty list, indicating no action.

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]

post_action(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, trade_results: list[agent0.core.hyperdrive.TradeResult]) None

Execute any behavior after after the actions specified by the action function have been executed.

This allows the policy to e.g., do additional bookkeeping based on the results of the executed actions.

Parameters:
  • interface (MarketInterface) – The trading market interface.

  • trade_results (list[HyperdriveTradeResult]) – A list of HyperdriveTradeResult objects, one for each trade made by the agent. The order of the list matches the original order of agent.action. HyperdriveTradeResult contains any information about the trade, as well as any errors that the trade resulted in.

class agent0.core.hyperdrive.policies.PolicyZoo

Bases: NamedTuple

All policies in agent0.

random
random_hold
smart_long
simple_lp
lp_and_arb
deterministic
describe(policies: list | str | None = None) str

Describe policies, either specific ones provided, or all of them.

Parameters:

policies (list | str | None, optional) – A policy name string or list of policy names to describe. If not provided, then all available policies are described.

Returns:

A string containing the policy descriptions joined by new-lines.

Return type:

str