Nikhil-Adithyan / Algorithmic-Trading-with-SuperTrend-Indicator-in-Python

2 stars 1 forks source link

Kindly provide a way to test with indian stocks through link or excel sheet input #1

Open raviyellani opened 3 years ago

raviyellani commented 3 years ago

Hi, Great work! Want to test these codes with Indian NSE stock data, can you kindly provide a way to get data for NSE stocks else any excel format through which get_historical_data (symbol ,date , price range etc..) function returning the data to provide input.

Appreciate for your tremendous work...

Kindly include a function and excel template where user can provide excel input of the stock which will help to analyze the logics.

Thank you

Nikhil-Adithyan commented 3 years ago

There is one package called 'NSEpy' that is particularly developed to extract the historical data of Indian stocks. So first install the package by following this command: pip install nsepy

After installing the package, use the following code to extract any NSE stock's historical data:

from nsepy import get_history from datetime import datetime as dt start = dt(2020,1,1) end = dt(2021,1) ticker = 'SBIN' data = get_history(ticker, start, end)

This code will extract the historical stock data of SBI from the starting of 2020 to the starting of 2021. You can change the start or end date and the symbol of the stock according to your needs. Hope this helps you. Cheers!

raviyellani commented 3 years ago

Thank a lot Mate..

On Sat, May 29, 2021 at 11:01 AM Nikhil Adithyan @.***> wrote:

There is one package called 'NSEpy' that is particularly developed to extract the historical data of Indian stocks. So first install the package by following this command: pip install nsepy

After installing the package, use the following code to extract any NSE stock's historical data:

from nsepy import get_history from datetime import datetime as dt start = dt(2020,1,1) end = dt(2021,1) ticker = 'SBIN' data = get_history(ticker, start, end)

This code will extract the historical stock data of SBI from the starting of 2020 to the starting of 2021. You can change the start or end date and the symbol of the stock according to your needs. Hope this helps you. Cheers!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Nikhil-Adithyan/Algorithmic-Trading-with-SuperTrend-Indicator-in-Python/issues/1#issuecomment-850773884, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2G3GK2EZVFFEISDYWWGTTQB3ZXANCNFSM45X5LR7Q .

-- Thanking You & Best Regards

raviyellani commented 3 years ago

Hi,

Used the snipped provided

def get_historical_data(symbol, start_date): start = dt(2020,1,1) end = dt(2021,1,1) ticker = 'SBIN' data = get_history(ticker, start, end) return data

tsla = get_historical_data('SBIN', '2020-01-01') print(tsla)

* AFTER RUNNING GOT BELOW RESULT KINDLY SUGGEST WHAT TO BE CHANGED

Traceback (most recent call last): File "C:\Users\raviy.conda\envs\screenpy\lib\site-packages\pandas\core\indexes\base.py", line 3080, in get_loc return self._engine.get_loc(casted_key) File "pandas_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas_libs\hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'high'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "F:\Trading\Python github\Nikhil Adithyan github\Algorithmic-Trading-with-SuperTrend-Indicator-in-Python-master\Supertrend_strategy_code.py", line 114, in tsla['st'], tsla['s_upt'], tsla['st_dt'] = get_supertrend(tsla['high'], tsla['low'], tsla['close'], 10, 3) File "C:\Users\raviy.conda\envs\screenpy\lib\site-packages\pandas\core\frame.py", line 3024, in getitem indexer = self.columns.get_loc(key) File "C:\Users\raviy.conda\envs\screenpy\lib\site-packages\pandas\core\indexes\base.py", line 3082, in get_loc raise KeyError(key) from err KeyError: 'high'

On Sat, May 29, 2021 at 11:02 AM Ravi Y @.***> wrote:

Thank a lot Mate..

On Sat, May 29, 2021 at 11:01 AM Nikhil Adithyan @.***> wrote:

There is one package called 'NSEpy' that is particularly developed to extract the historical data of Indian stocks. So first install the package by following this command: pip install nsepy

After installing the package, use the following code to extract any NSE stock's historical data:

from nsepy import get_history from datetime import datetime as dt start = dt(2020,1,1) end = dt(2021,1) ticker = 'SBIN' data = get_history(ticker, start, end)

This code will extract the historical stock data of SBI from the starting of 2020 to the starting of 2021. You can change the start or end date and the symbol of the stock according to your needs. Hope this helps you. Cheers!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Nikhil-Adithyan/Algorithmic-Trading-with-SuperTrend-Indicator-in-Python/issues/1#issuecomment-850773884, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2G3GK2EZVFFEISDYWWGTTQB3ZXANCNFSM45X5LR7Q .

-- Thanking You & Best Regards

  • Ravi Yellani*

-- Thanking You & Best Regards

raviyellani commented 3 years ago

Got it brthe changed key names....thank you

On Sat, May 29, 2021 at 3:13 PM Ravi Y @.***> wrote:

Hi,

Used the snipped provided

def get_historical_data(symbol, start_date): start = dt(2020,1,1) end = dt(2021,1,1) ticker = 'SBIN' data = get_history(ticker, start, end) return data

tsla = get_historical_data('SBIN', '2020-01-01') print(tsla)

* AFTER RUNNING GOT BELOW RESULT KINDLY SUGGEST WHAT TO BE CHANGED

Traceback (most recent call last): File "C:\Users\raviy.conda\envs\screenpy\lib\site-packages\pandas\core\indexes\base.py", line 3080, in get_loc return self._engine.get_loc(casted_key) File "pandas_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas_libs\hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'high'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "F:\Trading\Python github\Nikhil Adithyan github\Algorithmic-Trading-with-SuperTrend-Indicator-in-Python-master\Supertrend_strategy_code.py", line 114, in tsla['st'], tsla['s_upt'], tsla['st_dt'] = get_supertrend(tsla['high'], tsla['low'], tsla['close'], 10, 3) File "C:\Users\raviy.conda\envs\screenpy\lib\site-packages\pandas\core\frame.py", line 3024, in getitem indexer = self.columns.get_loc(key) File "C:\Users\raviy.conda\envs\screenpy\lib\site-packages\pandas\core\indexes\base.py", line 3082, in get_loc raise KeyError(key) from err KeyError: 'high'

On Sat, May 29, 2021 at 11:02 AM Ravi Y @.***> wrote:

Thank a lot Mate..

On Sat, May 29, 2021 at 11:01 AM Nikhil Adithyan < @.***> wrote:

There is one package called 'NSEpy' that is particularly developed to extract the historical data of Indian stocks. So first install the package by following this command: pip install nsepy

After installing the package, use the following code to extract any NSE stock's historical data:

from nsepy import get_history from datetime import datetime as dt start = dt(2020,1,1) end = dt(2021,1) ticker = 'SBIN' data = get_history(ticker, start, end)

This code will extract the historical stock data of SBI from the starting of 2020 to the starting of 2021. You can change the start or end date and the symbol of the stock according to your needs. Hope this helps you. Cheers!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Nikhil-Adithyan/Algorithmic-Trading-with-SuperTrend-Indicator-in-Python/issues/1#issuecomment-850773884, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2G3GK2EZVFFEISDYWWGTTQB3ZXANCNFSM45X5LR7Q .

-- Thanking You & Best Regards

  • Ravi Yellani*

-- Thanking You & Best Regards

  • Ravi Yellani*

-- Thanking You & Best Regards

raviyellani commented 3 years ago

After running through the code, by changing the key names after line number 227 below error is displaying continuously , kindly look into this

←[1mProfit gained from the ST strategy by investing $100k in TSLA : 35450.1←[0m ←[1mProfit percentage of the ST strategy : 35%←[0m Exception ignored in: <function Variable.del at 0x000002A7E8D66F70> Traceback (most recent call last): File "C:\Users\raviy.conda\envs\screenpy\lib\tkinter__init.py", line 363, in del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Exception ignored in: <function Image.del at 0x000002A7E8DB58B0> Traceback (most recent call last): File "C:\Users\raviy.conda\envs\screenpy\lib\tkinter__init.py", line 4017, in del self.tk.call('image', 'delete', self.name) RuntimeError: main thread is not in main loop Exception ignored in: <function Image.del at 0x000002A7E8DB58B0> Traceback (most recent call last): File "C:\Users\raviy.conda\envs\screenpy\lib\tkinter\init.py", line 4017, in del__ self.tk.call('image', 'delete', self.name) RuntimeError: main thread is not in main loop

On Sat, May 29, 2021 at 11:01 AM Nikhil Adithyan @.***> wrote:

There is one package called 'NSEpy' that is particularly developed to extract the historical data of Indian stocks. So first install the package by following this command: pip install nsepy

After installing the package, use the following code to extract any NSE stock's historical data:

from nsepy import get_history from datetime import datetime as dt start = dt(2020,1,1) end = dt(2021,1) ticker = 'SBIN' data = get_history(ticker, start, end)

This code will extract the historical stock data of SBI from the starting of 2020 to the starting of 2021. You can change the start or end date and the symbol of the stock according to your needs. Hope this helps you. Cheers!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Nikhil-Adithyan/Algorithmic-Trading-with-SuperTrend-Indicator-in-Python/issues/1#issuecomment-850773884, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2G3GK2EZVFFEISDYWWGTTQB3ZXANCNFSM45X5LR7Q .

-- Thanking You & Best Regards