📜  NseTools – 获取公司股票的平均价格

📅  最后修改于: 2022-05-13 01:55:30.351000             🧑  作者: Mango

NseTools – 获取公司股票的平均价格

在本文中,我们将了解如何使用 nsetools 获得给定公司的平均价格。 Nsetools是一个用于从印度国家证券交易所收集实时数据的库。股票报价是在交易所报价的股票价格。特定股票的基本报价提供信息,例如其买入价和卖出价、最后交易价格和交易量。对于给定的股票,将所有股票的总购买价格相加,然后加上已再投资的任何股息,然后将该总数除以拥有的股票总数。这将为您提供平均每股成本。

下面是实现

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 average price
value = quote['averagePrice']
 
# printing average price
print("Average 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 average price
value = quote['averagePrice']
 
# printing average price
print("Average Price  : " + str(value))


输出 :

Average Price  : 280.4

另一个例子

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 average price
value = quote['averagePrice']
 
# printing average price
print("Average Price  : " + str(value))

输出 :

Average Price  : 193.9