This trading strategy is designed for the Quantiacs platform, which hosts competitions for trading algorithms. Detailed information about the competitions is available on the official Quantiacs website.
The strategy can be executed in an online environment using Jupiter or JupiterLab on the Quantiacs personal dashboard. To do this, clone the template in your personal account.
To run the strategy locally, you need to install the Quantiacs Toolbox.
This notebook demonstrates the use of a Long Short Term Memory (LSTM) Neural Network to predict stock price movements. It focuses on trading the top NASDAQ-100 stocks with the lowest volatility, leveraging previous weights to determine positions for the next day.
- Universe: NASDAQ-100 stocks
- Trading Logic: Long positions based on the LSTM model’s prediction confidence level.
- Feature for Learning: Trend calculated using the rate of change (ROC) of the logarithm of the closing price with a linear weighted moving average (LWMA).
-
Data Loading and Preparation:
- Load stock data using
qndata.stocks.load_ndx_data
. - Calculate features using
qnta.lwma
andqnta.roc
. - Determine target classes for price movement prediction.
- Load stock data using
-
LSTM Model Definition:
- Define the LSTM architecture with input, hidden, and output layers.
- Implement training using Mean Squared Error (MSE) loss and L-BFGS optimizer.
-
Model Training:
- Filter data to focus on top assets with the lowest volatility.
- Train models for each asset in the dataset.
-
Prediction and State Management:
- Use trained models to predict future price movements.
- Combine predictions with previous weights to determine final positions.
- Save and load state.
-
Backtesting:
- Multi-pass version for development and testing.
- Single-pass version for competitive submissions to expedite processing.
- Simplify models to reduce computational demand.
- Enhance local development with high-performance computing resources.
- Utilize pre-calculated indicators.
- Quantiacs Community Topics: