| | |
| | | |
| | | zyltgb = l2_trade_factor.L2TradeFactorUtil.get_zyltgb(code) |
| | | zyltgb_unit_y = round(zyltgb / 100000000, 1) |
| | | threshold_big_deal = (2*zyltgb_unit_y + 339)*10000 |
| | | threshold_big_deal = (2 * zyltgb_unit_y + 339) * 10000 |
| | | if total_deal_money >= threshold_big_deal: |
| | | return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})" |
| | | |
| | |
| | | if not must_buy: |
| | | temp_thresh_hold_rate = round((total_num - max_num) * 0.9 / total_num, 2) |
| | | thresh_hold_rate = min(thresh_hold_rate, temp_thresh_hold_rate) |
| | | l2_log.l_cancel_debug(code, f"计算范围:{start_index}-{end_index},已撤单比例:{rate}/{thresh_hold_rate}") |
| | | l2_log.l_cancel_debug(code, f"L后计算范围:{start_index}-{end_index},已撤单比例:{rate}/{thresh_hold_rate}") |
| | | if rate >= thresh_hold_rate: |
| | | canceled_indexes.sort() |
| | | l2_log.l_cancel_debug(code, f"L下撤单,撤单位置:{canceled_indexes[-1]}") |
| | | l2_log.l_cancel_debug(code, f"L后撤单,撤单位置:{canceled_indexes[-1]}") |
| | | return True, total_data[canceled_indexes[-1]] |
| | | |
| | | return False, None |
| | |
| | | num = max60[0] |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if limit_up_price: |
| | | money_y = round((num * float(limit_up_price))/1e8,1) |
| | | money =int(200*money_y + 280) |
| | | count = int(money_y*10)//10 + 3 |
| | | return money,count |
| | | money_y = round((num * float(limit_up_price)) / 1e8, 1) |
| | | money = int(200 * money_y + 280) |
| | | count = int(money_y * 10) // 10 + 3 |
| | | return money, count |
| | | # 默认值 |
| | | return 300,3 |
| | | return 300, 3 |
| | | |
| | | # 下单3分钟内距离下单位置不足3笔(包含正在成交)且不到300w就需要撤单 |
| | | def need_cancel_for_deal_fast(self, code, trade_index=None): |
| | |
| | | def cancel_success(self, code): |
| | | self.clear(code) |
| | | |
| | | |
| | | # ---------------------------------新G撤------------------------------- |
| | | class NewGCancelBigNumComputer: |
| | | __db = 0 |
| | | __redis_manager = redis_manager.RedisManager(0) |
| | | __real_place_order_index_dict = {} |
| | | __trade_progress_index_dict = {} |
| | | __watch_indexes_dict = {} |
| | |
| | | def __new__(cls, *args, **kwargs): |
| | | if not cls.__instance: |
| | | cls.__instance = super(NewGCancelBigNumComputer, cls).__new__(cls, *args, **kwargs) |
| | | cls.__load_datas() |
| | | return cls.__instance |
| | | |
| | | @classmethod |
| | | def __load_datas(cls): |
| | | __redis = cls.__get_redis() |
| | | try: |
| | | keys = RedisUtils.keys(__redis, "g_cancel_watch_index_info-*") |
| | | for k in keys: |
| | | code = k.split("-")[-1] |
| | | val = RedisUtils.get(__redis, k) |
| | | if val: |
| | | val = json.loads(val) |
| | | val = set(val) |
| | | CodeDataCacheUtil.set_cache(cls.__watch_indexes_dict, code, val) |
| | | finally: |
| | | RedisUtils.realse(__redis) |
| | | |
| | | @classmethod |
| | | def __get_redis(cls): |
| | | return cls.__redis_manager.getRedis() |
| | | |
| | | def __set_watch_index(self, code, indexes): |
| | | CodeDataCacheUtil.set_cache(self.__watch_indexes_dict, code, indexes) |
| | | RedisUtils.setex_async(self.__db, f"g_cancel_watch_index_info-{code}", tool.get_expire(), |
| | | json.dumps(list(indexes))) |
| | | |
| | | def set_real_place_order_index(self, code, index, buy_single_index, is_default): |
| | | self.__real_place_order_index_dict[code] = (index, is_default) |
| | | start_index = buy_single_index |
| | | if code in self.__trade_progress_index_dict: |
| | | start_index = self.__trade_progress_index_dict.get(code) |
| | | if not is_default: |
| | | trade_index, is_default = TradeBuyQueue().get_traded_index(code) |
| | | if trade_index is None: |
| | | start_index = 0 |
| | | else: |
| | | start_index = trade_index |
| | | self.__commpute_watch_indexes(code, start_index, (index, is_default), from_real_order_index_changed=True) |
| | | |
| | | def clear(self, code=None): |
| | |
| | | self.__real_place_order_index_dict.pop(code) |
| | | if code in self.__watch_indexes_dict: |
| | | self.__watch_indexes_dict.pop(code) |
| | | RedisUtils.delete_async(self.__db, f"g_cancel_watch_index_info-{code}") |
| | | if code in self.__trade_progress_index_dict: |
| | | self.__trade_progress_index_dict.pop(code) |
| | | else: |
| | | self.__real_place_order_index_dict.clear() |
| | | self.__watch_indexes_dict.clear() |
| | | self.__trade_progress_index_dict.clear() |
| | | keys = RedisUtils.keys(self.__get_redis(), f"g_cancel_watch_index_info-*") |
| | | for k in keys: |
| | | RedisUtils.delete(self.__get_redis(), k) |
| | | |
| | | # recompute:是否重新计算 |
| | | def __commpute_watch_indexes(self, code, traded_index, real_order_index_info, from_real_order_index_changed=False, |
| | |
| | | if from_real_order_index_changed or recompute: |
| | | # 真实下单位改变后才会更新 |
| | | final_watch_indexes = origin_watch_index | watch_indexes |
| | | self.__watch_indexes_dict[code] = final_watch_indexes |
| | | self.__set_watch_index(code, final_watch_indexes) |
| | | l2_log.g_cancel_debug(code, f"大单监听:{final_watch_indexes} 是否重新计算:{recompute}") |
| | | |
| | | def set_trade_progress(self, code, buy_single_index, index): |
| | | if self.__trade_progress_index_dict.get(code) != index: |
| | | self.__trade_progress_index_dict[code] = index |
| | | self.__commpute_watch_indexes(code, index, self.__real_place_order_index_dict.get(code)) |
| | | # if self.__trade_progress_index_dict.get(code) != index: |
| | | self.__trade_progress_index_dict[code] = index |
| | | # self.__commpute_watch_indexes(code, index, self.__real_place_order_index_dict.get(code)) |
| | | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index): |
| | | if code not in self.__real_place_order_index_dict: |
| | |
| | | return True, total_datas[cancel_half_index], f"B撤:撤单索引-{cancel_half_index}" |
| | | return False, None, "还有大单没撤单" |
| | | |
| | | |
| | | def test(self): |
| | | self.__set_watch_index("000333", {1, 2, 3, 4, 5, 6, 7}) |
| | | |
| | | |
| | | # ---------------------------------独苗撤------------------------------- |