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 adhoc margin from the quote with the help of ‘adhocMargin’ key
5. Print the adhoc 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 adhoc margin
value = quote['adhocMargin']
# printing adhoc margin
print("Adhoc Margin : " + 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 adhoc margin
value = quote['adhocMargin']
# printing adhoc margin
print("Adhoc Margin : " + str(value))
输出 :
Adhoc Margin : None
另一个例子
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 adhoc margin
value = quote['adhocMargin']
# printing adhoc margin
print("Adhoc Margin : " + str(value))
输出 :
Adhoc Margin : 13.02