Spaces:
Running
on
Zero
Running
on
Zero
adds better docstrings , readme tags
Browse files
README.md
CHANGED
@@ -9,6 +9,8 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
short_description: Use Amazon Chronos To Predict Stock Prices
|
|
|
|
|
12 |
---
|
13 |
|
14 |
# Stock Analysis and Prediction Demo
|
|
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
short_description: Use Amazon Chronos To Predict Stock Prices
|
12 |
+
tags:
|
13 |
+
- mcp-server-track
|
14 |
---
|
15 |
|
16 |
# Stock Analysis and Prediction Demo
|
app.py
CHANGED
@@ -451,7 +451,6 @@ def create_interface():
|
|
451 |
with gr.Row():
|
452 |
with gr.Column():
|
453 |
|
454 |
-
|
455 |
gr.Markdown("### Structured Product Metrics")
|
456 |
daily_metrics = gr.JSON(label="Product Metrics")
|
457 |
|
@@ -605,22 +604,94 @@ def create_interface():
|
|
605 |
raise gr.Error(error_message)
|
606 |
|
607 |
# Daily analysis button click
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
daily_predict_btn.click(
|
609 |
-
fn=
|
610 |
inputs=[daily_symbol, daily_prediction_days, daily_lookback_days, daily_strategy],
|
611 |
outputs=[daily_signals, daily_plot, daily_metrics, daily_risk_metrics, daily_sector_metrics]
|
612 |
)
|
613 |
|
614 |
# Hourly analysis button click
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
hourly_predict_btn.click(
|
616 |
-
fn=
|
617 |
inputs=[hourly_symbol, hourly_prediction_days, hourly_lookback_days, hourly_strategy],
|
618 |
outputs=[hourly_signals, hourly_plot, hourly_metrics, hourly_risk_metrics, hourly_sector_metrics]
|
619 |
)
|
620 |
|
621 |
# 15-minute analysis button click
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
min15_predict_btn.click(
|
623 |
-
fn=
|
624 |
inputs=[min15_symbol, min15_prediction_days, min15_lookback_days, min15_strategy],
|
625 |
outputs=[min15_signals, min15_plot, min15_metrics, min15_risk_metrics, min15_sector_metrics]
|
626 |
)
|
|
|
451 |
with gr.Row():
|
452 |
with gr.Column():
|
453 |
|
|
|
454 |
gr.Markdown("### Structured Product Metrics")
|
455 |
daily_metrics = gr.JSON(label="Product Metrics")
|
456 |
|
|
|
604 |
raise gr.Error(error_message)
|
605 |
|
606 |
# Daily analysis button click
|
607 |
+
def daily_analysis(s: str, pd: int, ld: int, st: str) -> Tuple[Dict, go.Figure, Dict, Dict, Dict]:
|
608 |
+
"""
|
609 |
+
Process daily timeframe stock analysis and generate predictions.
|
610 |
+
|
611 |
+
Args:
|
612 |
+
s (str): Stock symbol (e.g., "AAPL", "MSFT", "GOOGL")
|
613 |
+
pd (int): Number of days to predict (1-365)
|
614 |
+
ld (int): Historical lookback period in days (1-3650)
|
615 |
+
st (str): Prediction strategy to use ("chronos" or "technical")
|
616 |
+
|
617 |
+
Returns:
|
618 |
+
Tuple[Dict, go.Figure, Dict, Dict, Dict]: A tuple containing:
|
619 |
+
- Trading signals dictionary
|
620 |
+
- Plotly figure with price and technical analysis
|
621 |
+
- Product metrics dictionary
|
622 |
+
- Risk metrics dictionary
|
623 |
+
- Sector metrics dictionary
|
624 |
+
|
625 |
+
Example:
|
626 |
+
>>> daily_analysis("AAPL", 30, 365, "chronos")
|
627 |
+
({'RSI': 'Neutral', 'MACD': 'Buy', ...}, <Figure>, {...}, {...}, {...})
|
628 |
+
"""
|
629 |
+
return analyze_stock(s, "1d", pd, ld, st)
|
630 |
+
|
631 |
daily_predict_btn.click(
|
632 |
+
fn=daily_analysis,
|
633 |
inputs=[daily_symbol, daily_prediction_days, daily_lookback_days, daily_strategy],
|
634 |
outputs=[daily_signals, daily_plot, daily_metrics, daily_risk_metrics, daily_sector_metrics]
|
635 |
)
|
636 |
|
637 |
# Hourly analysis button click
|
638 |
+
def hourly_analysis(s: str, pd: int, ld: int, st: str) -> Tuple[Dict, go.Figure, Dict, Dict, Dict]:
|
639 |
+
"""
|
640 |
+
Process hourly timeframe stock analysis and generate predictions.
|
641 |
+
|
642 |
+
Args:
|
643 |
+
s (str): Stock symbol (e.g., "AAPL", "MSFT", "GOOGL")
|
644 |
+
pd (int): Number of days to predict (1-7)
|
645 |
+
ld (int): Historical lookback period in days (1-30)
|
646 |
+
st (str): Prediction strategy to use ("chronos" or "technical")
|
647 |
+
|
648 |
+
Returns:
|
649 |
+
Tuple[Dict, go.Figure, Dict, Dict, Dict]: A tuple containing:
|
650 |
+
- Trading signals dictionary
|
651 |
+
- Plotly figure with price and technical analysis
|
652 |
+
- Product metrics dictionary
|
653 |
+
- Risk metrics dictionary
|
654 |
+
- Sector metrics dictionary
|
655 |
+
|
656 |
+
Example:
|
657 |
+
>>> hourly_analysis("AAPL", 3, 14, "chronos")
|
658 |
+
({'RSI': 'Neutral', 'MACD': 'Buy', ...}, <Figure>, {...}, {...}, {...})
|
659 |
+
"""
|
660 |
+
return analyze_stock(s, "1h", pd, ld, st)
|
661 |
+
|
662 |
hourly_predict_btn.click(
|
663 |
+
fn=hourly_analysis,
|
664 |
inputs=[hourly_symbol, hourly_prediction_days, hourly_lookback_days, hourly_strategy],
|
665 |
outputs=[hourly_signals, hourly_plot, hourly_metrics, hourly_risk_metrics, hourly_sector_metrics]
|
666 |
)
|
667 |
|
668 |
# 15-minute analysis button click
|
669 |
+
def min15_analysis(s: str, pd: int, ld: int, st: str) -> Tuple[Dict, go.Figure, Dict, Dict, Dict]:
|
670 |
+
"""
|
671 |
+
Process 15-minute timeframe stock analysis and generate predictions.
|
672 |
+
|
673 |
+
Args:
|
674 |
+
s (str): Stock symbol (e.g., "AAPL", "MSFT", "GOOGL")
|
675 |
+
pd (int): Number of days to predict (1-2)
|
676 |
+
ld (int): Historical lookback period in days (1-5)
|
677 |
+
st (str): Prediction strategy to use ("chronos" or "technical")
|
678 |
+
|
679 |
+
Returns:
|
680 |
+
Tuple[Dict, go.Figure, Dict, Dict, Dict]: A tuple containing:
|
681 |
+
- Trading signals dictionary
|
682 |
+
- Plotly figure with price and technical analysis
|
683 |
+
- Product metrics dictionary
|
684 |
+
- Risk metrics dictionary
|
685 |
+
- Sector metrics dictionary
|
686 |
+
|
687 |
+
Example:
|
688 |
+
>>> min15_analysis("AAPL", 1, 3, "chronos")
|
689 |
+
({'RSI': 'Neutral', 'MACD': 'Buy', ...}, <Figure>, {...}, {...}, {...})
|
690 |
+
"""
|
691 |
+
return analyze_stock(s, "15m", pd, ld, st)
|
692 |
+
|
693 |
min15_predict_btn.click(
|
694 |
+
fn=min15_analysis,
|
695 |
inputs=[min15_symbol, min15_prediction_days, min15_lookback_days, min15_strategy],
|
696 |
outputs=[min15_signals, min15_plot, min15_metrics, min15_risk_metrics, min15_sector_metrics]
|
697 |
)
|