NseTools – 获取公司适用的利润
在本文中,我们将了解如何使用 nsetools 获得给定公司的适用保证金。 Nsetools是一个用于从印度国家证券交易所收集实时数据的库。股票报价是在交易所报价的股票价格。特定股票的基本报价提供信息,例如其买入价和卖出价、最后交易价格和交易量。对于以交易为目的的证券 - 监控部分(TFT-S 部分),适用的预付保证金率(VaR 保证金 + 极端亏损保证金)为 100%,并且每笔交易都根据该证券的收盘价进行盯市。
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 applicable margin from the quote with the help of ‘applicableMargin’ key
5. Print the applicable margin 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 applicable margin
value = quote['applicableMargin']
# printing applicable margin
print("Applicable Margin : " + str(value))
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# nse stock code for hdfc
code = "hdfcbank"
# getting stock quote
quote = nse.get_quote(code)
# getting applicable margin
value = quote['applicableMargin']
# printing applicable margin
print("Applicable Margin : " + str(value))
输出 :
Applicable Margin : 19.23
另一个例子
Python3
# importing nse from nse tools
from nsetools import Nse
# creating a Nse object
nse = Nse()
# nse stock code for hdfc
code = "hdfcbank"
# getting stock quote
quote = nse.get_quote(code)
# getting applicable margin
value = quote['applicableMargin']
# printing applicable margin
print("Applicable Margin : " + str(value))
输出 :
Applicable Margin : 18.2