委托列表输出量比/动态L后撤单比例修改/最大单价买到250/参考量不取最近5个交易日最大/下午1点过后不自动加想
| | |
| | | async_log_util.info(logger_debug, f"统计实撤用时:{code} - {use_time}") |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | fdata["volume_info"] = code_volumn_manager.CodeVolumeManager().get_volume_rate(code, with_info=True) |
| | | fdatas.append(fdata) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | |
| | | if constant.CAN_AUTO_L_DOWN_RATE_CHANGE: |
| | | try: |
| | | if MaxPriceInfoManager().get_max_limit_up_time(code) > 60: |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | gpcode_manager.get_limit_up_price_as_num( |
| | | code)) |
| | | if deal_big_order_info and deal_big_order_info[5] > 5000e4: |
| | | temp_rate = round(deal_big_order_info[1] / deal_big_order_info[5], 2) |
| | | threshold_rate = min(max(temp_rate, 0.3), 0.9) |
| | | # deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | # gpcode_manager.get_limit_up_price_as_num( |
| | | # code)) |
| | | # if deal_big_order_info and deal_big_order_info[5] > 5000e4: |
| | | # temp_rate = round(deal_big_order_info[1] / deal_big_order_info[5], 2) |
| | | # threshold_rate = min(max(temp_rate, 0.3), 0.7) |
| | | volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate(code) |
| | | threshold_rate = min(max(volume_rate, 0.3), 0.7) |
| | | except: |
| | | pass |
| | | return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | |
| | | @return: |
| | | """ |
| | | # 60个交易日未涨停取 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | has_limit_up_in_60 = True |
| | | if k_format and not k_format[13]: |
| | | has_limit_up_in_60 = False |
| | | volume = self.get_max_volume_in_5days(code) |
| | | if volume and volume * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | return volume |
| | | # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | # has_limit_up_in_60 = True |
| | | # if k_format and not k_format[13]: |
| | | # has_limit_up_in_60 = False |
| | | # volume = self.get_max_volume_in_5days(code) |
| | | # if volume and volume * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | # return volume |
| | | return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price) |
| | | |
| | | def get_radical_buy_refer_volume_info(self, code, limit_up_price): |
| | |
| | | @return: |
| | | """ |
| | | # 60个交易日未涨停取 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | has_limit_up_in_60 = True |
| | | if k_format and not k_format[13]: |
| | | has_limit_up_in_60 = False |
| | | # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | # has_limit_up_in_60 = True |
| | | # if k_format and not k_format[13]: |
| | | # has_limit_up_in_60 = False |
| | | # (量, 日期) |
| | | volume_info = self.__max_volume_info_in_5days.get(code, None) |
| | | if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | return volume_info |
| | | # volume_info = self.__max_volume_info_in_5days.get(code, None) |
| | | # if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | # return volume_info |
| | | return self.get_reference_volume_info(code) |
| | | |
| | | def get_volume_rate_refer_in_5days(self, code, total_sell_volume=0): |
| | |
| | | max_volume = self.get_max_volume_in_5days(code) |
| | | if not max_volume: |
| | | return 0 |
| | | today_volume = self.get_today_volumn(code) |
| | | today_volume = self.get_today_volumn_cache(code) |
| | | return round((today_volume + total_sell_volume) / max_volume, 2) |
| | | |
| | | # 获取历史量 |
| | |
| | | _volumn = global_util.today_volumn.get(code) |
| | | if _volumn is None: |
| | | _volumn = RedisUtils.get(self.__redis_manager.getRedis(), "volumn_today-{}".format(code)) |
| | | if not _volumn: |
| | | _volumn = 0 |
| | | return int(_volumn) |
| | | |
| | | # 获取今日量 |
| | | def get_today_volumn_cache(self, code): |
| | | return global_util.today_volumn.get(code) |
| | | if code in global_util.today_volumn: |
| | | return global_util.today_volumn.get(code) |
| | | return 0 |
| | | |
| | | # 获取量比(今日量/max(60天最大量,昨日量)) |
| | | # 将总卖量计算在内 |
| | | def get_volume_rate(self, code, total_sell_volume=0, with_info=False): |
| | | today = self.get_today_volumn(code) |
| | | today = self.get_today_volumn_cache(code) |
| | | max60, yesterday = self.get_histry_volumn(code) |
| | | if today is None: |
| | | today = 0 |
| | |
| | | TRADE_ENABLE = True |
| | | |
| | | # 最大的代码价格 |
| | | MAX_CODE_PRICE = 100 |
| | | MAX_CODE_PRICE = 250 |
| | | MIN_CODE_PRICE = 2 |
| | | MAX_SUBSCRIPT_CODE_PRICE = 100 |
| | | MAX_SUBSCRIPT_CODE_PRICE = 250 |
| | | |
| | | # 扫入价格区间 |
| | | MAX_CODE_RADICAL_BUY_PRICE = 50 |
| | |
| | | |
| | | for d in datas: |
| | | code = d[0] |
| | | # 保存今日实时量 |
| | | temp_volumns.append((code, d[3])) |
| | | if not tool.is_can_buy_code(code): |
| | | continue |
| | | # 如果现价是0.0就取买1价 |
| | |
| | | if limit_up_price: |
| | | zylt = int(zylt / price * float(limit_up_price)) |
| | | global_util.zyltgb_map[code] = int(zylt) |
| | | # 保存今日实时量 |
| | | temp_volumns.append((code, d[3])) |
| | | |
| | | zyltgb = 0 |
| | | if code in global_util.zyltgb_map: |
| | | zyltgb = global_util.zyltgb_map[code] |
| | |
| | | refer_sell_money = refer_sell_data[1] |
| | | # 判断还需大单的金额(max(每次上板大单,累计成交大单)) |
| | | big_order_deal_enough_result = radical_buy_data_manager.is_big_order_deal_enough(code, |
| | | code_volumn_manager.CodeVolumeManager().get_volume_rate_refer_in_5days( |
| | | code_volumn_manager.CodeVolumeManager().get_volume_rate( |
| | | code), |
| | | refer_sell_money, |
| | | for_buy=True, |
| | |
| | | refer_volume_info = code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume_info( |
| | | code, limit_up_price) |
| | | if refer_volume_info: |
| | | data.append(refer_volume_info[1]) |
| | | # (日期,(量比, (今日量, 参考量))) |
| | | data.append((refer_volume_info[1], |
| | | code_volumn_manager.CodeVolumeManager().get_volume_rate(code, with_info=True))) |
| | | else: |
| | | data.append("--") |
| | | # L后撤单比例 |
| | |
| | | 执行自动加想策略 |
| | | @return: |
| | | """ |
| | | if tool.get_now_time_str() > '13:00:00': |
| | | # 下午不自动加想 |
| | | return |
| | | codes = LimitUpDataConstant.get_history_limit_up_codes() |
| | | if not codes: |
| | | return |
| | |
| | | # 获取近90天的最大量与最近的量 |
| | | # 获取最近一次涨停/涨停下一个交易日的最大值 |
| | | def get_volumns_by_code(code, count=60, juejin=False): |
| | | datas = HistoryKDatasUtils.get_history_tick_n(code, count, "open,high,low,close,volume,pre_close,bob,amount", juejin=juejin) |
| | | datas = HistoryKDatasUtils.get_history_tick_n(code, count, "open,high,low,close,volume,pre_close,bob,amount", |
| | | juejin=juejin) |
| | | if not datas: |
| | | return None |
| | | # 计算 |
| | |
| | | |
| | | # 判断是否涨停过 |
| | | target_index = None |
| | | has_limited_up = False |
| | | for i in range(len(datas)): |
| | | data = datas[i] |
| | | if __is_limited_up(data): |
| | | has_limited_up = True |
| | | next_data = None |
| | | if i > 0: |
| | | next_data = datas[i - 1] |
| | |
| | | target_index = i |
| | | if data['volume'] > datas[target_index]['volume']: |
| | | target_index = i |
| | | return datas[target_index]['volume'], datas[target_index]['volume'], datas[target_index]['bob'].strftime( |
| | | # 如果60个交易日没涨停,需要在最高量的基础上x2 |
| | | return datas[target_index]['volume'] * (2 if not has_limited_up else 1), datas[target_index]['volume'] * ( |
| | | 2 if not has_limited_up else 1), datas[target_index]['bob'].strftime( |
| | | "%Y-%m-%d"), target_index |
| | | |
| | | |
| | |
| | | if d["volume"] > max_volume_info[0]: |
| | | max_volume_info = (d["volume"], d) |
| | | if max_volume_info: |
| | | return max_volume_info[0], max_volume_info[1]['bob'].strftime("%Y-%m-%d") |
| | | return max_volume_info[0], max_volume_info[1]['bob'].strftime("%Y-%m-%d") |
| | | return None, None |
| | | |
| | | |