0

It's just a version of a model i made which predicts stocks, when I run it, it works fine, but returns errors with the output, note indentations were messed up but its self explanatory

This is the code:

import yfinance as yf
from sklearn.linear_model import LinearRegression

start_date = "2000-01-01"
end_date = None
model = LinearRegression()
tickers = ("AMZN","AAPL","TSLA")

for stock_symbol in tickers:
stock_data = yf.download(tickers = stock_symbol, start=start_date, end=end_date, interval = "1d")
model.fit(stock_data[['Open', 'Low', 'Close', 'Volume']], stock_data['High'])

today_data = yf.download(stock_symbol, period="1d", interval="1d")
today_features = today_data[['Open', 'Low', 'Close', 'Volume']]
predicted_high_tomorrow = model.predict(today_features)

if float(predicted_high_tomorrow) > float(today_data["High"]):
status = "BUY"
else:
status = "SELL"

today_high = today_data["High"]
print(f"{stock_symbol}  {today_high}    {predicted_high_tomorrow}   {status}")

It returns the correct output, aswell as some errors: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.