Spaces:
No application file
No application file
Delete Dockerfile, Dockerfile, app.py
Browse files- Dockerfile +0 -6
- app.py +0 -116
Dockerfile
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
FROM python:3.10-slim
|
| 2 |
-
WORKDIR /app
|
| 3 |
-
RUN pip install --no-cache-dir numpy pandas python-dateutil
|
| 4 |
-
COPY app.py .
|
| 5 |
-
EXPOSE 7860
|
| 6 |
-
CMD ["python","app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
DELETED
|
@@ -1,116 +0,0 @@
|
|
| 1 |
-
from http.server import HTTPServer, BaseHTTPRequestHandler
|
| 2 |
-
|
| 3 |
-
HTML = '''<!DOCTYPE html>
|
| 4 |
-
<html lang="en">
|
| 5 |
-
<head>
|
| 6 |
-
<meta charset="UTF-8">
|
| 7 |
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
| 8 |
-
<title>AlphaForge Pro</title>
|
| 9 |
-
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
|
| 10 |
-
<style>
|
| 11 |
-
:root{--bg:#0a0e17;--card:#111827;--accent:#38bdf8;--green:#10b981;--red:#ef4444;--yellow:#f59e0b;--text:#94a3b8;--bright:#e2e8f0;--border:#1e293b}
|
| 12 |
-
*{margin:0;padding:0;box-sizing:border-box}
|
| 13 |
-
body{background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,sans-serif;min-height:100vh}
|
| 14 |
-
.header{background:var(--card);padding:10px 24px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--border)}
|
| 15 |
-
.header .brand{color:var(--accent);font-size:20px;font-weight:800}
|
| 16 |
-
.header .meta{color:var(--text);font-size:12px}
|
| 17 |
-
.kpi-row{display:flex;gap:10px;flex-wrap:wrap;padding:16px 24px}
|
| 18 |
-
.kpi{background:var(--card);border:1px solid var(--border);border-radius:10px;padding:14px 18px;text-align:center;min-width:110px;flex:1}
|
| 19 |
-
.kpi .kpi-val{color:var(--accent);font-size:22px;font-weight:700}
|
| 20 |
-
.kpi .kpi-lbl{color:var(--text);font-size:11px;text-transform:uppercase;margin-top:4px}
|
| 21 |
-
.main-grid{display:grid;grid-template-columns:280px 1fr;gap:16px;padding:0 24px 40px}
|
| 22 |
-
.panel{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:16px;margin-bottom:16px}
|
| 23 |
-
.panel-title{color:var(--bright);font-weight:600;margin-bottom:12px}
|
| 24 |
-
.chart-container{min-height:320px}
|
| 25 |
-
.pos-pill{display:inline-block;background:rgba(30,41,59,0.5);border:1px solid var(--border);border-radius:8px;padding:6px 12px;margin:3px;font-size:13px}
|
| 26 |
-
.pos-pill .sym{color:var(--accent);font-weight:700}
|
| 27 |
-
.alert{background:var(--card);border-left:3px solid var(--accent);border-radius:4px;padding:8px 12px;margin:4px 0;font-size:12px}
|
| 28 |
-
@media(max-width:900px){.main-grid{grid-template-columns:1fr}}
|
| 29 |
-
</style>
|
| 30 |
-
</head>
|
| 31 |
-
<body>
|
| 32 |
-
<div class="header">
|
| 33 |
-
<div class="brand">AlphaForge Pro</div>
|
| 34 |
-
<div class="meta" id="timestamp"></div>
|
| 35 |
-
</div>
|
| 36 |
-
<div class="kpi-row" id="kpis"></div>
|
| 37 |
-
<div class="main-grid">
|
| 38 |
-
<div id="left-panel">
|
| 39 |
-
<div class="panel"><div class="panel-title">Portfolio</div><div id="positions"></div></div>
|
| 40 |
-
<div class="panel"><div class="panel-title">Market Regime</div><div class="chart-container" id="chart-regime"></div></div>
|
| 41 |
-
<div class="panel"><div class="panel-title">Sentiment</div><div class="chart-container" id="chart-sentiment"></div></div>
|
| 42 |
-
<div class="panel"><div class="panel-title">Alerts</div><div id="alerts"></div></div>
|
| 43 |
-
</div>
|
| 44 |
-
<div id="right-panel">
|
| 45 |
-
<div class="panel"><div class="panel-title">PnL & Drawdown</div><div class="chart-container" id="chart-pnl"></div></div>
|
| 46 |
-
<div class="panel"><div class="panel-title">Risk</div><div class="chart-container" id="chart-risk"></div></div>
|
| 47 |
-
<div class="panel"><div class="panel-title">Portfolio Weights</div><div class="chart-container" id="chart-weights"></div></div>
|
| 48 |
-
</div>
|
| 49 |
-
</div>
|
| 50 |
-
<script>
|
| 51 |
-
// --- Data ---
|
| 52 |
-
const sharpe=1.82,sortino=2.14,maxDD=-4.3,var95=18340,calmar=4.2;
|
| 53 |
-
const pos={SPY:0.18,QQQ:0.15,AAPL:0.10,MSFT:0.12,GOOGL:0.08,AMZN:0.07,META:0.06,NVDA:0.14,TSLA:0.05,JPM:0.05};
|
| 54 |
-
const sent={AAPL:0.72,MSFT:0.65,NVDA:0.88,TSLA:-0.34,SPY:0.15};
|
| 55 |
-
const alerts=[{t:"10:23",l:"info",ti:"Backtest Complete",tx:"Sharpe: 1.82, Max DD: -4.3%"},{t:"10:24",l:"warn",ti:"Volatility Spike",tx:"VIX at 28.5, reducing exposure"},{t:"10:25",l:"info",ti:"Regime Change",tx:"Switched to bull — increasing equity"}];
|
| 56 |
-
|
| 57 |
-
// --- KPIs ---
|
| 58 |
-
document.getElementById("kpis").innerHTML=[
|
| 59 |
-
["$"+pnlArr.slice(-1)[0].toLocaleString("en-US",{maximumFractionDigits:0}),"PnL"],
|
| 60 |
-
[sharpe.toFixed(2),"Sharpe",sharpe>=1?"var(--green)":"var(--yellow)"],
|
| 61 |
-
[sortino.toFixed(2),"Sortino"],
|
| 62 |
-
[maxDD.toFixed(1)+"%","Max DD","var(--red)"],
|
| 63 |
-
["$"+var95.toLocaleString("en-US",{maximumFractionDigits:0}),"VaR 95%","var(--yellow)"],
|
| 64 |
-
[calmar.toFixed(2),"Calmar"],
|
| 65 |
-
["+12.1%","Alpha","var(--green)"],
|
| 66 |
-
["0.95","Beta"]
|
| 67 |
-
].map(([v,l,c])=>`<div class="kpi"><div class="kpi-val" style="color:${c||"var(--accent)"}">${v}</div><div class="kpi-lbl">${l}</div></div>`).join("");
|
| 68 |
-
|
| 69 |
-
// --- Positions ---
|
| 70 |
-
document.getElementById("positions").innerHTML=Object.entries(pos).sort((a,b)=>b[1]-a[1]).map(([s,w])=>`<span class="pos-pill"><span class="sym">${s}</span> ${(w*100).toFixed(1)}%</span>`).join(" ");
|
| 71 |
-
|
| 72 |
-
// --- Alerts ---
|
| 73 |
-
const ac={"info":"var(--accent)","warn":"var(--yellow)","error":"var(--red)"};
|
| 74 |
-
document.getElementById("alerts").innerHTML=alerts.map(a=>`<div class="alert" style="border-left-color:${ac[a.l]}"><b style="color:${ac[a.l]}">[${a.t}] ${a.ti}</b> ${a.tx}</div>`).join("");
|
| 75 |
-
|
| 76 |
-
// --- Charts ---
|
| 77 |
-
const lo={template:"plotly_dark",paper_bgcolor:"#0a0e17",plot_bgcolor:"#0a0e17",font:{color:"#94a3b8",size:11},showlegend:false,margin:{l:8,r:24,t:32,b:8}};
|
| 78 |
-
|
| 79 |
-
// PnL
|
| 80 |
-
{"".join([f"const d{i}=new Date('{d.strftime('%Y-%m-%d')}');" for i, d in enumerate(dates_arr[:5])])}
|
| 81 |
-
Plotly.newPlot("chart-pnl",[
|
| 82 |
-
{type:"scatter",x:dates.map(d=>d.toISOString().slice(0,10)),y:pnlArr,line:{color:"#38bdf8",width:2},name:"PnL"},
|
| 83 |
-
{type:"scatter",x:dates.map(d=>d.toISOString().slice(0,10)),y:ddArr.map(v=>v*100),line:{color:"#ef4444",width:1.5},name:"Drawdown %",yaxis:"y2"}
|
| 84 |
-
],{...lo,height:400,yaxis:{tickprefix:"$",tickformat:",.0f"},yaxis2:{ticksuffix:"%",overlaying:"y",side:"right"},grid:{rows:2,columns:1,roworder:"top to bottom",pattern:"independent"}});
|
| 85 |
-
|
| 86 |
-
// Risk
|
| 87 |
-
Plotly.newPlot("chart-risk",[
|
| 88 |
-
{type:"scatter",x:dates.map(d=>d.toISOString().slice(0,10)),y:rollingSharpe,line:{color:"#38bdf8",width:2},name:"Rolling Sharpe"},
|
| 89 |
-
{type:"scatter",x:dates.map(d=>d.toISOString().slice(0,10)),y:Array(dates.length).fill(sharpe),line:{color:"#ef4444",dash:"dot",width:1},name:"Avg"},
|
| 90 |
-
{type:"scatter",x:dates.map(d=>d.toISOString().slice(0,10)),y:rollingVol,line:{color:"#f59e0b",width:2},name:"Vol %",yaxis:"y2"}
|
| 91 |
-
],{...lo,height:360,yaxis2:{ticksuffix:"%",overlaying:"y",side:"right"},grid:{rows:2,columns:1,roworder:"top to bottom",pattern:"independent"}});
|
| 92 |
-
|
| 93 |
-
// Weights
|
| 94 |
-
Plotly.newPlot("chart-weights",[{type:"bar",x:Object.keys(pos),y:Object.values(pos).map(v=>v*100),marker:{color:["#38bdf8","#38bdf8","#38bdf8","#6366f1","#6366f1","#6366f1","#10b981","#10b981","#8b5cf6","#8b5cf6"]}}],{...lo,height:280,yaxis:{title:"Weight %"}});
|
| 95 |
-
|
| 96 |
-
// Regime
|
| 97 |
-
Plotly.newPlot("chart-regime",[{type:"pie",labels:["Bull","Bear","High Vol","Neutral"],values:[0.45,0.12,0.28,0.15],hole:0.55,marker:{colors:["#10b981","#ef4444","#f59e0b","#64748b"]},textinfo:"label+percent"}],{...lo,height:240});
|
| 98 |
-
|
| 99 |
-
// Sentiment
|
| 100 |
-
Plotly.newPlot("chart-sentiment",[{type:"bar",x:Object.keys(sent),y:Object.values(sent),marker:{color:Object.values(sent).map(v=>v>0?"#10b981":"#ef4444")}}],{...lo,height:240,yaxis:{range:[-1.1,1.1]}});
|
| 101 |
-
|
| 102 |
-
// Timestamp
|
| 103 |
-
document.getElementById("timestamp").textContent=new Date().toLocaleString();
|
| 104 |
-
</script>
|
| 105 |
-
</body>
|
| 106 |
-
</html>'''
|
| 107 |
-
|
| 108 |
-
class Handler(BaseHTTPRequestHandler):
|
| 109 |
-
def do_GET(self):
|
| 110 |
-
self.send_response(200)
|
| 111 |
-
self.send_header("Content-Type","text/html")
|
| 112 |
-
self.end_headers()
|
| 113 |
-
self.wfile.write(HTML.encode())
|
| 114 |
-
|
| 115 |
-
if __name__ == "__main__":
|
| 116 |
-
HTTPServer(("0.0.0.0",7860),Handler).serve_forever()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|