agent0.core.hyperdrive.policies.hyperdrive_policy
Base class for hyperdrive policies.
Classes
Hyperdrive policy. |
Module Contents
- class agent0.core.hyperdrive.policies.hyperdrive_policy.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:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- 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.