harbor run -t LiteCoder/analyze-stock-data-visualizeharbor download LiteCoder/analyze-stock-data-visualizeYou are given a CSV file containing ~5 years of daily stock closing prices. Perform a comprehensive analysis including statistical summaries, moving averages, volatility metrics, and visualizations. Write a Python script that reads the data, computes all required metrics, saves visualizations as PNG images, and writes a structured JSON summary.
/app/input.csv/app/output.json — statistical summary and metrics/app/price_moving_averages.png — price chart with moving averages/app/daily_returns_histogram.png — histogram of daily returns/app/volatility_chart.png — rolling volatility chart/app/input.csv is a CSV file with the following columns:
| Column | Type | Description |
|---|---|---|
| Date | string | ISO date (YYYY-MM-DD) |
| Open | float | Opening price |
| High | float | Daily high |
| Low | float | Daily low |
| Close | float | Daily closing price |
| Adj Close | float | Adjusted closing price |
| Volume | int | Trading volume |
The file contains a header row followed by 1260 data rows sorted by date ascending.
All computations must use the Close column.
Basic Statistics: Compute mean, standard deviation, minimum, and maximum of the closing prices.
Moving Averages: Compute 30-day and 90-day simple moving averages (SMA). For each window, the SMA at row i is the arithmetic mean of the closing prices from row i - window + 1 to row i (inclusive). Rows where the full window is not available should be excluded (i.e., NaN/null — do not fill them).
Daily Returns: Compute the daily percentage return as (Close[i] - Close[i-1]) / Close[i-1] for each row (the first row will have no return and should be NaN/null).
Rolling Volatility: Compute the rolling 30-day standard deviation of daily returns. Rows where the full 30-day window is not available should be NaN/null.
/app/output.json must be a JSON object with the following structure:
{
"basic_statistics": {
"mean": <float>,
"std": <float>,
"min": <float>,
"max": <float>
},
"moving_averages": {
"sma_30": [<float or null>, ...],
"sma_90": [<float or null>, ...]
},
"daily_returns": [<float or null>, ...],
"rolling_volatility_30": [<float or null>, ...]
}
null.sma_30 and sma_90 arrays must each have exactly 1260 elements (one per data row), with null for rows where the window is incomplete.daily_returns array must have exactly 1260 elements, with the first element being null.rolling_volatility_30 array must have exactly 1260 elements, with null for the first 30 elements.Generate three PNG image files:
/app/price_moving_averages.png: A line chart showing the closing price, 30-day SMA, and 90-day SMA over time. The x-axis should represent dates and the y-axis should represent price.
/app/daily_returns_histogram.png: A histogram of daily returns (excluding NaN values).
/app/volatility_chart.png: A line chart showing the rolling 30-day volatility over time. The x-axis should represent dates and the y-axis should represent volatility.
All images must be non-empty valid PNG files.