agent0.core.hyperdrive.policies.random_hold

User strategy that opens random positions with set hold position times.

Classes

RandomHold

Random agent that opens random positions with random hold position times.

Module Contents

class agent0.core.hyperdrive.policies.random_hold.RandomHold(policy_config: Config)

Bases: agent0.core.hyperdrive.policies.random.Random

Random agent that opens random positions with random hold position times.

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.random.Random.Config

Custom config arguments for this policy.

max_open_positions_per_pool: int = 100

The maximum number of open positions per pool.

min_hold_time: int = 0

The minimum hold time in seconds. Defaults to 0.

max_hold_time: int | None = None

The minimum hold time in seconds. Defaults to 2 * position_duration.

open_positions: dict[str, list[RandomHold]]
max_open_positions_per_pool
min_hold_time
max_hold_time
generate_random_hold_time(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface) int

Generate a random hold time in seconds, uniform between 0 and 2*position_duration

Parameters:

interface (HyperdriveReadInterface) – Interface for the market on which this agent will be executing trades (MarketActions).

Returns:

A random hold time in seconds.

Return type:

int

get_available_actions(wallet: agent0.core.hyperdrive.HyperdriveWallet, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface) list[agent0.core.hyperdrive.agent.HyperdriveActionType]

Get all available actions.

Parameters:
Returns:

A list containing all of the available actions.

Return type:

list[HyperdriveActionType]

close_random_long(interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, wallet: agent0.core.hyperdrive.HyperdriveWallet) list[agent0.core.base.types.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]

Closes a random long that’s ready to be closed.

Parameters:
Returns:

A list with a single Trade element for closing 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.types.Trade[agent0.core.hyperdrive.HyperdriveMarketAction]]

Closes a random short that’s ready to be closed.

Parameters:
Returns:

A list with a single Trade element for closing a Hyperdrive short.

Return type:

list[Trade[HyperdriveMarketAction]]

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

Random hold updates open position bookkeeping based on which positions were closed.

Parameters:
  • interface (HyperdriveReadInterface) – The hyperdrive trading market interface.

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