| | |
| | | |
| | | # 下单临时信息 |
| | | class OrderBeginPosInfo(object): |
| | | MODE_NORMAL = 0 |
| | | MODE_NORMAL = 0 # 普通下单 |
| | | MODE_FAST = 1 |
| | | MODE_ACTIVE = 2 |
| | | MODE_RADICAL = 3 |
| | | MODE_ACTIVE = 2 # 积极动买 |
| | | MODE_RADICAL = 3 # 扫入 |
| | | MODE_OPEN_LIMIT_UP = 4 # 排1 |
| | | |
| | | # mode: 0-普通交易 1-快速交易 |
| | | def __init__(self, buy_single_index=None, buy_exec_index=-1, buy_compute_index=None, num=0, count=0, |
| | | max_num_set=None, buy_volume_rate=None, sell_info=None, threshold_money=None, mode=0, mode_desc=None, |
| | | at_limit_up=False): |
| | | at_limit_up=False, first_limit_up_buy=False, min_order_no = None): |
| | | self.buy_single_index = buy_single_index |
| | | self.buy_exec_index = buy_exec_index |
| | | self.buy_compute_index = buy_compute_index |
| | |
| | | self.mode_desc = mode_desc |
| | | # 是否是板上买 |
| | | self.at_limit_up = at_limit_up |
| | | # 是否为首封买 |
| | | self.first_limit_up_buy = first_limit_up_buy |
| | | # 统计批次大单成交的最小订单号 |
| | | self.min_order_no = min_order_no |
| | | |
| | | def get_max_num_set(self): |
| | | if self.max_num_set: |
| | |
| | | __buy_compute_index_info_cache = {} |
| | | __buy_cancel_single_pos_cache = {} |
| | | __instance = None |
| | | # 最近的下单模式 |
| | | __latest_place_order_mode_cache = {} |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | | if not cls.__instance: |
| | |
| | | |
| | | # 获取买入点信息 |
| | | # 返回数据为:买入点 累计纯买额 已经计算的数据索引 |
| | | |
| | | def get_buy_compute_start_data(self, code): |
| | | _key = "buy_compute_index_info-{}".format(code) |
| | | _data_json = RedisUtils.get(self.__get_redis(), _key) |
| | |
| | | # nums 累计纯买额 |
| | | |
| | | def set_buy_compute_start_data_v2(self, code, order: OrderBeginPosInfo): |
| | | |
| | | if order.mode is not None: |
| | | self.__latest_place_order_mode_cache[code] = order.mode |
| | | |
| | | expire = tool.get_expire() |
| | | _key = "buy_compute_index_info-{}".format(code) |
| | | data_ = None |
| | |
| | | def is_placed_order(cls, order_begin_pos: OrderBeginPosInfo): |
| | | return order_begin_pos and order_begin_pos.buy_exec_index is not None and order_begin_pos.buy_exec_index > -1 |
| | | |
| | | @classmethod |
| | | def get_latest_place_order_mode(cls, code): |
| | | """ |
| | | 获取最近下单的模式 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | return cls.__latest_place_order_mode_cache.get(code) |
| | | |
| | | |
| | | # 清除l2数据 |
| | | def clear_l2_data(code): |