docstr: Note: some future information is used in this function
  Parameter:
  target_position : dict { stock_id : amount }
  current_position : dict { stock_id : amount}
  trade_unit : trade_unit
  down sample : for amount 321 and trade_unit 100, deal_amount is 300
  deal order on trade_date
docstr_tok: ["Note",":","some","future","information","is","used","in","this","function","Parameter",":","target_position",":","dict","{","stock_id",":","amount","}","current_position",":","dict","{","stock_id",":","amount","}","trade_unit",":","trade_unit","down","sample",":","for","amount","321","and","trade_unit","100",",","deal_amount","is","300","deal","order","on","trade_date"]
code: def generate_order_for_target_amount_position(
      self,
      target_position: dict,
      current_position: dict,
      start_time: pd.Timestamp,
      end_time: pd.Timestamp,
  ) -> List[Order]:
      """
      Note: some future information is used in this function
      Parameter:
      target_position : dict { stock_id : amount }
      current_position : dict { stock_id : amount}
      trade_unit : trade_unit
      down sample : for amount 321 and trade_unit 100, deal_amount is 300
      deal order on trade_date
      """
      # split buy and sell for further use
      buy_order_list = []
      sell_order_list = []
      # three parts: kept stock_id, dropped stock_id, new stock_id
      # handle kept stock_id
  
      # because the order of the set is not fixed, the trading order of the stock is different, so that the backtest
      # results of the same parameter are different;
      # so here we sort stock_id, and then randomly shuffle the order of stock_id
      # because the same random seed is used, the final stock_id order is fixed
      sorted_ids = sorted(
          set(
              list(current_position.keys())
              + list(target_position.keys())
          )
      )
      random.seed(0)
      random.shuffle(sorted_ids)
      for stock_id in sorted_ids:
          # Do not generate order for the non-tradable stocks
          if not self.is_stock_tradable(
              stock_id=stock_id,
              start_time=start_time,
              end_time=end_time,
          ):
              continue
  
          target_amount = target_position.get(stock_id, 0)
          current_amount = current_position.get(stock_id, 0)
          factor = self.get_factor(
              stock_id, start_time=start_time, end_time=end_time
          )
  
          deal_amount = self.get_real_deal_amount(
              current_amount, target_amount, factor
          )
          if deal_amount == 0:
              continue
          if deal_amount > 0:
              # buy stock
              buy_order_list.append(
                  Order(
                      stock_id=stock_id,
                      amount=deal_amount,
                      direction=Order.BUY,
                      start_time=start_time,
                      end_time=end_time,
                      factor=factor,
                  ),
              )
          else:
              # sell stock
              sell_order_list.append(
                  Order(
                      stock_id=stock_id,
                      amount=abs(deal_amount),
                      direction=Order.SELL,
                      start_time=start_time,
                      end_time=end_time,
                      factor=factor,
                  ),
              )
      # return order_list : buy + sell
      return sell_order_list + buy_order_list
  
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 18 for calling the Exchange obj's underlying member method code with example usage: obj.generate_order_for_target_amount_position(target_position, current_position, start_time, end_time) and returns: unknown