2024-11-17

Data Loading and Initial Inspection

# Load the dataset for ES (S&P 500 E-mini Futures) 15-seconds data
data <- read.table("ohlcv15sec.txt", header = TRUE, sep = "\t")

# Display the first few rows in a properly formatted table
cat("### First Few Rows of the Dataset\n")

First Few Rows of the Dataset

kable(head(data, n = 3), format = "html") %>%
  kable_styling(bootstrap_options = "striped", full_width = FALSE, position = "left")
DateTime Open High Low Close Volume
2024-01-01 17:00:00 4946.25 4947.75 4944.0 4947.50 833
2024-01-01 17:00:15 4947.25 4947.50 4946.5 4946.75 128
2024-01-01 17:00:30 4946.50 4947.75 4946.5 4947.50 383

Time Series of Close Prices

Interactive Plot with Plotly Market Hours on a Specific Day

Point Estimation for Close Prices

# Filter data for a specific day and RTH hours (08:30-15:00)
specific_day <- subset(data, as.Date(DateTime) == as.Date("2024-08-01"))
rth_data <- subset(specific_day, 
                   format(as.POSIXct(DateTime), "%H:%M:%S") >= "08:30:00" &
                   format(as.POSIXct(DateTime), "%H:%M:%S") <= "15:00:00")

# Calculate mean and standard deviation of Close prices
mean_close <- mean(rth_data$Close)
sd_close <- sd(rth_data$Close)

# Display results
cat("### Point Estimation for Close Prices\n")

Point Estimation for Close Prices

cat("Mean Close Price:", mean_close, "\n")

Mean Close Price: 5500.097

cat("Standard Deviation:", sd_close, "\n")

Standard Deviation: 42.90448

Histogram with Mean Line

Linear Regression as a Trend Line

Analysis of Results

  1. Point Estimation:
    • The mean close price for the selected day is 5500.097.
    • The histogram reveals that most prices are concentrated around this value, with a few outliers.
    • Indicates a relatively stable day with a central tendency.
  2. Linear Regression:
    • The regression line shows a downward slope, indicating a decline in prices over the session.
    • Suggests possible selling pressure or negative market sentiment.
  3. Comparison:
    • The mean price aligns with the regression trend line.
    • Histogram shows some volatility, with asymmetry in price distribution.

Conclusion

  • Key Takeaways:
    • The mean price provides insight into the day’s trading range.
    • The downward trend in the regression suggests bearish market sentiment.
  • Recommendations:
    • Combine moving averages with regression for better short-term forecasting.
    • Analyze multiple days to confirm if trends persist.
  • Next Steps:
    • Extend analysis to include multiple sessions.
    • Explore ARIMA models or other statistical approaches for deeper insights.