Remove About tab, replace exposed API key with generic message
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""AlphaForge V3.
|
| 2 |
import os, json, warnings, math, random, time, hashlib, threading
|
| 3 |
from datetime import datetime
|
| 4 |
warnings.filterwarnings('ignore')
|
|
@@ -668,7 +668,7 @@ button.secondary { background: #1a1a1a !important; color: #FF6B00 !important; bo
|
|
| 668 |
|
| 669 |
def build_app():
|
| 670 |
with gr.Blocks(
|
| 671 |
-
title="AlphaForge V3.
|
| 672 |
theme=gr.themes.Soft(primary_hue="orange", secondary_hue="cyan", neutral_hue="gray",
|
| 673 |
font=[gr.themes.GoogleFont("Roboto Mono"), "monospace"]),
|
| 674 |
css=CSS
|
|
@@ -676,7 +676,7 @@ def build_app():
|
|
| 676 |
gr.Markdown("""
|
| 677 |
<div style="text-align:center; padding: 20px 0;">
|
| 678 |
<h1 style="color:#FF6B00; font-family:'Roboto Mono',monospace; font-size:2.2em; margin:0;">
|
| 679 |
-
ALPHAFORGE V3.
|
| 680 |
</h1>
|
| 681 |
<p style="color:#888; font-family:'Roboto Mono',monospace; font-size:0.9em; margin:8px 0 0 0;">
|
| 682 |
Institutional Quant Trading Platform | K2 Think V2 Powered
|
|
@@ -815,63 +815,38 @@ def build_app():
|
|
| 815 |
se_md = gr.Markdown()
|
| 816 |
se_btn.click(fn=sentiment_analyzer, inputs=se_ticker, outputs=[se_gauge, se_md])
|
| 817 |
|
| 818 |
-
with gr.TabItem("Macro
|
| 819 |
with gr.Row():
|
| 820 |
-
|
| 821 |
-
|
|
|
|
|
|
|
| 822 |
ma_md = gr.Markdown()
|
| 823 |
ma_btn.click(fn=macro_analysis, inputs=[], outputs=[ma_fig, ma_md])
|
| 824 |
|
| 825 |
-
with gr.TabItem("
|
| 826 |
with gr.Row():
|
| 827 |
with gr.Column(scale=1):
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
k2_btn = gr.Button("Ask K2")
|
| 831 |
with gr.Column(scale=3):
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
| AI Analysis | K2 Think V2 chain-of-thought with 7-section structured output | MBZUAI K2 |
|
| 847 |
-
| Backtest | 5 strategies, ATR sizing, equity curves, drawdown | Jane Street |
|
| 848 |
-
| Portfolio | Markowitz MPT, 10K-portfolio MC, efficient frontier | AQR, D.E. Shaw |
|
| 849 |
-
| Options | Black-Scholes + full Greeks (DGThVR), scenario P/L | Goldman Sachs |
|
| 850 |
-
| Pairs | Cointegration, OLS hedge ratio, OU half-life, Z-score | Two Sigma |
|
| 851 |
-
| Crypto Arb | Cross-exchange spread heatmap, funding rate concepts | Jump Trading |
|
| 852 |
-
| Risk Engine | VaR 95/99, stress testing, correlation breakdown | Bridgewater |
|
| 853 |
-
| Sentiment | Composite gauge (-100 to +100), keyword extraction | Citadel NLP |
|
| 854 |
-
| Macro | Cross-asset regime dashboard (S&P, 10Y, Gold, Oil, DXY, BTC) | Bridgewater All Weather |
|
| 855 |
-
|
| 856 |
-
### K2 Think V2 API Key Setup
|
| 857 |
-
1. Go to Space Settings > Repository Secrets
|
| 858 |
-
2. Add secret: `K2_API_KEY`
|
| 859 |
-
3. No key required - all quant modules work standalone
|
| 860 |
-
|
| 861 |
-
### Data Notice
|
| 862 |
-
When Yahoo Finance rate-limits shared IPs (common on HF Spaces), the app falls back to **deterministic synthetic data** seeded by ticker + date. Same ticker = same data on the same day.
|
| 863 |
-
|
| 864 |
-
### Stack
|
| 865 |
-
- yfinance / synthetic fallback
|
| 866 |
-
- Plotly (Bloomberg Terminal aesthetic)
|
| 867 |
-
- NumPy/Pandas (vectorized quant math)
|
| 868 |
-
- K2 Think V2 (MBZUAI reasoning)
|
| 869 |
-
|
| 870 |
-
---
|
| 871 |
-
*Built by Premchan | Build with K2 Think V2*
|
| 872 |
-
""")
|
| 873 |
|
| 874 |
return app
|
| 875 |
|
| 876 |
if __name__ == "__main__":
|
| 877 |
-
build_app()
|
|
|
|
|
|
| 1 |
+
"""AlphaForge V3.2 - Institutional Quant Trading Platform (No About tab, no exposed API keys)"""
|
| 2 |
import os, json, warnings, math, random, time, hashlib, threading
|
| 3 |
from datetime import datetime
|
| 4 |
warnings.filterwarnings('ignore')
|
|
|
|
| 668 |
|
| 669 |
def build_app():
|
| 670 |
with gr.Blocks(
|
| 671 |
+
title="AlphaForge V3.2 - Institutional Quant Platform",
|
| 672 |
theme=gr.themes.Soft(primary_hue="orange", secondary_hue="cyan", neutral_hue="gray",
|
| 673 |
font=[gr.themes.GoogleFont("Roboto Mono"), "monospace"]),
|
| 674 |
css=CSS
|
|
|
|
| 676 |
gr.Markdown("""
|
| 677 |
<div style="text-align:center; padding: 20px 0;">
|
| 678 |
<h1 style="color:#FF6B00; font-family:'Roboto Mono',monospace; font-size:2.2em; margin:0;">
|
| 679 |
+
ALPHAFORGE V3.2
|
| 680 |
</h1>
|
| 681 |
<p style="color:#888; font-family:'Roboto Mono',monospace; font-size:0.9em; margin:8px 0 0 0;">
|
| 682 |
Institutional Quant Trading Platform | K2 Think V2 Powered
|
|
|
|
| 815 |
se_md = gr.Markdown()
|
| 816 |
se_btn.click(fn=sentiment_analyzer, inputs=se_ticker, outputs=[se_gauge, se_md])
|
| 817 |
|
| 818 |
+
with gr.TabItem("Macro"):
|
| 819 |
with gr.Row():
|
| 820 |
+
with gr.Column(scale=1):
|
| 821 |
+
ma_btn = gr.Button("Refresh Macro Dashboard")
|
| 822 |
+
with gr.Column(scale=3):
|
| 823 |
+
ma_fig = gr.Plot()
|
| 824 |
ma_md = gr.Markdown()
|
| 825 |
ma_btn.click(fn=macro_analysis, inputs=[], outputs=[ma_fig, ma_md])
|
| 826 |
|
| 827 |
+
with gr.TabItem("Chat (K2)"):
|
| 828 |
with gr.Row():
|
| 829 |
with gr.Column(scale=1):
|
| 830 |
+
chat_input = gr.Textbox(label="Ask K2 Think V2", value="Explain gamma scalping", lines=3)
|
| 831 |
+
chat_btn = gr.Button("Send")
|
|
|
|
| 832 |
with gr.Column(scale=3):
|
| 833 |
+
chat_output = gr.Textbox(label="Response", lines=30)
|
| 834 |
+
chat_btn.click(
|
| 835 |
+
fn=lambda q: K2ThinkClient().chat([{"role":"user","content":q}], temperature=0.4, max_tokens=4096),
|
| 836 |
+
inputs=chat_input, outputs=chat_output
|
| 837 |
+
)
|
| 838 |
+
|
| 839 |
+
gr.Markdown("""
|
| 840 |
+
<div style="text-align:center; padding: 20px 0; margin-top: 20px; border-top: 1px solid #333;">
|
| 841 |
+
<p style="color:#555; font-family:'Roboto Mono',monospace; font-size:0.75em;">
|
| 842 |
+
AlphaForge V3.2 | For demonstration purposes only. Not financial advice.
|
| 843 |
+
<br>Configure K2_API_KEY in Space Settings > Repository Secrets for AI features.
|
| 844 |
+
</p>
|
| 845 |
+
</div>
|
| 846 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 847 |
|
| 848 |
return app
|
| 849 |
|
| 850 |
if __name__ == "__main__":
|
| 851 |
+
app = build_app()
|
| 852 |
+
app.launch()
|