swapniljariwala / nsepy

Python Library to get publicly available data on NSE website ie. stock quotes, historical data, live indices
https://nsepy-xyz.web.app
Other
749 stars 376 forks source link

is it working ? #42

Open pannet1 opened 6 years ago

pannet1 commented 6 years ago

i am unable to run none of the examples. everything returns blank. is it because of my distribution (Arch)

even the simple cli does not work

$ nsecli history --symbol SBIN -s 2017-01-01 -e 2017-01-31 -o output.csv Traceback (most recent call last): File "/usr/bin/nsecli", line 11, in load_entry_point('nsepy==0.6', 'console_scripts', 'nsecli')() File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 570, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2755, in load_entry_point return ep.load() File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2409, in load return self.resolve() File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2415, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "/usr/lib/python3.6/site-packages/nsepy/cli.py", line 60 print 'Saved to: {}'.format(file_name) ^ SyntaxError: invalid syntax

swapniljariwala commented 6 years ago

its because I have used -> print 'Saved to: {}'.format(file_name) , print without brackets. So it will not work with python3

My bad, I'll fix it soon.

For now please try downloading using a script like below

from datetime import date
from nsepy import get_history
sbin = get_history(symbol='SBIN',
                   start=date(2015,1,1),
                   end=date(2015,1,10))
sbin.to_csv('/path/to/csv/file')
mbmarx commented 6 years ago

Is this package working till today, i have tried executing but nothing coming

from nsepy import get_history from datetime import date data = get_history(symbol="SBIN", start=date(2015,1,1), end=date(2015,1,31))

Traceback (most recent call last): File "", line 1, in File "C:\python3\lib\site-packages\nsepy\history.py", line 135, in get_history

return get_history_quanta(**kwargs)

File "C:\python3\lib\site-packages\nsepy\history.py", line 142, in get_history _quanta headers=headers, scaling=scaling) File "C:\python3\lib\site-packages\nsepy\history.py", line 147, in url_to_df bs = BeautifulSoup(resp.text, 'lxml') File "C:\python3\lib\site-packages\bs4__init.py", line 165, in init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requeste d: lxml. Do you need to install a parser library?

data = get_history(symbol="SBIN", start=date(2015,1,1), end=date(2015,1,31))

Traceback (most recent call last): File "", line 1, in File "C:\python3\lib\site-packages\nsepy\history.py", line 135, in get_history

return get_history_quanta(**kwargs)

File "C:\python3\lib\site-packages\nsepy\history.py", line 142, in get_history _quanta headers=headers, scaling=scaling) File "C:\python3\lib\site-packages\nsepy\history.py", line 147, in url_to_df bs = BeautifulSoup(resp.text, 'lxml') File "C:\python3\lib\site-packages\bs4__init.py", line 165, in init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requeste d: lxml. Do you need to install a parser library?

sbin = get_history(symbol='SBIN', ... start=date(2015,1,1), ... end=date(2015,1,10)) Traceback (most recent call last): File "", line 3, in File "C:\python3\lib\site-packages\nsepy\history.py", line 135, in get_history

return get_history_quanta(**kwargs)

File "C:\python3\lib\site-packages\nsepy\history.py", line 142, in get_history _quanta headers=headers, scaling=scaling) File "C:\python3\lib\site-packages\nsepy\history.py", line 147, in url_to_df bs = BeautifulSoup(resp.text, 'lxml') File "C:\python3\lib\site-packages\bs4__init.py", line 165, in init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requeste d: lxml. Do you need to install a parser library?

sbin = get_history(symbol='SBIN',start=date(2015,1,1),end=date(2015,1,10)) Traceback (most recent call last): File "", line 1, in File "C:\python3\lib\site-packages\nsepy\history.py", line 135, in get_history

return get_history_quanta(**kwargs)

File "C:\python3\lib\site-packages\nsepy\history.py", line 142, in get_history _quanta headers=headers, scaling=scaling) File "C:\python3\lib\site-packages\nsepy\history.py", line 147, in url_to_df bs = BeautifulSoup(resp.text, 'lxml') File "C:\python3\lib\site-packages\bs4__init.py", line 165, in init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requeste d: lxml. Do you need to install a parser library?

sbin.to_csv('/path/to/csv/file') Traceback (most recent call last): File "", line 1, in NameError: name 'sbin' is not defined sbin = get_history(symbol='SBIN',start=date(2015,1,1),end=date(2015,1,10)) Traceback (most recent call last): File "", line 1, in File "C:\python3\lib\site-packages\nsepy\history.py", line 135, in get_history

return get_history_quanta(**kwargs)

File "C:\python3\lib\site-packages\nsepy\history.py", line 142, in get_history _quanta headers=headers, scaling=scaling) File "C:\python3\lib\site-packages\nsepy\history.py", line 147, in url_to_df bs = BeautifulSoup(resp.text, 'lxml') File "C:\python3\lib\site-packages\bs4__init.py", line 165, in init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requeste d: lxml. Do you need to install a parser library?

sbin Traceback (most recent call last): File "", line 1, in NameError: name 'sbin' is not defined SBIN Traceback (most recent call last): File "", line 1, in NameError: name 'SBIN' is not defined sbin = get_history(symbol='SBIN',start=date(2015,1,1),end=date(2015,1,10))

is there any other way i can run and retrieve some data

pannet1 commented 6 years ago

@mbmarx ,

I am no python expert. But my limited experience says that the problem is with BS4. To add confusion there is BS4 and BeautifulSoup Package in (Manjoro Linux).

Also setup a virtualenv to isolate your problems and avoid polluting the OS. Finally add the line which swapnil proposed.

sbin.to_csv('/path/to/csv/file')

swapnil is very kind and generous but also very busy man. So in the interim i am suggesting you.

mbmarx commented 6 years ago

@pannet1 @swapniljariwala I am new to python and learning it as it is my need now. I am using Windows not Linux. Can you provide details what needs to be done to get some output in windows. How to run this and see the output.

mbmarx commented 6 years ago

Some breakthrough The problem was using python3.6 BS4 Beautifulsoup not installed properly. Follow the below steps if you face the same problem :+1:

https://stackoverflow.com/questions/31730053/python-3-4-installing-bs4-running-python2-not-python3 I had the same issue after installing beautifulsoup4_4.5.1 on Python 3.4 via copying the .tar file. What worked for me was uninstalling the beautifulsoup and installing it again using the pip install method. If installation is successful, you will find bs4 in the list of installed modules. Here are the steps:c:\Python34\Scripts\pip.exe uninstall beautifulsoup4c:\Python34\Scripts\pip.exe install beautifulsoup4c:\Python34\python.exehelp('modules')from bs4 import BeautifulSoup -- | --

Also if you are using Windows for running instead of "sbin.to_csv('/path/to/csv/file')" use the path as below sbin.to_csv('C:\test\a.csv') it works

swapniljariwala commented 6 years ago

CLI should now work with python3.6 in NSEpy 0.7

Automatic installation of lxml should also be sorted out with 0.8 release, for now we would need to manually install lxml.

mbmarx commented 6 years ago

Hi Swapnil, When is the NSEpy0.7 release.

pannet1 commented 6 years ago

@swapniljariwala,

Seems the cli bug is not fixed yet.

The below cli example you gave ...

$ nsecli history --symbol "NIFTY 100" -s 2017-07-01 -e 2017-07-27 -o output.csv --index

... is returning this error.

Traceback (most recent call last): File "/usr/bin/nsecli", line 11, in <module> load_entry_point('nsepy==0.6', 'console_scripts', 'nsecli')() File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 572, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point return ep.load() File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2408, in load return self.resolve() File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2414, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/usr/lib/python3.6/site-packages/nsepy/cli.py", line 60 print 'Saved to: {}'.format(file_name) ^ SyntaxError: invalid syntax

mbmarx commented 6 years ago

Hello Swapnil, Is there any issue with nsepy until yesterday it was working fine suddenly today everything dataframe comes as zero.

I m using 0.6

Regards Marx

On 25-Nov-2017 1:42 am, "Swapnil Jariwala" notifications@github.com wrote:

NSEpy 0.7 should now work with python3.6.

Automatic installation of lxml should also be sorted out with 0.8 release, for now we would need to manually install lxml.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/swapniljariwala/nsepy/issues/42#issuecomment-346891083, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXQdQJBdekMPSVr0Qlj1eLs0q-5vEaCks5s5yMogaJpZM4QbC5G .

pannet1 commented 6 years ago

@mbmarx, I may be wrong. Was it a NSE working day? That's my problem is usually when I get zero values.

mbmarx commented 6 years ago

When is the NSEPY0.8 release ? Also cant this be run continuously to get all script data ;after 30-40 script run it throws error.Looks NSE blocking the link.

lalituor commented 4 years ago

is this package still working?