| | |
| | | # 除开最大单的影响权重 |
| | | 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) |
| | | if thresh_hold_rate > temp_thresh_hold_rate: |
| | | # 目标撤单比例大于大单撤单比例就取比例均值 |
| | | thresh_hold_rate = round((thresh_hold_rate+temp_thresh_hold_rate)/2, 2) |
| | | |
| | | l2_log.l_cancel_debug(code, |
| | | f"L后计算范围:{start_index}-{end_index},已撤单比例:{rate}/{thresh_hold_rate}, 下单位之后的索引:{after_place_order_index_dict}") |
| | | if rate >= thresh_hold_rate: |
| | |
| | | """ |
| | | from code_attribute import gpcode_manager |
| | | from l2 import l2_log |
| | | from log_module import async_log_util |
| | | from log_module import async_log_util, log_export |
| | | from log_module.log import hx_logger_l2_sell_delegate, hx_logger_l2_sell_deal |
| | | |
| | | |
| | |
| | | |
| | | if code in cls.__delegating_sell_num_dict: |
| | | cls.__delegating_sell_num_dict.pop(code) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | code = "300479" |
| | | datas = log_export.load_huaxin_l2_sell_deal(code).get(code) |
| | | print(datas) |
| | | total_volume = sum([x[1] for x in datas]) |
| | | print("涨停卖成交", total_volume * 20.41) |
| | | datas = log_export.load_huaxin_l2_sell_delegate(code).get(code) |
| | | total_delegate = sum([x[2][2] for x in datas]) |
| | | print("总委托",total_delegate) |
New file |
| | |
| | | """ |
| | | L2数据解析器 |
| | | """ |
| | | import csv |
| | | |
| | | |
| | | def parse_order_detail(): |
| | | with open('OrderDetail.csv', 'r', encoding='utf-8') as file: |
| | | csv_reader = csv.reader(file) |
| | | # 获取表头 |
| | | headers = next(csv_reader) |
| | | print("表头:", headers) |
| | | # 遍历数据行 |
| | | max_count = 10 |
| | | count = 0 |
| | | for row in csv_reader: |
| | | print(row) |
| | | count += 1 |
| | | if count > max_count: |
| | | break |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | parse_order_detail() |
New file |
| | |
| | | # -*- mode: python ; coding: utf-8 -*- |
| | | |
| | | |
| | | block_cipher = None |
| | | |
| | | |
| | | a = Analysis( |
| | | ['l2_data_parser.py'], |
| | | pathex=[], |
| | | binaries=[], |
| | | datas=[], |
| | | hiddenimports=[], |
| | | hookspath=[], |
| | | hooksconfig={}, |
| | | runtime_hooks=[], |
| | | excludes=[], |
| | | win_no_prefer_redirects=False, |
| | | win_private_assemblies=False, |
| | | noarchive=False, |
| | | cipher=block_cipher, |
| | | ) |
| | | pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) |
| | | |
| | | exe = EXE( |
| | | pyz, |
| | | a.scripts, |
| | | [], |
| | | exclude_binaries=True, |
| | | name='l2_data_parser', |
| | | debug=False, |
| | | bootloader_ignore_signals=False, |
| | | strip=False, |
| | | upx=True, |
| | | console=True, |
| | | disable_windowed_traceback=False, |
| | | argv_emulation=False, |
| | | target_arch=None, |
| | | codesign_identity=None, |
| | | entitlements_file=None, |
| | | ) |
| | | coll = COLLECT( |
| | | exe, |
| | | a.binaries, |
| | | a.zipfiles, |
| | | a.datas, |
| | | strip=False, |
| | | upx=True, |
| | | upx_exclude=[], |
| | | name='l2_data_parser', |
| | | ) |
| | |
| | | fdatas.append((time_str, code, type, data_json["data"])) |
| | | return fdatas |
| | | |
| | | |
| | | @cache_log |
| | | def load_cancel_buy_reasons(code, date=tool.get_now_date_str()): |
| | | """ |
| | |
| | | return fdatas |
| | | |
| | | |
| | | @cache_log |
| | | def load_huaxin_l2_sell_deal(code=None, date=tool.get_now_date_str()): |
| | | path = f"{constant.get_path_prefix()}/logs/huaxin/l2/sell_l2_deal.{date}.log" |
| | | fdatas = {} |
| | | if os.path.exists(path): |
| | | with open(path, 'r', encoding="utf-8") as f: |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if line: |
| | | time_str = __get_async_log_time(line) |
| | | data = line.split(" - ")[1].strip() |
| | | if data.startswith("["): |
| | | data = data[data.find("]") + 1:].strip() |
| | | data = data.split("有涨停主动卖:")[1] |
| | | code_ = data[:6] |
| | | if code and code != code_: |
| | | continue |
| | | data = data[6:].strip() |
| | | volume = int(data.split("成交量-")[1].strip()) |
| | | if code_ not in fdatas: |
| | | fdatas[code_] = [] |
| | | fdatas[code_].append((time_str, volume)) |
| | | return fdatas |
| | | |
| | | |
| | | @cache_log |
| | | def load_huaxin_l2_sell_delegate(code=None, date=tool.get_now_date_str()): |
| | | path = f"{constant.get_path_prefix()}/logs/huaxin/l2/sell_l2_delegate.{date}.log" |
| | | fdatas = {} |
| | | if os.path.exists(path): |
| | | with open(path, 'r', encoding="utf-8") as f: |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if line: |
| | | time_str = __get_async_log_time(line) |
| | | data = line.split(" - ")[1].strip() |
| | | if data.startswith("["): |
| | | data = data[data.find("]") + 1:].strip() |
| | | datas = data.split("-") |
| | | code_ = datas[0] |
| | | if code and code != code_: |
| | | continue |
| | | if code_ not in fdatas: |
| | | fdatas[code_] = [] |
| | | fdatas[code_].append((time_str, datas[1], eval(datas[2]))) |
| | | return fdatas |
| | | |
| | | |
| | | # 加载华鑫本地买入订单号 |
| | | def load_l2_market_data(): |
| | | path = f"{constant.get_path_prefix()}/logs/huaxin/l2/marketdata.{tool.get_now_date_str()}.log" |
| | |
| | | except: |
| | | pass |
| | | return fdatas |
| | | |
| | | |
| | | @cache_log |
| | | def load_huaxin_active_sell_map(date=tool.get_now_date_str()): |
| | |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | load_huaxin_transaction_sell_no(code = '2024-11-10') |
| | | load_huaxin_transaction_sell_no(code='2024-11-10') |
| | | load_huaxin_transaction_sell_no(code='2024-11-10') |
| | | # print(get_h_cancel_compute_info("603912")) |
| | | |