Spaces:
Runtime error
Runtime error
Update qlib/mcp_output/mcp_plugin/mcp_service.py
Browse files
qlib/mcp_output/mcp_plugin/mcp_service.py
CHANGED
|
@@ -9,8 +9,12 @@ print(f"Using Qlib data path: {data_dir}")
|
|
| 9 |
|
| 10 |
qlib.init(provider_uri=data_dir, region="cn")
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
instruments_path = os.path.join(data_dir, "instruments")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
if os.path.exists(instruments_path):
|
| 15 |
print("\n=== Instruments directory ===")
|
| 16 |
for freq in os.listdir(instruments_path):
|
|
@@ -21,31 +25,13 @@ if os.path.exists(instruments_path):
|
|
| 21 |
else:
|
| 22 |
print("Instruments directory not found!")
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
print("\
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
print("Calendars directory not found!")
|
| 32 |
-
|
| 33 |
-
# 4️⃣ 输出 features 目录信息
|
| 34 |
-
features_path = os.path.join(data_dir, "features")
|
| 35 |
-
if os.path.exists(features_path):
|
| 36 |
-
print("\n=== Features directory ===")
|
| 37 |
-
for f in os.listdir(features_path):
|
| 38 |
-
f_path = os.path.join(features_path, f)
|
| 39 |
-
if os.path.isdir(f_path):
|
| 40 |
-
n_files = len(os.listdir(f_path))
|
| 41 |
-
print(f"{f}/ : {n_files} feature files")
|
| 42 |
-
else:
|
| 43 |
-
print("Features directory not found!")
|
| 44 |
-
|
| 45 |
-
# 5️⃣ 可以进一步尝试获取标的列表
|
| 46 |
-
instruments = D.list_instruments(freq="day", market="cn")
|
| 47 |
-
print(f"\nNumber of day-frequency instruments: {len(instruments)}")
|
| 48 |
-
print(f"Sample instruments: {instruments[:10]}")
|
| 49 |
|
| 50 |
|
| 51 |
# Path settings
|
|
|
|
| 9 |
|
| 10 |
qlib.init(provider_uri=data_dir, region="cn")
|
| 11 |
|
| 12 |
+
# 根据你的数据包实际目录结构调整
|
| 13 |
+
instruments_path = os.path.join(data_dir, "instruments") # 或 "cn_data/instruments"
|
| 14 |
+
calendars_path = os.path.join(data_dir, "calendars")
|
| 15 |
+
features_path = os.path.join(data_dir, "features")
|
| 16 |
+
|
| 17 |
+
# 打印 instruments
|
| 18 |
if os.path.exists(instruments_path):
|
| 19 |
print("\n=== Instruments directory ===")
|
| 20 |
for freq in os.listdir(instruments_path):
|
|
|
|
| 25 |
else:
|
| 26 |
print("Instruments directory not found!")
|
| 27 |
|
| 28 |
+
# 尝试列出 day 级标的
|
| 29 |
+
try:
|
| 30 |
+
instruments = D.list_instruments(freq="day", market="cn")
|
| 31 |
+
print(f"\nNumber of day-frequency instruments: {len(instruments)}")
|
| 32 |
+
print(f"Sample instruments: {instruments[:10]}")
|
| 33 |
+
except Exception as e:
|
| 34 |
+
print("Error listing day-frequency instruments:", e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
# Path settings
|