| | |
| | | def __get_redis(self): |
| | | return self.__redis_manager.getRedis() |
| | | |
| | | def set_big_order_threshold(self, code, threshold_money): |
| | | def set_big_order_threshold(self, code, threshold_money, big_order_threshold_callback): |
| | | """ |
| | | 设置大单的阈值 |
| | | @param big_order_threshold_callback: 大单设置回调函数 |
| | | @param code: |
| | | @param threshold_money: |
| | | @return: |
| | |
| | | self.__big_order_threshold[code] = threshold_money |
| | | redis_manager.RedisUtils.setex_async(self.__db, f"radical_big_order_threshold-{code}", tool.get_expire(), |
| | | f"{threshold_money}") |
| | | big_order_threshold_callback(code, threshold_money) |
| | | |
| | | def set_big_sell_order_threshold(self, code, threshold_money): |
| | | """ |
| | |
| | | threshold_money = max((max_money // 2 + average_money) // 2, average_money) |
| | | return threshold_money |
| | | |
| | | def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price): |
| | | def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price, |
| | | big_order_threshold_callback): |
| | | """ |
| | | 设置大单成交数据 |
| | | @param big_order_threshold_callback: 均大单设置回调函数 |
| | | @param code: |
| | | @param buy_money_list:[(金额,价格,订单号)] |
| | | @param sell_money_list:[(金额,价格,订单号)] |
| | |
| | | total_deal_buy_money_info_list.append(info) |
| | | if limit_up_price_money_list: |
| | | threshold_money = self.compute_re_limit_up_big_money_threshold(limit_up_price_money_list) |
| | | self.set_big_order_threshold(code, threshold_money) |
| | | self.set_big_order_threshold(code, threshold_money, big_order_threshold_callback) |
| | | self.__already_total_deal_big_order_money[code] = (total_deal_buy_money, pre_limit_up_price_money_list) |
| | | async_log_util.info(logger_l2_radical_buy_data, |
| | | f"开板时间:{opened_time} 之前的大买单:{code}-{total_deal_buy_money}-{total_deal_buy_money_info_list}") |
| | |
| | | @param code_: |
| | | @return: |
| | | """ |
| | | |
| | | def big_order_threshold_callback(code, money): |
| | | """ |
| | | 设置均大单的回调 |
| | | @param money: |
| | | @return: |
| | | """ |
| | | async_log_util.info(logger_l2_radical_buy_data, f"均大单回调函数:{code}-{money},原均大单-{THRESHOLD_MONEY}") |
| | | if money - THRESHOLD_MONEY > 10: |
| | | # 新的阈大于老的阈值 |
| | | old_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | if old_setting_money: |
| | | new_setting_money = int(old_setting_money * money / THRESHOLD_MONEY) |
| | | async_log_util.info(logger_l2_radical_buy_data, |
| | | f"累计大单回调人为设置({code}): {old_setting_money}->{new_setting_money}") |
| | | TotalDealBigOrderThresholdMoneyManager().set_money(code, new_setting_money, |
| | | trade_manager.CodesTradeStateManager().get_trade_state_cache( |
| | | code)) |
| | | |
| | | # 只有涨停过的代码才需要拉大单 |
| | | if code_ not in LimitUpDataConstant.get_history_limit_up_codes(): |
| | | return |
| | | |
| | | result = request_deal_big_orders(code_) |
| | | THRESHOLD_MONEY = 0 |
| | | if result: |
| | | try: |
| | | buy_datas, sell_datas = result[0], result[1] |
| | | # 获取原始均大单 |
| | | THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info( |
| | | code_) |
| | | BeforeSubDealBigOrderManager().set_big_deal_order_list(code_, buy_datas, sell_datas, |
| | | gpcode_manager.get_limit_up_price_as_num(code_)) |
| | | gpcode_manager.get_limit_up_price_as_num(code_), |
| | | big_order_threshold_callback) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | |