From 1e0065d1f45ec3d9ecda1d3e35d958c08db537dc Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 02 四月 2024 15:07:05 +0800 Subject: [PATCH] bug修改/加入设置单支票买入金额接口 --- utils/data_export_util.py | 96 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 88 insertions(+), 8 deletions(-) diff --git a/utils/data_export_util.py b/utils/data_export_util.py index 1401cc0..69e0077 100644 --- a/utils/data_export_util.py +++ b/utils/data_export_util.py @@ -15,30 +15,50 @@ from log_module import log, log_export from l2 import l2_data_source_util from trade import deal_big_money_manager +from utils import tool def export_l2_excel(code, date=None): # 鑾峰彇L2鐨勬暟鎹� - fdatas = get_l2_datas(code) + fdatas = get_l2_datas(code, date=date) __save_l2_datas(code, fdatas) # 鑾峰彇L2鐨勬暟鎹� -def get_l2_datas(code, date=None): - local_today_datas = log_export.load_l2_from_log(date) - datas = local_today_datas[code] +def get_l2_datas(code, today_datas=None, date=None): + if date is None: + date = tool.get_now_date_str() + datas = today_datas + if datas is None: + local_today_datas = log_export.load_l2_from_log(date) + datas = local_today_datas.get(code) + if not datas: + datas = [] process_indexs = log_export.get_l2_process_position(code, date) trade_indexs = log_export.get_l2_trade_position(code, date) real_position_indexes = log_export.get_real_place_order_positions(code, date) - deal_list = log_export.load_huaxin_deal_record(code) + deal_list = log_export.load_huaxin_deal_record(code, date) deal_list_dict = {} for d in deal_list: deal_list_dict[str(d[0])] = d - fdatas = export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes, deal_list_dict) + + sell_no_dict = log_export.load_huaxin_transaction_sell_no(code=code, date=date) + sell_nos = sell_no_dict.get(code) + + fdatas = export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes, deal_list_dict, sell_nos) return fdatas -def export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes, deal_list_dict): +def get_l2_transaction_datas(code, date=None): + if date is None: + date = tool.get_now_date_str() + sell_no_dict = log_export.load_huaxin_transaction_sell_no(code=code, date=date) + sell_nos = sell_no_dict.get(code) + fdatas = export_l2_transaction_data(code,sell_nos) + return fdatas + + +def export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes, deal_list_dict, sell_nos): def find_process_index(index): for i in range(0, len(process_indexs)): if process_indexs[i][0] <= index <= process_indexs[i][1]: @@ -55,7 +75,9 @@ num_operate_map = {} l2.l2_data_util.load_num_operate_map(num_operate_map, code, datas) buy_no_map = {} + sell_no_map = {} l2.l2_data_util.load_buy_no_map(buy_no_map, code, datas) + l2.l2_data_util.load_sell_no_map(sell_no_map, code, datas) l2.l2_data_util.load_canceled_buy_no_map(l2.l2_data_util.local_today_canceled_buyno_map, code, datas) @@ -176,6 +198,64 @@ format_data.append(cancel_order_info) format_data.append(data["val"].get("orderNo")) fdatas.append((style_int, trade_info, format_data)) + + # 灏嗚鍗曞彿绱㈠紩 + order_no_index_map = {} + for i in range(len(fdatas)): + d = fdatas[i][2] + if d[6].find('鎾�') >= 0: + continue + order_no_index_map[int(d[10])] = i + order_no_indexes = [(k, order_no_index_map[k]) for k in order_no_index_map] + order_no_indexes.sort(key=lambda x: x[0]) + + if sell_nos: + for sell_info in sell_nos: + if sell_info[1] * sell_info[2] < 50 * 10000: + continue + for i in range(len(order_no_indexes) - 1): + if order_no_indexes[i][0] < sell_info[0] < order_no_indexes[i + 1][0]: + item = [] + item.append(order_no_indexes[i + 1][1]) + item.append(l2_huaxin_util.convert_time(sell_info[3][0], with_ms=True)) + item.append("") + item.append( + "{}涓�".format(round(sell_info[1] * sell_info[2] / 10000, 1))) + item.append(sell_info[2]) + item.append(sell_info[1] // 100) + item.append("涓诲姩鍗�") + item.append(1) + item.append(l2_huaxin_util.convert_time(sell_info[4][0], with_ms=True)) + item.append(None) + item.append(sell_info[0]) + fdatas.insert(order_no_indexes[i + 1][1], (0, None, item)) + break + + return fdatas + + +def export_l2_transaction_data(code, sell_nos): + fdatas = [] + if sell_nos: + index = 0 + for sell_info in sell_nos: + if sell_info[1] * sell_info[2] < 50 * 10000: + continue + index += 1 + item = [] + item.append(index) + item.append(l2_huaxin_util.convert_time(sell_info[3][0], with_ms=True)) + item.append("") + item.append( + "{}涓�".format(round(sell_info[1] * sell_info[2] / 10000, 1))) + item.append(sell_info[2]) + item.append(sell_info[1] // 100) + item.append("涓诲姩鍗�") + item.append(1) + item.append(l2_huaxin_util.convert_time(sell_info[4][0], with_ms=True)) + item.append(None) + item.append(sell_info[0]) + fdatas.append((0, None, item)) return fdatas @@ -279,6 +359,6 @@ if __name__ == "__main__": try: - export_l2_excel("002036") + get_l2_datas("600990") except Exception as e: logging.exception(e) -- Gitblit v1.8.0