import requests
import pandas as pd
import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
def income_statement(stock):
number_yrs = input('how many yr(s)?').strip()
api_key = 'd5abd8f1620e04709eeb05ebafa9af7e'
IS = requests.get(f'https://financialmodelingprep.com/api/v3/balance-sheet-statement/{stock}?limit={number_yrs}&apikey={api_key}').json()
IS = pd.DataFrame.from_dict(IS)
IS = IS.T
print(IS.T)
save_to_csv = input('save_to_csv? y or n').strip()
if save_to_csv == 'y':
IS.to_csv('IS' + stock + '.csv')
while True:
command = input('stock?')
stock = comman.split(' ')[1]
if comman == 'IS ' + stock:
income_statement(stock)
elif comman == 'quit':
break
else:
print('Invalid Command.')
I am learning python for finance right now. I would like to build a stock research terminal that allows me to call income statement, balance sheet, historical price etc. of a stock from the Internet. I used the above code but when I type IS TSLA, it still gives me the income statement of AAPL. I wonder which parts of the code go wrong? Thanks!