Files
sanguo_vnpy_v2/scripts/spike_s3_peewee.py

51 lines
1.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""S3: 验证 alphalens 与 vnpy_sqlite(peewee) 能否共存。
vnpy.alpha dataset/template.py:13 已 `from alphalens.utils import ...`
若 alphalens(empyrical-reloaded 要 peewee<3.17.4) 与 vnpy_sqlite(peewee 4.1.1)
冲突,vnpy.alpha 将无法 import —— 这是因子层方案 A 的前置阻塞项。
"""
import sys
import os
_VNPY_SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "vnpy_v4.4.0"))
sys.path.insert(0, _VNPY_SRC)
def main():
results = {}
# 1. alphalens 能否 import
try:
from alphalens.utils import get_clean_factor_and_forward_returns
from alphalens.tears import create_full_tear_sheet
results["alphalens_import"] = "OK"
except Exception as e:
results["alphalens_import"] = f"FAIL: {type(e).__name__}: {e}"
# 2. vnpy_sqlite 能否 importpeewee
try:
import peewee
results["peewee_version"] = peewee.__version__
from vnpy_sqlite.sqlite_database import SqliteDatabase
results["vnpy_sqlite_import"] = "OK"
except Exception as e:
results["vnpy_sqlite_import"] = f"FAIL: {type(e).__name__}: {e}"
# 3. alpha dataset 能否 import(同时拉 alphalens + vnpy
try:
from vnpy.alpha.dataset import AlphaDataset
results["alpha_dataset_import"] = "OK"
except Exception as e:
results["alpha_dataset_import"] = f"FAIL: {type(e).__name__}: {e}"
print("=== S3 Spike Result ===")
for k, v in results.items():
print(f" {k}: {v}")
ok = all(v == "OK" or v.startswith("4") for v in results.values())
print(f"\nS3 VERDICT: {'PASS' if ok else 'FAIL/CONFLICT'}")
if __name__ == "__main__":
main()