agent0.hyperfuzz.unit_fuzz.helpers.execute_random_trades

Return a list of results from opening a random longs and shorts.

Functions

execute_random_trades(...)

Conduct some trades specified by the trade list.

Module Contents

agent0.hyperfuzz.unit_fuzz.helpers.execute_random_trades.execute_random_trades(num_trades: int, chain: agent0.core.hyperdrive.interactive.LocalChain, rng: numpy.random.Generator, interactive_hyperdrive: agent0.core.hyperdrive.interactive.LocalHyperdrive, advance_time: bool = False) list[tuple[agent0.core.hyperdrive.interactive.local_hyperdrive_agent.LocalHyperdriveAgent, hyperdrivetypes.OpenLongEventFP | hyperdrivetypes.OpenShortEventFP]]

Conduct some trades specified by the trade list. If advance time is true, the sum of all time passed between all trades will be between 0 and the position duration.

Parameters:
  • num_trades (int) – The number of trades to execute.

  • chain (LocalChain) – An instantiated LocalChain.

  • rng (Generator) – The numpy Generator provides access to a wide range of distributions, and stores the random state.

  • interactive_hyperdrive (InteractiveHyperdrive) – An instantiated InteractiveHyperdrive object.

  • advance_time (bool, optional) – If True, advance time a random amount between 0 and the position duration after each trade. Defaults to False, which follows the anvil settings. Typically this advances one block and 12 seconds between each trade.

Returns:

A list with an entry per trade, containing a tuple with:
  • the agent executing the trade

  • either the OpenLong or OpenShort trade event

Return type:

list[tuple[InteractiveHyperdriveAgent, OpenLong | OpenShort]]