docstr: Please refer to the docs of get_amount_of_trade_unit
docstr_tok: ["Please","refer","to","the","docs","of","get_amount_of_trade_unit"]
code: def _get_factor_or_raise_error(
      self,
      factor: float | None = None,
      stock_id: str | None = None,
      start_time: pd.Timestamp = None,
      end_time: pd.Timestamp = None,
  ) -> float:
      """Please refer to the docs of get_amount_of_trade_unit"""
      if factor is None:
          if (
              stock_id is not None
              and start_time is not None
              and end_time is not None
          ):
              factor = self.get_factor(
                  stock_id=stock_id,
                  start_time=start_time,
                  end_time=end_time,
              )
          else:
              raise ValueError(
                  f"`factor` and (`stock_id`, `start_time`, `end_time`) can't both be None"
              )
      assert factor is not None
      return factor
  
imports: from __future__ import annotations
  from collections import defaultdict
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union, cast
  from ..utils.index_data import IndexData
  import random
  import numpy
  import pandas
  from qlib.backtest.position import BasePosition
  from ..config import C
  from ..constant import REG_CN, REG_TW
  from ..data.data import D
  from ..log import get_module_logger
  from .decision import Order, OrderDir, OrderHelper
  from .high_performance_ds import BaseQuote, NumpyQuote
label_desc: Use image node_id 20 for calling the Exchange obj's underlying member method code with example usage: obj._get_factor_or_raise_error(factor, stock_id, start_time, end_time) and returns: factor