Skip to content

Commit 6c7542d

Browse files
committed
updated project adr
1 parent a6d4016 commit 6c7542d

1 file changed

Lines changed: 160 additions & 76 deletions

File tree

docs/adr_project_foundation.md

Lines changed: 160 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -15,107 +15,191 @@
1515
- All trading pairs available on Kraken
1616
- Focus on USDT pairs (e.g., BTC/USDT, ETH/USDT)
1717
- Include all market cap sizes for comprehensive testing
18+
- Filter out stablecoin pairs (USDT, USDC, DAI, etc.)
1819

1920
- [x] Choose data provider/API
2021
- Selected Kraken API
2122
- Using REST API for historical data
2223
- Using WebSocket for real-time data
2324

2425
- [x] Define data structure
25-
- Using standard OHLCV format:
26+
- Using standard OHLCV format:
2627
- timestamp: int (Unix timestamp)
2728
- open: float
2829
- high: float
2930
- low: float
3031
- close: float
3132
- volume: float
32-
- Additional data:
33-
- trade_count: int
34-
- vwap: float (Volume Weighted Average Price)
35-
- [ ] Implement data fetching
36-
- [ ] Setup data storage
33+
- Additional data for real-time updates:
34+
- price: Decimal (current price)
35+
- volume: Decimal (24h volume)
36+
- timestamp: int (millisecond timestamp)
37+
38+
- [x] Implement data fetching
39+
- Implemented WebSocket connection for real-time data
40+
- Implemented REST API calls for historical OHLCV data
41+
- Created asset mapping for Kraken's symbol format (BTC→XBT)
42+
43+
- [x] Setup data storage
44+
- In-memory storage for real-time price data
45+
- Rolling window storage for technical analysis (50 data points)
46+
- Trade execution history for performance analysis
3747

3848
## 3. Trading Bot Architecture
49+
### ADR 2: Trading Modes
50+
51+
- [x] Define trading modes
52+
- Single-coin mode: Focus on a single trading pair (BTC/USDT)
53+
- Multi-coin mode: Dynamically switch between coins based on opportunity scores
54+
55+
- [x] Design allocation strategy
56+
- Single-coin: Allocate entire portfolio to one symbol
57+
- Multi-coin: 80% allocation to best opportunity, able to switch between coins
58+
3959
### ADR 3: Core Components
40-
- [ ] Define bot architecture
41-
- [ ] Implement basic trading logic
42-
- [ ] Setup risk management
43-
- [ ] Create position sizing logic
44-
- [ ] Implement order execution
45-
46-
### ADR 4: Machine Learning Implementation
47-
- [ ] Choose TensorFlow models
48-
- [ ] Define feature engineering
49-
- [ ] Create training pipeline
50-
- [ ] Implement prediction logic
51-
- [ ] Setup model evaluation
52-
53-
## 4. Testing Strategy
60+
61+
- [x] Define bot architecture
62+
- Modular design with separate client and trading logic
63+
- Event-driven price updates via callbacks
64+
- Asynchronous execution using asyncio
65+
66+
- [x] Implement basic trading logic
67+
- Technical analysis based signal generation
68+
- RSI, moving averages, and volume analysis
69+
- Opportunity scoring system (0-100) for coin selection
70+
71+
- [x] Setup risk management
72+
- Position size limits (95% of allocated balance)
73+
- Minimum order size checks
74+
- Error handling in trading and analysis loops
75+
76+
- [x] Create position sizing logic
77+
- Dynamic sizing based on allocated balance
78+
- Support for partial position exits
79+
- Automatic balance reallocation on coin switching
80+
81+
- [x] Implement order execution
82+
- Buy execution with price validation
83+
- Sell execution with P&L tracking
84+
- Order execution history tracking
85+
86+
## 4. Technical Analysis Implementation
87+
### ADR 4: Analysis Strategy
88+
89+
- [x] Choose technical indicators
90+
- RSI (Relative Strength Index) for overbought/oversold conditions
91+
- Short and long moving averages for trend detection
92+
- Volume analysis for momentum confirmation
93+
94+
- [x] Implement signal generation
95+
- Buy signals: RSI < 35 or (short MA > long MA and RSI < 65)
96+
- Sell signals: RSI > 65 or (short MA < long MA and RSI > 35)
97+
- Neutral signals when conditions aren't met
98+
99+
- [x] Create opportunity scoring system
100+
- Base score of 50 (neutral)
101+
- Adjust based on recent price changes
102+
- Adjust based on RSI values
103+
- Adjust based on MA trends
104+
- Adjust based on volume spikes
105+
- Clamped to 0-100 range
106+
107+
## 5. Testing Strategy
54108
### ADR 5: Testing Framework
55-
- [ ] Unit tests
109+
110+
- [x] Unit tests
111+
- Created test fixtures for client and bot
112+
- Test individual methods in isolation
113+
- Mocking of external dependencies
114+
56115
- [ ] Integration tests
116+
- Test interaction between client and trading bot
117+
- Validate end-to-end functionality
118+
57119
- [ ] Backtesting framework
58-
- [ ] Performance metrics
120+
- Historical data processing
121+
- Strategy performance evaluation
122+
123+
- [x] Performance metrics
124+
- Implemented tracking of:
125+
- Total trades
126+
- Win rate
127+
- Profit/loss tracking
128+
- Position P&L calculations
129+
- Portfolio value calculation
130+
59131
- [ ] Paper trading tests
132+
- Live testing without real money
133+
134+
## 6. User Interface
135+
### ADR 6: Command Line Interface
60136

61-
## 5. Documentation
62-
- [ ] Setup documentation structure
63-
- [ ] Write technical documentation
64-
- [ ] Create API documentation
65-
- [ ] Document trading strategies
66-
- [ ] Create user guide
67-
68-
## 6. Performance Monitoring
69-
### ADR 6: Monitoring System
70-
- [ ] Define KPIs
71-
- [ ] Setup logging
72-
- [ ] Implement monitoring dashboard
73-
- [ ] Create alert system
74-
- [ ] Performance reporting
75-
76-
## 7. Project Report Components
77-
- [ ] Abstract
78-
- [ ] Introduction
79-
- [ ] Problem statement
80-
- [ ] Project goals
81-
- [ ] Main section
82-
- [ ] Methodology
83-
- [ ] Implementation
84-
- [ ] Results
85-
- [ ] Discussion
86-
- [ ] Conclusion and outlook
87-
- [ ] Create presentation
88-
- [ ] Prepare handout
137+
- [x] User configuration
138+
- Initial balance input
139+
- Trading mode selection
140+
- Symbol selection (automatic or manual)
141+
142+
- [x] Status display
143+
- Real-time portfolio status updates
144+
- Position tracking with P&L
145+
- Trading opportunity scores
146+
- Session duration tracking
147+
148+
- [x] Performance reporting
149+
- Session summary on exit
150+
- Comprehensive P&L breakdown
151+
- Win rate calculation
152+
- Remaining position reporting
153+
154+
## 7. Project Structure
155+
- [x] Implemented code organization
156+
- `traid/trading_bot.py`: Core trading bot implementation
157+
- `traid/kraken_client.py`: Kraken API client implementation
158+
- `traid/main.py`: User interface and entry point
159+
- `tests/`: Test directory for pytest test files
89160

90161
## Directory Structure
91162
```
92163
TRAID/
93-
├── docs/
94-
├── src/
95-
│ ├── data/ # Data handling
96-
│ ├── models/ # ML models
97-
│ ├── trading/ # Trading logic
98-
│ └── utils/ # Utilities
164+
├── traid/
165+
│ ├── __init__.py
166+
│ ├── trading_bot.py # Trading bot implementation
167+
│ ├── kraken_client.py # Kraken API client
168+
│ └── main.py # Entry point and CLI
99169
├── tests/
100-
│ ├── unit/
101-
── integration/
102-
├── notebooks/ # Jupyter notebooks for analysis
103-
├── configs/ # Configuration files
104-
└── results/ # Trading results and analysis
170+
│ ├── __init__.py
171+
── test_trading_bot.py
172+
│ └── test_kraken_client.py
173+
├── requirements.txt
174+
└── README.md
105175
```
106176

107-
## Important Deadlines
108-
- [ ] Project proposal submission
109-
- [ ] Midterm review
110-
- [ ] Testing phase completion
111-
- [ ] Documentation completion
112-
- [ ] Final presentation
113-
- [ ] Project submission
114-
115-
## Notes
116-
- Remember to update this checklist regularly
117-
- Each ADR should be documented separately with:
118-
- Context
119-
- Decision
120-
- Consequences
121-
- Status
177+
## Implementation Details
178+
179+
### main.py:
180+
- Command-line interface for user configuration
181+
- Fetches available trading pairs from Kraken
182+
- Handles startup, execution, and graceful shutdown
183+
- Error handling and user interruption
184+
185+
### trading_bot.py:
186+
- Core trading logic implementation
187+
- Technical analysis and signal generation
188+
- Trade execution and position management
189+
- Portfolio tracking and performance metrics
190+
- Asynchronous operation with two main loops:
191+
- Analysis loop (5-minute interval)
192+
- Trading loop (1-second interval)
193+
194+
### kraken_client.py:
195+
- WebSocket connection for real-time data
196+
- REST API for historical data
197+
- Symbol formatting and mapping
198+
- Message handling and callback system
199+
200+
## Future Enhancements
201+
- [ ] Implement machine learning models for improved signal generation
202+
- [ ] Add database storage for historical trades and performance
203+
- [ ] Create web dashboard for monitoring
204+
- [ ] Implement additional trading strategies
205+
- [ ] Add support for more exchanges

0 commit comments

Comments
 (0)