{"id":25555070,"url":"https://github.com/deepbiolab/drl-trading","last_synced_at":"2026-04-26T16:32:37.248Z","repository":{"id":278100723,"uuid":"934510598","full_name":"deepbiolab/drl-trading","owner":"deepbiolab","description":"Research on Deep Reinforcement Learning (DRL) for stock trading","archived":false,"fork":false,"pushed_at":"2025-02-25T16:55:29.000Z","size":4140,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-23T22:38:08.350Z","etag":null,"topics":["ai-trading","ddpg","dqn","reinforcement-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepbiolab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-18T00:37:04.000Z","updated_at":"2025-03-04T22:29:42.000Z","dependencies_parsed_at":"2025-02-25T08:21:22.939Z","dependency_job_id":null,"html_url":"https://github.com/deepbiolab/drl-trading","commit_stats":null,"previous_names":["deepbiolab/drl-trading"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deepbiolab/drl-trading","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fdrl-trading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fdrl-trading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fdrl-trading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fdrl-trading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepbiolab","download_url":"https://codeload.github.com/deepbiolab/drl-trading/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fdrl-trading/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32305035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-trading","ddpg","dqn","reinforcement-learning"],"created_at":"2025-02-20T13:55:38.719Z","updated_at":"2026-04-26T16:32:37.242Z","avatar_url":"https://github.com/deepbiolab.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deep Reinforcement Learning Trading Agent\n\nThis project implements a Deep Reinforcement Learning (DRL) agent for trading financial assets using historical market data. The agent is trained using the Deep Q-Learning (DQN) algorithm and supports both training and testing modes.\n\n![](assets/rl-trading.svg)\n\n## Features\n\n- **Deep Q-Learning Implementation**: \n  - Supports epsilon-greedy exploration.\n  - Uses experience replay and target networks for stable learning.\n- **Customizable Environment**: \n  - Simulates trading scenarios with historical market data.\n  - Supports multiple technical indicators like Bollinger Bands and Moving Averages.\n- **Data Normalization**: \n  - Static and rolling normalization methods.\n  - Automatic method selection based on data characteristics.\n- **Technical Indicators**: \n  - Automatic parameter selection for Moving Averages, Bollinger Bands, RSI, and more.\n- **Visualization**: \n  - Plots trading behavior and model losses.\n\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/your-repo/drl-trading.git\n   cd drl-trading\n   ```\n\n2. Install dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. Ensure you have the dataset in the `datasets/` directory. The default dataset is `datasets/AAPL_2009-2010_6m_raw_1d.csv`.\n\n\n\n## Usage\n\n### Command-Line Arguments\n\nThe main script (`main.py`) uses command-line arguments to configure the training and testing process. Below is a list of supported arguments:\n\n| Argument            | Default Value                          | Description                              |\n| --------            | -------------                          | -----------                              |\n| `--data_path`       | `datasets/AAPL_2009-2010_6m_raw_1d.csv`| Path to the dataset.                     |\n| `--backtest_data`   | `datasets/GOOG_2009-2010_6m_raw_1d.csv`| Path to the backtestdataset.             |\n| `--cv`              | `True`                                 | Whether to use cross validation.         |\n| `--n_folds`         | `5`                                    | Number of folds for cross validation.    |\n| `--train_split`     | `0.8`                                  | Train/test split ratio.                  |\n| `--n_episodes`      | `3`                                    | Number of training episodes.             |\n| `--window`          | `1`                                    | Window size for averaging scores.        |\n| `--window_size`     | `1`                                    | Observation window size.                 |\n| `--epsilon`         | `1.0`                                  | Initial epsilon for exploration.         |\n| `--eps_min`         | `0.01`                                 | Minimum epsilon value.                   |\n| `--eps_decay`       | `0.995`                                | Epsilon decay rate.                      |\n| `--buffer_size`     | `1000`                                 | Replay buffer size.                      |\n| `--batch_size`      | `32`                                   | Training batch size.                     |\n| `--gamma`           | `0.95`                                 | Discount factor.                         |\n| `--alpha`           | `1e-3`                                 | Soft update parameter.                   |\n| `--lr`              | `0.001`                                | Learning rate.                           |\n| `--update_step`     | `4`                                    | Steps between network updates.           |\n| `--seed`            | `42`                                   | Random seed.                             |\n| `--verbose`         | `False`                                | Enable verbose output.                   |\n| `--model_path`      | `checkpoint.pth`                       | Path to save/load the model.             |\n| `--mode`            | `both`                                 | Run mode: `train`, `backtest`.           |\n\n### Example Commands\n\n#### Train and Test\n```bash\npython main.py\n```\n\n#### Cross Validation\n```bash\npython main.py --cv --n_folds 5\n```\n\n#### Backtest Only\n```bash\npython main.py --mode backtest \\\n--model_path checkpoints/checkpoint.pth \\\n--backtest_data datasets/GOOG_2009-2010_6m_raw_1d.csv\n```\n\n\n## Project Structure\n\n```\ndrl-trading/\n├── datasets/                   \n│   ├── GOOG_2009-2010_6m_raw_1d.csv      # Directory for backtesting\n│   └── AAPL_2009-2010_6m_raw_1d.csv      # Directory for training and testing datasets\n├── src/                                  # Source code directory\n│   ├── agent.py                          # DQN agent implementation\n│   ├── environment.py                    # Trading environment\n│   ├── features.py                       # Technical indicators computation\n│   ├── model.py                          # Neural network model for DQN\n│   ├── preprocess.py                     # Data preprocessing utilities\n│   ├── normalize.py                      # Data normalization utilities\n│   ├── replay_buffer.py                  # Experience replay buffer\n│   └── plots.py                          # Plotting utilities\n├── checkpoints/                          # Directory for saving model checkpoints\n│   └── checkpoint.pth                    # Checkpoint file\n├── results/                              # Directory for backtesting results\n│   └── results.csv                       # Results file\n├── main.py                               # Main script for training and testing\n├── requirements.txt                      # Python dependencies\n└── README.md                             # Project documentation\n```\n\n\n## Development\n\n### Add New Features\n1. Extend the `src/` directory with new modules.\n2. Update `main.py` to integrate new features or arguments.\n3. Add test cases to ensure functionality.\n\n### Testing\nRun the scripts in `src/` individually to test specific components. For example:\n```bash\npython -m src.environment\n```\n\n## Contributions\nContributions are welcome! Please fork the repository and submit a pull request with detailed explanations of your changes.\n\n\n## License\nThis project is licensed under the MIT License. See the `LICENSE` file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepbiolab%2Fdrl-trading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepbiolab%2Fdrl-trading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepbiolab%2Fdrl-trading/lists"}