code something that does math uses api's and picks a stock for me -- 2

Job ID: 37290108

Budget: $250 – $750 USD

I'm looking for someone to write some code for me using Python. This code will need to use APIs and pick a stock for me every week. I have some basic math calculations that will need to be performed, such as basic arithmetic and statistical analysis. I'm looking for a programmer who can help me out by creating a program that can do all of this. This is a very important project and I would appreciate any help I can get. I got this so far : import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import yfinance as yf

def DCF(stock_ticker, discount_rate, growth_rate, num_years):
# Get the stock's historical prices
stock = yf.Ticker(stock_ticker)
hist = stock.history(period="max")

# Mocking Free Cash Flow with Close prices (for demonstration purposes)
fcf = hist['Close'].values

# Calculate the present value of each year's cash flow
pv_cf = np.array([cf / (1 + discount_rate)**i for i, cf in enumerate(fcf)])

# Calculate the terminal value of the stock
terminal_value = fcf[-1] * (1 + growth_rate) / (discount_rate - growth_rate)

# Calculate the present value of the terminal value
pv_terminal_value = terminal_value / (1 + discount_rate)**num_years

# Calculate the intrinsic value of the stock
intrinsic_value = np.sum(pv_cf) + pv_terminal_value

return intrinsic_value

def main():
# Get the stock ticker from the user
stock_ticker = input("Enter the stock ticker: ")

# Error handling for invalid ticker
try:
yf.Ticker(stock_ticker).history(period="1d")
except:
print("Invalid stock ticker. Exiting.")
return

# Get the discount rate from the user
try:
discount_rate = float(input("Enter the discount rate (e.g., 0.05 for 5%): "))
except ValueError:
print("Invalid discount rate. Exiting.")
return

# Get the growth rate from the user
try:
growth_rate = float(input("Enter the growth rate (e.g., 0.03 for 3%): "))
except ValueError:
print("Invalid growth rate. Exiting.")
return

# Get the number of years to project the cash flows
try:
num_years = int(input("Enter the number of years to project the cash flows: "))
except ValueError:
print("Invalid number of years. Exiting.")
return

# Calculate the intrinsic value of the stock
intrinsic_value = DCF(stock_ticker, discount_rate, growth_rate, num_years)

# Print the intrinsic value of the stock
print(f"The intrinsic value of {stock_ticker} is ${intrinsic_value:.2f}")

if __name__ == "__main__":
main()
Related categories: Python Web Scraping API Data Analysis