@@ -67,107 +67,165 @@ source venv/bin/activate # On Windows: venv\Scripts\activate
6767pip install -r requirements.txt
6868```
6969
70- 4 . Configure your settings :
70+ 4 . Install WinstonAI as a package :
7171``` bash
72- # Edit the configuration files in src/
73- cp src/training_config.json src/training_config.local.json
74- cp src/trading_config.json src/trading_config.local.json
75- # Update with your API keys and preferences
72+ pip install -e .
7673```
7774
78- ### Training the Model
75+ ### Quick Start
7976
80- ** Quick Start (GPU): **
77+ Run the quick start example:
8178``` bash
82- cd src
83- python quick_start_gpu.py
79+ python examples/quickstart.py
8480```
8581
86- ** Full Training: **
82+ Or train with more control:
8783``` bash
88- cd src
89- python train_gpu_optimized.py
84+ python examples/train_model.py
9085```
9186
92- ** Reinforcement Learning Training (5-second timeframe):**
93- ``` bash
94- cd src
95- python train_rl_5s.py
96- ```
87+ ### Using the Library
9788
98- ### Live Trading
89+ After installation, you can import WinstonAI in your Python scripts:
9990
100- ⚠️ ** Warning:** Live trading involves real financial risk. Always test thoroughly with a demo account first.
101-
102- ``` bash
103- cd src
104- python ultra_live_trading_bot.py
91+ ``` python
92+ from winston_ai import Trainer, Config, LiveTrader
93+ from winston_ai import WinstonAI, AdvancedWinstonAI
94+ from winston_ai.indicators import TechnicalIndicators
10595```
10696
97+ See ` examples/ ` directory for complete usage examples.
98+
10799## 📁 Project Structure
108100
109101```
110102WinstonAI/
111- ├── src/
103+ ├── winston_ai/ # Main library package
104+ │ ├── __init__.py # Package initialization
105+ │ ├── models/ # Neural network models
106+ │ │ ├── winston_model.py # WinstonAI & AdvancedWinstonAI models
107+ │ │ └── attention.py # Multi-head attention mechanism
108+ │ ├── training/ # Training utilities
109+ │ │ ├── trainer.py # High-level training orchestration
110+ │ │ ├── agent.py # DQN agent implementation
111+ │ │ └── environment.py # Trading environment simulation
112+ │ ├── trading/ # Live trading functionality
113+ │ │ └── live_trader.py # Live trading interface
114+ │ ├── indicators/ # Technical analysis
115+ │ │ └── technical.py # Technical indicators calculator
116+ │ └── utils/ # Utility functions
117+ │ ├── config.py # Configuration management
118+ │ ├── device.py # GPU/device management
119+ │ └── checkpoints.py # Model checkpoint utilities
120+ ├── examples/ # Example scripts
121+ │ ├── quickstart.py # Quick start example
122+ │ ├── train_model.py # Full training example
123+ │ ├── use_model.py # Inference example
124+ │ └── README.md # Examples documentation
125+ ├── src/ # Legacy scripts (for reference)
112126│ ├── train_gpu_optimized.py # GPU-optimized training script
113- │ ├── train_rl_5s.py # Reinforcement learning trainer (5s)
114- │ ├── ultra_live_trading_bot.py # High-performance live trading bot
127+ │ ├── train_rl_5s.py # RL trainer (5s timeframe )
128+ │ ├── ultra_live_trading_bot.py # High-performance trading bot
115129│ ├── live_trading_bot.py # Standard live trading bot
116- │ ├── gpu_monitor.py # GPU monitoring utilities
117- │ ├── gpu_benchmark.py # GPU performance benchmarking
118- │ ├── quick_start_gpu.py # Quick start script for GPU training
119- │ ├── download.py # Historical data downloader
120- │ ├── gethistory.py # Historical data fetcher
121- │ ├── training_config.json # Training configuration
122- │ ├── gpu_config.json # GPU settings
123- │ ├── trading_config.json # Trading bot configuration
124- │ ├── ultra_trading_config.json # Ultra bot configuration
125- │ └── README_GPU_OPTIMIZATION.md # Detailed GPU optimization guide
130+ │ └── gpu_monitor.py # GPU monitoring utilities
131+ ├── data/ # Data directory
132+ │ └── configs/ # Configuration files
133+ │ ├── training_config.json # Training configuration
134+ │ ├── trading_config.json # Trading configuration
135+ │ └── gpu_config.json # GPU settings
136+ ├── models/ # Saved models (gitignored)
137+ ├── docs/ # Documentation
138+ ├── tests/ # Unit tests
126139├── requirements.txt # Python dependencies
127- ├── setup.py # Package setup
128- ├── LICENSE # MIT License
129- ├── CONTRIBUTING.md # Contribution guidelines
130- ├── CODE_OF_CONDUCT.md # Code of conduct
131- ├── CHANGELOG.md # Version history
140+ ├── setup.py # Package installation
132141└── README.md # This file
133142```
134143
135144## 🎮 Usage Examples
136145
137- ### Training a New Model
146+ ### Quick Start
138147
139- ``` python
140- from train_gpu_optimized import AdvancedWinstonAI
148+ ``` bash
149+ # Install the package
150+ pip install -e .
141151
142- # Create model
143- model = AdvancedWinstonAI(
144- state_size = 100 ,
145- action_size = 3 , # CALL, PUT, HOLD
146- device = ' cuda'
152+ # Run quick start example
153+ python examples/quickstart.py
154+ ```
155+
156+ ### Training a New Model (Library API)
157+
158+ ``` python
159+ from winston_ai import Trainer, Config
160+ import pandas as pd
161+
162+ # Load your market data
163+ data = pd.read_csv(' your_market_data.csv' )
164+ # Ensure data has columns: open, high, low, close, volume
165+
166+ # Configure training
167+ config = Config()
168+ config.update(' training' ,
169+ episodes = 1000 ,
170+ batch_size = 512 ,
171+ learning_rate = 0.0001
147172)
148173
149- # Train
150- model.train(episodes = 5000 )
174+ # Create trainer and train
175+ trainer = Trainer(data = data, config = config)
176+ metrics = trainer.train(episodes = 1000 )
177+
178+ # Plot results
179+ trainer.plot_results(' training_results.png' )
151180```
152181
153- ### Making Predictions
182+ ### Using a Trained Model
154183
155184``` python
156- import torch
157- from train_gpu_optimized import AdvancedWinstonAI
185+ from winston_ai import LiveTrader
186+ import pandas as pd
158187
159188# Load trained model
160- model = torch.load(' winston_ai_final.pth' )
161- model.eval()
189+ trader = LiveTrader(
190+ model_path = ' models/winston_ai_final.pth' ,
191+ lookback_window = 100
192+ )
193+
194+ # Get recent market data
195+ data = get_recent_market_data() # Your data source
196+
197+ # Make prediction
198+ prediction = trader.predict(data)
199+ print (f " Action: { prediction[' action_name' ]} " )
200+ print (f " Confidence: { prediction[' confidence' ]:.2% } " )
162201
163- # Prepare state (your market data)
164- state = prepare_market_data() # Your function to get market data
202+ # Check if should trade
203+ if trader.should_trade(data, min_confidence = 0.7 ):
204+ execute_trade(prediction[' action_name' ])
205+ ```
206+
207+ ### Importing Models Directly
165208
166- # Get action
209+ ``` python
210+ from winston_ai import WinstonAI, AdvancedWinstonAI
211+ import torch
212+
213+ # Create model
214+ model = AdvancedWinstonAI(
215+ state_size = 10000 ,
216+ action_size = 3 , # HOLD, CALL, PUT
217+ hidden_size = 4096
218+ )
219+
220+ # Use for training or inference
221+ model.eval()
167222with torch.no_grad():
168- action = model.act(state)
223+ q_values = model(state_tensor)
224+ action = q_values.argmax().item()
169225```
170226
227+ For more examples, see the ` examples/ ` directory.
228+
171229## 📊 Model Architecture
172230
173231WinstonAI uses a sophisticated deep learning architecture:
0 commit comments