code: def test_simulator_stop_twap() -> None:
      order = get_order()
      simulator = get_simulator(order)
      NUM_STEPS = 7
      for i in range(NUM_STEPS):
          simulator.step(TOTAL_POSITION / NUM_STEPS)
  
      HISTORY_STEP_LENGTH = 30 * NUM_STEPS
      state = simulator.get_state()
      assert len(state.history_exec) == HISTORY_STEP_LENGTH
  
      assert (
          state.history_exec["deal_amount"]
          == TOTAL_POSITION / HISTORY_STEP_LENGTH
      ).all()
      assert is_close(
          state.history_steps["position"].iloc[0],
          TOTAL_POSITION * (NUM_STEPS - 1) / NUM_STEPS,
      )
      assert is_close(state.history_steps["position"].iloc[-1], 0.0)
      assert is_close(state.position, 0.0)
      assert is_close(state.metrics["ffr"], 1.0)
  
      assert is_close(
          state.metrics["market_price"],
          state.backtest_data.get_deal_price().mean(),
      )
      assert is_close(
          state.metrics["market_volume"],
          state.backtest_data.get_volume().sum(),
      )
      assert is_close(
          state.metrics["trade_price"], state.metrics["market_price"]
      )
      assert is_close(state.metrics["pa"], 0.0)
  
      assert simulator.done()
  
file_path: qlib/tests/rl/test_qlib_simulator.py
imports: import sys
  from pathlib import Path
  from typing import Tuple
  import pandas
  import pytest
  from qlib.backtest.decision import Order, OrderDir
  from qlib.backtest.executor import SimulatorExecutor
  from qlib.rl.order_execution import CategoricalActionInterpreter
  from qlib.rl.order_execution.simulator_qlib import SingleAssetOrderExecution
label_desc: Use image node_id 6 for calling a global function with example usage: test_simulator_stop_twap() without return types