Spaces:
Sleeping
Sleeping
Falcao Zane Vijay
commited on
Commit
·
edbf119
1
Parent(s):
c66a8d9
Readme update
Browse files- README.md +285 -4
- src/README.md +287 -1
README.md
CHANGED
@@ -11,9 +11,290 @@ pinned: false
|
|
11 |
short_description: h2h assignment
|
12 |
---
|
13 |
|
14 |
-
#
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
short_description: h2h assignment
|
12 |
---
|
13 |
|
14 |
+
# 📈 Complete Stock Trading & Prediction Platform
|
15 |
|
16 |
+
A sophisticated web-based stock trading platform that combines machine learning price predictions with rule-based trading strategies. Built with Streamlit, this platform offers comprehensive technical analysis, backtesting capabilities, and interactive visualizations for Indian stock markets.
|
17 |
|
18 |
+

|
19 |
+

|
20 |
+

|
21 |
+

|
22 |
+
|
23 |
+
## 🌟 Features
|
24 |
+
|
25 |
+
### 🔮 Price Prediction Engine
|
26 |
+
- **Machine Learning Model**: Logistic regression with 59+ technical features
|
27 |
+
- **Advanced Features**: Volatility ratios, momentum indicators, lag features
|
28 |
+
- **Confidence Analysis**: Prediction probability with visual confidence gauge
|
29 |
+
- **Technical Indicators**: RSI, MACD, SMA, EMA, Bollinger Bands
|
30 |
+
|
31 |
+
### 📊 Trading Dashboard
|
32 |
+
- **Multiple Strategies**: SMA-based and EMA-based trading strategies
|
33 |
+
- **Comprehensive Backtesting**: Historical performance analysis with risk metrics
|
34 |
+
- **Risk Management**: Configurable stop-loss, take-profit, and position sizing
|
35 |
+
- **Interactive Visualizations**: Plotly-powered charts and analysis tools
|
36 |
+
|
37 |
+
### 📈 Technical Analysis
|
38 |
+
- **50+ Indian Stocks**: Pre-configured NSE stock symbols
|
39 |
+
- **Real-time Data**: Yahoo Finance integration with reliable data fetching
|
40 |
+
- **Multiple Timeframes**: Customizable periods for technical indicators
|
41 |
+
- **Advanced Charts**: Candlestick patterns, volume analysis, drawdown charts
|
42 |
+
|
43 |
+
## 🚀 Quick Start
|
44 |
+
|
45 |
+
### Prerequisites
|
46 |
+
```bash
|
47 |
+
Python 3.8+
|
48 |
+
pip package manager
|
49 |
+
```
|
50 |
+
|
51 |
+
### Installation
|
52 |
+
|
53 |
+
1. **Clone the repository**
|
54 |
+
```bash
|
55 |
+
git clone https://github.com/yourusername/stock-trading-platform.git
|
56 |
+
cd stock-trading-platform
|
57 |
+
```
|
58 |
+
|
59 |
+
2. **Install dependencies**
|
60 |
+
```bash
|
61 |
+
pip install -r requirements.txt
|
62 |
+
```
|
63 |
+
|
64 |
+
3. **Set up the project structure**
|
65 |
+
```bash
|
66 |
+
mkdir -p src/logs src/models
|
67 |
+
```
|
68 |
+
|
69 |
+
4. **Download or train the ML models**
|
70 |
+
```bash
|
71 |
+
# Place your trained models in src/models/
|
72 |
+
# - logistic_regression_model.pkl
|
73 |
+
# - scaler.pkl
|
74 |
+
```
|
75 |
+
|
76 |
+
5. **Run the application**
|
77 |
+
```bash
|
78 |
+
streamlit run app.py
|
79 |
+
```
|
80 |
+
|
81 |
+
6. **Access the platform**
|
82 |
+
```
|
83 |
+
Open your browser and navigate to http://localhost:8501
|
84 |
+
```
|
85 |
+
|
86 |
+
## 📁 Project Structure
|
87 |
+
|
88 |
+
```
|
89 |
+
stock-trading-platform/
|
90 |
+
│
|
91 |
+
├── app.py # Main Streamlit application
|
92 |
+
├── requirements.txt # Python dependencies
|
93 |
+
├── README.md # Project documentation
|
94 |
+
│
|
95 |
+
├── src/
|
96 |
+
│ ├── indicators/ # Technical indicator modules
|
97 |
+
│ │ ├── __init__.py
|
98 |
+
│ │ ├── rsi.py # RSI calculation
|
99 |
+
│ │ ├── sma.py # Simple Moving Average
|
100 |
+
│ │ ├── ema.py # Exponential Moving Average
|
101 |
+
│ │ ├── macd.py # MACD indicator
|
102 |
+
│ │ └── enhanced_features.py # Advanced feature engineering
|
103 |
+
│ │
|
104 |
+
│ ├── strategy/ # Trading strategy modules
|
105 |
+
│ │ ├── __init__.py
|
106 |
+
│ │ └── rule_based_strategy.py # SMA/EMA trading strategies
|
107 |
+
│ │
|
108 |
+
│ ├── utils/ # Utility modules
|
109 |
+
│ │ ├── __init__.py
|
110 |
+
│ │ ├── backtester.py # Backtesting engine
|
111 |
+
│ │ └── logger.py # Logging configuration
|
112 |
+
│ │
|
113 |
+
│ ├── models/ # ML models and scalers
|
114 |
+
│ │ ├── logistic_regression_model.pkl
|
115 |
+
│ │ └── scaler.pkl
|
116 |
+
│ │
|
117 |
+
│ └── logs/ # Application logs
|
118 |
+
│ └── trading_app.log
|
119 |
+
│
|
120 |
+
└── data/ # Data storage (optional)
|
121 |
+
└── processed/
|
122 |
+
```
|
123 |
+
|
124 |
+
## 🛠️ Dependencies
|
125 |
+
|
126 |
+
### Core Libraries
|
127 |
+
```python
|
128 |
+
streamlit>=1.28.0 # Web application framework
|
129 |
+
pandas>=1.5.0 # Data manipulation
|
130 |
+
numpy>=1.24.0 # Numerical computing
|
131 |
+
plotly>=5.15.0 # Interactive visualizations
|
132 |
+
yfinance>=0.2.18 # Stock data fetching
|
133 |
+
scikit-learn>=1.3.0 # Machine learning
|
134 |
+
```
|
135 |
+
|
136 |
+
### Additional Dependencies
|
137 |
+
```python
|
138 |
+
curl-cffi>=0.5.10 # HTTP requests with browser impersonation
|
139 |
+
pickle>=4.0 # Model serialization
|
140 |
+
datetime # Date/time handling
|
141 |
+
warnings # Warning management
|
142 |
+
logging # Application logging
|
143 |
+
```
|
144 |
+
|
145 |
+
## 📊 Supported Stocks
|
146 |
+
|
147 |
+
The platform supports 50+ major Indian stocks including:
|
148 |
+
|
149 |
+
**Banking & Finance**
|
150 |
+
- HDFCBANK.NS, ICICIBANK.NS, AXISBANK.NS, KOTAKBANK.NS, SBIN.NS
|
151 |
+
|
152 |
+
**Technology**
|
153 |
+
- TCS.NS, INFY.NS, HCLTECH.NS, TECHM.NS, WIPRO.NS
|
154 |
+
|
155 |
+
**Energy & Materials**
|
156 |
+
- RELIANCE.NS, ONGC.NS, COALINDIA.NS, NTPC.NS, POWERGRID.NS
|
157 |
+
|
158 |
+
**Consumer Goods**
|
159 |
+
- HINDUNILVR.NS, ITC.NS, NESTLEIND.NS, TATACONSUM.NS, BRITANNIA.NS
|
160 |
+
|
161 |
+
**And many more...**
|
162 |
+
|
163 |
+
## 🔧 Configuration
|
164 |
+
|
165 |
+
### Technical Indicators
|
166 |
+
- **RSI Period**: 5-30 days (default: 14)
|
167 |
+
- **Short-term SMA/EMA**: 5-50 days (default: 20)
|
168 |
+
- **Long-term SMA/EMA**: 50-200 days (default: 50)
|
169 |
+
|
170 |
+
### Trading Parameters
|
171 |
+
- **Initial Capital**: ₹10,000 - ₹10,00,000 (default: ₹1,00,000)
|
172 |
+
- **Transaction Cost**: 0.0% - 1.0% (default: 0.1%)
|
173 |
+
- **Stop Loss**: 0% - 20% (default: 5%)
|
174 |
+
- **Take Profit**: 0% - 50% (default: 15%)
|
175 |
+
|
176 |
+
### Risk Management
|
177 |
+
- Position sizing based on available capital
|
178 |
+
- Automatic stop-loss and take-profit execution
|
179 |
+
- Transaction cost simulation
|
180 |
+
- Drawdown analysis and monitoring
|
181 |
+
|
182 |
+
## 🎯 Usage Guide
|
183 |
+
|
184 |
+
### 1. Price Prediction
|
185 |
+
1. Select a stock from the dropdown menu
|
186 |
+
2. Choose your date range and technical indicator periods
|
187 |
+
3. View the ML model's next-day price prediction
|
188 |
+
4. Analyze confidence levels and technical charts
|
189 |
+
5. Export prediction data for further analysis
|
190 |
+
|
191 |
+
### 2. Trading Dashboard
|
192 |
+
1. Configure your trading strategy (SMA or EMA based)
|
193 |
+
2. Set backtesting parameters and risk management rules
|
194 |
+
3. Run the backtest and analyze performance metrics
|
195 |
+
4. Compare strategy performance vs buy-and-hold
|
196 |
+
5. Review detailed trade analysis and export results
|
197 |
+
|
198 |
+
### 3. Technical Analysis
|
199 |
+
1. Examine multiple technical indicators simultaneously
|
200 |
+
2. Identify trading signals and market trends
|
201 |
+
3. Analyze volume patterns and momentum indicators
|
202 |
+
4. Use Bollinger Bands for volatility analysis
|
203 |
+
5. Monitor drawdown and risk metrics
|
204 |
+
|
205 |
+
## 📈 Model Performance
|
206 |
+
|
207 |
+
### Machine Learning Metrics
|
208 |
+
- **Accuracy**: 55.0%
|
209 |
+
- **F1 Score**: 0.4839
|
210 |
+
- **AUC Score**: 0.5370
|
211 |
+
- **Average Precision**: 0.5300
|
212 |
+
|
213 |
+
### Feature Engineering
|
214 |
+
- **Total Features**: 59 technical indicators
|
215 |
+
- **Feature Categories**: Price, Volume, Volatility, Momentum, Position
|
216 |
+
- **Data Processing**: StandardScaler normalization
|
217 |
+
- **Model Type**: Logistic Regression with regularization
|
218 |
+
|
219 |
+
## 🔍 Advanced Features
|
220 |
+
|
221 |
+
### Enhanced Technical Analysis
|
222 |
+
- **Volatility Features**: Multi-timeframe volatility ratios and rankings
|
223 |
+
- **Lag Features**: Historical price and indicator dependencies
|
224 |
+
- **Volume Analysis**: Volume-price relationships and momentum
|
225 |
+
- **Position Features**: Price position relative to historical ranges
|
226 |
+
|
227 |
+
### Backtesting Engine
|
228 |
+
- **Performance Metrics**: Sharpe ratio, maximum drawdown, win rate
|
229 |
+
- **Trade Analysis**: Individual trade performance and statistics
|
230 |
+
- **Risk Assessment**: Drawdown analysis and volatility measures
|
231 |
+
- **Comparison Tools**: Strategy vs buy-and-hold performance
|
232 |
+
|
233 |
+
### Interactive Visualizations
|
234 |
+
- **Real-time Charts**: Dynamic price action with technical overlays
|
235 |
+
- **Signal Visualization**: Buy/sell signals on price charts
|
236 |
+
- **Performance Tracking**: Portfolio value progression over time
|
237 |
+
- **Distribution Analysis**: Trade returns and risk metrics
|
238 |
+
|
239 |
+
## 🚨 Disclaimer
|
240 |
+
|
241 |
+
**Important**: This platform is designed for educational and research purposes only. Stock market investments carry inherent risks, and past performance does not guarantee future results.
|
242 |
+
|
243 |
+
**Risk Warning**:
|
244 |
+
- Always conduct your own research before making investment decisions
|
245 |
+
- Consider consulting with a qualified financial advisor
|
246 |
+
- Never invest more than you can afford to lose
|
247 |
+
- Markets can be volatile and unpredictable
|
248 |
+
|
249 |
+
## 🤝 Contributing
|
250 |
+
|
251 |
+
We welcome contributions to improve the platform! Here's how you can help:
|
252 |
+
|
253 |
+
### Areas for Contribution
|
254 |
+
- **New Trading Strategies**: Implement additional algorithmic strategies
|
255 |
+
- **Enhanced ML Models**: Add new prediction models and features
|
256 |
+
- **UI/UX Improvements**: Enhance the user interface and experience
|
257 |
+
- **Performance Optimization**: Improve code efficiency and speed
|
258 |
+
- **Bug Fixes**: Report and fix issues in the codebase
|
259 |
+
|
260 |
+
### Contribution Process
|
261 |
+
1. Fork the repository
|
262 |
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
263 |
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
264 |
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
265 |
+
5. Open a Pull Request
|
266 |
+
|
267 |
+
## 📝 License
|
268 |
+
|
269 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
270 |
+
|
271 |
+
## 👨💻 Author
|
272 |
+
|
273 |
+
**Zane Vijay Falcao**
|
274 |
+
- Email: [email protected]
|
275 |
+
- LinkedIn: [Your LinkedIn Profile]
|
276 |
+
- GitHub: [Your GitHub Profile]
|
277 |
+
|
278 |
+
## 🙏 Acknowledgments
|
279 |
+
|
280 |
+
- **Yahoo Finance** for providing reliable stock market data
|
281 |
+
- **Streamlit** for the excellent web application framework
|
282 |
+
- **Plotly** for interactive visualization capabilities
|
283 |
+
- **Scikit-learn** for machine learning tools and utilities
|
284 |
+
|
285 |
+
## 📞 Support
|
286 |
+
|
287 |
+
If you encounter any issues or have questions:
|
288 |
+
|
289 |
+
1. **Check the Documentation**: Review this README and code comments
|
290 |
+
2. **Search Issues**: Look through existing GitHub issues
|
291 |
+
3. **Create New Issue**: Submit a detailed bug report or feature request
|
292 |
+
4. **Contact Developer**: Reach out via email for urgent matters
|
293 |
+
|
294 |
+
---
|
295 |
+
|
296 |
+
⭐ **Star this repository if you find it helpful!** ⭐
|
297 |
+
|
298 |
+
---
|
299 |
+
|
300 |
+
*Last Updated: August 2025*
|
src/README.md
CHANGED
@@ -1 +1,287 @@
|
|
1 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 📈 Complete Stock Trading & Prediction Platform
|
2 |
+
|
3 |
+
A sophisticated web-based stock trading platform that combines machine learning price predictions with rule-based trading strategies. Built with Streamlit, this platform offers comprehensive technical analysis, backtesting capabilities, and interactive visualizations for Indian stock markets.
|
4 |
+
|
5 |
+

|
6 |
+

|
7 |
+

|
8 |
+

|
9 |
+
|
10 |
+
## 🌟 Features
|
11 |
+
|
12 |
+
### 🔮 Price Prediction Engine
|
13 |
+
- **Machine Learning Model**: Logistic regression with 59+ technical features
|
14 |
+
- **Advanced Features**: Volatility ratios, momentum indicators, lag features
|
15 |
+
- **Confidence Analysis**: Prediction probability with visual confidence gauge
|
16 |
+
- **Technical Indicators**: RSI, MACD, SMA, EMA, Bollinger Bands
|
17 |
+
|
18 |
+
### 📊 Trading Dashboard
|
19 |
+
- **Multiple Strategies**: SMA-based and EMA-based trading strategies
|
20 |
+
- **Comprehensive Backtesting**: Historical performance analysis with risk metrics
|
21 |
+
- **Risk Management**: Configurable stop-loss, take-profit, and position sizing
|
22 |
+
- **Interactive Visualizations**: Plotly-powered charts and analysis tools
|
23 |
+
|
24 |
+
### 📈 Technical Analysis
|
25 |
+
- **50+ Indian Stocks**: Pre-configured NSE stock symbols
|
26 |
+
- **Real-time Data**: Yahoo Finance integration with reliable data fetching
|
27 |
+
- **Multiple Timeframes**: Customizable periods for technical indicators
|
28 |
+
- **Advanced Charts**: Candlestick patterns, volume analysis, drawdown charts
|
29 |
+
|
30 |
+
## 🚀 Quick Start
|
31 |
+
|
32 |
+
### Prerequisites
|
33 |
+
```bash
|
34 |
+
Python 3.8+
|
35 |
+
pip package manager
|
36 |
+
```
|
37 |
+
|
38 |
+
### Installation
|
39 |
+
|
40 |
+
1. **Clone the repository**
|
41 |
+
```bash
|
42 |
+
git clone https://github.com/yourusername/stock-trading-platform.git
|
43 |
+
cd stock-trading-platform
|
44 |
+
```
|
45 |
+
|
46 |
+
2. **Install dependencies**
|
47 |
+
```bash
|
48 |
+
pip install -r requirements.txt
|
49 |
+
```
|
50 |
+
|
51 |
+
3. **Set up the project structure**
|
52 |
+
```bash
|
53 |
+
mkdir -p src/logs src/models
|
54 |
+
```
|
55 |
+
|
56 |
+
4. **Download or train the ML models**
|
57 |
+
```bash
|
58 |
+
# Place your trained models in src/models/
|
59 |
+
# - logistic_regression_model.pkl
|
60 |
+
# - scaler.pkl
|
61 |
+
```
|
62 |
+
|
63 |
+
5. **Run the application**
|
64 |
+
```bash
|
65 |
+
streamlit run app.py
|
66 |
+
```
|
67 |
+
|
68 |
+
6. **Access the platform**
|
69 |
+
```
|
70 |
+
Open your browser and navigate to http://localhost:8501
|
71 |
+
```
|
72 |
+
|
73 |
+
## 📁 Project Structure
|
74 |
+
|
75 |
+
```
|
76 |
+
stock-trading-platform/
|
77 |
+
│
|
78 |
+
├── app.py # Main Streamlit application
|
79 |
+
├── requirements.txt # Python dependencies
|
80 |
+
├── README.md # Project documentation
|
81 |
+
│
|
82 |
+
├── src/
|
83 |
+
│ ├── indicators/ # Technical indicator modules
|
84 |
+
│ │ ├── __init__.py
|
85 |
+
│ │ ├── rsi.py # RSI calculation
|
86 |
+
│ │ ├── sma.py # Simple Moving Average
|
87 |
+
│ │ ├── ema.py # Exponential Moving Average
|
88 |
+
│ │ ├── macd.py # MACD indicator
|
89 |
+
│ │ └── enhanced_features.py # Advanced feature engineering
|
90 |
+
│ │
|
91 |
+
│ ├── strategy/ # Trading strategy modules
|
92 |
+
│ │ ├── __init__.py
|
93 |
+
│ │ └── rule_based_strategy.py # SMA/EMA trading strategies
|
94 |
+
│ │
|
95 |
+
│ ├── utils/ # Utility modules
|
96 |
+
│ │ ├── __init__.py
|
97 |
+
│ │ ├── backtester.py # Backtesting engine
|
98 |
+
│ │ └── logger.py # Logging configuration
|
99 |
+
│ │
|
100 |
+
│ ├── models/ # ML models and scalers
|
101 |
+
│ │ ├── logistic_regression_model.pkl
|
102 |
+
│ │ └── scaler.pkl
|
103 |
+
│ │
|
104 |
+
│ └── logs/ # Application logs
|
105 |
+
│ └── trading_app.log
|
106 |
+
│
|
107 |
+
└── data/ # Data storage (optional)
|
108 |
+
└── processed/
|
109 |
+
```
|
110 |
+
|
111 |
+
## 🛠️ Dependencies
|
112 |
+
|
113 |
+
### Core Libraries
|
114 |
+
```python
|
115 |
+
streamlit>=1.28.0 # Web application framework
|
116 |
+
pandas>=1.5.0 # Data manipulation
|
117 |
+
numpy>=1.24.0 # Numerical computing
|
118 |
+
plotly>=5.15.0 # Interactive visualizations
|
119 |
+
yfinance>=0.2.18 # Stock data fetching
|
120 |
+
scikit-learn>=1.3.0 # Machine learning
|
121 |
+
```
|
122 |
+
|
123 |
+
### Additional Dependencies
|
124 |
+
```python
|
125 |
+
curl-cffi>=0.5.10 # HTTP requests with browser impersonation
|
126 |
+
pickle>=4.0 # Model serialization
|
127 |
+
datetime # Date/time handling
|
128 |
+
warnings # Warning management
|
129 |
+
logging # Application logging
|
130 |
+
```
|
131 |
+
|
132 |
+
## 📊 Supported Stocks
|
133 |
+
|
134 |
+
The platform supports 50+ major Indian stocks including:
|
135 |
+
|
136 |
+
**Banking & Finance**
|
137 |
+
- HDFCBANK.NS, ICICIBANK.NS, AXISBANK.NS, KOTAKBANK.NS, SBIN.NS
|
138 |
+
|
139 |
+
**Technology**
|
140 |
+
- TCS.NS, INFY.NS, HCLTECH.NS, TECHM.NS, WIPRO.NS
|
141 |
+
|
142 |
+
**Energy & Materials**
|
143 |
+
- RELIANCE.NS, ONGC.NS, COALINDIA.NS, NTPC.NS, POWERGRID.NS
|
144 |
+
|
145 |
+
**Consumer Goods**
|
146 |
+
- HINDUNILVR.NS, ITC.NS, NESTLEIND.NS, TATACONSUM.NS, BRITANNIA.NS
|
147 |
+
|
148 |
+
**And many more...**
|
149 |
+
|
150 |
+
## 🔧 Configuration
|
151 |
+
|
152 |
+
### Technical Indicators
|
153 |
+
- **RSI Period**: 5-30 days (default: 14)
|
154 |
+
- **Short-term SMA/EMA**: 5-50 days (default: 20)
|
155 |
+
- **Long-term SMA/EMA**: 50-200 days (default: 50)
|
156 |
+
|
157 |
+
### Trading Parameters
|
158 |
+
- **Initial Capital**: ₹10,000 - ₹10,00,000 (default: ₹1,00,000)
|
159 |
+
- **Transaction Cost**: 0.0% - 1.0% (default: 0.1%)
|
160 |
+
- **Stop Loss**: 0% - 20% (default: 5%)
|
161 |
+
- **Take Profit**: 0% - 50% (default: 15%)
|
162 |
+
|
163 |
+
### Risk Management
|
164 |
+
- Position sizing based on available capital
|
165 |
+
- Automatic stop-loss and take-profit execution
|
166 |
+
- Transaction cost simulation
|
167 |
+
- Drawdown analysis and monitoring
|
168 |
+
|
169 |
+
## 🎯 Usage Guide
|
170 |
+
|
171 |
+
### 1. Price Prediction
|
172 |
+
1. Select a stock from the dropdown menu
|
173 |
+
2. Choose your date range and technical indicator periods
|
174 |
+
3. View the ML model's next-day price prediction
|
175 |
+
4. Analyze confidence levels and technical charts
|
176 |
+
5. Export prediction data for further analysis
|
177 |
+
|
178 |
+
### 2. Trading Dashboard
|
179 |
+
1. Configure your trading strategy (SMA or EMA based)
|
180 |
+
2. Set backtesting parameters and risk management rules
|
181 |
+
3. Run the backtest and analyze performance metrics
|
182 |
+
4. Compare strategy performance vs buy-and-hold
|
183 |
+
5. Review detailed trade analysis and export results
|
184 |
+
|
185 |
+
### 3. Technical Analysis
|
186 |
+
1. Examine multiple technical indicators simultaneously
|
187 |
+
2. Identify trading signals and market trends
|
188 |
+
3. Analyze volume patterns and momentum indicators
|
189 |
+
4. Use Bollinger Bands for volatility analysis
|
190 |
+
5. Monitor drawdown and risk metrics
|
191 |
+
|
192 |
+
## 📈 Model Performance
|
193 |
+
|
194 |
+
### Machine Learning Metrics
|
195 |
+
- **Accuracy**: 55.0%
|
196 |
+
- **F1 Score**: 0.4839
|
197 |
+
- **AUC Score**: 0.5370
|
198 |
+
- **Average Precision**: 0.5300
|
199 |
+
|
200 |
+
### Feature Engineering
|
201 |
+
- **Total Features**: 59 technical indicators
|
202 |
+
- **Feature Categories**: Price, Volume, Volatility, Momentum, Position
|
203 |
+
- **Data Processing**: StandardScaler normalization
|
204 |
+
- **Model Type**: Logistic Regression with regularization
|
205 |
+
|
206 |
+
## 🔍 Advanced Features
|
207 |
+
|
208 |
+
### Enhanced Technical Analysis
|
209 |
+
- **Volatility Features**: Multi-timeframe volatility ratios and rankings
|
210 |
+
- **Lag Features**: Historical price and indicator dependencies
|
211 |
+
- **Volume Analysis**: Volume-price relationships and momentum
|
212 |
+
- **Position Features**: Price position relative to historical ranges
|
213 |
+
|
214 |
+
### Backtesting Engine
|
215 |
+
- **Performance Metrics**: Sharpe ratio, maximum drawdown, win rate
|
216 |
+
- **Trade Analysis**: Individual trade performance and statistics
|
217 |
+
- **Risk Assessment**: Drawdown analysis and volatility measures
|
218 |
+
- **Comparison Tools**: Strategy vs buy-and-hold performance
|
219 |
+
|
220 |
+
### Interactive Visualizations
|
221 |
+
- **Real-time Charts**: Dynamic price action with technical overlays
|
222 |
+
- **Signal Visualization**: Buy/sell signals on price charts
|
223 |
+
- **Performance Tracking**: Portfolio value progression over time
|
224 |
+
- **Distribution Analysis**: Trade returns and risk metrics
|
225 |
+
|
226 |
+
## 🚨 Disclaimer
|
227 |
+
|
228 |
+
**Important**: This platform is designed for educational and research purposes only. Stock market investments carry inherent risks, and past performance does not guarantee future results.
|
229 |
+
|
230 |
+
**Risk Warning**:
|
231 |
+
- Always conduct your own research before making investment decisions
|
232 |
+
- Consider consulting with a qualified financial advisor
|
233 |
+
- Never invest more than you can afford to lose
|
234 |
+
- Markets can be volatile and unpredictable
|
235 |
+
|
236 |
+
## 🤝 Contributing
|
237 |
+
|
238 |
+
We welcome contributions to improve the platform! Here's how you can help:
|
239 |
+
|
240 |
+
### Areas for Contribution
|
241 |
+
- **New Trading Strategies**: Implement additional algorithmic strategies
|
242 |
+
- **Enhanced ML Models**: Add new prediction models and features
|
243 |
+
- **UI/UX Improvements**: Enhance the user interface and experience
|
244 |
+
- **Performance Optimization**: Improve code efficiency and speed
|
245 |
+
- **Bug Fixes**: Report and fix issues in the codebase
|
246 |
+
|
247 |
+
### Contribution Process
|
248 |
+
1. Fork the repository
|
249 |
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
250 |
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
251 |
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
252 |
+
5. Open a Pull Request
|
253 |
+
|
254 |
+
## 📝 License
|
255 |
+
|
256 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
257 |
+
|
258 |
+
## 👨💻 Author
|
259 |
+
|
260 |
+
**Zane Vijay Falcao**
|
261 |
+
- Email: [email protected]
|
262 |
+
- LinkedIn: [Your LinkedIn Profile]
|
263 |
+
- GitHub: [Your GitHub Profile]
|
264 |
+
|
265 |
+
## 🙏 Acknowledgments
|
266 |
+
|
267 |
+
- **Yahoo Finance** for providing reliable stock market data
|
268 |
+
- **Streamlit** for the excellent web application framework
|
269 |
+
- **Plotly** for interactive visualization capabilities
|
270 |
+
- **Scikit-learn** for machine learning tools and utilities
|
271 |
+
|
272 |
+
## 📞 Support
|
273 |
+
|
274 |
+
If you encounter any issues or have questions:
|
275 |
+
|
276 |
+
1. **Check the Documentation**: Review this README and code comments
|
277 |
+
2. **Search Issues**: Look through existing GitHub issues
|
278 |
+
3. **Create New Issue**: Submit a detailed bug report or feature request
|
279 |
+
4. **Contact Developer**: Reach out via email for urgent matters
|
280 |
+
|
281 |
+
---
|
282 |
+
|
283 |
+
⭐ **Star this repository if you find it helpful!** ⭐
|
284 |
+
|
285 |
+
---
|
286 |
+
|
287 |
+
*Last Updated: August 2025*
|