24 lines
512 B
Python
24 lines
512 B
Python
import os
|
|
import sys
|
|
|
|
import tushare as ts
|
|
|
|
|
|
def main() -> int:
|
|
token = os.environ.get("TUSHARE_TOKEN")
|
|
if not token:
|
|
print("[ERROR] 未设置 TUSHARE_TOKEN 环境变量", file=sys.stderr)
|
|
return 1
|
|
|
|
ts.set_token(token)
|
|
pro = ts.pro_api()
|
|
|
|
df = pro.trade_cal(exchange="SHFE", start_date="20260101", end_date="20260110")
|
|
print(f"[OK] tushare 连通,返回 {len(df)} 行交易日历样本")
|
|
print(df.head())
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|