0

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

enter image description here

shubham
  • 1
  • 3
  • Please provide an example `StockName.csv` file to make your problem completely repeatable – kilojoules Dec 21 '22 at 21:09
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 21 '22 at 21:09
  • This is the whole code which works for me... Adding StockName.csv though... – shubham Dec 22 '22 at 06:00
  • Does this answer your question? [Why do I get AttributeError: 'NoneType' object has no attribute 'something'?](https://stackoverflow.com/questions/8949252/why-do-i-get-attributeerror-nonetype-object-has-no-attribute-something) – Ture Pålsson Dec 22 '22 at 06:32
  • No actually... I am getting error after printing some output from the code.. That means my code is accepting input processing it and providing output till some extent. (A2ZINFRA) Till I found this stock. Next stock name is AAATECH which I am able to find on trading view but it is giving error while running this code.... – shubham Dec 22 '22 at 07:10

0 Answers0