python获取网上股市信息示例

编程入门 行业动态 更新时间:2024-10-25 17:28:33

python获取网上股市信息<a href=https://www.elefans.com/category/jswz/34/1770116.html style=示例"/>

python获取网上股市信息示例

# 从网上获取股票交易历史数据
# url = '.html?code=1000001&start=19910401&end=19910409'
# url += '&fields=LCLOSE;TOPEN;HIGH;LOW;TCLOSE;CHG;PCHG;TURNOVER;VOTURNOVER;VATURNOVER;TCAP;MCAP'  import requests 
import pandas as pd
import matplotlib.pyplot as pltstock_code='1000020'
start_date='19990809'
end_date='20190809'url = '.html?code={}&start={}&end={}'.format(stock_code,start_date,end_date)#从网上获取数据
online_data=requests.get(url)csv_file_name='stock_{}.csv'.format(stock_code)#将数据保存到本地csv文件
with open(csv_file_name,"wb") as f:f.write(online_data.content)stock_data=pd.read_csv(csv_file_name,encoding='gb2312')stock_data=stock_data.sort_values(by = ["日期"],ascending = [True],i

更多推荐

python获取网上股市信息示例

本文发布于:2024-03-12 06:13:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1730872.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   股市信息   网上   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!