Skip to content

This example shows how to use neural networks for writing a trading system on stocks using state

License

Notifications You must be signed in to change notification settings

quantiacs/strategy-ml_lstm_state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LSTM Neural Network for Predicting Stock Price Movements Using State

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.

How to Run the Strategy

In an Online Environment

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.

In a Local Environment

To run the strategy locally, you need to install the Quantiacs Toolbox.

Strategy Overview

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.

Key Features:

  • 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).

Strategy Components:

  1. Data Loading and Preparation:

    • Load stock data using qndata.stocks.load_ndx_data.
    • Calculate features using qnta.lwma and qnta.roc.
    • Determine target classes for price movement prediction.
  2. 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.
  3. Model Training:

    • Filter data to focus on top assets with the lowest volatility.
    • Train models for each asset in the dataset.
  4. 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.
  5. Backtesting:

    • Multi-pass version for development and testing.
    • Single-pass version for competitive submissions to expedite processing.

Recommendations for Competitive Submissions:

  • Simplify models to reduce computational demand.
  • Enhance local development with high-performance computing resources.
  • Utilize pre-calculated indicators.

Additional Resources:

About

This example shows how to use neural networks for writing a trading system on stocks using state

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published