Python中的NSE工具模块介绍
NSE National Stock Exchange of India Limited 是印度领先的证券交易所,位于马哈拉施特拉邦的孟买。 NSE 成立于 1992 年,是该国第一家非物质化电子交易所。
nsetools是一个用于从印度国家证券交易所收集实时数据的库。它可用于需要获取给定股票或指数的实时报价或构建大型数据集以进行进一步数据分析的各种类型的项目。我们还可以构建命令行界面应用程序,它可以以极快的速度为我们提供实时市场详细信息,比任何浏览器都快得多。数据的准确性仅与 http://www.nseindia.com 上提供的一样正确
为了安装 nse 工具,我们必须使用下面给出的命令
pip install nsetools
创建 Nse 对象
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# printing Nse object
print(nse)
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# getting quote of the sbin
quote = nse.get_quote('sbin')
# printing company name
print(quote['companyName'])
# printing buy price
print("Buy Price : " + str(quote['buyPrice1']))
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# getting quote of the sbin
quote = nse.get_quote('sbin')
# printing company name
print(quote['companyName'])
# printing average price
print("Average Price : " + str(quote['averagePrice']))
输出 :
Driver Class for National Stock Exchange (NSE)
获取资讯
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# getting quote of the sbin
quote = nse.get_quote('sbin')
# printing company name
print(quote['companyName'])
# printing buy price
print("Buy Price : " + str(quote['buyPrice1']))
输出 :
State Bank of India
Buy Price : 191.45
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# getting quote of the sbin
quote = nse.get_quote('sbin')
# printing company name
print(quote['companyName'])
# printing average price
print("Average Price : " + str(quote['averagePrice']))
输出 :
State Bank of India
Average Price : 193.9