| | |
| | | # 下单L2的安全笔数管理 |
| | | import json |
| | | |
| | | from db.redis_manager import RedisUtils |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from l2 import l2_data_source_util |
| | | from trade import l2_trade_factor |
| | | from db import redis_manager |
| | | from db import redis_manager_delegate as redis_manager |
| | | from utils import tool |
| | | from l2.l2_data_util import L2DataUtil |
| | | from l2.l2_data_util import L2DataUtil, local_today_buyno_map |
| | | |
| | | |
| | | class BuyL2SafeCountManager(object): |
| | |
| | | tool.CodeDataCacheUtil.set_cache(self.latest_place_order_info_cache, code, |
| | | (buy_single_index, buy_exec_index, cancel_index)) |
| | | key = "latest_place_order_info-{}".format(code) |
| | | RedisUtils.setex(self.__get_redis(), key, tool.get_expire(), |
| | | json.dumps((buy_single_index, buy_exec_index, cancel_index))) |
| | | RedisUtils.setex_async(self.__db, key, tool.get_expire(), |
| | | json.dumps((buy_single_index, buy_exec_index, cancel_index))) |
| | | |
| | | def __get_latest_place_order_info(self, code): |
| | | key = "latest_place_order_info-{}".format(code) |
| | |
| | | buy_num += int(val["num"]) * data["re"] |
| | | elif L2DataUtil.is_limit_up_price_buy_cancel(val): |
| | | # 获取买入信息 |
| | | buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data(code, data, |
| | | local_today_num_operate_map) |
| | | buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(data, local_today_buyno_map.get(code)) |
| | | if buy_index is not None: |
| | | if last_buy_single_index <= buy_index <= end_index: |
| | | cancel_num += int(val["num"]) * data["re"] |