| | |
| | | """ |
| | | import decimal |
| | | |
| | | from trade.l2_transaction_data_manager import HuaXinBuyOrderManager |
| | | from utils import tool |
| | | |
| | | |
| | |
| | | self.__latest_market_info_dict = {} |
| | | |
| | | def set_pre_close_price(self, code, price): |
| | | if code.find("00") == 0 or code.find("60") == 0: |
| | | limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1")) |
| | | else: |
| | | limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.2")) |
| | | limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_up_rate(code)}")) |
| | | self.__limit_up_price_dict[code] = round(float(limit_up_price), 2) |
| | | |
| | | def add_market_info(self, info): |
| | |
| | | self.set_pre_close_price(code, info[8]) |
| | | self.__latest_market_info_dict[info[0]] = info |
| | | |
| | | def add_transaction_info(self, info): |
| | | def add_transaction_info(self, info, backtest = False): |
| | | |
| | | """ |
| | | 添加成交信息 |
| | | :param backtest: 是否是回测 |
| | | :param info: 示例-{'SecurityID': '002842', 'TradePrice': 6.66, 'TradeVolume': 1100, 'OrderTime': 95436390, |
| | | 'MainSeq': 2011, 'SubSeq': 8162612, 'BuyNo': 8162610, 'SellNo': 8159424, 'ExecType': '1'} |
| | | :return: 返回是否下单 |
| | | """ |
| | | if not backtest: |
| | | HuaXinBuyOrderManager.statistic_big_buy_data(info['SecurityID'], |
| | | [(info['SecurityID'], info['TradePrice'], info['TradeVolume'], |
| | | info['OrderTime'], info['MainSeq'], info['SubSeq'], |
| | | info['BuyNo'], |
| | | info['SellNo'], info['ExecType'])]) |
| | | code = info["SecurityID"] |
| | | try: |
| | | if info["TradePrice"] == self.__limit_up_price_dict.get(code): |