tushare上的股票数据哪里来的
时间: 2024-06-09 19:07:08 浏览: 6
Tushare是一个免费的股票数据接口,其数据来源主要包括中国证券监督管理委员会(CSRC)、上交所、深交所、中国银行间市场交易商协会(NFC)等机构,同时也包括了新浪财经、东方财富等互联网财经媒体的数据。Tushare通过对这些机构公开的数据进行整合和加工,提供给用户一系列易于调用的API接口,以方便用户进行股票数据的查询、分析和应用。
相关问题
tushare获取股票数据
要使用 tushare 获取股票数据,首先需要安装 tushare 库。可以使用以下命令在命令行中安装:
```
pip install tushare
```
然后,在 Python 脚本中导入 tushare 库:
```python
import tushare as ts
```
接下来,可以使用 tushare 库中的函数来获取股票数据。例如,以下代码将获取股票代码为“000001”的股票在 2021 年 6 月的日线数据:
```python
data = ts.get_hist_data('000001', start='2021-06-01', end='2021-06-30')
print(data)
```
除了日线数据,tushare 还提供了其他类型的数据,例如周线、月线、季度线和年线数据。具体可以参考 tushare 官方文档。
tushare获取股票数据excel
作为AI语言模型,我无法在本地提供tushare获取股票数据excel的代码。不过,你可以在tushare官方文档中查看如何使用tushare获取股票数据并将其保存为excel文件。以下是一个简单的示例:
```python
import tushare as ts
# 获取股票数据
data = ts.get_hist_data('600036', start='2021-01-01', end='2021-12-31')
# 将数据保存为excel文件
data.to_excel('600036.xlsx')
```
这个例子用tushare库获取了中国平安(股票代码为600036)从2021年1月1日到2021年12月31日的历史数据,并将其保存为名为“600036.xlsx”的excel文件。你可以根据自己的需要调整代码中的股票代码和日期范围。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)