docstr: Deal order when the actual transaction
  the results section in `Order` will be changed.
  :param order:  Deal the order.
  :param trade_account: Trade account to be updated after dealing the order.
  :param position: position to be updated after dealing the order.
  :param dealt_order_amount: the dealt order amount dict with the format of {stock_id: float}
  :return: trade_val, trade_cost, trade_price
docstr_tok: ["Deal","order","when","the","actual","transaction","the","results","section","in","`","Order","`","will","be","changed",".",":","param","order",":","Deal","the","order",".",":","param","trade_account",":","Trade","account","to","be","updated","after","dealing","the","order",".",":","param","position",":","position","to","be","updated","after","dealing","the","order",".",":","param","dealt_order_amount",":","the","dealt","order","amount","dict","with","the","format","of","{","stock_id",":","float","}",":","return",":","trade_val",",","trade_cost",",","trade_price"]
code: def deal_order(
      self,
      order: Order,
      trade_account: Account | None = None,
      position: BasePosition | None = None,
      dealt_order_amount: Dict[str, float] = defaultdict(float),
  ) -> Tuple[float, float, float]:
      """
      Deal order when the actual transaction
      the results section in `Order` will be changed.
      :param order:  Deal the order.
      :param trade_account: Trade account to be updated after dealing the order.
      :param position: position to be updated after dealing the order.
      :param dealt_order_amount: the dealt order amount dict with the format of {stock_id: float}
      :return: trade_val, trade_cost, trade_price
      """
      # check order first.
      if not self.check_order(order):
          order.deal_amount = 0.0
          # using np.nan instead of None to make it more convenient to show the value in format string
          self.logger.debug(
              f"Order failed due to trading limitation: {order}"
          )
          return 0.0, 0.0, np.nan
  
      if trade_account is not None and position is not None:
          raise ValueError(
              "trade_account and position can only choose one"
          )
  
      # NOTE: order will be changed in this function
      (
          trade_price,
          trade_val,
          trade_cost,
      ) = self._calc_trade_info_by_order(
          order,
          trade_account.current_position if trade_account else position,
          dealt_order_amount,
      )
      if trade_val > 1e-5:
          # If the order can only be deal 0 value. Nothing to be updated
          # Otherwise, it will result in
          # 1) some stock with 0 value in the position
          # 2) `trade_unit` of trade_cost will be lost in user account
          if trade_account:
              trade_account.update_order(
                  order=order,
                  trade_val=trade_val,
                  cost=trade_cost,
                  trade_price=trade_price,
              )
          elif position:
              position.update_order(
                  order=order,
                  trade_val=trade_val,
                  cost=trade_cost,
                  trade_price=trade_price,
              )
  
      return trade_val, trade_cost, trade_price
  
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 10 for calling the Exchange obj's underlying member method code with example usage: obj.deal_order(order, trade_account, position, dealt_order_amount) and returns: trade_val,  trade_cost,  trade_price, int,  int,  np