Skip to content
Related Articles

Related Articles

Improve Article

NseTools – Getting Adhoc Margin of Company

  • Last Updated : 07 Oct, 2021

In this article, we will see how we can get the adhoc margin of given company using nsetools. Nsetools is a library for collecting real time data from National Stock Exchange of India. A stock quote is the price of a stock as quoted on an exchange. A basic quote for a specific stock provides information, such as its bid and ask price, last traded price, and volume traded. Adhoc margin collected by the Stock Exchange from the members having unduly large outstanding position or the margin levied on volatile scripts based on adhoc basis keeping in view the risk perspective.

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 
 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Below is the implementation  



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))

Output : 

Adhoc Margin  : None

Another example  

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))

Output : 

Adhoc Margin  : 13.02

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :