agent0.core.hyperdrive.policies.random
User strategy that opens or closes a random position with a random allowed amount.
Classes
Random agent. |
Module Contents
- class agent0.core.hyperdrive.policies.random.Random(policy_config: Config)
Bases:
agent0.core.hyperdrive.policies.hyperdrive_policy.HyperdriveBasePolicyRandom agent.
- classmethod description() str
Describe the policy in a user friendly manner that allows newcomers to decide whether to use it.
- Returns:
A description of the policy.
- Return type:
str
- class Config
Bases:
agent0.core.hyperdrive.policies.hyperdrive_policy.HyperdriveBasePolicy.ConfigCustom config arguments for this policy.
- trade_chance: fixedpointmath.FixedPoint
The probability of this bot to make a trade on an action call.
- randomly_ignore_slippage_tolerance: bool = False
If we randomly ignore slippage tolerance.
- allowable_actions: list[agent0.core.hyperdrive.agent.HyperdriveActionType]
A list of Hyperdrive actions that are allowed. Defaults to all possible actions.
- trade_chance
- allowable_actions
- randomly_ignore_slippage_tolerance
- gas_limit
- get_available_actions(wallet: agent0.core.hyperdrive.HyperdriveWallet, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface) list[agent0.core.hyperdrive.agent.HyperdriveActionType]
Get all available actions.
- Parameters:
wallet (HyperdriveWallet) – The agent’s wallet.
interface (HyperdriveReadInterface) – The interface to the Hyperdrive contract.
- Returns:
A list containing all of the available actions.
- Return type:
list[HyperdriveActionType]
- open_short_with_random_amount(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]
Open a short with a random allowable amount.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for opening a Hyperdrive short.
- Return type:
list[Trade[HyperdriveMarketAction]]
- close_random_short(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]
Fully close the short balance for a random mint time.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for closing a Hyperdrive short.
- Return type:
list[Trade[HyperdriveMarketAction]]
- open_long_with_random_amount(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]
Open a long with a random allowable amount.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for opening a Hyperdrive long.
- Return type:
list[Trade[HyperdriveMarketAction]]
- close_random_long(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]
Fully close the long balance for a random mint time.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for closing a Hyperdrive long.
- Return type:
list[Trade[HyperdriveMarketAction]]
- add_liquidity_with_random_amount(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]
Add liquidity with a random allowable amount.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for adding liquidity to a Hyperdrive pool.
- Return type:
list[Trade[HyperdriveMarketAction]]
- remove_liquidity_with_random_amount(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]
Remove liquidity with a random allowable amount.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for removing liquidity from a Hyperdrive pool.
- Return type:
list[Trade[HyperdriveMarketAction]]
Redeem withdraw shares with a random allowable amount.
- Parameters:
interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).
wallet (HyperdriveWallet) – The agent’s wallet.
- Returns:
A list with a single Trade element for redeeming the LP withdraw shares.
- Return type:
list[Trade[HyperdriveMarketAction]]
- action(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) tuple[list[agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]], bool]
Implement a random user strategy.
- The agent performs one of four possible trades:
[OPEN_LONG, OPEN_SHORT, CLOSE_LONG, CLOSE_SHORT] with the condition that close actions can only be performed after open actions
The amount opened and closed is random, within constraints given by agent budget & market reserve levels
- 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]