From a21cbb2a3e01e088c9cebc7c38c02e7e5d614cbe Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: 星期一, 10 三月 2025 17:31:21 +0800
Subject: [PATCH] 日志调整

---
 data_server.py |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/data_server.py b/data_server.py
index c8967f2..4ef16d3 100644
--- a/data_server.py
+++ b/data_server.py
@@ -1,4 +1,5 @@
 import concurrent.futures
+import copy
 import hashlib
 import http
 import json
@@ -32,6 +33,9 @@
         if url.path == "/get_position_list":
             # 鑾峰彇鎸佷粨鍒楄〃
             results = PositionManager.get_position_cache()
+            results = copy.deepcopy(results)
+            for r in results:
+                r["auto_sell"] = 1 if r["securityID"] in data_cache.LIMIT_UP_SELL_CODES else 0
             response_data = json.dumps({"code": 0, "data": results})
         elif url.path == "/get_money":
             # 鑾峰彇璧勯噾淇℃伅
@@ -87,6 +91,11 @@
                 if data:
                     fdatas.append(data)
             response_data = json.dumps({"code": 0, "data": fdatas})
+        elif url.path == "/get_buy_money":
+            # 鑾峰彇姣忔涔板叆鐨勯噾棰�
+            money = data_cache.BUY_MONEY_PER_CODE
+            response_data = json.dumps({"code": 0, "data": {"money": money}})
+
         self.send_response(200)
         # 鍙戠粰璇锋眰瀹㈡埛绔殑鍝嶅簲鏁版嵁
         self.send_header('Content-type', 'application/json')
@@ -144,7 +153,7 @@
                     pre_price = data[1]
                     current_price = data[2] if data[2] else data[5][0][0]
                     price = tool.get_buy_max_price(current_price)
-                    price = min(price, tool.get_limit_up_price(code,pre_price))
+                    price = min(price, tool.get_limit_up_price(code, pre_price))
                 else:
                     price = round(float(params.get("price")), 2)  # 浠锋牸
                 result = huaxin_trade_api.order(1, code, volume, price, blocking=True)
@@ -173,6 +182,45 @@
                     price = round(params.get("price"), 2)  # 浠锋牸
                 result = huaxin_trade_api.order(2, code, volume, price, blocking=True)
                 result_str = json.dumps(result)
+
+            elif url.path == "/set_buy_money":
+                # 璁剧疆姣忔涔板叆鐨勯噾棰�
+                params = self.__parse_request()
+                # 绛惧悕楠岃瘉
+                if not self.__is_sign_right(params):
+                    result_str = json.dumps({"code": 1001, "msg": "绛惧悕閿欒"})
+                    return
+                # 鍗栧嚭
+                print("姣忔涔板叆鐨勯噾棰�", params)
+                money = params.get("money")  # 閲戦
+                if money is None:
+                    result_str = json.dumps({"code": 1, "msg": "鏈笂浼犻噾棰�"})
+                    return
+                money = int(money)
+                data_cache.BUY_MONEY_PER_CODE = money
+                result_str = json.dumps({"code": 0})
+
+            elif url.path == "/set_limit_up_sell":
+                # 璁剧疆姣忔涔板叆鐨勯噾棰�
+                params = self.__parse_request()
+                # 绛惧悕楠岃瘉
+                if not self.__is_sign_right(params):
+                    result_str = json.dumps({"code": 1001, "msg": "绛惧悕閿欒"})
+                    return
+                # 鍗栧嚭
+                print("姣忔涔板叆鐨勯噾棰�", params)
+                code = params.get("code")  #浠g爜
+                enable = params.get("enable")  # 鏄惁寮�鍚�
+                if code is None or enable is None:
+                    result_str = json.dumps({"code": 1, "msg": "涓婁紶鏁版嵁缂哄け"})
+                    return
+                enable = int(enable)
+                if enable:
+                    data_cache.LIMIT_UP_SELL_CODES.add(code)
+                else:
+                    data_cache.LIMIT_UP_SELL_CODES.discard(code)
+                result_str = json.dumps({"code": 0})
+
             elif url.path == "/cancel_order":
                 params = self.__parse_request()
                 # 绛惧悕楠岃瘉
@@ -229,3 +277,7 @@
         httpd.serve_forever()
     except Exception as e:
         pass
+
+
+if __name__ == "__main__":
+    run()

--
Gitblit v1.8.0