Spaces:
Paused
Paused
Tonic commited on
Commit ·
f2e16b4
1
Parent(s): 8481b42
attempt more advanced predictions using model ensemble
Browse files
app.py
CHANGED
|
@@ -1692,6 +1692,9 @@ def create_interface():
|
|
| 1692 |
daily_signals = gr.JSON(label="Trading Signals")
|
| 1693 |
|
| 1694 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
| 1695 |
gr.Markdown("### Stress Test Results")
|
| 1696 |
daily_stress_results = gr.JSON(label="Stress Test Results")
|
| 1697 |
|
|
@@ -1938,55 +1941,58 @@ def create_interface():
|
|
| 1938 |
pd (int): Number of days to predict (1-7)
|
| 1939 |
ld (int): Historical lookback period in days (1-60)
|
| 1940 |
st (str): Prediction strategy to use ("chronos" or "technical")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1941 |
|
| 1942 |
Returns:
|
| 1943 |
-
Tuple
|
| 1944 |
-
- Trading signals dictionary
|
| 1945 |
-
- Plotly figure with price and technical analysis
|
| 1946 |
-
- Product metrics dictionary
|
| 1947 |
-
- Risk metrics dictionary
|
| 1948 |
-
- Sector metrics dictionary
|
| 1949 |
-
|
| 1950 |
-
Example:
|
| 1951 |
-
>>> hourly_analysis("AAPL", 3, 14, "chronos")
|
| 1952 |
-
({'RSI': 'Neutral', 'MACD': 'Buy', ...}, <Figure>, {...}, {...}, {...})
|
| 1953 |
"""
|
| 1954 |
-
return analyze_stock(s, "1h", pd, ld, st)
|
| 1955 |
|
| 1956 |
hourly_predict_btn.click(
|
| 1957 |
fn=hourly_analysis,
|
| 1958 |
-
inputs=[hourly_symbol, hourly_prediction_days, hourly_lookback_days, hourly_strategy
|
|
|
|
|
|
|
| 1959 |
outputs=[hourly_signals, hourly_plot, hourly_metrics, hourly_risk_metrics, hourly_sector_metrics]
|
| 1960 |
)
|
| 1961 |
|
| 1962 |
# 15-minute analysis button click
|
| 1963 |
-
def min15_analysis(s: str, pd: int, ld: int, st: str
|
|
|
|
| 1964 |
"""
|
| 1965 |
-
Process 15-minute timeframe stock analysis
|
| 1966 |
|
| 1967 |
Args:
|
| 1968 |
s (str): Stock symbol (e.g., "AAPL", "MSFT", "GOOGL")
|
| 1969 |
pd (int): Number of days to predict (1-2)
|
| 1970 |
ld (int): Historical lookback period in days (1-7)
|
| 1971 |
st (str): Prediction strategy to use ("chronos" or "technical")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1972 |
|
| 1973 |
Returns:
|
| 1974 |
-
Tuple
|
| 1975 |
-
- Trading signals dictionary
|
| 1976 |
-
- Plotly figure with price and technical analysis
|
| 1977 |
-
- Product metrics dictionary
|
| 1978 |
-
- Risk metrics dictionary
|
| 1979 |
-
- Sector metrics dictionary
|
| 1980 |
-
|
| 1981 |
-
Example:
|
| 1982 |
-
>>> min15_analysis("AAPL", 1, 3, "chronos")
|
| 1983 |
-
({'RSI': 'Neutral', 'MACD': 'Buy', ...}, <Figure>, {...}, {...}, {...})
|
| 1984 |
"""
|
| 1985 |
-
return analyze_stock(s, "15m", pd, ld, st)
|
| 1986 |
|
| 1987 |
min15_predict_btn.click(
|
| 1988 |
fn=min15_analysis,
|
| 1989 |
-
inputs=[min15_symbol, min15_prediction_days, min15_lookback_days, min15_strategy
|
|
|
|
|
|
|
| 1990 |
outputs=[min15_signals, min15_plot, min15_metrics, min15_risk_metrics, min15_sector_metrics]
|
| 1991 |
)
|
| 1992 |
|
|
|
|
| 1692 |
daily_signals = gr.JSON(label="Trading Signals")
|
| 1693 |
|
| 1694 |
with gr.Column():
|
| 1695 |
+
gr.Markdown("### Sector & Financial Analysis")
|
| 1696 |
+
daily_sector_metrics = gr.JSON(label="Sector Metrics")
|
| 1697 |
+
|
| 1698 |
gr.Markdown("### Stress Test Results")
|
| 1699 |
daily_stress_results = gr.JSON(label="Stress Test Results")
|
| 1700 |
|
|
|
|
| 1941 |
pd (int): Number of days to predict (1-7)
|
| 1942 |
ld (int): Historical lookback period in days (1-60)
|
| 1943 |
st (str): Prediction strategy to use ("chronos" or "technical")
|
| 1944 |
+
ue (bool): Use ensemble methods
|
| 1945 |
+
urd (bool): Use regime detection
|
| 1946 |
+
ust (bool): Use stress testing
|
| 1947 |
+
rfr (float): Risk-free rate
|
| 1948 |
+
mi (str): Market index
|
| 1949 |
+
cw (float): Chronos weight
|
| 1950 |
+
tw (float): Technical weight
|
| 1951 |
+
sw (float): Statistical weight
|
| 1952 |
|
| 1953 |
Returns:
|
| 1954 |
+
Tuple containing analysis results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1955 |
"""
|
| 1956 |
+
return analyze_stock(s, "1h", pd, ld, st, ue, urd, ust, rfr, mi, cw, tw, sw)
|
| 1957 |
|
| 1958 |
hourly_predict_btn.click(
|
| 1959 |
fn=hourly_analysis,
|
| 1960 |
+
inputs=[hourly_symbol, hourly_prediction_days, hourly_lookback_days, hourly_strategy,
|
| 1961 |
+
use_ensemble, use_regime_detection, use_stress_testing, risk_free_rate, market_index,
|
| 1962 |
+
chronos_weight, technical_weight, statistical_weight],
|
| 1963 |
outputs=[hourly_signals, hourly_plot, hourly_metrics, hourly_risk_metrics, hourly_sector_metrics]
|
| 1964 |
)
|
| 1965 |
|
| 1966 |
# 15-minute analysis button click
|
| 1967 |
+
def min15_analysis(s: str, pd: int, ld: int, st: str, ue: bool, urd: bool, ust: bool,
|
| 1968 |
+
rfr: float, mi: str, cw: float, tw: float, sw: float) -> Tuple[Dict, go.Figure, Dict, Dict, Dict]:
|
| 1969 |
"""
|
| 1970 |
+
Process 15-minute timeframe stock analysis with advanced features.
|
| 1971 |
|
| 1972 |
Args:
|
| 1973 |
s (str): Stock symbol (e.g., "AAPL", "MSFT", "GOOGL")
|
| 1974 |
pd (int): Number of days to predict (1-2)
|
| 1975 |
ld (int): Historical lookback period in days (1-7)
|
| 1976 |
st (str): Prediction strategy to use ("chronos" or "technical")
|
| 1977 |
+
ue (bool): Use ensemble methods
|
| 1978 |
+
urd (bool): Use regime detection
|
| 1979 |
+
ust (bool): Use stress testing
|
| 1980 |
+
rfr (float): Risk-free rate
|
| 1981 |
+
mi (str): Market index
|
| 1982 |
+
cw (float): Chronos weight
|
| 1983 |
+
tw (float): Technical weight
|
| 1984 |
+
sw (float): Statistical weight
|
| 1985 |
|
| 1986 |
Returns:
|
| 1987 |
+
Tuple containing analysis results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1988 |
"""
|
| 1989 |
+
return analyze_stock(s, "15m", pd, ld, st, ue, urd, ust, rfr, mi, cw, tw, sw)
|
| 1990 |
|
| 1991 |
min15_predict_btn.click(
|
| 1992 |
fn=min15_analysis,
|
| 1993 |
+
inputs=[min15_symbol, min15_prediction_days, min15_lookback_days, min15_strategy,
|
| 1994 |
+
use_ensemble, use_regime_detection, use_stress_testing, risk_free_rate, market_index,
|
| 1995 |
+
chronos_weight, technical_weight, statistical_weight],
|
| 1996 |
outputs=[min15_signals, min15_plot, min15_metrics, min15_risk_metrics, min15_sector_metrics]
|
| 1997 |
)
|
| 1998 |
|