From c285883d71ef8a362b012983dadc7ce4256b40f6 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 23 五月 2025 01:52:07 +0800
Subject: [PATCH] bug修复

---
 test/test_k_datas.py |  109 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 94 insertions(+), 15 deletions(-)

diff --git a/test/test_k_datas.py b/test/test_k_datas.py
index 1f0e68f..49e029a 100644
--- a/test/test_k_datas.py
+++ b/test/test_k_datas.py
@@ -1,21 +1,100 @@
+import threading
+import time
+
+from code_attribute import code_nature_analyse, gpcode_manager
+from log_module.log import logger_debug
 from third_data import history_k_data_manager
-from third_data.history_k_data_manager import HistoryKDataManager
 from third_data.history_k_data_util import JueJinApi
+from trade import l2_trade_util
 from utils import tool, init_data_util
 
-if __name__ == '__main__':
-    # code = "603960"
-    # day = tool.get_now_date_str()
-    # datas = init_data_util.get_volumns_by_code(code, 150)
-    # HistoryKDataManager().save_history_bars(code, day, datas, force=True)
-    # print(HistoryKDataManager().get_history_bars(code, day))
-    # print(HistoryKDataManager().get_pre_close(code, day))
-    # history_k_data_manager.re_set_price_pres([code])
-    # volumes_data = init_data_util.get_volumns_by_code("600211", 150)
-    # for volume in volumes_data:
-    #     print(volume)
-    code = "000333"
-    now_day = "2024-10-10"
+
+def __update():
+    time.sleep(5)
+    history_k_data_manager.update_history_k_bars()
+
+
+def __is_normal_in_5d(code):
+    """
+    鏈�杩�5澶╂槸鍚﹀浜庢甯哥姸鎬�
+    @param code:
+    @return:
+    """
+    now_day = tool.get_now_date_str()
     results = JueJinApi.get_history_instruments(JueJinApi.get_juejin_code_list_with_prefix([code]),
                                                 tool.date_sub(now_day, 30), tool.date_sub(now_day, 1))
-    print(results)
+    results = results[-5:]
+    normal = True
+    for r in results:
+        if r["sec_level"] != 1:
+            normal = False
+            break
+    return normal
+
+
+if __name__ == '__main__1':
+    codes = {'300947', '002025', '002875', '000757', '603076', '600785', '300766', '600595', '603511', '002205',
+             '002943', '002802', '002715', '603967', '600818', '000796', '600960', '603882', '002883', '603578',
+             '600650', '603028', '002905', '300058', '000503', '603228', '603920', '603693', '002209', '300819',
+             '002105', '300155', '002152', '002982', '600588', '001282', '605186', '600889', '002364', '603106',
+             '300451', '600506', '002559', '002363', '603888', '605259', '605069', '002622', '001258', '601566',
+             '002946', '002733', '002448', '000056', '600101', '603979', '002800', '603881', '003010', '002295',
+             '600322', '603580', '300153', '605398', '300946', '603506', '601218', '603938', '600120', '601619',
+             '002229', '002990', '002298', '603305', '002188', '002560', '300244', '001313', '000899', '600319',
+             '603183', '603876', '002662', '601579', '605333', '000818', '300069', '000048', '002881', '600590',
+             '002261', '002734', '600868', '002285', '002847', '002444', '000715', '601777', '000710', '002133',
+             '600143', '600280', '605011', '600728', '300488', '002286', '600718', '002354', '002475', '600114',
+             '603312', '300454', '300941', '000151', '600708', '002163', '002305', '002851', '002173', '002785',
+             '600032', '000920', '002913', '001389', '603121', '603063', '002384', '300067', '603273', '600602',
+             '000599', '603517', '002335', '002529', '002463', '600719', '601921', '603280', '600336', '600533',
+             '002358', '002357', '600979', '301396', '002068', '605255', '002248', '000722', '000688', '002518',
+             '603001', '600318', '600095', '300746', '001333', '002976', '002122', '301230', '603829', '300599',
+             '001279', '000007', '603269', '002743', '603286', '002134', '603193', '600376', '002970', '603860',
+             '002044', '000657', '002273', '605228', '002953', '002484', '600758', '600456', '605388', '603729',
+             '300288', '001298', '300528', '300643', '002707', '603108', '605162', '000592', '603716', '000558',
+             '600173', '002380', '300534', '600238', '002394', '603901', '002418', '002965', '002296', '603566',
+             '002779', '000888', '600825', '603268', '003038', '002993', '000659', '002580', '300253', '603215',
+             '002725', '603038', '002938', '002666', '002599', '600665', '603500', '002065', '002760', '301299',
+             '300078', '002436', '601869', '603610', '002888', '000815', '600183', '603238', '002829', '603296',
+             '603950', '603109', '000428'}
+    print(",".join(codes))
+
+if __name__ == '__main__':
+    code = "002809"
+    limit_up_price = 13.01
+    volumes_data = init_data_util.get_volumns_by_code(code, 150)
+    volumes = init_data_util.parse_max_volume_new(code, volumes_data[:60])
+    if code_nature_analyse.is_price_too_high_in_days(code, volumes_data, limit_up_price)[0]:
+        pass
+    # 淇濆瓨K绾垮舰鎬�
+    k_format = code_nature_analyse.get_k_format(code, limit_up_price, volumes_data)
+
+    if k_format[10] and k_format[10][0]:
+        # 杩�5涓氦鏄撴棩鏈夋定鍋�/鐐告澘/璺屽仠
+        price_info = k_format[10][1]
+        p_price_info = price_info[0]  # (浠锋牸,閲�)
+        t_price_info = price_info[1]  # (浠锋牸,閲�)/None
+        # 鍒濆鍖栦笉鑳戒拱
+        can_buy = False
+        # 鎶涘帇宸查噴鏀撅細浠婃棩娑ㄥ仠浠封墺T楂樹环涓擳楂樹环褰撴棩鎴愪氦閲忊墺P楂樹环瀵瑰簲鐨勯偅涓�澶╃殑鎴愪氦閲�*101%
+        if t_price_info and limit_up_price >= t_price_info[0] and t_price_info[1] >= p_price_info[0] * 1.01:
+            can_buy = True
+
+        if not can_buy:
+            # 鎶涘帇褰撴棩澶у箙閲婃斁锛氫粖鏃ユ定鍋滀环鈮楂樹环+2%涓斾粖鏃ユ定鍋滃疄鏃舵垚浜ら噺鈮楂樹环褰撴棩鎴愪氦閲�*90%
+            if t_price_info and limit_up_price >= t_price_info[0] * 1.02:
+                today_volume = int(98.02 * 10000 * 100)
+                if today_volume >= t_price_info[1] * 0.9:
+                    can_buy = True
+
+        if not can_buy:
+            # 鎶涘帇浠婃棩寮哄娍閲婃斁锛氭病鏈塗楂樹环鏃讹紝浠婃棩娑ㄥ仠浠封墺P楂樹环+6%涓斾粖鏃ユ定鍋滃疄鏃舵垚浜ら噺鈮楂樹环褰撴棩鎴愪氦閲�*101%
+            if not t_price_info and limit_up_price >= p_price_info[0] * 1.06:
+                today_volume = int(98.02 * 10000 * 100)
+                if today_volume >= p_price_info[1] * 1.01:
+                    can_buy = True
+
+        if not can_buy:
+            print("鎶涘帇娌¢噴鏀�")
+        else:
+            print("鎶涘帇宸查噴鏀�")

--
Gitblit v1.8.0