agent0.hyperfuzz.unit_fuzz.helpers ================================== .. py:module:: agent0.hyperfuzz.unit_fuzz.helpers .. autoapi-nested-parse:: Shared functions for interactive fuzz testing. .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/agent0/hyperfuzz/unit_fuzz/helpers/advance_time/index /autoapi/agent0/hyperfuzz/unit_fuzz/helpers/close_random_trades/index /autoapi/agent0/hyperfuzz/unit_fuzz/helpers/execute_random_trades/index /autoapi/agent0/hyperfuzz/unit_fuzz/helpers/setup_fuzz/index Functions --------- .. autoapisummary:: agent0.hyperfuzz.unit_fuzz.helpers.advance_time_after_checkpoint agent0.hyperfuzz.unit_fuzz.helpers.advance_time_before_checkpoint agent0.hyperfuzz.unit_fuzz.helpers.close_trades agent0.hyperfuzz.unit_fuzz.helpers.permute_trade_events agent0.hyperfuzz.unit_fuzz.helpers.execute_random_trades agent0.hyperfuzz.unit_fuzz.helpers.setup_fuzz Package Contents ---------------- .. py:function:: advance_time_after_checkpoint(chain: agent0.core.hyperdrive.interactive.LocalChain, interactive_hyperdrive: agent0.core.hyperdrive.interactive.LocalHyperdrive) -> None Advance time on the chain to the next checkpoint boundary plus some buffer. :param chain: An instantiated LocalChain. :type chain: LocalChain :param interactive_hyperdrive: An instantiated InteractiveHyperdrive object. :type interactive_hyperdrive: InteractiveHyperdrive .. !! processed by numpydoc !! .. py:function:: advance_time_before_checkpoint(chain: agent0.core.hyperdrive.interactive.LocalChain, rng: numpy.random.Generator, interactive_hyperdrive: agent0.core.hyperdrive.interactive.LocalHyperdrive) -> None Advance time on the chain a random amount that is less than the next checkpoint time. :param chain: An instantiated LocalChain. :type chain: LocalChain :param rng: The numpy Generator provides access to a wide range of distributions, and stores the random state. :type rng: `Generator `_ :param interactive_hyperdrive: An instantiated InteractiveHyperdrive object. :type interactive_hyperdrive: InteractiveHyperdrive .. !! processed by numpydoc !! .. py:function:: close_trades(trade_events: list[tuple[agent0.core.hyperdrive.interactive.local_hyperdrive_agent.LocalHyperdriveAgent, hyperdrivetypes.OpenLongEventFP | hyperdrivetypes.OpenShortEventFP]]) -> None Close trades provided. :param trade_events: A list with an entry per trade, containing a tuple with: - the agent executing the trade - either the OpenLong or OpenShort trade event :type trade_events: list[tuple[InteractiveHyperdriveAgent, OpenLong | OpenShort]] .. !! processed by numpydoc !! .. py:function:: permute_trade_events(trade_events: list[tuple[agent0.core.hyperdrive.interactive.local_hyperdrive_agent.LocalHyperdriveAgent, hyperdrivetypes.OpenLongEventFP | hyperdrivetypes.OpenShortEventFP]], rng: numpy.random.Generator) -> list[tuple[agent0.core.hyperdrive.interactive.local_hyperdrive_agent.LocalHyperdriveAgent, hyperdrivetypes.OpenLongEventFP | hyperdrivetypes.OpenShortEventFP]] Given a list of trade events, returns the list in random order. :param trade_events: A list with an entry per trade, containing a tuple with: - the agent executing the trade - either the OpenLong or OpenShort trade event :type trade_events: list[tuple[InteractiveHyperdriveAgent, OpenLong | OpenShort]] :param rng: The numpy Generator provides access to a wide range of distributions, and stores the random state. :type rng: `Generator `_ :returns: The trade event list in random order :rtype: list[tuple[InteractiveHyperdriveAgent, OpenLong | OpenShort]] .. !! processed by numpydoc !! .. py:function:: 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. :param num_trades: The number of trades to execute. :type num_trades: int :param chain: An instantiated LocalChain. :type chain: LocalChain :param rng: The numpy Generator provides access to a wide range of distributions, and stores the random state. :type rng: `Generator `_ :param interactive_hyperdrive: An instantiated InteractiveHyperdrive object. :type interactive_hyperdrive: InteractiveHyperdrive :param advance_time: 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. :type advance_time: bool, optional :returns: A list with an entry per trade, containing a tuple with: - the agent executing the trade - either the OpenLong or OpenShort trade event :rtype: list[tuple[InteractiveHyperdriveAgent, OpenLong | OpenShort]] .. !! processed by numpydoc !! .. py:function:: setup_fuzz(chain_config: agent0.core.hyperdrive.interactive.LocalChain.Config, log_to_rollbar: bool = True, crash_log_level: int | None = None, fuzz_test_name: str | None = None, curve_fee: fixedpointmath.FixedPoint | None = None, flat_fee: fixedpointmath.FixedPoint | None = None, governance_lp_fee: fixedpointmath.FixedPoint | None = None, governance_zombie_fee: fixedpointmath.FixedPoint | None = None, var_interest: fixedpointmath.FixedPoint | None = None, steth: bool = False) -> tuple[agent0.core.hyperdrive.interactive.LocalChain, int, numpy.random.Generator, agent0.core.hyperdrive.interactive.LocalHyperdrive] Setup the fuzz experiment. :param chain_config: Configuration options for the local chain. :type chain_config: LocalChain.Config, optional :param log_to_rollbar: If True, log errors rollbar. Defaults to True. :type log_to_rollbar: bool, optional :param crash_log_level: The log level to log crashes at. Defaults to critical. :type crash_log_level: int | None, optional :param fuzz_test_name: The prefix to prepend to rollbar exception messages :type fuzz_test_name: str | None, optional :param curve_fee: The curve fee for the test. Defaults to using the default fee :type curve_fee: FixedPoint | None, optional :param flat_fee: The flat fee for the test. Defaults to using the default fee :type flat_fee: FixedPoint | None, optional :param governance_lp_fee: The governance lp fee for the test. Defaults to using the default fee :type governance_lp_fee: FixedPoint | None, optional :param governance_zombie_fee: The governance zombie fee for the test. Defaults to using the default fee :type governance_zombie_fee: FixedPoint | None, optional :param var_interest: The variable interest rate. Defaults to using the default variable interest rate defined in interactive hyperdrive. :type var_interest: FixedPoint | None, optional :param steth: If True, use steth. Defaults to False. :type steth: bool, optional :returns: A tuple containing: chain: LocalChain An instantiated LocalChain. random_seed: int The random seed used to construct the Generator. 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. :rtype: tuple[str, LocalChain, int, Generator, InteractiveHyperdrive] .. !! processed by numpydoc !!