docstr: return the real order amount after cash limit for buying.
  Parameters
  ----------
  trade_price : float
  cash : float
  cost_ratio : float
  
  Return
  ----------
  float
      the real order amount after cash limit for buying.
docstr_tok: ["return","the","real","order","amount","after","cash","limit","for","buying",".","Parameters","--","--","--","--","--","trade_price",":","float","cash",":","float","cost_ratio",":","float","Return","--","--","--","--","--","float","the","real","order","amount","after","cash","limit","for","buying","."]
code: def _get_buy_amount_by_cash_limit(
      self, trade_price: float, cash: float, cost_ratio: float
  ) -> float:
      """return the real order amount after cash limit for buying.
      Parameters
      ----------
      trade_price : float
      cash : float
      cost_ratio : float
  
      Return
      ----------
      float
          the real order amount after cash limit for buying.
      """
      max_trade_amount = 0.0
      if cash >= self.min_cost:
          # critical_price means the stock transaction price when the service fee is equal to min_cost.
          critical_price = self.min_cost / cost_ratio + self.min_cost
          if cash >= critical_price:
              # the service fee is equal to cost_ratio * trade_amount
              max_trade_amount = cash / (1 + cost_ratio) / trade_price
          else:
              # the service fee is equal to min_cost
              max_trade_amount = (cash - self.min_cost) / trade_price
      return max_trade_amount
  
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 24 for calling the Exchange obj's underlying member method code with example usage: obj._get_buy_amount_by_cash_limit(trade_price, cash, cost_ratio) and returns: max_trade_amount