Spaces:
Sleeping
Sleeping
V2.1: Fix Gradio compatibility (remove size, show_copy_button params)
Browse files
app.py
CHANGED
|
@@ -829,7 +829,7 @@ def ai_chat(question, temp):
|
|
| 829 |
# GRADIO APP
|
| 830 |
def build_app():
|
| 831 |
with gr.Blocks(
|
| 832 |
-
title="AlphaForge x K2 Think V2
|
| 833 |
theme=gr.themes.Soft(
|
| 834 |
primary_hue="blue", secondary_hue="indigo", neutral_hue="slate",
|
| 835 |
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"]
|
|
@@ -882,8 +882,8 @@ def build_app():
|
|
| 882 |
ticker_in = gr.Textbox(label="Ticker", value="AAPL", placeholder="e.g., AAPL, BTC-USD, EURUSD=X")
|
| 883 |
period_in = gr.Dropdown(label="Period", choices=["1mo","3mo","6mo","1y","2y","5y"], value="6mo")
|
| 884 |
interval_in = gr.Dropdown(label="Interval", choices=["1d","1wk","1mo"], value="1d")
|
| 885 |
-
analyze_btn = gr.Button("π Analyze", variant="primary"
|
| 886 |
-
ai_btn = gr.Button("π€ AI Deep Analysis (K2 Think V2)", variant="secondary"
|
| 887 |
with gr.Column(scale=2):
|
| 888 |
summary_out = gr.Markdown()
|
| 889 |
with gr.Row():
|
|
@@ -896,7 +896,7 @@ def build_app():
|
|
| 896 |
chart5 = gr.Plot(label="ADX Trend Strength")
|
| 897 |
chart6 = gr.Plot(label="Return Distribution")
|
| 898 |
with gr.Row():
|
| 899 |
-
ai_out = gr.Textbox(label="π€ K2 Think V2 Analysis", lines=30, max_lines=50
|
| 900 |
|
| 901 |
analyze_btn.click(fn=analyze_stock, inputs=[ticker_in, mkt_select, period_in, interval_in],
|
| 902 |
outputs=[chart1, chart2, chart3, chart4, chart5, chart6, summary_out])
|
|
@@ -908,8 +908,8 @@ def build_app():
|
|
| 908 |
with gr.Column(scale=1):
|
| 909 |
port_in = gr.Textbox(label="Tickers (comma-separated)", value="AAPL, MSFT, GOOGL, AMZN, NVDA")
|
| 910 |
port_period = gr.Dropdown(label="Lookback", choices=["6mo","1y","2y","3y"], value="1y")
|
| 911 |
-
opt_btn = gr.Button("π― Optimize", variant="primary"
|
| 912 |
-
ai_port_btn = gr.Button("π€ AI Portfolio Advice", variant="secondary"
|
| 913 |
with gr.Column(scale=2):
|
| 914 |
port_md = gr.Markdown()
|
| 915 |
with gr.Row():
|
|
@@ -918,7 +918,7 @@ def build_app():
|
|
| 918 |
with gr.Row():
|
| 919 |
weights_df = gr.DataFrame(label="Optimal Weights", interactive=False)
|
| 920 |
with gr.Row():
|
| 921 |
-
ai_port_out = gr.Textbox(label="π€ AI Portfolio Advice", lines=25, max_lines=40
|
| 922 |
opt_btn.click(fn=optimize_portfolio, inputs=[port_in, port_period], outputs=[frontier_plot, corr_plot, weights_df, port_md])
|
| 923 |
ai_port_btn.click(fn=ai_portfolio, inputs=[port_in, port_period], outputs=[ai_port_out])
|
| 924 |
|
|
@@ -928,7 +928,7 @@ def build_app():
|
|
| 928 |
pair_a = gr.Textbox(label="Ticker A (Long)", value="AAPL")
|
| 929 |
pair_b = gr.Textbox(label="Ticker B (Short)", value="MSFT")
|
| 930 |
pair_period = gr.Dropdown(label="Lookback", choices=["6mo","1y","2y"], value="1y")
|
| 931 |
-
pair_btn = gr.Button("Analyze Pair", variant="primary"
|
| 932 |
with gr.Column(scale=2):
|
| 933 |
pair_md = gr.Markdown()
|
| 934 |
with gr.Row():
|
|
@@ -945,7 +945,7 @@ def build_app():
|
|
| 945 |
opt_days = gr.Slider(label="Days to Expiry", minimum=7, maximum=365, value=30, step=7)
|
| 946 |
opt_rfr = gr.Slider(label="Risk-Free Rate (%)", minimum=0, maximum=10, value=4.5, step=0.25)
|
| 947 |
opt_vol = gr.Number(label="Vol Override (%)", value=0, info="0 = use historical vol")
|
| 948 |
-
opt_calc_btn = gr.Button("π Calculate Greeks", variant="primary"
|
| 949 |
with gr.Column(scale=2):
|
| 950 |
opt_md = gr.Markdown()
|
| 951 |
with gr.Row():
|
|
@@ -956,19 +956,19 @@ def build_app():
|
|
| 956 |
|
| 957 |
with gr.Tab("π Macro Analysis"):
|
| 958 |
with gr.Row():
|
| 959 |
-
macro_btn = gr.Button("π Analyze Global Macro (K2 Think V2)", variant="primary"
|
| 960 |
with gr.Row():
|
| 961 |
-
macro_out = gr.Textbox(label="π€ K2 Think V2 Macro Analysis", lines=40, max_lines=60
|
| 962 |
macro_btn.click(fn=ai_macro, outputs=[macro_out])
|
| 963 |
|
| 964 |
with gr.Tab("π¬ K2 Think V2 Chat"):
|
| 965 |
gr.Markdown("## Direct Chat with K2 Think V2")
|
| 966 |
gr.Markdown("Ask any financial question - strategy, market analysis, quant interview prep, portfolio advice.")
|
| 967 |
with gr.Row():
|
| 968 |
-
chat_in = gr.Textbox(label="Your Question", placeholder="e.g., 'Explain gamma scalping with a real trade example'", lines=4
|
| 969 |
-
chat_temp = gr.Slider(label="Temp", minimum=0, maximum=1, value=0.4, step=0.1
|
| 970 |
-
chat_btn = gr.Button("π Ask K2 Think V2", variant="primary"
|
| 971 |
-
chat_out = gr.Textbox(label="π€ Response", lines=30, max_lines=50
|
| 972 |
chat_btn.click(fn=ai_chat, inputs=[chat_in, chat_temp], outputs=[chat_out])
|
| 973 |
|
| 974 |
with gr.Tab("βΉοΈ About & Setup"):
|
|
|
|
| 829 |
# GRADIO APP
|
| 830 |
def build_app():
|
| 831 |
with gr.Blocks(
|
| 832 |
+
title="AlphaForge x K2 Think V2 - Institutional Quant Platform",
|
| 833 |
theme=gr.themes.Soft(
|
| 834 |
primary_hue="blue", secondary_hue="indigo", neutral_hue="slate",
|
| 835 |
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"]
|
|
|
|
| 882 |
ticker_in = gr.Textbox(label="Ticker", value="AAPL", placeholder="e.g., AAPL, BTC-USD, EURUSD=X")
|
| 883 |
period_in = gr.Dropdown(label="Period", choices=["1mo","3mo","6mo","1y","2y","5y"], value="6mo")
|
| 884 |
interval_in = gr.Dropdown(label="Interval", choices=["1d","1wk","1mo"], value="1d")
|
| 885 |
+
analyze_btn = gr.Button("π Analyze", variant="primary")
|
| 886 |
+
ai_btn = gr.Button("π€ AI Deep Analysis (K2 Think V2)", variant="secondary")
|
| 887 |
with gr.Column(scale=2):
|
| 888 |
summary_out = gr.Markdown()
|
| 889 |
with gr.Row():
|
|
|
|
| 896 |
chart5 = gr.Plot(label="ADX Trend Strength")
|
| 897 |
chart6 = gr.Plot(label="Return Distribution")
|
| 898 |
with gr.Row():
|
| 899 |
+
ai_out = gr.Textbox(label="π€ K2 Think V2 Analysis", lines=30, max_lines=50)
|
| 900 |
|
| 901 |
analyze_btn.click(fn=analyze_stock, inputs=[ticker_in, mkt_select, period_in, interval_in],
|
| 902 |
outputs=[chart1, chart2, chart3, chart4, chart5, chart6, summary_out])
|
|
|
|
| 908 |
with gr.Column(scale=1):
|
| 909 |
port_in = gr.Textbox(label="Tickers (comma-separated)", value="AAPL, MSFT, GOOGL, AMZN, NVDA")
|
| 910 |
port_period = gr.Dropdown(label="Lookback", choices=["6mo","1y","2y","3y"], value="1y")
|
| 911 |
+
opt_btn = gr.Button("π― Optimize", variant="primary")
|
| 912 |
+
ai_port_btn = gr.Button("π€ AI Portfolio Advice", variant="secondary")
|
| 913 |
with gr.Column(scale=2):
|
| 914 |
port_md = gr.Markdown()
|
| 915 |
with gr.Row():
|
|
|
|
| 918 |
with gr.Row():
|
| 919 |
weights_df = gr.DataFrame(label="Optimal Weights", interactive=False)
|
| 920 |
with gr.Row():
|
| 921 |
+
ai_port_out = gr.Textbox(label="π€ AI Portfolio Advice", lines=25, max_lines=40)
|
| 922 |
opt_btn.click(fn=optimize_portfolio, inputs=[port_in, port_period], outputs=[frontier_plot, corr_plot, weights_df, port_md])
|
| 923 |
ai_port_btn.click(fn=ai_portfolio, inputs=[port_in, port_period], outputs=[ai_port_out])
|
| 924 |
|
|
|
|
| 928 |
pair_a = gr.Textbox(label="Ticker A (Long)", value="AAPL")
|
| 929 |
pair_b = gr.Textbox(label="Ticker B (Short)", value="MSFT")
|
| 930 |
pair_period = gr.Dropdown(label="Lookback", choices=["6mo","1y","2y"], value="1y")
|
| 931 |
+
pair_btn = gr.Button("Analyze Pair", variant="primary")
|
| 932 |
with gr.Column(scale=2):
|
| 933 |
pair_md = gr.Markdown()
|
| 934 |
with gr.Row():
|
|
|
|
| 945 |
opt_days = gr.Slider(label="Days to Expiry", minimum=7, maximum=365, value=30, step=7)
|
| 946 |
opt_rfr = gr.Slider(label="Risk-Free Rate (%)", minimum=0, maximum=10, value=4.5, step=0.25)
|
| 947 |
opt_vol = gr.Number(label="Vol Override (%)", value=0, info="0 = use historical vol")
|
| 948 |
+
opt_calc_btn = gr.Button("π Calculate Greeks", variant="primary")
|
| 949 |
with gr.Column(scale=2):
|
| 950 |
opt_md = gr.Markdown()
|
| 951 |
with gr.Row():
|
|
|
|
| 956 |
|
| 957 |
with gr.Tab("π Macro Analysis"):
|
| 958 |
with gr.Row():
|
| 959 |
+
macro_btn = gr.Button("π Analyze Global Macro (K2 Think V2)", variant="primary")
|
| 960 |
with gr.Row():
|
| 961 |
+
macro_out = gr.Textbox(label="π€ K2 Think V2 Macro Analysis", lines=40, max_lines=60)
|
| 962 |
macro_btn.click(fn=ai_macro, outputs=[macro_out])
|
| 963 |
|
| 964 |
with gr.Tab("π¬ K2 Think V2 Chat"):
|
| 965 |
gr.Markdown("## Direct Chat with K2 Think V2")
|
| 966 |
gr.Markdown("Ask any financial question - strategy, market analysis, quant interview prep, portfolio advice.")
|
| 967 |
with gr.Row():
|
| 968 |
+
chat_in = gr.Textbox(label="Your Question", placeholder="e.g., 'Explain gamma scalping with a real trade example'", lines=4)
|
| 969 |
+
chat_temp = gr.Slider(label="Temp", minimum=0, maximum=1, value=0.4, step=0.1)
|
| 970 |
+
chat_btn = gr.Button("π Ask K2 Think V2", variant="primary")
|
| 971 |
+
chat_out = gr.Textbox(label="π€ Response", lines=30, max_lines=50)
|
| 972 |
chat_btn.click(fn=ai_chat, inputs=[chat_in, chat_temp], outputs=[chat_out])
|
| 973 |
|
| 974 |
with gr.Tab("βΉοΈ About & Setup"):
|