Training a PyTorch Price Regression Model for SPY Signals
Summary
This QuantConnect example trains a small PyTorch feed-forward network each trading day using recent daily SPY opening prices. It pairs each observation with the following day’s open, optimizes the network with mean squared error, and derives upper and lower price thresholds from the final model output plus or minus the training target’s standard deviation. The scheduled trading rule buys when the current bar opens above the upper threshold and liquidates an existing holding when it falls below the lower threshold.
The document provides implementation details rather than empirical evidence: the configured simulation spans only two dates, and it reports no performance measures. The model uses raw prices and a short historical sample, without documented validation, transaction-cost analysis, or safeguards against overfitting. The thresholds and retraining procedure therefore illustrate a machine-learning workflow, but do not establish that the signals predict returns or are suitable for live trading.
Key ideas
- The example predicts next-day SPY opening prices from recent daily opening prices using a neural network.
- It trains with mean squared error and stochastic gradient descent, then sets trading thresholds around the model output.
- The rules enter a long position above the upper threshold and liquidate below the lower threshold.
- The sample simulation is very short and offers no performance evidence or out-of-sample validation.
- Using raw prices and a small training set leaves prediction quality and practical robustness unestablished.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.