From 21b84025d0d2543b5f6dc8c22859d25ce0e5de30 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 10 十月 2023 18:13:46 +0800
Subject: [PATCH] 交易日志格式化处理

---
 output/code_info_output.py |   78 ++++++++++++++++++++++++--------------
 1 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/output/code_info_output.py b/output/code_info_output.py
index f937c86..c47e614 100644
--- a/output/code_info_output.py
+++ b/output/code_info_output.py
@@ -18,7 +18,7 @@
 import l2.l2_data_manager_new
 from third_data import kpl_data_manager, kpl_api
 from third_data.kpl_data_manager import KPLLimitUpDataRecordManager
-from trade import first_code_score_manager, l2_trade_factor, trade_manager, l2_trade_util
+from trade import first_code_score_manager, l2_trade_factor, trade_manager, l2_trade_util, trade_record_log_util
 from trade.l2_trade_factor import L2TradeFactorUtil
 import trade.deal_big_money_manager
 
@@ -338,7 +338,7 @@
     break_time = limit_up_info[1]
     records = []
     try:
-        records = log_export.load_buy_score_recod(code)
+        records = log_export.load_trade_recod(code)
     except:
         pass
     records_new = []
@@ -350,32 +350,52 @@
                 time_ = record[0]
                 type = record[1]
                 data = record[2]
-                if type == '涓嬪崟':
-                    index += 1
-                    temp = f"绗瑊index}娆′笅鍗曪細銆恵time_}銆�&銆恵data['score']}鍒嗐��,{data.get('desc')}"
-                    records_new.append(temp)
-                    records_new_data.append({"type": 1, "index": index, "time": time_, "score": data['score']})
-                elif type == 'S鎾�':
-                    # index':378 , 'rate':0.51 , 'target_rate':0.49
-                    pass
-                elif type == 'S鎾よ寖鍥�':
-                    start = format_l2_data(total_datas[data['start_index']])
-                    end = format_l2_data(total_datas[data['end_index']])
-                    range_seconds = data['range_seconds']
-                    temp = f"绗瑊index}娆℃挙鍗曪細S鎾ゅ泭鎷寖鍥达細銆愯捣濮嬩綅:{start}銆戣嚦銆愭埅姝綅:{end}銆戝泭鎷椂闂淬�恵range_seconds}銆戠"
-                elif type == 'H鎾よ寖鍥�':
-                    start = format_l2_data(total_datas[data['start_index']])
-                    end = format_l2_data(total_datas[data['end_index']])
-                    count = data['count']
-                    temp = f"H鎾ゅ泭鎷寖鍥达細銆愯捣濮嬩綅:{start}銆戣嚦銆愭埅姝綅:{end}銆戠墿鐞嗙瑪鏁板叡銆恵count}銆戠瑪"
-                elif type == 'H鎾�':
-                    # 'start_index':339,'end_index':464, 'count':17
-                    pass
-                elif type == '鎾ゅ崟':
-                    temp = f"绗瑊index}娆℃挙鍗曪細銆恵time_}銆憑data['msg']}"
-                    records_new.append(temp)
-                    records_new_data.append({"type": 0, "time": time_, "desc": data['msg']})
+                if type == trade_record_log_util.TYPE_PLACE_ORDER:
+                    records_new_data.append((time_, "寮�鐩樺暒鎺ㄨ崘鍘熷洜",
+                                             f"{'銆�'.join(data['kpl_blocks'])}",
+                                             None))
+                    extra_datas = []
+                    if data['big_num_indexes']:
+                        big_num_desc = []
+                        for i in data['big_num_indexes']:
+                            big_num_desc.append(format_l2_data(total_datas[i]))
+                        extra_datas.append(f"鍖呭惈澶у崟锛歿' & '.join(big_num_desc)}")
+                    extra_datas.append(f"M鍊硷細{money_desc(data['m_val'])}")
+                    extra_datas.append(f"瀹夊叏绗旀暟锛歿data['safe_count']}")
 
+                    records_new_data.append((time_, "涓嬪崟",
+                                             f"銆恵format_l2_data(total_datas[data['buy_single_index']])}銆�-銆恵format_l2_data(total_datas[data['buy_exec_index']])}銆�",
+                                             data))
+                elif type == trade_record_log_util.TYPE_REAL_PLACE_ORDER_POSITION:
+                    records_new_data.append((time_, "瀹為檯鎸傚崟浣�", f"銆恵format_l2_data(data['index'])}銆�", None))
+                elif type == trade_record_log_util.TYPE_CANCEL_WATCH_INDEXES:
+                    indexes = data['watch_indexes']
+                    if indexes:
+                        cancel_type = data['cancel_type']
+                        indexes.sort()
+                        indexes_data = []
+                        for index in indexes:
+                            indexes_data.append(format_l2_data(total_datas[index]))
+                        desc = f"銆恵format_l2_data(total_datas[indexes[0]])}銆�-銆恵format_l2_data(total_datas[indexes[-1]])}銆�"
+                        if cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN:
+                            records_new_data.append((time_, "L鎾ゅ悗鍥婃嫭", desc, indexes_data))
+                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_UP:
+                            records_new_data.append((time_, "L鎾ゅ墠鍥婃嫭", desc, indexes_data))
+                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_H:
+                            records_new_data.append((time_, "H鎾ゅ泭鎷�", desc, indexes_data))
+                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_D:
+                            records_new_data.append((time_, "D鎾ゅ泭鎷�", desc, indexes_data))
+                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_S:
+                            records_new_data.append((time_, "S鎾ゅ泭鎷�", desc, indexes_data))
+                elif type == trade_record_log_util.TYPE_FORBIDDEN_BUY:
+                    records_new_data.append((time_, "鍔犲叆榛戝悕鍗�", f"鍘熷洜锛歿data['msg']}", None))
+                elif type == trade_record_log_util.TYPE_CANT_PLACE_ORDER:
+                    records_new_data.append((time_, "涓嶈兘涓嬪崟", f"鍘熷洜锛歿data['msg']}", None))
+                elif type == trade_record_log_util.TYPE_CANCEL:
+                    records_new_data.append((time_, "鎾ゅ崟", f"鍘熷洜锛歿data['msg']}", None))
+            if records_new_data:
+                for d in records_new_data:
+                    records_new.append(f"銆恵d[0]}銆�"+"{:<10}".format(d[1])+d[2])
         except:
             pass
 
@@ -383,5 +403,5 @@
 
 
 if __name__ == '__main__':
-    plate_info = kpl_api.getStockIDPlate("600748")
-    print(plate_info)
+    ts = ("0", "1", "2", "3")
+    print(','.join(ts[:-1]))

--
Gitblit v1.8.0