Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
@@ -13,229 +13,41 @@ tags:
|
|
13 |
- mcp-server-track
|
14 |
---
|
15 |
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
for a fast and functional deployment using ZerGPU please use : https://huggingface.co/spaces/Tonic/stock-predictions
|
20 |
-
|
21 |
-
|
22 |
-
# Stock Analysis and Prediction Demo
|
23 |
-
|
24 |
-
A comprehensive stock analysis and prediction tool built with Gradio, featuring multiple prediction strategies and technical analysis indicators. The application is particularly suited for structured financial product creation and analysis.
|
25 |
|
26 |
## Features
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
- **
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
-
|
44 |
-
-
|
45 |
-
-
|
46 |
-
-
|
47 |
-
-
|
48 |
-
|
49 |
-
- **Structured Product Analysis**:
|
50 |
-
- Extended prediction horizons (up to 1 year)
|
51 |
-
- Historical analysis up to 10 years
|
52 |
-
- Comprehensive risk metrics
|
53 |
-
- Sector and industry analysis
|
54 |
-
- Liquidity assessment
|
55 |
-
|
56 |
-
## Structured Product Features
|
57 |
-
|
58 |
-
### Extended Time Horizons
|
59 |
-
- Prediction window up to 365 days
|
60 |
-
- Historical data analysis up to 10 years
|
61 |
-
- Long-term trend analysis
|
62 |
-
- Extended technical indicators
|
63 |
-
|
64 |
-
### Risk Analysis
|
65 |
-
- Annualized volatility
|
66 |
-
- Maximum drawdown analysis
|
67 |
-
- Current drawdown tracking
|
68 |
-
- Sharpe and Sortino ratios
|
69 |
-
- Risk-adjusted return metrics
|
70 |
-
|
71 |
-
### Product Metrics
|
72 |
-
- Market capitalization
|
73 |
-
- Sector and industry classification
|
74 |
-
- Dividend yield analysis
|
75 |
-
- Volume metrics
|
76 |
-
- Liquidity scoring
|
77 |
-
|
78 |
-
### Sector Analysis
|
79 |
-
- Market cap ranking (Large/Mid/Small)
|
80 |
-
- Sector exposure
|
81 |
-
- Industry classification
|
82 |
-
- Liquidity assessment
|
83 |
|
84 |
## Installation
|
85 |
|
86 |
-
|
87 |
-
```bash
|
88 |
-
git clone <repository-url>
|
89 |
-
cd stock-prediction
|
90 |
-
```
|
91 |
|
92 |
-
2. Create and activate a virtual environment:
|
93 |
```bash
|
|
|
|
|
94 |
python -m venv .venv
|
95 |
-
source .venv/bin/activate #
|
96 |
-
```
|
97 |
-
|
98 |
-
3. Install dependencies:
|
99 |
-
```bash
|
100 |
pip install -r requirements.txt
|
101 |
```
|
102 |
-
|
103 |
-
## Usage
|
104 |
-
|
105 |
-
1. Start the Gradio demo:
|
106 |
-
```bash
|
107 |
-
python app.py
|
108 |
-
```
|
109 |
-
|
110 |
-
2. Open your web browser and navigate to the URL shown in the terminal (typically http://localhost:7860)
|
111 |
-
|
112 |
-
3. Enter a stock symbol (e.g., AAPL, GOOGL, MSFT) and select your desired parameters:
|
113 |
-
- Timeframe (1d, 1h, 15m)
|
114 |
-
- Number of days to predict (up to 365 days)
|
115 |
-
- Historical lookback period (up to 10 years)
|
116 |
-
- Prediction strategy (Chronos or Technical)
|
117 |
-
|
118 |
-
4. Click "Analyze Stock" to get:
|
119 |
-
- Price predictions and trading signals
|
120 |
-
- Structured product metrics
|
121 |
-
- Risk analysis
|
122 |
-
- Sector analysis
|
123 |
-
|
124 |
-
## Using for Structured Products
|
125 |
-
|
126 |
-
### Initial Screening
|
127 |
-
1. Use extended lookback period (up to 10 years) for long-term performance analysis
|
128 |
-
2. Look for stocks with stable volatility and good risk-adjusted returns
|
129 |
-
3. Check liquidity scores for trading feasibility
|
130 |
-
|
131 |
-
### Risk Assessment
|
132 |
-
1. Review risk metrics to match client risk profile
|
133 |
-
2. Analyze maximum drawdowns for worst-case scenarios
|
134 |
-
3. Compare risk-adjusted returns using Sharpe and Sortino ratios
|
135 |
-
|
136 |
-
### Product Structuring
|
137 |
-
1. Use prediction horizon (up to 1 year) for product maturity design
|
138 |
-
2. Consider dividend yields for income-generating products
|
139 |
-
3. Use sector analysis for proper diversification
|
140 |
-
|
141 |
-
### Portfolio Construction
|
142 |
-
1. Analyze multiple stocks for diversified bundles
|
143 |
-
2. Use sector metrics to avoid overexposure
|
144 |
-
3. Consider market cap rankings for appropriate sizing
|
145 |
-
|
146 |
-
## Prediction Strategies
|
147 |
-
|
148 |
-
### Chronos Strategy
|
149 |
-
Uses Amazon's Chronos model for ML-based price prediction. This strategy:
|
150 |
-
- Analyzes historical price patterns
|
151 |
-
- Generates probabilistic forecasts
|
152 |
-
- Provides confidence intervals
|
153 |
-
|
154 |
-
### Technical Strategy
|
155 |
-
Uses traditional technical analysis indicators to generate predictions:
|
156 |
-
- RSI for overbought/oversold conditions
|
157 |
-
- MACD for trend direction
|
158 |
-
- Bollinger Bands for volatility
|
159 |
-
- Moving Averages for trend confirmation
|
160 |
-
|
161 |
-
## Trading Signals
|
162 |
-
|
163 |
-
The demo provides trading signals based on multiple technical indicators:
|
164 |
-
- RSI: Oversold (<30), Overbought (>70), Neutral
|
165 |
-
- MACD: Buy (MACD > Signal), Sell (MACD < Signal)
|
166 |
-
- Bollinger Bands: Buy (price < lower band), Sell (price > upper band)
|
167 |
-
- SMA: Buy (20-day > 50-day), Sell (20-day < 50-day)
|
168 |
-
|
169 |
-
An overall trading signal is calculated by combining all individual signals.
|
170 |
-
|
171 |
-
## Contributing
|
172 |
-
|
173 |
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
174 |
-
|
175 |
-
## License
|
176 |
-
|
177 |
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
178 |
-
|
179 |
-
## Practical Example: Creating a 6-Month 8% Yield Structured Product
|
180 |
-
|
181 |
-
### Scenario
|
182 |
-
A bank needs to create a structured product that offers an 8% yield over 6 months while maintaining profitability for the institution.
|
183 |
-
|
184 |
-
### Step-by-Step Implementation
|
185 |
-
|
186 |
-
1. **Initial Stock Screening**
|
187 |
-
- Use the application to analyze stocks with:
|
188 |
-
- High liquidity (for easy hedging)
|
189 |
-
- Stable volatility (for predictable risk)
|
190 |
-
- Strong technical indicators
|
191 |
-
- Positive long-term trends
|
192 |
-
- Recommended stocks: AAPL, MSFT, GOOGL (high liquidity, stable volatility)
|
193 |
-
|
194 |
-
2. **Product Structure Design**
|
195 |
-
- Use the 6-month prediction horizon
|
196 |
-
- Analyze historical volatility for barrier setting
|
197 |
-
- Set participation rate based on risk metrics
|
198 |
-
- Structure: Reverse Convertible with 8% coupon
|
199 |
-
|
200 |
-
3. **Risk Analysis**
|
201 |
-
- Use the application's risk metrics:
|
202 |
-
- Check maximum drawdown (should be < 15% for 6 months)
|
203 |
-
- Verify liquidity scores (should be > 80%)
|
204 |
-
- Analyze Sharpe ratio (should be > 1.5)
|
205 |
-
|
206 |
-
4. **Business Case Example**
|
207 |
-
|
208 |
-
**Product Parameters:**
|
209 |
-
- Notional Amount: $1,000,000
|
210 |
-
- Term: 6 months
|
211 |
-
- Coupon: 8% p.a. (4% for 6 months)
|
212 |
-
- Underlying: AAPL
|
213 |
-
- Barrier: 85% of initial price
|
214 |
-
- Participation: 100%
|
215 |
-
|
216 |
-
**Revenue Structure:**
|
217 |
-
- Client receives: 8% p.a. (4% for 6 months)
|
218 |
-
- Bank's hedging cost: ~5% p.a.
|
219 |
-
- Bank's profit margin: ~3% p.a.
|
220 |
-
- Total client payout: $40,000 (4% of $1M)
|
221 |
-
- Bank's profit: $15,000 (1.5% of $1M)
|
222 |
-
|
223 |
-
5. **Implementation Steps**
|
224 |
-
- Use the application's extended prediction horizon (180 days)
|
225 |
-
- Set technical indicators to monitor barrier risk
|
226 |
-
- Implement dynamic delta hedging based on predictions
|
227 |
-
- Monitor risk metrics daily using the application
|
228 |
-
|
229 |
-
6. **Risk Management**
|
230 |
-
- Use the application's volatility predictions for dynamic hedging
|
231 |
-
- Monitor technical indicators for early warning signals
|
232 |
-
- Set up automated alerts for barrier proximity
|
233 |
-
- Regular rebalancing based on prediction updates
|
234 |
-
|
235 |
-
### Key Success Factors
|
236 |
-
- Regular monitoring of prediction accuracy
|
237 |
-
- Dynamic adjustment of hedging strategy
|
238 |
-
- Clear communication of product risks to clients
|
239 |
-
- Proper documentation of all assumptions and methodologies
|
240 |
-
|
241 |
-
This example demonstrates how the application can be used to create profitable structured products while managing risk effectively. The bank can use this framework to create similar products with different underlying assets, terms, and yield targets.
|
|
|
13 |
- mcp-server-track
|
14 |
---
|
15 |
|
16 |
+
# Structured Product & Crypto Prediction App
|
17 |
|
18 |
+
This Gradio-based app allows users to analyze stocks for structured financial products using advanced predictive models (Chronos T5), technical indicators, and visualize results. It also supports simple cryptocurrency predictions and provides affiliate links for automated trading bots.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
## Features
|
21 |
|
22 |
+
### Stock & Structured Product Analysis
|
23 |
+
- Historical stock data fetching (daily, hourly, 15-minute intervals)
|
24 |
+
- Technical indicators: SMA, RSI, MACD, Bollinger Bands
|
25 |
+
- Volatility, drawdown, liquidity, and risk metrics
|
26 |
+
- Predictive analysis using **Chronos T5 pipeline**
|
27 |
+
- Automatic fallback to technical strategy if prediction fails
|
28 |
+
- Interactive Plotly visualizations
|
29 |
+
- Trading signals generation
|
30 |
+
|
31 |
+
### Crypto Predictions
|
32 |
+
- Pulls historical crypto data (BTC, ETH, etc.) from Yahoo Finance
|
33 |
+
- Calculates SMA20 and SMA50 for trend signals
|
34 |
+
- Provides buy/sell indicators
|
35 |
+
|
36 |
+
### Affiliate Links
|
37 |
+
- Links to popular crypto bots for automated trading:
|
38 |
+
- [Pionex](https://www.pionex.com/?affiliate_id=YOUR_ID)
|
39 |
+
- [Cornix](https://cornix.io/?ref=YOUR_ID)
|
40 |
+
- [Cryptohopper](https://www.cryptohopper.com/signup?ref=YOUR_ID)
|
41 |
+
- [3Commas](https://3commas.io/?r=YOUR_ID)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
## Installation
|
44 |
|
45 |
+
Clone the repository and create a virtual environment:
|
|
|
|
|
|
|
|
|
46 |
|
|
|
47 |
```bash
|
48 |
+
git clone <repository-url>
|
49 |
+
cd crypto-prediction
|
50 |
python -m venv .venv
|
51 |
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
|
|
|
|
|
|
|
52 |
pip install -r requirements.txt
|
53 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|