From ae8d76a456b64c1c6c4ebf11b6ec33b7df217b1a Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 18 八月 2025 13:43:46 +0800
Subject: [PATCH] bug修复

---
 third_data/history_k_data_util.py |   76 +++++++++++++++++++++++++------------
 1 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/third_data/history_k_data_util.py b/third_data/history_k_data_util.py
index 42573e8..197e0e0 100644
--- a/third_data/history_k_data_util.py
+++ b/third_data/history_k_data_util.py
@@ -170,7 +170,7 @@
 
     # 鑾峰彇浜ゆ槗鎵�鐨勪唬鐮�
     @classmethod
-    def get_exchanges_codes(cls, exchanges, skip_suspended=True, skip_st=True):
+    def get_exchanges_codes(cls, exchanges, skip_suspended=True, skip_st=True, fields=None):
         if constant.JUEJIN_LOCAL_API:
             account_id, s_id, token = cls.getJueJinAccountInfo()
             gmapi.set_token(token)
@@ -178,10 +178,11 @@
                                          skip_st=skip_st,
                                          fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
         else:
+            if not fields:
+                fields = "symbol,sec_type,sec_id,sec_name,listed_date,sec_level," "is_suspended,pre_close"
             return JueJinHttpApi.get_exchanges_codes(exchanges=exchanges, sec_types=[1], skip_suspended=skip_suspended,
                                                      skip_st=skip_st,
-                                                     fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,"
-                                                            "is_suspended,pre_close")
+                                                     fields=fields)
 
     @classmethod
     def get_history_instruments(cls, symbols, start_date, end_date, fields=None):
@@ -232,13 +233,15 @@
         return JueJinApi.get_gp_latest_info(codes, fields)
 
     @classmethod
-    def get_history_tick_n(cls, code, count, fields=None):
+    def get_history_tick_n(cls, code, count, fields=None, juejin=False):
         # return JueJinApi.get_history_tick_n(code, count, fields)
-        try:
-            return hx_qc_value_util.get_history_k_bars(code, count)
-        except Exception as e:
-            logger_debug.exception(e)
-
+        if constant.is_windows() or juejin:
+            return JueJinApi.get_history_tick_n(code, count, fields)
+        else:
+            try:
+                return hx_qc_value_util.get_history_k_bars(code, count)
+            except Exception as e:
+                logger_debug.exception(e)
 
     @classmethod
     def get_gp_current_info(cls, codes):
@@ -247,7 +250,13 @@
     # 杩斿洖鎸囧畾鏃ユ湡鐨勪笂涓氦鏄撴棩
     @classmethod
     def get_previous_trading_date(cls, date):
-        return hx_qc_value_util.get_previous_trading_date(date)
+        if constant.is_windows():
+            return JueJinApi.get_previous_trading_date(date)
+        else:
+            try:
+                return hx_qc_value_util.get_previous_trading_date(date)
+            except:
+                return JueJinApi.get_previous_trading_date(date)
 
     @classmethod
     def get_previous_trading_date_cache(cls, date):
@@ -292,7 +301,10 @@
     @classmethod
     def get_next_trading_date(cls, date):
         # return JueJinApi.get_next_trading_date(date)
-        return hx_qc_value_util.get_next_trading_date(date)
+        if constant.is_windows():
+            return JueJinApi.get_next_trading_date(date)
+        else:
+            return hx_qc_value_util.get_next_trading_date(date)
 
     @classmethod
     def get_trading_dates(cls, start_date, end_date):
@@ -349,19 +361,33 @@
             results[code] = code_name
         return results
 
+    @classmethod
+    def get_st_codes(cls):
+        """
+        鑾峰彇st浠g爜
+        @return:
+        """
+        results = JueJinApi.get_exchanges_codes("SHSE,SZSE", skip_st=False, fields="sec_id,sec_level")
+        codes = [x["sec_id"] for x in results if x["sec_level"] != 1]
+        return codes
+
+
+def get_k_bar_dead_date():
+    """
+    鑾峰彇K绾跨殑鎴鏃ユ湡
+    @return:
+    """
+    dates = HistoryKDatasUtils.get_latest_trading_date_cache(5)
+    latest_trading_date = None
+    if dates:
+        latest_trading_date = dates[0]
+    if latest_trading_date is None:
+        raise Exception("娌℃湁鑾峰彇鍒颁笂涓�涓氦鏄撴棩鐨勬棩鏈�")
+    # 4鐐逛箣鍚庢敼涓鸿幏鍙栦粖鏃ョ殑鏁版嵁
+    if tool.get_now_time_as_int() > 160000:
+        latest_trading_date = tool.get_now_date_str()
+    return latest_trading_date
+
 
 if __name__ == "__main__":
-    print(HistoryKDatasUtils.get_previous_trading_date("2024-12-31"))
-    print(HistoryKDatasUtils.get_history_tick_n("000095", 10))
-
-
-    # now_day = tool.get_now_date_str()
-    # results = JueJinApi.get_history_instruments(JueJinApi.get_juejin_code_list_with_prefix(["600265"]),
-    #                                             tool.date_sub(now_day, 30), tool.date_sub(now_day, 1))
-    # results = results[-5:]
-    # normal = True
-    # for r in results:
-    #     if r["sec_level"] != 1:
-    #         normal = False
-    #         break
-    # print(normal)
+    pass

--
Gitblit v1.8.0