Hello community fellows,
I’m building an app that relies on a python script to call an external api and return values. The app will then uses these values for visualization purpose.
Python script looks like the following:
import FundamentalAnalysis as fa
api_key = "my-api-key"
class Checklist:
def __init__(self, stock_ticker="AAPL"):
self.time_now = datetime.datetime.now().strftime("%Y-%m-%d")
self.ticker = stock_ticker
self.income_statement = fa.income_statement(
stock_ticker, api_key, period="annual"
)
self.cash_f_statement = fa.cash_flow_statement(
stock_ticker, api_key, period="annual"
)
self.balance_s_statement = fa.balance_sheet_statement(
stock_ticker, api_key, period="annual"
)
self.key_ratios = fa.financial_ratios(stock_ticker, api_key)
self.key_metrics = fa.key_metrics(stock_ticker, api_key)
self.dividend = fa.stock_dividend(
stock_ticker, api_key, begin="1000-01-01", end=self.time_now
)
def price_to_earning(self, years=10):
"""
P/E ratio over the years
"""
return self.key_ratios.loc["priceEarningsRatio"].values[0:years]
Is there a way that I can integrate this python script as part of the services? What’re the recommended approach to integrate a python script as part of the api?
Some examples would be very helpful.
Thank you.