Edwin Salguero
commited on
Commit
Β·
81964c7
1
Parent(s):
6d01b44
fix: add YAML metadata to README.md for Hugging Face repository card
Browse files
README.md
CHANGED
@@ -1,560 +1,56 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
- **Multi-source Data Ingestion**: CSV files, Alpaca Markets API, and synthetic data generation
|
9 |
-
- **Technical Analysis**: 20+ technical indicators including RSI, MACD, Bollinger Bands, and more
|
10 |
-
- **Risk Management**: Position sizing, drawdown limits, and portfolio protection
|
11 |
-
- **Real-time Execution**: Live order placement and portfolio monitoring
|
12 |
|
13 |
-
|
14 |
-
- **
|
15 |
-
- **
|
16 |
-
- **
|
17 |
-
- **
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
- **Paper Trading**: Risk-free testing with virtual money
|
21 |
-
- **Live Trading**: Real market execution (use with caution!)
|
22 |
-
- **Market Data**: Real-time and historical data from Alpaca
|
23 |
-
- **Account Management**: Portfolio monitoring and position tracking
|
24 |
-
- **Order Types**: Market orders, limit orders, and order cancellation
|
25 |
|
26 |
-
### π¨ Comprehensive UI System
|
27 |
-
- **Streamlit UI**: Quick prototyping and data science workflows
|
28 |
-
- **Dash UI**: Enterprise-grade interactive dashboards
|
29 |
-
- **Jupyter UI**: Interactive notebook-based interfaces
|
30 |
-
- **WebSocket API**: Real-time trading data streaming
|
31 |
-
- **Multi-interface Support**: Choose the right UI for your needs
|
32 |
-
|
33 |
-
### Advanced Features
|
34 |
-
- **Docker Support**: Containerized deployment for consistency
|
35 |
-
- **Comprehensive Logging**: Detailed logs for debugging and performance analysis
|
36 |
-
- **Backtesting Engine**: Historical performance evaluation
|
37 |
-
- **Live Trading Simulation**: Real-time trading with configurable duration
|
38 |
-
- **Performance Metrics**: Returns, Sharpe ratio, drawdown analysis
|
39 |
-
|
40 |
-
## π Prerequisites
|
41 |
-
|
42 |
-
- Python 3.8+
|
43 |
-
- Alpaca Markets account (free paper trading available)
|
44 |
-
- Docker (optional, for containerized deployment)
|
45 |
-
|
46 |
-
## π οΈ Installation
|
47 |
-
|
48 |
-
### 1. Clone the Repository
|
49 |
```bash
|
50 |
-
|
|
|
51 |
cd algorithmic_trading
|
52 |
-
```
|
53 |
|
54 |
-
|
55 |
-
```bash
|
56 |
pip install -r requirements.txt
|
57 |
-
```
|
58 |
-
|
59 |
-
### 3. Set Up Alpaca API Credentials
|
60 |
-
Create a `.env` file in the project root:
|
61 |
-
```bash
|
62 |
-
cp env.example .env
|
63 |
-
```
|
64 |
-
|
65 |
-
Edit `.env` with your Alpaca credentials:
|
66 |
-
```env
|
67 |
-
# Get these from https://app.alpaca.markets/paper/dashboard/overview
|
68 |
-
ALPACA_API_KEY=your_paper_api_key_here
|
69 |
-
ALPACA_SECRET_KEY=your_paper_secret_key_here
|
70 |
-
|
71 |
-
# For live trading (use with caution!)
|
72 |
-
# ALPACA_API_KEY=your_live_api_key_here
|
73 |
-
# ALPACA_SECRET_KEY=your_live_secret_key_here
|
74 |
-
```
|
75 |
-
|
76 |
-
### 4. Configure Trading Parameters
|
77 |
-
Edit `config.yaml` to customize your trading strategy:
|
78 |
-
```yaml
|
79 |
-
# Data source configuration
|
80 |
-
data_source:
|
81 |
-
type: 'alpaca' # Options: 'alpaca', 'csv', 'synthetic'
|
82 |
-
|
83 |
-
# Trading parameters
|
84 |
-
trading:
|
85 |
-
symbol: 'AAPL'
|
86 |
-
timeframe: '1m'
|
87 |
-
capital: 100000
|
88 |
-
|
89 |
-
# Risk management
|
90 |
-
risk:
|
91 |
-
max_position: 100
|
92 |
-
max_drawdown: 0.05
|
93 |
-
|
94 |
-
# Execution settings
|
95 |
-
execution:
|
96 |
-
broker_api: 'alpaca_paper' # Options: 'paper', 'alpaca_paper', 'alpaca_live'
|
97 |
-
order_size: 10
|
98 |
-
|
99 |
-
# FinRL configuration
|
100 |
-
finrl:
|
101 |
-
algorithm: 'PPO'
|
102 |
-
learning_rate: 0.0003
|
103 |
-
training:
|
104 |
-
total_timesteps: 100000
|
105 |
-
save_best_model: true
|
106 |
-
```
|
107 |
-
|
108 |
-
## π Quick Start
|
109 |
-
|
110 |
-
### 1. Launch the UI (Recommended)
|
111 |
-
```bash
|
112 |
-
# Launch Streamlit UI (best for beginners)
|
113 |
-
python ui_launcher.py streamlit
|
114 |
-
|
115 |
-
# Launch Dash UI (best for production)
|
116 |
-
python ui_launcher.py dash
|
117 |
-
|
118 |
-
# Launch Jupyter Lab
|
119 |
-
python ui_launcher.py jupyter
|
120 |
-
|
121 |
-
# Launch all UIs
|
122 |
-
python ui_launcher.py all
|
123 |
-
```
|
124 |
-
|
125 |
-
### 2. Run the Demo
|
126 |
-
```bash
|
127 |
-
python demo.py
|
128 |
-
```
|
129 |
-
|
130 |
-
This will:
|
131 |
-
- Test data ingestion from Alpaca
|
132 |
-
- Demonstrate FinRL training
|
133 |
-
- Show trading workflow execution
|
134 |
-
- Run backtesting on historical data
|
135 |
-
|
136 |
-
### 3. Start Paper Trading
|
137 |
-
```bash
|
138 |
-
python -m agentic_ai_system.main --mode live --duration 60
|
139 |
-
```
|
140 |
-
|
141 |
-
### 4. Run Backtesting
|
142 |
-
```bash
|
143 |
-
python -m agentic_ai_system.main --mode backtest --start-date 2024-01-01 --end-date 2024-01-31
|
144 |
-
```
|
145 |
-
|
146 |
-
## π Usage Examples
|
147 |
-
|
148 |
-
### Basic Trading Workflow
|
149 |
-
```python
|
150 |
-
from agentic_ai_system.main import load_config
|
151 |
-
from agentic_ai_system.orchestrator import run
|
152 |
-
|
153 |
-
# Load configuration
|
154 |
-
config = load_config()
|
155 |
-
|
156 |
-
# Run single trading cycle
|
157 |
-
result = run(config)
|
158 |
-
print(f"Trading result: {result}")
|
159 |
-
```
|
160 |
-
|
161 |
-
### FinRL Training
|
162 |
-
```python
|
163 |
-
from agentic_ai_system.finrl_agent import FinRLAgent, FinRLConfig
|
164 |
-
from agentic_ai_system.data_ingestion import load_data
|
165 |
-
|
166 |
-
# Load data and configuration
|
167 |
-
config = load_config()
|
168 |
-
data = load_data(config)
|
169 |
-
|
170 |
-
# Initialize FinRL agent
|
171 |
-
finrl_config = FinRLConfig(algorithm='PPO', learning_rate=0.0003)
|
172 |
-
agent = FinRLAgent(finrl_config)
|
173 |
-
|
174 |
-
# Train the agent
|
175 |
-
result = agent.train(
|
176 |
-
data=data,
|
177 |
-
config=config,
|
178 |
-
total_timesteps=100000,
|
179 |
-
use_real_broker=False # Use simulation for training
|
180 |
-
)
|
181 |
-
|
182 |
-
print(f"Training completed: {result}")
|
183 |
-
```
|
184 |
-
|
185 |
-
### Alpaca Integration
|
186 |
-
```python
|
187 |
-
from agentic_ai_system.alpaca_broker import AlpacaBroker
|
188 |
-
|
189 |
-
# Initialize Alpaca broker
|
190 |
-
config = load_config()
|
191 |
-
broker = AlpacaBroker(config)
|
192 |
-
|
193 |
-
# Get account information
|
194 |
-
account_info = broker.get_account_info()
|
195 |
-
print(f"Account balance: ${account_info['buying_power']:,.2f}")
|
196 |
-
|
197 |
-
# Place a market order
|
198 |
-
result = broker.place_market_order(
|
199 |
-
symbol='AAPL',
|
200 |
-
quantity=10,
|
201 |
-
side='buy'
|
202 |
-
)
|
203 |
-
print(f"Order result: {result}")
|
204 |
-
```
|
205 |
-
|
206 |
-
### Real-time Trading with FinRL
|
207 |
-
```python
|
208 |
-
from agentic_ai_system.finrl_agent import FinRLAgent
|
209 |
-
|
210 |
-
# Load trained model
|
211 |
-
agent = FinRLAgent(FinRLConfig())
|
212 |
-
agent.model = agent._load_model('models/finrl_best/best_model', config)
|
213 |
-
|
214 |
-
# Make predictions with real execution
|
215 |
-
result = agent.predict(
|
216 |
-
data=recent_data,
|
217 |
-
config=config,
|
218 |
-
use_real_broker=True # Execute real trades!
|
219 |
-
)
|
220 |
-
```
|
221 |
-
|
222 |
-
## ποΈ Architecture
|
223 |
-
|
224 |
-
### System Components
|
225 |
-
|
226 |
-
```
|
227 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
228 |
-
β Data Sources β β Strategy Agent β β Execution Agent β
|
229 |
-
β β β β β β
|
230 |
-
β β’ Alpaca API βββββΆβ β’ Technical βββββΆβ β’ Alpaca Broker β
|
231 |
-
β β’ CSV Files β β Indicators β β β’ Order Mgmt β
|
232 |
-
β β’ Synthetic β β β’ Signal Gen β β β’ Risk Control β
|
233 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
234 |
-
β β β
|
235 |
-
βΌ βΌ βΌ
|
236 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
237 |
-
β Data Ingestion β β FinRL Agent β β Portfolio β
|
238 |
-
β β β β β Management β
|
239 |
-
β β’ Validation β β β’ PPO/A2C/DDPG β β β’ Positions β
|
240 |
-
β β’ Indicators β β β’ Training β β β’ P&L Tracking β
|
241 |
-
β β’ Preprocessing β β β’ Prediction β β β’ Risk Metrics β
|
242 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
243 |
-
```
|
244 |
-
|
245 |
-
### Data Flow
|
246 |
-
|
247 |
-
1. **Data Ingestion**: Market data from Alpaca, CSV, or synthetic sources
|
248 |
-
2. **Preprocessing**: Technical indicators, data validation, and feature engineering
|
249 |
-
3. **Strategy Generation**: Traditional technical analysis or FinRL predictions
|
250 |
-
4. **Risk Management**: Position sizing and portfolio protection
|
251 |
-
5. **Order Execution**: Real-time order placement through Alpaca
|
252 |
-
6. **Performance Tracking**: Continuous monitoring and logging
|
253 |
-
|
254 |
-
## π Project Directory Structure
|
255 |
-
|
256 |
-
```
|
257 |
-
algorithmic_trading/
|
258 |
-
βββ π README.md # Project documentation
|
259 |
-
βββ π LICENSE # Alpaca 2 License
|
260 |
-
βββ π requirements.txt # Python dependencies
|
261 |
-
βββ π config.yaml # Main configuration file
|
262 |
-
βββ π env.example # Environment variables template
|
263 |
-
βββ π .gitignore # Git ignore rules
|
264 |
-
βββ π pytest.ini # Test configuration
|
265 |
-
β
|
266 |
-
βββ π³ Docker/
|
267 |
-
β βββ π Dockerfile # Container definition
|
268 |
-
β βββ π docker-entrypoint.sh # Container startup script
|
269 |
-
β βββ π .dockerignore # Docker ignore rules
|
270 |
-
β βββ π docker-compose.yml # Default compose file
|
271 |
-
β βββ π docker-compose.dev.yml # Development environment
|
272 |
-
β βββ π docker-compose.prod.yml # Production environment
|
273 |
-
β βββ π docker-compose.hub.yml # Docker Hub deployment
|
274 |
-
β
|
275 |
-
βββ π€ agentic_ai_system/ # Core AI trading system
|
276 |
-
β βββ π main.py # Main entry point
|
277 |
-
β βββ π orchestrator.py # System coordination
|
278 |
-
β βββ π agent_base.py # Base agent class
|
279 |
-
β βββ π data_ingestion.py # Market data processing
|
280 |
-
β βββ π strategy_agent.py # Trading strategy logic
|
281 |
-
β βββ π execution_agent.py # Order execution
|
282 |
-
β βββ π finrl_agent.py # FinRL reinforcement learning
|
283 |
-
β βββ π alpaca_broker.py # Alpaca API integration
|
284 |
-
β βββ π synthetic_data_generator.py # Test data generation
|
285 |
-
β βββ π logger_config.py # Logging configuration
|
286 |
-
β
|
287 |
-
βββ π¨ ui/ # User interface system
|
288 |
-
β βββ π __init__.py # UI package initialization
|
289 |
-
β βββ π streamlit_app.py # Streamlit web application
|
290 |
-
β βββ π dash_app.py # Dash enterprise dashboard
|
291 |
-
β βββ π jupyter_widgets.py # Jupyter interactive widgets
|
292 |
-
β βββ π websocket_server.py # Real-time WebSocket server
|
293 |
-
β
|
294 |
-
βββ π§ͺ tests/ # Test suite
|
295 |
-
β βββ π __init__.py
|
296 |
-
β βββ π test_data_ingestion.py
|
297 |
-
β βββ π test_strategy_agent.py
|
298 |
-
β βββ π test_execution_agent.py
|
299 |
-
β βββ π test_finrl_agent.py
|
300 |
-
β βββ π test_synthetic_data_generator.py
|
301 |
-
β βββ π test_integration.py
|
302 |
-
β
|
303 |
-
βββ π data/ # Market data storage
|
304 |
-
β βββ π synthetic_market_data.csv
|
305 |
-
β
|
306 |
-
βββ π§ models/ # Trained AI models
|
307 |
-
β βββ π finrl_best/ # Best FinRL models
|
308 |
-
β
|
309 |
-
βββ π plots/ # Generated charts/visualizations
|
310 |
-
β
|
311 |
-
βββ π logs/ # System logs
|
312 |
-
β βββ π trading_system.log
|
313 |
-
β βββ π trading.log
|
314 |
-
β βββ π performance.log
|
315 |
-
β βββ π errors.log
|
316 |
-
β βββ π finrl_tensorboard/ # FinRL training logs
|
317 |
-
β βββ π finrl_eval/ # Model evaluation logs
|
318 |
-
β
|
319 |
-
βββ π§ scripts/ # Utility scripts
|
320 |
-
β βββ π docker-build.sh # Docker build automation
|
321 |
-
β βββ π docker-hub-deploy.sh # Docker Hub deployment
|
322 |
-
β
|
323 |
-
βββ π demo.py # Main demo script
|
324 |
-
βββ π finrl_demo.py # FinRL-specific demo
|
325 |
-
βββ π ui_launcher.py # UI launcher script
|
326 |
-
βββ π UI_SETUP.md # UI setup documentation
|
327 |
-
βββ π DOCKER_HUB_SETUP.md # Docker Hub documentation
|
328 |
-
β
|
329 |
-
βββ π .venv/ # Python virtual environment
|
330 |
-
```
|
331 |
-
|
332 |
-
### ποΈ Architecture Overview
|
333 |
-
|
334 |
-
#### **Core Components:**
|
335 |
-
- **Data Layer**: Market data ingestion and preprocessing
|
336 |
-
- **Strategy Layer**: Technical analysis and signal generation
|
337 |
-
- **AI Layer**: FinRL reinforcement learning agents
|
338 |
-
- **Execution Layer**: Order management and broker integration
|
339 |
-
- **Orchestration**: System coordination and workflow management
|
340 |
-
|
341 |
-
#### **Key Features:**
|
342 |
-
- **Modular Design**: Each component is independent and testable
|
343 |
-
- **Docker Support**: Complete containerization for deployment
|
344 |
-
- **Testing**: Comprehensive test suite for all components
|
345 |
-
- **Logging**: Detailed logging for monitoring and debugging
|
346 |
-
- **Configuration**: Centralized configuration management
|
347 |
-
- **Documentation**: Extensive documentation and examples
|
348 |
-
|
349 |
-
#### **Development Workflow:**
|
350 |
-
1. **Data Ingestion** β Market data from Alpaca/CSV/synthetic sources
|
351 |
-
2. **Strategy Generation** β Technical indicators and FinRL predictions
|
352 |
-
3. **Risk Management** β Position sizing and portfolio protection
|
353 |
-
4. **Order Execution** β Real-time trading through Alpaca
|
354 |
-
5. **Performance Tracking** β Continuous monitoring and logging
|
355 |
-
|
356 |
-
## π§ Configuration
|
357 |
-
|
358 |
-
### Alpaca Settings
|
359 |
-
```yaml
|
360 |
-
alpaca:
|
361 |
-
api_key: '' # Set via environment variable
|
362 |
-
secret_key: '' # Set via environment variable
|
363 |
-
paper_trading: true
|
364 |
-
base_url: 'https://paper-api.alpaca.markets'
|
365 |
-
live_url: 'https://api.alpaca.markets'
|
366 |
-
data_url: 'https://data.alpaca.markets'
|
367 |
-
account_type: 'paper' # 'paper' or 'live'
|
368 |
-
```
|
369 |
-
|
370 |
-
### FinRL Settings
|
371 |
-
```yaml
|
372 |
-
finrl:
|
373 |
-
algorithm: 'PPO' # PPO, A2C, DDPG, TD3
|
374 |
-
learning_rate: 0.0003
|
375 |
-
batch_size: 64
|
376 |
-
buffer_size: 1000000
|
377 |
-
training:
|
378 |
-
total_timesteps: 100000
|
379 |
-
eval_freq: 10000
|
380 |
-
save_best_model: true
|
381 |
-
model_save_path: 'models/finrl_best/'
|
382 |
-
inference:
|
383 |
-
use_trained_model: false
|
384 |
-
model_path: 'models/finrl_best/best_model'
|
385 |
-
```
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
risk:
|
390 |
-
max_position: 100
|
391 |
-
max_drawdown: 0.05
|
392 |
-
stop_loss: 0.02
|
393 |
-
take_profit: 0.05
|
394 |
```
|
395 |
|
396 |
-
##
|
397 |
-
|
398 |
-
The project includes a comprehensive UI system with multiple interface options:
|
399 |
-
|
400 |
-
### Available UIs
|
401 |
-
|
402 |
-
#### **Streamlit UI** (Recommended for beginners)
|
403 |
-
- **URL**: http://localhost:8501
|
404 |
-
- **Features**: Interactive widgets, real-time data visualization, easy configuration
|
405 |
-
- **Best for**: Data scientists, quick experiments, rapid prototyping
|
406 |
-
|
407 |
-
#### **Dash UI** (Recommended for production)
|
408 |
-
- **URL**: http://localhost:8050
|
409 |
-
- **Features**: Enterprise-grade dashboards, advanced charts, professional styling
|
410 |
-
- **Best for**: Production dashboards, real-time monitoring, complex analytics
|
411 |
-
|
412 |
-
#### **Jupyter UI** (For research)
|
413 |
-
- **URL**: http://localhost:8888
|
414 |
-
- **Features**: Interactive notebooks, code execution, rich documentation
|
415 |
-
- **Best for**: Research, experimentation, educational purposes
|
416 |
-
|
417 |
-
#### **WebSocket API** (For developers)
|
418 |
-
- **URL**: ws://localhost:8765
|
419 |
-
- **Features**: Real-time data streaming, trading signals, portfolio updates
|
420 |
-
- **Best for**: Real-time trading signals, live data streaming
|
421 |
-
|
422 |
-
### Quick UI Launch
|
423 |
-
```bash
|
424 |
-
# Launch individual UIs
|
425 |
-
python ui_launcher.py streamlit # Streamlit UI
|
426 |
-
python ui_launcher.py dash # Dash UI
|
427 |
-
python ui_launcher.py jupyter # Jupyter Lab
|
428 |
-
python ui_launcher.py websocket # WebSocket server
|
429 |
-
|
430 |
-
# Launch all UIs at once
|
431 |
-
python ui_launcher.py all
|
432 |
-
```
|
433 |
-
|
434 |
-
### UI Features
|
435 |
-
- **Real-time Data Visualization**: Live market data charts and indicators
|
436 |
-
- **Portfolio Monitoring**: Real-time portfolio value and P&L tracking
|
437 |
-
- **Trading Controls**: Start/stop trading, backtesting, risk management
|
438 |
-
- **FinRL Training**: Interactive model training and evaluation
|
439 |
-
- **Alpaca Integration**: Account management and order execution
|
440 |
-
- **Configuration Management**: Easy parameter tuning and strategy setup
|
441 |
-
|
442 |
-
For detailed UI documentation, see [UI_SETUP.md](UI_SETUP.md).
|
443 |
-
|
444 |
-
## π Performance Monitoring
|
445 |
-
|
446 |
-
### Logging
|
447 |
-
The system provides comprehensive logging:
|
448 |
-
- `logs/trading_system.log`: Main system logs
|
449 |
-
- `logs/trading.log`: Trading-specific events
|
450 |
-
- `logs/performance.log`: Performance metrics
|
451 |
-
- `logs/finrl_tensorboard/`: FinRL training logs
|
452 |
-
|
453 |
-
### Metrics Tracked
|
454 |
-
- Portfolio value and returns
|
455 |
-
- Trade execution statistics
|
456 |
-
- Risk metrics (Sharpe ratio, drawdown)
|
457 |
-
- FinRL training progress
|
458 |
-
- Alpaca account status
|
459 |
-
|
460 |
-
### Real-time Monitoring
|
461 |
-
```python
|
462 |
-
# Get account information
|
463 |
-
account_info = broker.get_account_info()
|
464 |
-
print(f"Portfolio Value: ${account_info['portfolio_value']:,.2f}")
|
465 |
-
|
466 |
-
# Get current positions
|
467 |
-
positions = broker.get_positions()
|
468 |
-
for pos in positions:
|
469 |
-
print(f"{pos['symbol']}: {pos['quantity']} shares")
|
470 |
-
|
471 |
-
# Check market status
|
472 |
-
market_open = broker.is_market_open()
|
473 |
-
print(f"Market: {'OPEN' if market_open else 'CLOSED'}")
|
474 |
-
```
|
475 |
-
|
476 |
-
## π³ Docker Deployment
|
477 |
-
|
478 |
-
### Build and Run
|
479 |
-
```bash
|
480 |
-
# Build the image
|
481 |
-
docker build -t algorithmic-trading .
|
482 |
-
|
483 |
-
# Run with environment variables
|
484 |
-
docker run -it --env-file .env algorithmic-trading
|
485 |
-
|
486 |
-
# Run with Jupyter Lab for development
|
487 |
-
docker-compose -f docker-compose.dev.yml up
|
488 |
-
```
|
489 |
-
|
490 |
-
### Production Deployment
|
491 |
-
```bash
|
492 |
-
# Use production compose file
|
493 |
-
docker-compose -f docker-compose.prod.yml up -d
|
494 |
-
|
495 |
-
# Monitor logs
|
496 |
-
docker-compose -f docker-compose.prod.yml logs -f
|
497 |
-
```
|
498 |
-
|
499 |
-
## π§ͺ Testing
|
500 |
-
|
501 |
-
### Run All Tests
|
502 |
-
```bash
|
503 |
-
pytest tests/ -v
|
504 |
-
```
|
505 |
-
|
506 |
-
### Test Specific Components
|
507 |
-
```bash
|
508 |
-
# Test Alpaca integration
|
509 |
-
pytest tests/test_alpaca_integration.py -v
|
510 |
-
|
511 |
-
# Test FinRL agent
|
512 |
-
pytest tests/test_finrl_agent.py -v
|
513 |
-
|
514 |
-
# Test trading workflow
|
515 |
-
pytest tests/test_integration.py -v
|
516 |
-
```
|
517 |
-
|
518 |
-
## β οΈ Important Notes
|
519 |
-
|
520 |
-
### Paper Trading vs Live Trading
|
521 |
-
- **Paper Trading**: Uses virtual money, safe for testing
|
522 |
-
- **Live Trading**: Uses real money, use with extreme caution
|
523 |
-
- Always test strategies thoroughly in paper trading before going live
|
524 |
-
|
525 |
-
### Risk Management
|
526 |
-
- Set appropriate position limits and drawdown thresholds
|
527 |
-
- Monitor your portfolio regularly
|
528 |
-
- Use stop-loss orders to limit potential losses
|
529 |
-
- Never risk more than you can afford to lose
|
530 |
-
|
531 |
-
### API Rate Limits
|
532 |
-
- Alpaca has rate limits on API calls
|
533 |
-
- The system includes built-in delays to respect these limits
|
534 |
-
- Monitor your API usage in the Alpaca dashboard
|
535 |
-
|
536 |
-
## π€ Contributing
|
537 |
-
|
538 |
-
1. Fork the repository
|
539 |
-
2. Create a feature branch
|
540 |
-
3. Make your changes
|
541 |
-
4. Add tests for new functionality
|
542 |
-
5. Submit a pull request
|
543 |
-
|
544 |
-
## π License
|
545 |
|
546 |
-
|
|
|
|
|
|
|
547 |
|
548 |
-
##
|
549 |
|
550 |
-
-
|
551 |
-
-
|
552 |
-
-
|
553 |
-
- **Community**: Join our Discord/Telegram for discussions
|
554 |
|
555 |
-
##
|
556 |
|
557 |
-
- [
|
558 |
-
- [FinRL Documentation](https://finrl.readthedocs.io/)
|
559 |
-
- [Stable Baselines3 Documentation](https://stable-baselines3.readthedocs.io/)
|
560 |
-
- [Gymnasium Documentation](https://gymnasium.farama.org/)
|
|
|
1 |
+
---
|
2 |
+
title: Algorithmic Trading System
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: green
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.46.1
|
8 |
+
app_file: streamlit_app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
---
|
12 |
|
13 |
+
# Algorithmic Trading System
|
14 |
|
15 |
+
A comprehensive algorithmic trading platform with multiple AI agents, real-time data processing, and interactive UI interfaces.
|
16 |
|
17 |
+
## Features
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
- π€ **Multi-Agent System**: Strategy, Execution, and Data Ingestion agents
|
20 |
+
- π **Real-time Data**: Market data ingestion and processing
|
21 |
+
- π§ **FinRL Integration**: Deep reinforcement learning for trading strategies
|
22 |
+
- π― **Multiple UIs**: Streamlit, Dash, Jupyter, and WebSocket interfaces
|
23 |
+
- π **Backtesting**: Comprehensive backtesting and performance analysis
|
24 |
+
- π **Risk Management**: Built-in risk controls and monitoring
|
25 |
+
- π **Deployment Ready**: Docker and cloud deployment support
|
26 |
|
27 |
+
## Quick Start
|
|
|
|
|
|
|
|
|
|
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
```bash
|
30 |
+
# Clone the repository
|
31 |
+
git clone https://github.com/EAName/algorithmic_trading.git
|
32 |
cd algorithmic_trading
|
|
|
33 |
|
34 |
+
# Install dependencies
|
|
|
35 |
pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
# Run the Streamlit UI
|
38 |
+
streamlit run streamlit_app.py
|
|
|
|
|
|
|
|
|
|
|
39 |
```
|
40 |
|
41 |
+
## Architecture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
- **Agentic AI System**: Core trading logic and agent coordination
|
44 |
+
- **Data Pipeline**: Real-time market data ingestion and processing
|
45 |
+
- **UI Layer**: Multiple interface options for different use cases
|
46 |
+
- **Deployment**: Docker and cloud-ready configuration
|
47 |
|
48 |
+
## Documentation
|
49 |
|
50 |
+
- [UI Setup Guide](UI_SETUP.md)
|
51 |
+
- [Deployment Guide](STREAMLIT_DEPLOYMENT.md)
|
52 |
+
- [Release Checklist](RELEASE_CHECKLIST.md)
|
|
|
53 |
|
54 |
+
## License
|
55 |
|
56 |
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
|
|
|
|