Crates.io | ClawFoxyVision |
lib.rs | ClawFoxyVision |
version | 0.2.0 |
created_at | 2025-05-17 22:48:55.535099+00 |
updated_at | 2025-05-19 18:05:46.390661+00 |
description | Advanced financial time series forecasting library using LSTM, GRU, and CNN-LSTM neural networks for price prediction with Rust and Burn |
homepage | https://github.com/rustic-ml/ClawFoxyVision |
repository | https://github.com/rustic-ml/ClawFoxyVision |
max_upload_size | |
id | 1678200 |
size | 530,436 |
ClawFoxyVision: Your Sharper View into Financial Fortunes.
Clawy and Foxy, our visionary duo, power this library to help you navigate the complexities of financial time series data. Clawy's razor-sharp analytical abilities dissect intricate market patterns, while Foxy's cunning intelligence detects subtle movements often missed by others.
ClawFoxyVision empowers traders and analysts with enhanced foresight into market trends. By transforming raw data into actionable insights, our advanced vision algorithms cut through market noise, revealing the true signals that can inform tomorrow's movements. Trust ClawFoxyVision to illuminate your path through the often murky waters of financial forecasting.
Built with Burn, a deep learning framework in Rust.
AAPL-ticker_minute_bars.csv
.git clone <repository-url> # Replace <repository-url> with the actual URL
cd ClawFoxyVision
You can train and run forecasting models using either the provided shell script or directly with Cargo.
Using the shell script:
./run_model.sh [ticker] [model_type]
## Usage
### Running the Models
You can run either the LSTM or GRU model using the provided shell script:
```bash
./run_model.sh [ticker] [model_type]
Examples:
# Run with LSTM model
./run_model.sh AAPL lstm
# Run with GRU model
./run_model.sh AAPL gru
Alternatively, you can run directly with Cargo:
cargo run --release -- [ticker] [model_type]
The application supports two types of recurrent neural networks:
Both models support:
The application expects stock data in CSV format with OHLC (Open, High, Low, Close) values.
Example input file: AAPL_minute_ohlcv.csv
src/minute/lstm/
- LSTM implementation modulessrc/minute/gru/
- GRU implementation modulessrc/constants.rs
- Common configuration constantssrc/main.rs
- Entry point and execution logicEach model implementation follows the same module pattern:
step_1_tensor_preparation.rs
- Data preparation utilitiesstep_2_*_cell.rs
- Core cell implementationstep_3_*_model_arch.rs
- Complete architecturestep_4_train_model.rs
- Training workflowstep_5_prediction.rs
- Prediction utilitiesstep_6_model_serialization.rs
- Model saving/loadingWhen a GRU model is run with an existing LSTM model for the same ticker, the application will automatically compare predictions from both models. This helps in evaluating which model performs better for your specific dataset.
MIT License
ClawFoxyVision/
├── src/ # Main source code
│ ├── util/ # Utility functions
│ ├── daily/ # Daily data processing
│ ├── minute/ # Minute data processing
│ ├── constants/ # Project constants
│ └── test/ # Test files and utilities
├── examples/ # Example code
│ └── csv/ # Sample data files
└── .cursor/ # Cursor IDE configuration
└── baseline.json # Project baseline
Formatting:
Naming Conventions:
snake_case
snake_case
PascalCase
PascalCase
SCREAMING_SNAKE_CASE
Documentation:
read_financial_data
as a single entry point for all financial data operationsExample usage:
use predict_price_lstm::util::file_utils::read_financial_data;
// Read financial data from either CSV or Parquet with the same function
let (df, metadata) = read_financial_data("path/to/data.csv")?;
// OR
let (df, metadata) = read_financial_data("path/to/data.parquet")?;
cargo build
cargo run --example lstm_example
cargo run --example gru_example
cargo run --example parquet_lstm_gru_example # Example using Parquet files
Module Organization:
Error Handling:
anyhow::Result
for error propagationTesting:
Documentation:
This project is licensed under the MIT License - see the LICENSE file for details.
The repository includes several example implementations to demonstrate the usage of LSTM and GRU models:
standalone_lstm_gru_daily.rs: A self-contained example that demonstrates both LSTM and GRU models for daily stock price prediction. It includes:
simplified_lstm_gru_comparison.rs: A comprehensive comparison between LSTM and GRU models focusing on:
parquet_lstm_gru_example.rs: A complete example demonstrating how to use Parquet files with LSTM and GRU models:
Our examples use the Burn 0.17.0 neural network API. There are some important implementation details to be aware of:
The LSTM forward method returns a tuple containing the output tensor and a state:
// LSTM forward signature
fn forward(&self, x: Tensor<B, 3>, state: Option<LstmState<B, 2>>) -> (Tensor<B, 3>, LstmState<B, 2>)
// Usage example
let (output, _) = lstm.forward(x, None);
The GRU forward method returns just the output tensor:
// GRU forward signature
fn forward(&self, x: Tensor<B, 3>, state: Option<Tensor<B, 2>>) -> Tensor<B, 3>
// Usage example
let output = gru.forward(x, None);
When working with tensors, be careful with moved values. It's often necessary to:
// Get dimensions before using tensor
let sequence_length = output.dims()[1];
let hidden_size = output.dims()[2];
// Shape transformation
let last_output = output.narrow(1, sequence_length - 1, 1)
.reshape([batch_size, hidden_size]);
When using autodiff backends, make sure to specify the type explicitly:
let auto_lstm_model: StockModel<AutoDevice> = StockModel::new(&lstm_config, &auto_device);