From 4905b98d221044f08c8ac8db49e86a769e574bae Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 05 六月 2024 12:42:07 +0800
Subject: [PATCH] P撤修改/买入2000以下,买所有

---
 third_data/history_k_data_util.py |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/third_data/history_k_data_util.py b/third_data/history_k_data_util.py
index ed60d06..b9db9b3 100644
--- a/third_data/history_k_data_util.py
+++ b/third_data/history_k_data_util.py
@@ -83,6 +83,13 @@
                               "skip_st": skip_st, "fields": fields})
 
     @classmethod
+    def get_history_instruments(cls, symbols, start_date, end_date, fields):
+        return cls.__request("get_history_instruments",
+                             {"symbols": symbols, "start_date": start_date, "end_date": end_date, "fields": fields})
+
+
+
+    @classmethod
     def get_previous_trading_date(cls, exchange, date):
         return cls.__request("get_previous_trading_date", {"exchange": exchange, "date": date})
 
@@ -164,16 +171,27 @@
 
     # 鑾峰彇浜ゆ槗鎵�鐨勪唬鐮�
     @classmethod
-    def get_exchanges_codes(cls, exchanges):
+    def get_exchanges_codes(cls, exchanges, skip_suspended=True, skip_st=True):
         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,
+            return gmapi.get_instruments(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")
         else:
-            return JueJinHttpApi.get_exchanges_codes(exchanges=exchanges, sec_types=[1], skip_suspended=True,
-                                                     skip_st=True,
+            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")
+
+    @classmethod
+    def get_history_instruments(cls, symbols, start_date, end_date, fields=None):
+        if constant.JUEJIN_LOCAL_API:
+            account_id, s_id, token = cls.getJueJinAccountInfo()
+            gmapi.set_token(token)
+            return gmapi.get_history_instruments(symbols=symbols, start_date=start_date, end_date=end_date,
+                                         fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
+        else:
+            return JueJinHttpApi.get_history_instruments(symbols, start_date, end_date, fields)
 
     @classmethod
     def get_previous_trading_date(cls, date):
@@ -316,5 +334,12 @@
 
 
 if __name__ == "__main__":
-    results = HistoryKDatasUtils.get_codes_limit_rate(list({"000422", "600610"}))
-    print(results)
+    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)

--
Gitblit v1.8.0