From 3feed17ec1a1bf174d8ddd05741d0eab9b2b13b4 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 26 七月 2023 18:18:34 +0800
Subject: [PATCH] bug修复

---
 third_data/history_k_data_util.py |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/third_data/history_k_data_util.py b/third_data/history_k_data_util.py
index 8678dc7..12a13bf 100644
--- a/third_data/history_k_data_util.py
+++ b/third_data/history_k_data_util.py
@@ -58,6 +58,12 @@
         return cls.__request("current", {"symbols": symbols, "fields": fields})
 
     @classmethod
+    def get_exchanges_codes(cls, exchanges, sec_types, skip_suspended, skip_st, fields):
+        return cls.__request("get_instruments",
+                             {"exchanges": exchanges, "sec_types": sec_types, "skip_suspended": skip_suspended,
+                              "skip_st": skip_st, "fields": fields})
+
+    @classmethod
     def get_previous_trading_date(cls, exchange, date):
         return cls.__request("get_previous_trading_date", {"exchange": exchange, "date": date})
 
@@ -133,6 +139,19 @@
             data = JueJinHttpApi.current(symbols=",".join(symbols), fields='')
             return data
         # 杩斿洖鎸囧畾鏃ユ湡鐨勪笂涓氦鏄撴棩
+
+    # 鑾峰彇浜ゆ槗鎵�鐨勪唬鐮�
+    @classmethod
+    def get_exchanges_codes(cls, exchanges):
+        if constant.JUEJIN_LOCAL_API:
+            account_id, s_id, token = cls.getJueJinAccountInfo()
+            gmapi.set_token(token)
+            return gmapi.get_instruments(exchanges=exchanges, sec_types=[1], skip_suspended=True, skip_st=True,
+                                         fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
+        else:
+            return JueJinHttpApi.get_exchanges_codes(exchanges=exchanges, sec_types=[1], skip_suspended=True,
+                                                     skip_st=True,
+                                                     fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
 
     @classmethod
     def get_previous_trading_date(cls, date):
@@ -244,4 +263,17 @@
 
 
 if __name__ == "__main__":
-    print(JueJinApi.get_gp_current_info(["000333", "600686"]))
+    constant.JUEJIN_LOCAL_API = False
+    list_ = JueJinApi.get_exchanges_codes(["SHSE","SZSE"])
+    fdatas = []
+    for d in list_:
+        if d["sec_id"].find("60") != 0 and d["sec_id"].find("00") != 0:
+            continue
+        if d["sec_level"] != 1:
+            continue
+        if d["pre_close"] * 1.1 > 40:
+            continue
+        if (d["listed_date"] + datetime.timedelta(days=100)).timestamp() > datetime.datetime.now().timestamp():
+            continue
+        fdatas.append(d)
+    print(len(fdatas))

--
Gitblit v1.8.0