NseTools – 获取公司股票的基本价格
在本文中,我们将了解如何使用 nsetools 获得给定公司的平均价格。 Nsetools是一个用于从印度国家证券交易所收集实时数据的库。股票报价是在交易所报价的股票价格。特定股票的基本报价提供信息,例如其买入价和卖出价、最后交易价格和交易量。基础市值是一个价值加权指数,由在任何给定时间交易的指数中的所有证券组成。基础市场价值有助于确定股票市场价值或指数的价值。基值被视为交易所股票和证券市场的脉搏。
Steps to get the Stock Quote
1. Import the Nse from nsetools
2. Create a Nse object
3. From the Nse object get the stock quote with the help of get_quote method with the NSE Stock code of the company
4. Get the base price from the quote with the help of ‘basePrice’ key
5. Print the base price value
下面是实现
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# nse stock code for wipro
code = "wipro"
# getting stock quote
quote = nse.get_quote(code)
# getting base price
value = quote['basePrice']
# printing base price
print("Base Price : " + str(value))
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# nse stock code for sbi
code = "sbin"
# getting stock quote
quote = nse.get_quote(code)
# getting base price
value = quote['basePrice']
# printing base price
print("Base Price : " + str(value))
输出 :
Base Price : 281.05
另一个例子
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# nse stock code for sbi
code = "sbin"
# getting stock quote
quote = nse.get_quote(code)
# getting base price
value = quote['basePrice']
# printing base price
print("Base Price : " + str(value))
输出 :
Base Price : 191.6