Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSE stock price scraper #1

Closed
pratik-choudhari opened this issue Jan 24, 2021 · 7 comments
Closed

NSE stock price scraper #1

pratik-choudhari opened this issue Jan 24, 2021 · 7 comments

Comments

@pratik-choudhari
Copy link
Contributor

I would like to contribute an NSE scraper which will help scrape the following:

  1. Nifty50 index value
  2. Last traded price of a particular stock
  3. All nifty50 stock prices

P.S. This repository is a Great initiative✨

@pratik-choudhari pratik-choudhari changed the title NSE stock price scarper NSE stock price scraper Jan 24, 2021
@DarshanDeshpande
Copy link
Owner

Sure. Go ahead. Make sure to read and follow the contributing guidelines here

@Ashish0804
Copy link

@pratik-choudhari Why write a separate scraper for NSE when yahoo finance already provides it?

@pratik-choudhari
Copy link
Contributor Author

pratik-choudhari commented Jan 24, 2021

@Ashish0804 Does yahoo finance API provide indian stock prices? If so, could you name the library?

@Ashish0804
Copy link

@Ashish0804 Does yahoo finance API provide indian stock prices? If so, could you name the library?

Yes YF does provide data for both NSE aswell as BSE.
https://finance.yahoo.com/quote/RELIANCE.NS?p=RELIANCE.NS&.tsrc=fin-srch

Here's the library mostly used for getting data from YF
https://pypi.org/project/yfinance/

AFAIK pandas can also download data from YF.

@pratik-choudhari
Copy link
Contributor Author

@Ashish0804 If its from yahoo website we still need to scrape it right? and yfinance doesn't recognize indian stocks, I have tried it, it doesn't recognize SBI or its ticker SBIN

@Ashish0804
Copy link

Ashish0804 commented Jan 24, 2021

@Ashish0804 If its from yahoo website we still need to scrape it right? and yfinance doesn't recognize indian stocks, I have tried it, it doesn't recognize SBI or its ticker SBIN

for non us exchanges you have to provide it's name along with exchange name
so for sbi it is SBIN.NS

And you don't have to scrape it from website. the yfinance library does everything. It is also used by algo traders so if fairly robust.

Here's the code to scrape SBI aswell as the output.

Python 3.7.7 (default, May 7 2020, 21:25:33)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

import yfinance as yf
sbi = yf.Ticker("SBIN.NS")
hist = sbi.history(period="1day")
print(hist)
Open High Low Close Volume Dividends Stock Splits
Date
2021-01-22 295.5 298.0 282.399994 283.700012 44440810 0 0
2021-01-22 295.5 298.0 282.399994 283.700012 44435474 0 0

Please let me know if i am missing or confusing something.

@pratik-choudhari
Copy link
Contributor Author

Oh yeah, thats great. @DarshanDeshpande If you want, you can close this issue. No problem by my side.

DarshanDeshpande pushed a commit that referenced this issue Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants