14 lines
703 B
Python
14 lines
703 B
Python
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}") |