From b8eff41fef7b4ee2c20a4d268ac83a4f420f34b0 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 21 十一月 2024 14:26:13 +0800
Subject: [PATCH] 测试日志

---
 api/outside_api_command_callback.py |   73 +++++++++++++++++++++++++++++++-----
 1 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/api/outside_api_command_callback.py b/api/outside_api_command_callback.py
index d49dafc..d39d432 100644
--- a/api/outside_api_command_callback.py
+++ b/api/outside_api_command_callback.py
@@ -36,8 +36,7 @@
     logger_real_place_order_position, logger_device
 from output import l2_output_util
 from third_data import kpl_util, history_k_data_manager, huaxin_l1_data_manager, third_blocks_manager, kpl_data_manager
-from third_data.code_plate_key_manager import CodePlateKeyBuyManager, KPLCodeJXBlockManager, RealTimeKplMarketData, \
-    RadicalBuyBlockManager
+from third_data.code_plate_key_manager import  KPLCodeJXBlockManager
 from third_data.history_k_data_manager import HistoryKDataManager
 from third_data.history_k_data_util import JueJinApi, HistoryKDatasUtils
 from third_data.kpl_data_manager import KPLDataManager
@@ -51,6 +50,7 @@
 from trade.huaxin import huaxin_trade_api, huaxin_trade_data_update, \
     huaxin_trade_record_manager, huaxin_trade_order_processor, huaxin_sell_util
 from trade.huaxin.huaxin_trade_record_manager import PositionManager, DealRecordManager, DelegateRecordManager
+from trade.buy_radical.radical_buy_data_manager import RadicalBuyBlockManager
 from trade.sell import sell_manager
 from trade.sell.sell_rule_manager import TradeRuleManager, SellRule
 from trade.trade_manager import TradeTargetCodeModeManager, AutoCancelSellModeManager
@@ -93,7 +93,7 @@
     def __cancel_not_deal_order(self, code, order_ref, timeout=3):
         time.sleep(timeout)
         # 鎾や拱鍗�
-        huaxin_trade_api.cancel_order(1, code, "", orderRef=order_ref)
+        huaxin_trade_api.cancel_order(huaxin_trade_api.TRADE_DIRECTION_BUY, code, "", orderRef=order_ref)
 
     # 浜ゆ槗
     def OnTrade(self, client_id, request_id, data):
@@ -384,6 +384,7 @@
             elif code_list_type == outside_api_command_manager.CODE_LIST_GREEN:
                 if operate == outside_api_command_manager.OPERRATE_SET:
                     gpcode_manager.GreenListCodeManager().add_code(code)
+                    gpcode_manager.WantBuyCodesManager().add_code(code)
                     name = gpcode_manager.get_code_name(code)
                     if not name:
                         results = HistoryKDatasUtils.get_gp_codes_names([code])
@@ -391,6 +392,7 @@
                             gpcode_manager.CodesNameManager.add_first_code_name(code, results[code])
                 elif operate == outside_api_command_manager.OPERRATE_DELETE:
                     gpcode_manager.GreenListCodeManager().remove_code(code)
+                    gpcode_manager.WantBuyCodesManager().remove_code(code)
                 elif operate == outside_api_command_manager.OPERRATE_GET:
                     codes = gpcode_manager.GreenListCodeManager().list_codes_cache()
                     datas = []
@@ -880,6 +882,8 @@
                                 order_begin_pos = OrderBeginPosInfo(buy_single_index=0, buy_exec_index=0)
                             l2_data_util.load_l2_data(code)
                             total_datas = l2_data_util.local_today_datas.get(code)
+                            if not total_datas:
+                                continue
                             trade_index, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code)
                             if trade_index is None:
                                 trade_index = 0
@@ -930,7 +934,7 @@
                             limit_up_price = gpcode_manager.get_limit_up_price(code)
                             buy1_money = Buy1PriceManager().get_latest_buy1_money(code)
                             if buy1_money is None:
-                                buy1_money = 0
+                                buy1_money = 1
                             # 鑾峰彇宸茬粡鎴愪氦鐨勫ぇ鍗曟暟閲�
                             total_big_num = 0
                             total_big_count = 0
@@ -1013,7 +1017,7 @@
                                     real_place_order_after_num += val["num"]
 
                             # 鑾峰彇褰撴棩鐨勯噺姣�
-                            volume_rate = code_volumn_manager.get_volume_rate(code)
+                            volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate(code)
 
                             # 鏄惁闇�瑕佹敞鎰�
                             need_pay_attention = (total_left_count <= 10 or total_left_num * float(
@@ -1071,7 +1075,7 @@
                                      "pay_attention": need_pay_attention,
                                      "trade_progress_percent": round(
                                          total_left_num * float(limit_up_price) * 100 * 100 / buy1_money, 2),  # 鎴愪氦杩涘害姣斾緥
-                                     "limit_up_price": float(gpcode_manager.get_limit_up_price(code)),
+                                     "limit_up_price": gpcode_manager.get_limit_up_price_as_num(code),
                                      "is_near_big_order": is_near_big_order,
                                      "block": '',
                                      "trade_queue": []
@@ -1101,6 +1105,14 @@
                                 zyltgb = global_util.zyltgb_map.get(code)
                                 if zyltgb is not None:
                                     fdata['zyltgb'] = output_util.money_desc(zyltgb)
+                            except:
+                                pass
+
+                            try:
+                                if order_begin_pos:
+                                    fdata['mode'] = order_begin_pos.mode
+                                else:
+                                    fdata['mode'] = -1
                             except:
                                 pass
 
@@ -1172,8 +1184,8 @@
             elif ctype == "set_per_code_buy_money":
                 # 璁剧疆鍗曞彧绁ㄧ殑涔板叆閲戦
                 money = data["money"]
-                if money > 30000:
-                    raise Exception("鏈�澶氬彧鑳借缃�3w")
+                if money > 50000:
+                    raise Exception("鏈�澶氬彧鑳借缃�5w")
                 constant.BUY_MONEY_PER_CODE = money
                 self.send_response({"code": 0, "data": {"money": constant.BUY_MONEY_PER_CODE}}, client_id, request_id)
             elif ctype == "get_per_code_buy_money":
@@ -1183,6 +1195,8 @@
                 kpl_data_manager.PullTask.repaire_pull_task()
                 # 淇鏁版嵁鏈嶅姟
                 server_util.repaire_data_server()
+                # 浠诲姟淇
+                huaxin_trade_data_update.repaire_task()
                 self.send_response({"code": 0, "data": {}}, client_id, request_id)
             elif ctype == "get_trade_queue":
                 code = data["code"]
@@ -1196,7 +1210,7 @@
                 # 鑾峰彇澶у崟鎴愪氦鍒楄〃
                 code = data["code"]
                 data_list = BigOrderDealManager().get_total_buy_money_list(code)
-                bigger_money = l2_data_util_old.get_big_money_val(float(gpcode_manager.get_limit_up_price(code)),
+                bigger_money = l2_data_util_old.get_big_money_val(gpcode_manager.get_limit_up_price_as_num(code),
                                                                   tool.is_ge_code(code))
                 fdatas = []
                 for d in data_list:
@@ -1270,6 +1284,10 @@
                 # 璁剧疆涔板叆閲戦鍜屾暟閲�
                 normal = data["normal"]
                 radical = data["radical"]
+                default_buy_money = data["default_buy_money"]
+                if int(default_buy_money) not in constant.AVAILABLE_BUY_MONEYS:
+                    raise Exception("榛樿閲戦涓嶅湪棰勮閲戦鍐�")
+                constant.BUY_MONEY_PER_CODE = default_buy_money
                 BuyMoneyAndCountSetting().set_normal_buy_data(normal[0], json.loads(normal[1]))
                 BuyMoneyAndCountSetting().set_radical_buy_data(radical[0], json.loads(radical[1]))
                 data = {
@@ -1284,7 +1302,8 @@
                 data = {
                     "normal": BuyMoneyAndCountSetting().get_normal_buy_setting(),
                     "radical": BuyMoneyAndCountSetting().get_radical_buy_setting(),
-                    "moneys": constant.AVAILABLE_BUY_MONEYS
+                    "moneys": constant.AVAILABLE_BUY_MONEYS,
+                    "default_buy_money": constant.BUY_MONEY_PER_CODE
                 }
                 self.send_response({"code": 0, "data": data, "msg": f""},
                                    client_id,
@@ -1304,7 +1323,41 @@
                 self.send_response({"code": 0, "data": data, "msg": f""},
                                    client_id,
                                    request_id)
+            elif ctype == "get_place_order_settings":
+                # 鑾峰彇涔板叆涓嬪崟璁剧疆
+                data = {
+                    "radical_buy": {"price": (constant.MIN_CODE_RADICAL_BUY_PRICE, constant.MAX_CODE_RADICAL_BUY_PRICE),
+                                    "zyltgb": constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES}}
+                self.send_response({"code": 0, "data": data, "msg": f""},
+                                   client_id,
+                                   request_id)
+            elif ctype == "set_place_order_settings":
+                radical_buy = data.get("radical_buy")
+                if radical_buy:
+                    radical_buy = json.loads(radical_buy)
+                    constant.MIN_CODE_RADICAL_BUY_PRICE = radical_buy["price"][0]
+                    constant.MAX_CODE_RADICAL_BUY_PRICE = radical_buy["price"][1]
+                    constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES = radical_buy["zyltgb"]
+                self.send_response({"code": 0, "data": {}, "msg": f""},
+                                   client_id,
+                                   request_id)
+            elif ctype == "get_buy_open_limit_up_codes":
+                # 鑾峰彇闅斿鍗曟帓1鐨勪唬鐮�
+                codes = gpcode_manager.BuyOpenLimitUpCodeManager().get_codes()
+                if not codes:
+                    codes = set()
+                self.send_response({"code": 0, "data": list(codes), "msg": f""},
+                                   client_id,
+                                   request_id)
 
+            elif ctype == "set_buy_open_limit_up_codes":
+                # 璁剧疆闅斿鍗曟帓1鐨勪唬鐮�
+                codes = data.get("codes")
+                codes = json.loads(codes)
+                gpcode_manager.BuyOpenLimitUpCodeManager().set_codes(set(codes))
+                self.send_response({"code": 0, "data": list(codes), "msg": f""},
+                                   client_id,
+                                   request_id)
         except Exception as e:
             logging.exception(e)
             logger_debug.exception(e)

--
Gitblit v1.8.0