Trading NVIDIA Derivatives using SAC
12 JULY 2025: Project EOL. Moving on to pastures new.
DerivSAC/
βββ config/
β βββ config.yaml # Configuration parameters
βββ docs/
βββ hyperparameters/
β βββ sac.yml
βββ notebooks/
βββ tests/
β βββ __init__.py
β βββ alpha_test.py
β βββ conftest.py
β βββ test_engine.py
β βββ test_simple.py
βββ trading_bot/
β βββ analysis/
β β βββ __init__.py
β β βββ technical.py # Technical analysis
β βββ core/
β β βββ bot.py
β β βββ sac_bot.py
β βββ data/
β β βββ local_data/
β β β βββ NVDA_1d_max.pkl
β β βββ __init__.py
β β βββ data_pipeline.py # Data fetching and processing
β β βββ indicators.py # Technical indicators
β β βββ sentiment_pipeline.py
β βββ sac/
β β βββ zoo/
β β β βββ __init__.py
β β β βββ gradient_clipping_callback.py
β β β βββ hyperparams_opt.py
β β β βββ rl_zoo_env.py
β β β βββ trading_zoo_callback.py
β β β βββ train.py
β β β βββ utils.py
β β βββ __init__.py
β β βββ test_model.py
β βββ strategies/
β β βββ macd.py
β βββ trade_env/
β β βββ __init__.py
β β βββ engine.py
β β βββ metrics.py
β β βββ nvidia.py
β β βββ position.py
β βββ utils/
β β βββ __init__.py
β β βββ config.py
β β βββ logger.py # Logging utilities
β β βββ output.py
β βββ __init__.py
β βββ main.py # Main entry point
βββ trading_bot.egg-info/
β βββ PKG-INFO
β βββ SOURCES.txt
β βββ dependency_links.txt
β βββ requires.txt
β βββ top_level.txt
βββ utils/
β βββ README.md
β βββ __init__.py
β βββ generate_directory_structure.py
β βββ update_readme_directory.py
βββ .gitignore
βββ README.md
βββ backtest_results.png
βββ pyproject.toml
βββ requirements.txt
βββ setup.cfg
βββ setup.py
βββ strategy_comparison.png
- Create and activate virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txtNOTE: If the dependencies did not install CUDA toolkit for you, go online to download it. The version used here is CUDA 12.4. This is required to train the model using GPU.
- Run main.py for current analysis
python trading_bot\main.py- Run this command to begin RL-Baseline3 Zoo environment wrapped to ours.
python -m trading_bot.sac.zoo.train --algo sac --env NVIDIATrading-v0 --device cuda --conf-file .\hyperparameters\sac.ymlpython -m trading_bot.sac.zoo.train --algo sac --env NVIDIATrading-v0 --device cuda --optimize --n-trials 50 --max-total-trials 50 --n-jobs 4 --sampler tpe --pruner median --n-evaluations 5 --eval-episodes 10 --conf-file .\hyperparameters\sac.yml --optimization-log-path logs/optimizer_results --tensorboard-log logs/tensorboardpython -m trading_bot.sac.zoo.train --algo sac --env NVIDIATrading-v0 --device cuda --optimize --n-trials 100 --n-jobs 6 --sampler tpe --pruner median --conf-file ./hyperparameters/sac.yml --optimization-log-path /opt/ml/model/optimizer_results --tensorboard-log /opt/ml/model/tensorboard --n-evaluations 5 --eval-episodes 5 --storage sqlite:////opt/ml/model/optuna.dbpython -m trading_bot.sac.zoo.train --algo sac --env NVIDIATrading-v0 --device cuda --optimize --n-trials 150 --n-jobs 8 --sampler tpe --pruner median --conf-file ./hyperparameters/sac.yml --optimization-log-path /opt/ml/model/optimizer_results --tensorboard-log /opt/ml/model/tensorboard --n-evaluations 5 --eval-episodes 8 --storage sqlite:////opt/ml/model/optuna.dbpython -m trading_bot.sac.zoo.train --algo sac --env NVIDIATrading-v0 --device cuda --optimize --n-trials 200 --n-jobs 24 --sampler tpe --pruner median --conf-file ./hyperparameters/sac.yml --optimization-log-path /opt/ml/model/optimizer_results --tensorboard-log /opt/ml/model/tensorboard --n-evaluations 5 --eval-episodes 10 --storage sqlite:////opt/ml/model/optuna.dbTo begin unit testing, run the following command:
pytestRunning main one time would generate a default config file. From there, you can edit and change certain parameters to your liking.