| | |
| | | logger_trade, logger_trade_position_api_request, logger_request_api, \ |
| | | logger_real_place_order_position, logger_device |
| | | from output import l2_output_util |
| | | from third_data import kpl_data_manager, kpl_util, history_k_data_manager |
| | | from third_data import kpl_data_manager, kpl_util, history_k_data_manager, huaxin_l1_data_manager |
| | | from third_data.code_plate_key_manager import CodePlateKeyBuyManager |
| | | from third_data.history_k_data_manager import HistoryKDataManager |
| | | from third_data.history_k_data_util import JueJinApi, HistoryKDatasUtils |
| | |
| | | raise Exception("尚未获取到现价") |
| | | # 获取买1金额 |
| | | price = round(float(current_price), 2) |
| | | buy1_info = L1DataManager.current_buy1_dict.get(code) |
| | | buy1_info = huaxin_l1_data_manager.get_buy1_info(code) |
| | | if buy1_info and buy1_info[0] * buy1_info[1] > 50 * 10000: |
| | | # 如果买1在50w以上就加一档 |
| | | price += 0.01 |
| | |
| | | return _volumn |
| | | |
| | | |
| | | # 获取今日量 |
| | | def get_today_volumn_cache(code): |
| | | return global_util.today_volumn.get(code) |
| | | |
| | | |
| | | # 获取量比(今日量/max(60天最大量,昨日量)) |
| | | # 将总卖量计算在内 |
| | | def get_volume_rate(code, total_sell_volume=0, with_info=False): |
| | |
| | | from cancel_strategy.s_l_h_cancel_strategy import HourCancelBigNumComputer, LCancelRateManager |
| | | from output.limit_up_data_filter import IgnoreCodeManager |
| | | from third_data import kpl_util, kpl_data_manager, kpl_api, block_info |
| | | from third_data.code_plate_key_manager import RealTimeKplMarketData, KPLPlateForbiddenManager |
| | | from third_data.code_plate_key_manager import RealTimeKplMarketData, KPLPlateForbiddenManager, CodePlateKeyBuyManager |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | | from third_data.kpl_data_manager import KPLDataManager, KPLLimitUpDataRecordManager, \ |
| | | KPLCodeLimitUpReasonManager |
| | |
| | | pass |
| | | try: |
| | | OpenLimitUpGoodBlocksBuyStrategy.set_current_limit_up_data(result_list_) |
| | | CodePlateKeyBuyManager.compute_open_limit_up_code_dict_for_radical_buy(result_list_) |
| | | except: |
| | | pass |
| | | |
| | |
| | | from log_module.log import hx_logger_contact_debug, hx_logger_trade_callback, \ |
| | | hx_logger_l2_orderdetail, hx_logger_l2_market_data, logger_l2_g_cancel, logger_debug, \ |
| | | logger_system, logger_trade, logger_local_huaxin_l1_trade_info, logger_l2_codes_subscript |
| | | from third_data import block_info, kpl_data_manager, history_k_data_manager |
| | | from third_data import block_info, kpl_data_manager, history_k_data_manager, huaxin_l1_data_manager |
| | | from third_data.code_plate_key_manager import KPLCodeJXBlockManager, CodePlateKeyBuyManager |
| | | from third_data.history_k_data_util import JueJinApi |
| | | from trade import trade_manager, l2_trade_util, \ |
| | |
| | | __GCancelBigNumComputer = GCancelBigNumComputer() |
| | | __sell_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| | | __process_l1_data_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| | | current_buy1_dict = {} |
| | | __updating_jx_blocks_codes = set() |
| | | |
| | | @classmethod |
| | |
| | | # 格式 (代码,现价,涨幅,量,更新时间,买1价格,买1量) |
| | | price = d[1] |
| | | L1DataManager.set_l1_current_price(code, price) |
| | | cls.current_buy1_dict[code] = (d[5], d[6]) |
| | | huaxin_l1_data_manager.set_buy1_data(code,d[5], d[6]) |
| | | |
| | | # 获取L1现价 |
| | | @classmethod |
| | |
| | | |
| | | # 涨停代码关键词板块管理 |
| | | import copy |
| | | import datetime |
| | | import json |
| | | import time |
| | | |
| | | import constant |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from third_data import kpl_block_util, kpl_api, kpl_util |
| | | from third_data import kpl_block_util, kpl_api, kpl_util, kpl_data_constant, huaxin_l1_data_manager |
| | | from settings.trade_setting import MarketSituationManager |
| | | from third_data.history_k_data_manager import HistoryKDataManager |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | |
| | | return self.__redisManager.getRedis() |
| | | |
| | | # 返回key集合(排除无效板块),今日涨停原因,今日历史涨停原因,历史涨停原因,二级,精选板块 |
| | | def get_plate_keys(self, code): |
| | | def get_plate_keys(self, code, contains_today = True): |
| | | """ |
| | | 获取代码的板块: (180天的涨停原因+推荐原因)+今日涨停原因+今日涨停推荐原因+今日推荐原因 |
| | | @param code: |
| | |
| | | if jingxuan_block_info: |
| | | jingxuan_blocks = jingxuan_block_info[0] |
| | | k4 |= set(jingxuan_blocks) # set([x[1] for x in jingxuan_blocks]) |
| | | if k1: |
| | | if k1 and contains_today: |
| | | # 涨停过 |
| | | keys |= k1 |
| | | |
| | | # 获取不到涨停原因 |
| | | keys |= k4 |
| | | if contains_today: |
| | | keys |= k4 |
| | | keys = keys - set(constant.KPL_INVALID_BLOCKS) |
| | | return keys, k1, k11, k2, k3, k4 |
| | | |
| | |
| | | # 加载涨停代码的目标板块 |
| | | def load_code_block(): |
| | | if limit_up_record_datas: |
| | | # 获取今日9:30以前的时间 |
| | | time_str = datetime.datetime.now().strftime("%Y-%m-%d") + " 09:30:00" |
| | | timestamp = time.mktime(time.strptime(time_str, '%Y-%m-%d %H:%M:%S')) |
| | | |
| | | for d in limit_up_record_datas: |
| | | if d[2] in constant.KPL_INVALID_BLOCKS and d[3] in before_blocks_dict: |
| | | code_limit_up_reasons_dict[d[3]] = {list(before_blocks_dict.get(d[3]))[0]} |
| | | else: |
| | | code_limit_up_reasons_dict[d[3]] = {d[2]} |
| | | # 不包含推荐原因 |
| | | # if d[6]: |
| | | # code_limit_up_reasons_dict[d[3]] |= set(d[6].split("、")) |
| | | # 开1才能包含推荐原因 |
| | | if d[6] and int(d[5]) < timestamp: |
| | | code_limit_up_reasons_dict[d[3]] |= set(d[6].split("、")) |
| | | return code_limit_up_reasons_dict |
| | | |
| | | if current_limit_up_datas is None: |
| | |
| | | can_buy_blocks, unique, msg, can_buy_strong_blocks, keys, active_buy_blocks) |
| | | |
| | | |
| | | |
| | | @classmethod |
| | | def compute_open_limit_up_code_dict_for_radical_buy(cls, current_limit_up_datas): |
| | | """ |
| | | 计算开1的代码信息,不包含5板以上的 |
| | | @param current_limit_up_datas: |
| | | @return: |
| | | """ |
| | | time_str = datetime.datetime.now().strftime("%Y-%m-%d") + " 09:30:00" |
| | | timestamp = time.mktime(time.strptime(time_str, '%Y-%m-%d %H:%M:%S')) |
| | | temp_dict = {} |
| | | for d in current_limit_up_datas: |
| | | code = d[0] |
| | | # d: (代码, 名称, 首次涨停时间, 最近涨停时间, 几板, 涨停原因, 板块, 实际流通, 主力净额,涨停原因代码,涨停原因代码数量) |
| | | # 计算是否开1 |
| | | if int(d[2]) >= timestamp: |
| | | continue |
| | | # 剔除5板以上的 |
| | | if d[4].find("连板") > 0 and int(d[4].replace("连板","")) >=5: |
| | | continue |
| | | buy1_money = huaxin_l1_data_manager.get_buy1_money(code) |
| | | if not buy1_money or buy1_money < 1e8: |
| | | continue |
| | | if not tool.is_can_buy_code(code): |
| | | continue |
| | | # 买1是否大于1亿 |
| | | blocks = {d[5]} |
| | | if d[6]: |
| | | blocks |= set(d[6].split("、")) |
| | | blocks-=constant.KPL_INVALID_BLOCKS |
| | | temp_dict[code] = (kpl_util.get_high_level_count(d[4]), d[6]) |
| | | kpl_data_constant.open_limit_up_code_dict_for_radical_buy = temp_dict |
| | | |
| | | |
| | | @classmethod |
| | | def is_radical_buy(cls, code): |
| | | """ |
| | | 是否是激进买 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | # 获取今日开一的代码,剔除5板以上的 |
| | | current_limit_up_datas = kpl_data_constant.current_limit_up_datas |
| | | # 计算 |
| | | |
| | | # 获取代码的板块 |
| | | keys_, k1_, k11_, k2_, k3_, k4_ = cls.__TargetCodePlateKeyManager.get_plate_keys(code, contains_today=False) |
| | | # 获取 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | pass |
New file |
| | |
| | | """ |
| | | 华鑫L1数据管理器 |
| | | """ |
| | | __current_buy1_data_dict = {} |
| | | |
| | | |
| | | def set_buy1_data(code, buy1_price, buy1_volume): |
| | | """ |
| | | 设置买1的数据 |
| | | @param code: |
| | | @param buy1_price: |
| | | @param buy1_volume: |
| | | @return: |
| | | """ |
| | | __current_buy1_data_dict[code] = (buy1_price, buy1_volume) |
| | | |
| | | |
| | | def get_buy1_info(code): |
| | | """ |
| | | 获取买1信息 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | return __current_buy1_data_dict.get(code) |
| | | |
| | | |
| | | def get_buy1_money(code): |
| | | """ |
| | | 获取买1金额 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | info = get_buy1_info(code) |
| | | if not info: |
| | | return None |
| | | return info[0] * info[1] |
New file |
| | |
| | | # 当前涨停数据 |
| | | current_limit_up_datas = [] |
| | | |
| | | # 用于计算激进买开1的板数:{"代码":(几版,板块)} |
| | | open_limit_up_code_dict_for_radical_buy = None |
| | |
| | | from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager |
| | | from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up, \ |
| | | logger_kpl_open_limit_up |
| | | from third_data import kpl_util, kpl_api |
| | | from third_data import kpl_util, kpl_api, kpl_data_constant |
| | | from third_data.code_plate_key_manager import LimitUpCodesPlateKeyManager, CodesHisReasonAndBlocksManager |
| | | |
| | | # 代码对应的涨停原因保存 |
| | |
| | | code_block_dict[code] = set() |
| | | code_block_dict[code].add(b) |
| | | # 设置涨停数据 |
| | | |
| | | if records: |
| | | cls.latest_origin_datas = records |
| | | cls.__LimitUpCodesPlateKeyManager.set_today_limit_up( |
| | | [(r[0], r[5], r[6].split('、') if r[6] else []) for r in records]) |
| | | kpl_data_constant.current_limit_up_datas = records |
| | | |
| | | code_reasons_dict = {} |
| | | reason_codes_dict = {} |
| | |
| | | """ |
| | | import time |
| | | |
| | | from code_attribute import gpcode_manager |
| | | from code_attribute import gpcode_manager, code_volumn_manager |
| | | from l2 import l2_data_util, l2_data_source_util, transaction_progress |
| | | from l2.l2_data_util import L2DataUtil |
| | | from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_l2_error |
| | | from settings.trade_setting import MarketSituationManager, TradeBlockBuyModeManager |
| | | from trade import trade_data_manager |
| | | from utils import tool, buy_condition_util, global_util |
| | |
| | | @param trade_index: |
| | | @return: |
| | | """ |
| | | total_data = l2_data_util.local_today_datas.get(code) |
| | | total_count = 0 |
| | | total_big_count = 0 |
| | | for i in range(trade_index + 1, total_data[-1]["index"] + 1): |
| | | data = total_data[i] |
| | | val = data["val"] |
| | | if not l2_data_util.L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | money = val["num"] * float(val["price"]) |
| | | if money < 5000: |
| | | continue |
| | | # 获取今日成交量与参考量 |
| | | # today = get_today_volumn(code) |
| | | # max60, yesterday = get_histry_volumn(code) |
| | | try: |
| | | today_volume = code_volumn_manager.get_today_volumn_cache(code) |
| | | histry_volumn = code_volumn_manager.get_histry_volumn(code) |
| | | if not today_volume or not histry_volumn: |
| | | return False, "尚未获取到量" |
| | | threshhold_volume = (histry_volumn[0][0] - today_volume) // 3 |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | threshhold_volumes = threshhold_volume // 100, int(50000 / limit_up_price), int(200000 / limit_up_price) |
| | | |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( |
| | | code, |
| | | i, |
| | | total_data, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_count += 1 |
| | | if money > 29900: |
| | | total_big_count += 1 |
| | | if total_count > 10: |
| | | break |
| | | if total_count > 10 or total_big_count < 1: |
| | | return False, f"未成交数量-{total_count},大单数量-{total_big_count}" |
| | | return True, "" |
| | | total_data = l2_data_util.local_today_datas.get(code) |
| | | total_count = 0 |
| | | total_big_count = 0 |
| | | total_num = 0 |
| | | for i in range(trade_index + 1, total_data[-1]["index"] + 1): |
| | | data = total_data[i] |
| | | val = data["val"] |
| | | if not l2_data_util.L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | money = val["num"] * float(val["price"]) |
| | | if money < 5000: |
| | | continue |
| | | |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( |
| | | code, |
| | | i, |
| | | total_data, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_num += val["num"] |
| | | total_count += 1 |
| | | if money > 29900: |
| | | total_big_count += 1 |
| | | if threshhold_volumes[2] < total_num: |
| | | break |
| | | if threshhold_volumes[1] <= total_num <= threshhold_volumes[2] and total_num < threshhold_volumes[ |
| | | 0] and total_big_count > 0: |
| | | # 剩余的值在500w-2000w之间才会参与计算 |
| | | return True, "" |
| | | return False, f"未成交手数-{total_num},阈值-{threshhold_volumes[0]},大单数量-{total_big_count}" |
| | | except Exception as e: |
| | | async_log_util.error(logger_l2_error, f"计算是否距离成交进度位置近:{str(e)}") |
| | | return False, "计算异常" |
| | | |
| | | |
| | | def is_quantization(code, start_index, end_index): |