tushareAPI获取股票沪深指数

  • Post author:
  • Post category:其他




上证指数历史数据采集


ID:503658

在这里插入图片描述



代码

# 
# 导入tushare
import tushare as ts
# 初始化pro接口
pro = ts.pro_api('你自己的TOKEN')

# 拉取数据
df = pro.index_daily(**{
    "ts_code": "000001.SH",
    "trade_date": "",
    "start_date": 20200101,
    "end_date": 20220415,
    "limit": "",
    "offset": ""
}, fields=[
    "ts_code",
    "trade_date",
    "close",
    "open",
    "high",
    "low",
    "pre_close",
    "change",
    "pct_chg",
    "vol",
    "amount"
])
print(df)



深证指数历史数据采集

在这里插入图片描述



代码

# 
# 导入tushare
import tushare as ts
# 初始化pro接口
pro = ts.pro_api(''你自己的TOKEN')

# 拉取深证数据
df = pro.index_daily(**{
    "ts_code": "399001.SZ",
    "trade_date": "",
    "start_date": 20200101,
    "end_date": 20220415,
    "limit": "",
    "offset": ""
}, fields=[
    "ts_code",
    "trade_date",
    "close",
    "open",
    "high",
    "low",
    "pre_close",
    "change",
    "pct_chg",
    "vol",
    "amount"
])
print(df)



版权声明:本文为qq_44757551原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。