From 403f53e86f04ce0efb285d5d60c8519ab8ce1e15 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 15 九月 2023 10:56:00 +0800
Subject: [PATCH] 注释下单阻止

---
 utils/data_export_util.py |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/utils/data_export_util.py b/utils/data_export_util.py
index 4ef3bec..e5a50f3 100644
--- a/utils/data_export_util.py
+++ b/utils/data_export_util.py
@@ -2,6 +2,7 @@
 鏁版嵁瀵煎嚭宸ュ叿
 """
 import json
+import logging
 import os
 import time
 
@@ -50,12 +51,9 @@
     local_time = time.strftime("%Y%m%dT%H%M%S", time.localtime(time.time()))
     file_name = "{}/{}_{}.xls".format(dest_dir, code, local_time)
     file_name_txt = "{}/{}_{}.txt".format(dest_dir, code, local_time)
-    openfile = open(file_name_txt, 'w')
-    try:
+    with open(file_name_txt, 'w') as openfile:
         for data in datas:
             openfile.write(json.dumps(data) + "\n")
-    finally:
-        openfile.close()
     wb = xlwt.Workbook(encoding="utf-8")
     ws = wb.add_sheet('sheet1')
     ws.write(0, 0, '搴忓彿')
@@ -67,6 +65,7 @@
     ws.write(0, 6, '绫诲瀷')
     ws.write(0, 7, '閲嶅鏁伴噺')
     ws.write(0, 8, '鎾ゅ崟鏃堕棿')
+    ws.write(0, 9, '璁㈠崟鍙�')
 
     index = 0
     for data in datas:
@@ -138,6 +137,7 @@
             else:
                 ws.write(index, 6, '鍗栨挙', style)
         ws.write(index, 7, data["re"], style)
+        ws.write(index, 9, data["val"].get("orderNo"), style)
         # 鏌ヨ鏄惁鎾ゅ崟
         if int(data["val"]["operateType"]) == 0:
             cancel = False
@@ -148,8 +148,11 @@
                                                                                                      num_operate_map[
                                                                                                          code])
                     if buy_index == data["index"]:
-                        ws.write(index, 8, "{}-{}".format(d["index"], d["val"]["time"]), cancel_style)
-                        break
+                        try:
+                            ws.write(index, 8, "{}-{}".format(d["index"], d["val"]["time"]), cancel_style)
+                            break
+                        except Exception as e:
+                            logging.exception(e)
 
         ws.write(index, 3, "{}涓�".format(round(int(data["val"]["num"]) * float(data["val"]["price"]) / 100, 2)), style)
     wb.save(file_name)
@@ -207,4 +210,4 @@
 
 
 if __name__ == "__main__":
-    export_l2_excel("002765")
+    export_l2_excel("600360", date="2023-09-11")

--
Gitblit v1.8.0