You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
code - import yfinance as yf
import quantstats as qs
import os
stock_ticker = "AAPL" # Replace with your stock ticker
start_date = "2020-01-01" # Start date for historical data
output_dir = "quantstats_reports"
os.makedirs(output_dir, exist_ok=True)
data = yf.download(stock_ticker, start=start_date, progress=False)
if data.empty:
print(f"No data found for {stock_ticker}. Please check the ticker or date range.")
else:
stock_close = data['Close'].dropna()
stock_close.name = stock_ticker # Set a name for the Series
stock_close.index = stock_close.index.to_pydatetime()
report_path = os.path.join(output_dir, f"{stock_ticker}_full_report.html")
try:
qs.reports.html(
stock_close,
title=f"QuantStats Report for {stock_ticker}",
output=report_path
)
print(f"QuantStats report generated successfully: {report_path}")
except Exception as e:
print(f"An error occurred while generating the QuantStats report: {e}")
CAN SOMEONE HELP SOLVING ME THIS ERROR?
The text was updated successfully, but these errors were encountered:
Make sure the data is stored as a pandas Series and not as a dataframe. You can convertt the Dataframe to a series by using the squeeze method. stock_close = stock_close['(column_name)'].squeeze()
code - import yfinance as yf
import quantstats as qs
import os
stock_ticker = "AAPL" # Replace with your stock ticker
start_date = "2020-01-01" # Start date for historical data
output_dir = "quantstats_reports"
os.makedirs(output_dir, exist_ok=True)
data = yf.download(stock_ticker, start=start_date, progress=False)
if data.empty:
print(f"No data found for {stock_ticker}. Please check the ticker or date range.")
else:
stock_close = data['Close'].dropna()
CAN SOMEONE HELP SOLVING ME THIS ERROR?
The text was updated successfully, but these errors were encountered: