代码拉取完成,页面将自动刷新
#导入相关库
import tushare as ts
# 初始化pro接口
pro = ts.pro_api('1c7f85b9026518588c0d0cdac712c2d17344332c9c8cfe6bc83ee75c')
# 拉取数据
df = pro.daily(**{
"ts_code": "",
"trade_date": "",
"start_date": 20230101,
"end_date": 20240101,
"offset": "",
"limit": ""
}, fields=[
"ts_code",
"trade_date",
"open",
"high",
"low",
"close",
"pre_close",
"change",
"pct_chg",
"vol",
"amount"
])
print(df)
df.head()
df = df.set_index('trade_date')
df.head()
df['close-open'] = (df['close'] - df['open']) / df['open']
df['high-low'] = (df['high'] - df['low']) / df['low']
df['pre-close'] = df['close'].shift(1)
df['price_change'] = df['close'] - df['pre-close']
df['p-change'] = (df['close'] - df['pre-close']) / df['pre-close'] * 100
df.head()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。