ak13/sh000300.py
2025-07-21 20:55:01 +08:00

14 lines
703 B
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.

import akshare as ak
def day():
# 获取收盘价
index_data = ak.stock_zh_index_daily(symbol="sh000300") # 上海证券交易所代码 sh000300
latest_close = index_data.iloc[-1]["close"] # 获取最新收盘价
print(f"沪深300指数000300最新收盘价: {latest_close}")
# 获取沪深300指数实时行情需在交易时间段内运行
# index_realtime = ak.stock_zh_ah_spot() # 获取所有指数实时行情
# sh000300_realtime = index_realtime[index_realtime["代码"] == "000300"] # 筛选沪深300指数
# current_price = sh000300_realtime["最新价"].values[0]
# print(f"沪深300指数000300当前实时价格: {current_price}")