简体   繁体   English

使用 python 查找最近 90 天内股票的收盘价

[英]Find the closing price of stocks in last 90 days using python

Details of Case: There are 161 stocks in excel file, you have to find closing price for these stocks for last 90days案例详情:excel文件中有161只股票,你要找出这些股票最近90天的收盘价

Download files using following links: https://drive.google.com/drive/folders/1utGBygI2vcs0hYlnTpCA_i3Uo8VRj1lH?usp=sharing File 1: List of Stocks case study: Symbol of stocks File 2: Sample Output Format for one stock: This file has desired output format for one stock.使用以下链接下载文件: https://drive.google.com/drive/folders/1utGBygI2vcs0hYlnTpCA_i3Uo8VRj1lH?usp=sharing文件 1:股票案例研究列表:股票代码 文件 2:示例 Output 一只股票的格式:该文件具有一只股票需要 output 格式。

I think you shoud try pandas_datareader package. It will help you to find a data as you want.我想你应该试试pandas_datareader package。它会帮助你找到你想要的数据。

import pandas as pd
from pandas_datareader import data

symbol = 'INFY' # pass the symbol name
end = pd.datetime.now() # current date and time - can be changed as per requirement
start = end - pd.Timedelta(days=90) # ninety days before

df = data.DataReader(symbol, 'yahoo', start, end)

# get close price
close_price = df['Close']

# get last n close prices
n = 3
last_n_close_price = close_price.tail(n)

print("Last {} close prices:".format(n))
print(last_n_close_price)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM