Tushare了解并使用
作者:互联网
Tushare是Python中一个十分好用的免费调用股票数据的接口包。运用tushare可以很轻松的调取各种股票数据。
import tushare as ts import pandas as pd #使用tushare需导入panda库 print(ts.__version__) pd.set_option('display.max_columns',None) #设置列不限制数量 pd.set_option('display.max_rows',None) #设置行不限制数量 ts.set_token("233c46e202c80053a852405341c94d6f0060ae7ee882316361f9f9a5") #所使用的账户通行证 pro=ts.pro_api() data = pro.index_daily(ts_code='399300.SZ', start_date='20210601', end_date='20210630') #data=pro.index_basic() #data = pro.stock_basic(exchange='', list_status='L',fields='ts_code,symbol,name,area,industry,list_date') print(data)
输出格式
名称 | 类型 | 默认显示 | 描述 |
---|---|---|---|
ts_code | str | Y | TS代码 |
symbol | str | Y | 股票代码 |
name | str | Y | 股票名称 |
area | str | Y | 地域 |
industry | str | Y | 所属行业 |
fullname | str | N | 股票全称 |
enname | str | N | 英文全称 |
cnspell | str | N | 拼音缩写 |
market | str | Y | 市场类型(主板/创业板/科创板/CDR) |
exchange | str | N | 交易所代码 |
curr_type | str | N | 交易货币 |
list_status | str | N | 上市状态 L上市 D退市 P暂停上市 |
list_date | str | Y | 上市日期 |
delist_date | str | N | 退市日期 |
is_hs | str | N | 是否沪深港通标的,N否 H沪股通 S深股通 |
输出结果
1.2.64
ts_code trade_date close open high low \
0 399300.SZ 20210630 5224.0410 5189.3797 5231.4262 5186.6250
1 399300.SZ 20210629 5190.5445 5248.5249 5248.5249 5182.6771
2 399300.SZ 20210628 5251.7604 5253.6081 5260.6372 5226.2201
3 399300.SZ 20210625 5239.9684 5159.8017 5251.6076 5157.4758
4 399300.SZ 20210624 5155.9738 5156.5638 5160.4346 5120.5844
5 399300.SZ 20210623 5147.3938 5127.1910 5171.0330 5109.7571
6 399300.SZ 20210622 5122.1583 5106.0743 5125.8186 5086.2776
7 399300.SZ 20210621 5090.3854 5088.0893 5123.7827 5058.5699
8 399300.SZ 20210618 5102.4657 5104.9297 5128.0309 5064.9208
9 399300.SZ 20210617 5101.8924 5074.3839 5123.3651 5073.8211
10 399300.SZ 20210616 5080.4909 5163.2493 5164.5192 5076.0222
11 399300.SZ 20210615 5166.5597 5218.5648 5225.5021 5137.4090
12 399300.SZ 20210611 5224.7030 5275.7456 5276.1039 5213.5991
13 399300.SZ 20210610 5271.4661 5236.4691 5299.5299 5229.5182
14 399300.SZ 20210609 5236.4493 5224.9496 5253.3555 5215.3506
15 399300.SZ 20210608 5232.1165 5276.9711 5319.0406 5201.1404
16 399300.SZ 20210607 5277.6271 5284.8907 5286.8424 5242.9481
17 399300.SZ 20210604 5282.2772 5228.2761 5334.4899 5221.2291
18 399300.SZ 20210603 5255.2855 5285.7098 5314.3691 5255.0719
19 399300.SZ 20210602 5289.9736 5348.3440 5352.6404 5266.7852
20 399300.SZ 20210601 5341.6798 5320.4745 5343.7529 5269.2590
pre_close change pct_chg vol amount
0 5190.5445 33.4965 0.6453 103752671.0 281015504.9
1 5251.7604 -61.2159 -1.1656 125162997.0 314896843.0
2 5239.9684 11.7920 0.2250 133193783.0 337452771.6
3 5155.9738 83.9946 1.6291 154931061.0 368265641.2
4 5147.3938 8.5800 0.1667 126685625.0 312607422.6
5 5122.1583 25.2355 0.4927 136356058.0 358765666.3
6 5090.3854 31.7729 0.6242 130416753.0 313690367.1
7 5102.4657 -12.0803 -0.2368 132184516.0 331527114.6
8 5101.8924 0.5733 0.0112 148585805.0 356697096.1
9 5080.4909 21.4015 0.4212 120452518.0 281927280.7
10 5166.5597 -86.0688 -1.6659 125147985.0 298286772.9
11 5224.7030 -58.1433 -1.1129 142880058.0 330616618.6
12 5271.4661 -46.7631 -0.8871 180807173.0 365363494.5
13 5236.4493 35.0168 0.6687 138991967.0 301454334.6
14 5232.1165 4.3328 0.0828 121820321.0 255075448.7
15 5277.6271 -45.5106 -0.8623 130559532.0 304042218.2
16 5282.2772 -4.6501 -0.0880 127704971.0 280463260.5
17 5255.2855 26.9917 0.5136 144732087.0 292326048.7
18 5289.9736 -34.6881 -0.6557 141968878.0 285448632.4
19 5341.6798 -51.7062 -0.9680 137754319.0 296176177.1
20 5331.5696 10.1102 0.1896 143831474.0 321845842.1
标签:SZ,Tushare,pro,list,ts,了解,使用,date,399300 来源: https://blog.csdn.net/caoodwadwadwa/article/details/118459103