I am getting AttributeError: 'NoneType' object has no attribute 'summary' after some displaying some output of my code.
import pandas as pd
from tradingview_ta import TA_Handler, Interval, Exchange
stkfilename = f"F:/Python/HistoricStockInfo/StockName.csv"
stkFile = pd.read_csv(stkfilename)
for i in range(len(stkFile)):
#print(stkFile['Symbol'].iloc[i])
NIFTY = TA_Handler(
symbol=stkFile['Symbol'].iloc[i],
#symbol = "ACE",
screener="india",
exchange="NSE",
interval=Interval.INTERVAL_1_WEEK
)
result = NIFTY.get_analysis().summary
if NIFTY.get_analysis().summary:
summary = (result.find('summary').text or '').encode('utf8')
#if result['RECOMMENDATION']=="STRONG_BUY":
if result is None:
print(stkFile['Symbol'].iloc[i])
print(result)
else:
print("Symbol not found")
Here is my code.
What I am trying to do it to read Stock Symbols from my excel file and pass it to TA_handler function to get result using get_analysis method. Trying to print the results of symbols found on trading view as per criteria.
Giving me below error after some output.
5PAISA
{'RECOMMENDATION': 'SELL', 'BUY': 6, 'SELL': 10, 'NEUTRAL': 10}
63MOONS
{'RECOMMENDATION': 'SELL', 'BUY': 3, 'SELL': 14, 'NEUTRAL': 9}
A2ZINFRA
File "f:\Python\datacheck.py", line 27, in <module>
result = NIFTY.get_analysis().summary
AttributeError: 'NoneType' object has no attribute 'summary'
What I am trying to do it to read Stock Symbols from my excel file and pass it to TA_handler function to get result using get_analysis method. Trying to print the results of symbols found on trading view as per criteria.
SymbolName.csv looks like below..