PROSTLE commited on
Commit
7d603aa
·
1 Parent(s): 4238963

Refined dashboard UI layout, integrated taskbar, fixed chart rendering bug

Browse files
backend/__pycache__/app.cpython-313.pyc CHANGED
Binary files a/backend/__pycache__/app.cpython-313.pyc and b/backend/__pycache__/app.cpython-313.pyc differ
 
backend/__pycache__/intraday_model.cpython-313.pyc CHANGED
Binary files a/backend/__pycache__/intraday_model.cpython-313.pyc and b/backend/__pycache__/intraday_model.cpython-313.pyc differ
 
backend/__pycache__/model.cpython-313.pyc CHANGED
Binary files a/backend/__pycache__/model.cpython-313.pyc and b/backend/__pycache__/model.cpython-313.pyc differ
 
backend/__pycache__/sentiment.cpython-313.pyc CHANGED
Binary files a/backend/__pycache__/sentiment.cpython-313.pyc and b/backend/__pycache__/sentiment.cpython-313.pyc differ
 
backend/__pycache__/stock_data.cpython-313.pyc CHANGED
Binary files a/backend/__pycache__/stock_data.cpython-313.pyc and b/backend/__pycache__/stock_data.cpython-313.pyc differ
 
backend/__pycache__/trader.cpython-313.pyc CHANGED
Binary files a/backend/__pycache__/trader.cpython-313.pyc and b/backend/__pycache__/trader.cpython-313.pyc differ
 
backend/backtest.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import yfinance as yf
3
+ import numpy as np
4
+ import sys
5
+ import os
6
+
7
+ from stock_data import fetch_stock_data, add_technical_indicators
8
+ from technical_signals import score_technical_signals
9
+ from model import train_and_predict
10
+
11
+ def run_backtest(ticker="RELIANCE.NS", test_days=5):
12
+ print(f"Running Backtest for {ticker} over {test_days} periods...")
13
+ raw_df = fetch_stock_data(ticker, period="1y")
14
+ full_df = add_technical_indicators(raw_df)
15
+
16
+ T = len(full_df) - test_days
17
+ df_train = full_df.iloc[:T].copy()
18
+ actual_future = full_df["Close"].iloc[T:T+test_days].values
19
+
20
+ current_price = df_train["Close"].iloc[-1]
21
+
22
+ tech = score_technical_signals(df_train)
23
+ tech_score = tech.get("score", 0.0)
24
+ atr_pct = (df_train["ATR"].iloc[-1] / current_price * 100) if "ATR" in df_train else 0.0
25
+
26
+ print(f"Current Price before test window: {current_price:.2f}")
27
+
28
+ res = train_and_predict(
29
+ df_train,
30
+ epochs=30, # Decent train time
31
+ sentiment_score=0.0,
32
+ technical_score=tech_score,
33
+ llm_score=0.0,
34
+ atr_pct=atr_pct,
35
+ vix_level=15.0
36
+ )
37
+
38
+ preds = res["predicted_prices"]
39
+ print("Actual Prices: ", [round(x, 2) for x in actual_future])
40
+ print("Predicted Prices:", preds)
41
+
42
+ mape = np.mean([abs(a - p) / a for a, p in zip(actual_future, preds)]) * 100
43
+ acc = 100 - mape
44
+ print(f"Prediction Accuracy: {acc:.2f}%")
45
+ return acc
46
+
47
+ if __name__ == "__main__":
48
+ ticker = sys.argv[1] if len(sys.argv) > 1 else "RELIANCE.NS"
49
+ run_backtest(ticker, 5)
backend/enterprise_models.py CHANGED
@@ -67,16 +67,23 @@ def _build_tabular_dataset(df: pd.DataFrame, target_shift: int = PREDICT_DAYS):
67
  ] if c in df.columns]
68
  df = df.dropna(subset=feature_cols)
69
 
70
- # Target: close price at t+target_shift
71
- df["target"] = df["Close"].shift(-target_shift)
72
- df = df.dropna(subset=["target"])
 
 
73
 
74
- if len(df) < 50:
75
- return None, None, None
 
 
 
 
 
76
 
77
- X = df[feature_cols].values.astype(np.float64)
78
- y = df["target"].values.astype(np.float64)
79
- return X, y, df[feature_cols]
80
 
81
 
82
  def _quadratic_interpolate(current_price: float, pred_day3: float, pred_day5: float) -> list[float]:
@@ -111,8 +118,8 @@ def _dual_target_predict(df, current_price, fit_fn):
111
  quadratic interpolated 5-day curve. Much more realistic than linear.
112
  fit_fn(X_train, y_train) -> model with .predict(X) method.
113
  """
114
- X3, y3, _ = _build_tabular_dataset(df, target_shift=3)
115
- X5, y5, _ = _build_tabular_dataset(df, target_shift=5)
116
  if X3 is None or X5 is None or len(X3) < 50 or len(X5) < 50:
117
  return None
118
 
@@ -122,8 +129,11 @@ def _dual_target_predict(df, current_price, fit_fn):
122
  model3 = fit_fn(X3[:split3], y3[:split3])
123
  model5 = fit_fn(X5[:split5], y5[:split5])
124
 
125
- pred_day3 = float(model3.predict(X3[-1:])[0])
126
- pred_day5 = float(model5.predict(X5[-1:])[0])
 
 
 
127
 
128
  return _quadratic_interpolate(current_price, pred_day3, pred_day5)
129
 
@@ -147,7 +157,7 @@ def predict_h2o(df: pd.DataFrame, current_price: float) -> list[float] | None:
147
  """H2O.ai AutoML prediction. Uses H2O if available, else sklearn fallback."""
148
  if H2O_AVAILABLE:
149
  try:
150
- X, y, frame = _build_tabular_dataset(df)
151
  if X is None or len(X) < 80:
152
  return _predict_h2o_local(df, current_price)
153
 
@@ -159,10 +169,11 @@ def predict_h2o(df: pd.DataFrame, current_price: float) -> list[float] | None:
159
  aml = H2OAutoML(max_models=5, max_runtime_secs=60, seed=42)
160
  aml.train(x=x_cols, y="target", training_frame=hf)
161
 
162
- last_row = pd.DataFrame(X[-1:], columns=x_cols)
163
  hf_pred = h2o.H2OFrame(last_row)
164
  pred = aml.predict(hf_pred)
165
- pred_day5 = float(pred.as_data_frame().iloc[0, 0])
 
166
  h2o.shutdown(prompt=False)
167
 
168
  # H2O only predicts day-5, so we use linear interpolation for now.
@@ -186,12 +197,13 @@ def predict_datarobot(df: pd.DataFrame, current_price: float) -> list[float] | N
186
  if DATAROBOT_AVAILABLE and dr_url and dr_key and deployment_id:
187
  try:
188
  dr.Client(token=dr_key, endpoint=dr_url)
189
- X, y, frame = _build_tabular_dataset(df)
190
  if X is None:
191
  return None
192
- last_row = pd.DataFrame(X[-1:], columns=frame.columns)
193
  pred = dr.PredictionEndpoint.predict(deployment_id, last_row)
194
- pred_day5 = float(pred.loc[0, "prediction"])
 
195
  return [round(current_price + (i / PREDICT_DAYS) * (pred_day5 - current_price), 2)
196
  for i in range(1, PREDICT_DAYS + 1)]
197
  except Exception:
 
67
  ] if c in df.columns]
68
  df = df.dropna(subset=feature_cols)
69
 
70
+ # Extract the very latest row (today's features) BEFORE shifting target
71
+ if len(df) < 50 + target_shift:
72
+ return None, None, None, None
73
+
74
+ X_latest = df[feature_cols].values[-1:].astype(np.float64)
75
 
76
+ # Target: percentage return at t+target_shift for training (prevents tree extrapolation limits)
77
+ df_train = df.copy()
78
+ df_train["target"] = (df_train["Close"].shift(-target_shift) / df_train["Close"]) - 1
79
+ df_train = df_train.dropna(subset=["target"])
80
+
81
+ if len(df_train) < 50:
82
+ return None, None, None, None
83
 
84
+ X_train = df_train[feature_cols].values.astype(np.float64)
85
+ y_train = df_train["target"].values.astype(np.float64)
86
+ return X_train, y_train, X_latest, df_train[feature_cols]
87
 
88
 
89
  def _quadratic_interpolate(current_price: float, pred_day3: float, pred_day5: float) -> list[float]:
 
118
  quadratic interpolated 5-day curve. Much more realistic than linear.
119
  fit_fn(X_train, y_train) -> model with .predict(X) method.
120
  """
121
+ X3, y3, X3_latest, _ = _build_tabular_dataset(df, target_shift=3)
122
+ X5, y5, X5_latest, _ = _build_tabular_dataset(df, target_shift=5)
123
  if X3 is None or X5 is None or len(X3) < 50 or len(X5) < 50:
124
  return None
125
 
 
129
  model3 = fit_fn(X3[:split3], y3[:split3])
130
  model5 = fit_fn(X5[:split5], y5[:split5])
131
 
132
+ pred_day3_return = float(model3.predict(X3_latest)[0])
133
+ pred_day5_return = float(model5.predict(X5_latest)[0])
134
+
135
+ pred_day3 = current_price * (1 + pred_day3_return)
136
+ pred_day5 = current_price * (1 + pred_day5_return)
137
 
138
  return _quadratic_interpolate(current_price, pred_day3, pred_day5)
139
 
 
157
  """H2O.ai AutoML prediction. Uses H2O if available, else sklearn fallback."""
158
  if H2O_AVAILABLE:
159
  try:
160
+ X, y, X_latest, frame = _build_tabular_dataset(df)
161
  if X is None or len(X) < 80:
162
  return _predict_h2o_local(df, current_price)
163
 
 
169
  aml = H2OAutoML(max_models=5, max_runtime_secs=60, seed=42)
170
  aml.train(x=x_cols, y="target", training_frame=hf)
171
 
172
+ last_row = pd.DataFrame(X_latest, columns=x_cols)
173
  hf_pred = h2o.H2OFrame(last_row)
174
  pred = aml.predict(hf_pred)
175
+ pred_day5_return = float(pred.as_data_frame().iloc[0, 0])
176
+ pred_day5 = current_price * (1 + pred_day5_return)
177
  h2o.shutdown(prompt=False)
178
 
179
  # H2O only predicts day-5, so we use linear interpolation for now.
 
197
  if DATAROBOT_AVAILABLE and dr_url and dr_key and deployment_id:
198
  try:
199
  dr.Client(token=dr_key, endpoint=dr_url)
200
+ X, y, X_latest, frame = _build_tabular_dataset(df)
201
  if X is None:
202
  return None
203
+ last_row = pd.DataFrame(X_latest, columns=frame.columns)
204
  pred = dr.PredictionEndpoint.predict(deployment_id, last_row)
205
+ pred_day5_return = float(pred.loc[0, "prediction"])
206
+ pred_day5 = current_price * (1 + pred_day5_return)
207
  return [round(current_price + (i / PREDICT_DAYS) * (pred_day5 - current_price), 2)
208
  for i in range(1, PREDICT_DAYS + 1)]
209
  except Exception:
backend/model.py CHANGED
@@ -29,14 +29,14 @@ W_LLM = 0.32 # Google Gemini market analysis
29
 
30
  # Max price adjustment from directional factors (% of price)
31
  # Prevents extreme swings from sentiment/LLM alone
32
- MAX_DIRECTIONAL_IMPACT_PCT = 3.0
33
 
34
  # Drawdown dampening: when recent 2-day drop > 3%, reduce rubber-band bounce
35
  DRAWDOWN_THRESHOLD_PCT = 2.9
36
- DAMPER_STRENGTH = 0.45 # moderate damping; too high creates flatline
37
 
38
  # Minimum daily price movement as % of price (prevents dead-pulse flat lines)
39
- MIN_DAILY_MOVE_PCT = 0.15
40
 
41
  # Deterministic seed for reproducibility
42
  RANDOM_SEED = 42
@@ -374,7 +374,7 @@ def train_and_predict(
374
  test_preds = model(X_test_t).numpy()
375
  test_loss = float(criterion(torch.tensor(test_preds), y_test_t))
376
 
377
- confidence = max(0, min(100, round((1 - test_loss * 10) * 100, 1)))
378
  if confidence >= 70:
379
  risk = "Low"
380
  elif confidence >= 45:
 
29
 
30
  # Max price adjustment from directional factors (% of price)
31
  # Prevents extreme swings from sentiment/LLM alone
32
+ MAX_DIRECTIONAL_IMPACT_PCT = 2.0
33
 
34
  # Drawdown dampening: when recent 2-day drop > 3%, reduce rubber-band bounce
35
  DRAWDOWN_THRESHOLD_PCT = 2.9
36
+ DAMPER_STRENGTH = 0.70 # smoother damping; flattens 'V' shape bounce
37
 
38
  # Minimum daily price movement as % of price (prevents dead-pulse flat lines)
39
+ MIN_DAILY_MOVE_PCT = 0.05
40
 
41
  # Deterministic seed for reproducibility
42
  RANDOM_SEED = 42
 
374
  test_preds = model(X_test_t).numpy()
375
  test_loss = float(criterion(torch.tensor(test_preds), y_test_t))
376
 
377
+ confidence = max(5, min(95, round((1 - test_loss * 5) * 100, 1)))
378
  if confidence >= 70:
379
  risk = "Low"
380
  elif confidence >= 45:
backend/portfolio.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "balance": 765802.6,
3
  "initial_balance": 850000.0,
4
  "positions": {
5
  "BHARTIARTL.NS": {
@@ -23,6 +23,28 @@
23
  "regime": "SIDEWAYS",
24
  "buy_time": "2026-02-14T00:07:30.503438",
25
  "bar_count": 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
  },
28
  "trade_history": [],
@@ -35,5 +57,11 @@
35
  "timestamp": "2026-02-13T23:31:16.126691",
36
  "status": "success"
37
  }
 
 
 
 
 
 
38
  ]
39
- }
 
1
  {
2
+ "balance": 690721.6,
3
  "initial_balance": 850000.0,
4
  "positions": {
5
  "BHARTIARTL.NS": {
 
23
  "regime": "SIDEWAYS",
24
  "buy_time": "2026-02-14T00:07:30.503438",
25
  "bar_count": 0
26
+ },
27
+ "TCS.NS": {
28
+ "ticker": "TCS.NS",
29
+ "shares": 29,
30
+ "buy_price": 2589.0,
31
+ "cost": 75081.0,
32
+ "stop_loss": 2550.16,
33
+ "tp1": 2640.78,
34
+ "tp2": null,
35
+ "trailing_stop": 2550.16,
36
+ "peak_price": 2589.0,
37
+ "predicted_prices": [
38
+ 2821.39,
39
+ 2930.99,
40
+ 3030.35,
41
+ 3038.75,
42
+ 3051.34
43
+ ],
44
+ "confidence": 53.9,
45
+ "regime": "SIDEWAYS",
46
+ "buy_time": "2026-04-09T20:21:39.850556",
47
+ "bar_count": 1
48
  }
49
  },
50
  "trade_history": [],
 
57
  "timestamp": "2026-02-13T23:31:16.126691",
58
  "status": "success"
59
  }
60
+ ],
61
+ "value_history": [
62
+ {
63
+ "timestamp": "2026-04-09T20:21:39.851630",
64
+ "value": 850000.0
65
+ }
66
  ]
67
+ }
backend/reliability_scoring.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Reliability Score Calculator (Pseudo-code)
3
+ Pillars:
4
+ - 40% Fundamental Health (Piotroski F-Score + Altman Z-Score)
5
+ - 30% AI News Sentiment (30-day NLP)
6
+ - 30% Technical Volatility (Beta + Std Dev penalty)
7
+ """
8
+
9
+ def compute_fundamentals_score(financials):
10
+ """
11
+ Simulates calculating Piotroski F-score and Altman Z-score.
12
+ Maps results to a base 100-point scale.
13
+ """
14
+ print(f"[*] Calculating fundamental solvency for {financials.get('ticker')}...")
15
+ f_score = 7 # Out of 9
16
+ z_score = 3.2 # Safe zone > 2.99
17
+
18
+ # Base mapping: F-Score gives up to 60 pts, Z score up to 40 pts
19
+ fundamental_strength = (f_score / 9) * 60 + min(40, (z_score / 3.0) * 40)
20
+ return fundamental_strength
21
+
22
+
23
+ def compute_sentiment_score(nlp_results):
24
+ """
25
+ Analyzes historical sentiment data. Penalizes highly erratic behavior.
26
+ """
27
+ bullish_pct = nlp_results.count('bullish') / len(nlp_results)
28
+ bearish_pct = nlp_results.count('bearish') / len(nlp_results)
29
+
30
+ # Scale from 0 to 100. We want a strong bullish ratio.
31
+ net_sentiment = bullish_pct - bearish_pct
32
+ base = 50 + (net_sentiment * 50)
33
+ return max(0, min(100, base))
34
+
35
+
36
+ def compute_volatility_score(beta, std_dev):
37
+ """
38
+ Scores the stock's stability relative to the index.
39
+ Beta ~ 1.0 is stable.
40
+ High beta / high std dev is penalized for 'long term reliability'.
41
+ """
42
+ # Ideal beta for stable reliability is ~0.8 to 1.1
43
+ beta_penalty = abs(1.0 - beta) * 50
44
+ score = 100 - beta_penalty
45
+
46
+ if std_dev > 0.05: # e.g., >5% daily volatility
47
+ score -= 20
48
+
49
+ return max(0, min(100, score))
50
+
51
+
52
+ def calculate_long_term_reliability(ticker):
53
+ # Data aggregation mock
54
+ financials = {"ticker": ticker, "fcf": 91_000_000}
55
+ nlp_results = ['bullish'] * 20 + ['neutral'] * 5 + ['bearish'] * 5 # 30 day window
56
+ beta = 1.05
57
+ std_dev = 0.02
58
+
59
+ # --- Pillar Integration weights ---
60
+ W_FUNDAMENTAL = 0.40
61
+ W_SENTIMENT = 0.30
62
+ W_VOLATILITY = 0.30
63
+
64
+ score_fund = compute_fundamentals_score(financials)
65
+ score_sent = compute_sentiment_score(nlp_results)
66
+ score_vol = compute_volatility_score(beta, std_dev)
67
+
68
+ final_score = (
69
+ (score_fund * W_FUNDAMENTAL) +
70
+ (score_sent * W_SENTIMENT) +
71
+ (score_vol * W_VOLATILITY)
72
+ )
73
+
74
+ return {
75
+ "ticker": ticker,
76
+ "score_out_of_100": int(final_score),
77
+ "pillars": {
78
+ "fundamentals": round(score_fund, 2),
79
+ "sentiment": round(score_sent, 2),
80
+ "volatility": round(score_vol, 2)
81
+ }
82
+ }
83
+
84
+ # Example execution:
85
+ # res = calculate_long_term_reliability("LT.NS")
86
+ # print(f"Reliability Score: {res['score_out_of_100']}/100")
frontend/app.js CHANGED
@@ -611,6 +611,7 @@ function drawPredictionChart(pred) {
611
  },
612
  options: {
613
  responsive: true,
 
614
  plugins: { legend: { labels: { color: "#6b7280" } } },
615
  scales: {
616
  x: { ticks: { color: "#4b5563", maxTicksLimit: 10, maxRotation: 45, font: { size: 9 } }, grid: { color: "#1f2937" } },
@@ -750,13 +751,13 @@ async function loadPortfolio() {
750
  botDot.className = "bot-dot active";
751
  botStatus.textContent = "Bot: ACTIVE";
752
  botStatus.style.color = "#22c55e";
753
- toggleBtn.textContent = "⏹ Deactivate Bot";
754
  toggleBtn.classList.add("active");
755
  } else {
756
  botDot.className = "bot-dot";
757
  botStatus.textContent = "Bot: OFF";
758
  botStatus.style.color = "#ef4444";
759
- toggleBtn.textContent = "⚡ Activate Bot";
760
  toggleBtn.classList.remove("active");
761
  }
762
 
 
611
  },
612
  options: {
613
  responsive: true,
614
+ maintainAspectRatio: false,
615
  plugins: { legend: { labels: { color: "#6b7280" } } },
616
  scales: {
617
  x: { ticks: { color: "#4b5563", maxTicksLimit: 10, maxRotation: 45, font: { size: 9 } }, grid: { color: "#1f2937" } },
 
751
  botDot.className = "bot-dot active";
752
  botStatus.textContent = "Bot: ACTIVE";
753
  botStatus.style.color = "#22c55e";
754
+ toggleBtn.textContent = "Deactivate Bot";
755
  toggleBtn.classList.add("active");
756
  } else {
757
  botDot.className = "bot-dot";
758
  botStatus.textContent = "Bot: OFF";
759
  botStatus.style.color = "#ef4444";
760
+ toggleBtn.textContent = "Activate Bot";
761
  toggleBtn.classList.remove("active");
762
  }
763
 
frontend/dashboard.css ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Use the same core variables defined in style.css */
2
+
3
+ .dashboard-body {
4
+ background: var(--bg);
5
+ color: var(--text);
6
+ margin: 0;
7
+ padding: 0;
8
+ min-height: 100vh;
9
+ font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
10
+ overflow-y: auto;
11
+ }
12
+
13
+ .loading-overlay {
14
+ position: fixed;
15
+ inset: 0;
16
+ background: rgba(11, 14, 20, 0.9);
17
+ z-index: 9999;
18
+ display: flex;
19
+ flex-direction: column;
20
+ justify-content: center;
21
+ align-items: center;
22
+ transition: opacity 0.5s ease;
23
+ }
24
+
25
+ .loading-overlay.hidden {
26
+ opacity: 0;
27
+ pointer-events: none;
28
+ }
29
+
30
+ .spinner {
31
+ border: 4px solid var(--border);
32
+ border-top: 4px solid var(--cyan);
33
+ border-radius: 50%;
34
+ width: 40px;
35
+ height: 40px;
36
+ animation: spin 1s linear infinite;
37
+ margin-bottom: 20px;
38
+ }
39
+
40
+ @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
41
+
42
+ .dashboard-grid {
43
+ display: grid;
44
+ /* Matches exactly the proportions described */
45
+ grid-template-columns: 1fr 2fr;
46
+ grid-template-rows: auto auto minmax(400px, auto);
47
+ gap: 1.5rem;
48
+ width: 100%;
49
+ max-width: 1600px;
50
+ margin: 1.5rem auto;
51
+ padding: 0 1rem 3rem 1rem;
52
+ box-sizing: border-box;
53
+ opacity: 0;
54
+ transform: translateY(20px);
55
+ transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
56
+ }
57
+
58
+ .dashboard-body:not(.loading-state) .dashboard-grid {
59
+ opacity: 1;
60
+ transform: translateY(0);
61
+ }
62
+
63
+ /* Zone 1: Header */
64
+ .zone-header {
65
+ grid-column: 1 / 3;
66
+ grid-row: 1;
67
+ display: flex;
68
+ justify-content: space-between;
69
+ align-items: center;
70
+ background: var(--bg2);
71
+ padding: 1.2rem 2.5rem;
72
+ border-radius: 12px;
73
+ border: 1px solid var(--border);
74
+ box-shadow: 0 8px 32px rgba(0,0,0,0.3);
75
+ }
76
+
77
+ .header-left, .header-center, .header-right {
78
+ display: flex;
79
+ align-items: center;
80
+ gap: 1.5rem;
81
+ }
82
+
83
+ .company-logo {
84
+ width: 50px;
85
+ height: 50px;
86
+ background: linear-gradient(135deg, var(--bg3), var(--border));
87
+ border-radius: 12px;
88
+ display: flex;
89
+ justify-content: center;
90
+ align-items: center;
91
+ font-size: 1.5rem;
92
+ color: var(--cyan);
93
+ }
94
+
95
+ .company-name {
96
+ margin: 0;
97
+ font-size: 1.5rem;
98
+ font-weight: 700;
99
+ color: #fff;
100
+ }
101
+
102
+ .company-ticker {
103
+ color: var(--text-dim);
104
+ font-size: 0.9rem;
105
+ }
106
+
107
+ .real-time-metric {
108
+ display: flex;
109
+ flex-direction: column;
110
+ padding: 0 1.5rem;
111
+ border-right: 1px solid var(--border);
112
+ }
113
+
114
+ .real-time-metric:last-child {
115
+ border-right: none;
116
+ }
117
+
118
+ .metric-label {
119
+ font-size: 0.75rem;
120
+ color: var(--text-dim);
121
+ text-transform: uppercase;
122
+ letter-spacing: 0.05em;
123
+ margin-bottom: 0.25rem;
124
+ }
125
+
126
+ .metric-value {
127
+ font-size: 1.2rem;
128
+ font-weight: 700;
129
+ color: #fff;
130
+ }
131
+
132
+ .metric-value.positive { color: var(--green); text-shadow: 0 0 10px rgba(34,197,94,0.3); }
133
+ .metric-value.negative { color: var(--red); text-shadow: 0 0 10px rgba(239,68,68,0.3); }
134
+
135
+ /* Circular Ring */
136
+ .reliability-label {
137
+ font-size: 0.8rem;
138
+ color: var(--text-dim);
139
+ font-weight: 600;
140
+ }
141
+
142
+ .circular-progress {
143
+ width: 60px;
144
+ height: 60px;
145
+ }
146
+
147
+ .circular-chart {
148
+ display: block;
149
+ margin: 0 auto;
150
+ max-width: 100%;
151
+ max-height: 250px;
152
+ }
153
+
154
+ .circle-bg {
155
+ fill: none;
156
+ stroke: var(--bg3);
157
+ stroke-width: 3.8;
158
+ }
159
+
160
+ .circle {
161
+ fill: none;
162
+ stroke-width: 2.8;
163
+ stroke-linecap: round;
164
+ transition: stroke-dasharray 1.5s cubic-bezier(0.65, 0, 0.35, 1), stroke 0.5s ease;
165
+ }
166
+
167
+ .percentage {
168
+ fill: #fff;
169
+ font-family: inherit;
170
+ font-size: 0.6em;
171
+ font-weight: 700;
172
+ text-anchor: middle;
173
+ }
174
+
175
+ /* Zone Structure */
176
+ .bento-card {
177
+ background: var(--bg2);
178
+ border: 1px solid var(--border);
179
+ border-radius: 12px;
180
+ padding: 1.5rem;
181
+ overflow: hidden;
182
+ display: flex;
183
+ flex-direction: column;
184
+ min-height: 0;
185
+ }
186
+
187
+ .bento-card h2 {
188
+ font-size: 1.05rem;
189
+ color: #fff;
190
+ margin: 0 0 1rem 0;
191
+ border-bottom: 1px solid var(--border);
192
+ padding-bottom: 0.75rem;
193
+ }
194
+
195
+ .zone-news { grid-column: 1; grid-row: 2; }
196
+ .zone-parameters { grid-column: 2; grid-row: 2; }
197
+ .zone-profile { grid-column: 1; grid-row: 3; }
198
+ .zone-chart { grid-column: 2; grid-row: 3; }
199
+
200
+ /* News List */
201
+ .news-list {
202
+ flex: 1;
203
+ overflow-y: auto;
204
+ display: flex;
205
+ flex-direction: column;
206
+ gap: 0.75rem;
207
+ padding-right: 0.5rem;
208
+ min-height: 0;
209
+ }
210
+
211
+ .news-card {
212
+ background: var(--bg3);
213
+ padding: 1rem;
214
+ border-radius: 8px;
215
+ border-left: 3px solid transparent;
216
+ transition: transform 0.2s, border-left-color 0.2s;
217
+ }
218
+
219
+ .news-card:hover {
220
+ transform: translateX(4px);
221
+ }
222
+
223
+ .news-card[data-sentiment="Bullish"] { border-left-color: var(--green); }
224
+ .news-card[data-sentiment="Bearish"] { border-left-color: var(--red); }
225
+ .news-card[data-sentiment="Neutral"] { border-left-color: var(--blue); }
226
+
227
+ .news-card h3 {
228
+ font-size: 0.9rem;
229
+ margin: 0 0 0.5rem;
230
+ color: #fff;
231
+ line-height: 1.4;
232
+ }
233
+
234
+ .news-meta {
235
+ display: flex;
236
+ justify-content: space-between;
237
+ align-items: center;
238
+ font-size: 0.75rem;
239
+ color: var(--text-dim);
240
+ }
241
+
242
+ .sentiment-badge {
243
+ padding: 0.2rem 0.5rem;
244
+ border-radius: 4px;
245
+ font-weight: 600;
246
+ background: rgba(255,255,255,0.05);
247
+ }
248
+ .badge-Bullish { color: var(--green); }
249
+ .badge-Bearish { color: var(--red); }
250
+ .badge-Neutral { color: var(--blue); }
251
+
252
+ /* Parameters Bento Box */
253
+ .params-grid {
254
+ display: grid;
255
+ grid-template-columns: repeat(4, 1fr);
256
+ grid-template-rows: repeat(2, 1fr);
257
+ gap: 1rem;
258
+ height: 100%;
259
+ }
260
+
261
+ .param-card {
262
+ background: var(--bg3);
263
+ border-radius: 8px;
264
+ padding: 1rem;
265
+ display: flex;
266
+ flex-direction: column;
267
+ justify-content: space-between;
268
+ border: 1px solid var(--border);
269
+ position: relative;
270
+ cursor: default;
271
+ }
272
+
273
+ .param-card:hover {
274
+ border-color: var(--cyan);
275
+ }
276
+
277
+ .param-label {
278
+ font-size: 0.8rem;
279
+ color: var(--text-dim);
280
+ text-transform: uppercase;
281
+ font-weight: 600;
282
+ }
283
+
284
+ .param-value {
285
+ font-size: 1.5rem;
286
+ font-weight: 700;
287
+ color: #fff;
288
+ }
289
+
290
+ /* Tooltip implementation */
291
+ .param-card[title]:hover::after {
292
+ content: attr(title);
293
+ position: absolute;
294
+ bottom: 110%; left: 50%; transform: translateX(-50%);
295
+ background: var(--bg);
296
+ padding: 0.5rem;
297
+ border-radius: 4px;
298
+ border: 1px solid var(--border);
299
+ font-size: 0.75rem;
300
+ color: #fff;
301
+ white-space: nowrap;
302
+ z-index: 100;
303
+ }
304
+
305
+ /* Profile */
306
+ .company-desc {
307
+ font-size: 0.85rem;
308
+ line-height: 1.7;
309
+ color: #cbd5e1;
310
+ }
311
+
312
+ /* Chart */
313
+ .chart-header {
314
+ display: flex;
315
+ justify-content: space-between;
316
+ align-items: center;
317
+ margin-bottom: 1rem;
318
+ border-bottom: 1px solid var(--border);
319
+ padding-bottom: 0.75rem;
320
+ }
321
+
322
+ .chart-header h2 {
323
+ border-bottom: none;
324
+ margin: 0;
325
+ padding: 0;
326
+ }
327
+
328
+ .generate-btn {
329
+ background: linear-gradient(135deg, var(--blue), var(--cyan));
330
+ color: #000;
331
+ border: none;
332
+ padding: 0.5rem 1rem;
333
+ border-radius: 6px;
334
+ font-size: 0.8rem;
335
+ font-weight: 700;
336
+ cursor: pointer;
337
+ transition: transform 0.2s, box-shadow 0.2s;
338
+ font-family: inherit;
339
+ }
340
+
341
+ .generate-btn:hover {
342
+ transform: translateY(-2px);
343
+ box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
344
+ }
345
+
346
+ .chart-container {
347
+ flex: 1;
348
+ position: relative;
349
+ min-height: 380px;
350
+ width: 100%;
351
+ }
frontend/dashboard.html ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Company Analysis Dashboard</title>
7
+ <!-- Use existing StockSense-AI global styles and colors -->
8
+ <link rel="stylesheet" href="style.css">
9
+ <!-- Our custom CSS grid rules for the dashboard -->
10
+ <link rel="stylesheet" href="dashboard.css">
11
+ <!-- Chart.js replacing React's Recharts given vanilla JS constraints -->
12
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
13
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
14
+ </head>
15
+ <body class="dashboard-body loading-state">
16
+ <!-- Main Taskbar -->
17
+ <nav class="topbar">
18
+ <div class="brand">📈 <span>StockSense AI</span></div>
19
+ <div class="search-area">
20
+ <div class="search-wrapper">
21
+ <input id="tickerInput" type="text" placeholder="Search stock… (e.g. Tata, Reliance, INFY)" spellcheck="false" autocomplete="off" />
22
+ <div class="search-dropdown hidden" id="searchDropdown"></div>
23
+ </div>
24
+ <button id="analyzeBtn">Analyze</button>
25
+ </div>
26
+ <div class="nav-tabs">
27
+ <button class="nav-tab" onclick="window.location.href='index.html'">Charts</button>
28
+ <button class="nav-tab" onclick="window.location.href='index.html'">Auto Trade</button>
29
+ <button class="nav-tab active" onclick="window.location.href='dashboard.html'">Company Dashboard</button>
30
+ <button class="btn-wallet nav-btn" onclick="window.location.href='index.html'">Wallet</button>
31
+ <button class="btn-trade nav-btn" onclick="window.location.href='index.html'">Trade</button>
32
+ </div>
33
+ </nav>
34
+
35
+ <div class="loading-overlay" id="loadingOverlay">
36
+ <div class="spinner"></div>
37
+ <p>Loading Deep Analysis...</p>
38
+ </div>
39
+
40
+ <!-- The Full Height CSS Grid -->
41
+ <div class="dashboard-grid">
42
+
43
+ <!-- Zone 1: Header Panel (Top Row) -->
44
+ <header class="zone-header">
45
+ <div class="header-left">
46
+ <div class="company-logo">
47
+ <i class="fa-solid fa-code-compare"></i>
48
+ </div>
49
+ <div class="company-info">
50
+ <h1 class="company-name" id="hdr-name">--</h1>
51
+ <span class="company-ticker" id="hdr-ticker">--</span>
52
+ </div>
53
+ </div>
54
+
55
+ <div class="header-center">
56
+ <div class="real-time-metric">
57
+ <span class="metric-label">Current Price</span>
58
+ <span class="metric-value" id="hdr-price">--</span>
59
+ </div>
60
+ <div class="real-time-metric" id="hdr-change-box">
61
+ <span class="metric-label">24h Change</span>
62
+ <span class="metric-value" id="hdr-change">--</span>
63
+ </div>
64
+ <div class="real-time-metric">
65
+ <span class="metric-label">Market Cap</span>
66
+ <span class="metric-value" id="hdr-mcap">--</span>
67
+ </div>
68
+ </div>
69
+
70
+ <div class="header-right">
71
+ <div class="reliability-label">Reliability Score</div>
72
+ <div class="circular-progress" id="reliabilityScoreRing">
73
+ <svg viewBox="0 0 36 36" class="circular-chart">
74
+ <path class="circle-bg"
75
+ d="M18 2.0845
76
+ a 15.9155 15.9155 0 0 1 0 31.831
77
+ a 15.9155 15.9155 0 0 1 0 -31.831"
78
+ />
79
+ <path class="circle" id="ringPath"
80
+ stroke-dasharray="0, 100"
81
+ d="M18 2.0845
82
+ a 15.9155 15.9155 0 0 1 0 31.831
83
+ a 15.9155 15.9155 0 0 1 0 -31.831"
84
+ />
85
+ <text x="18" y="20.35" class="percentage" id="ringText">--</text>
86
+ </svg>
87
+ </div>
88
+ </div>
89
+ </header>
90
+
91
+ <!-- Zone 2: News & Sentiment Feed (Middle Row Left) -->
92
+ <section class="zone-news bento-card">
93
+ <h2>News & Sentiment Feed</h2>
94
+ <div class="news-list" id="newsList">
95
+ <!-- JavaScript will populate items here -->
96
+ </div>
97
+ </section>
98
+
99
+ <!-- Zone 3: Core Parameters (Middle Row Right) -->
100
+ <section class="zone-parameters bento-card">
101
+ <h2>Core Parameters</h2>
102
+ <div class="params-grid" id="paramsGrid">
103
+ <!-- Bento box metrics populated here -->
104
+ </div>
105
+ </section>
106
+
107
+ <!-- Zone 4: Company Profile (Bottom Row Left) -->
108
+ <section class="zone-profile bento-card">
109
+ <h2>Company Overview</h2>
110
+ <p id="companyOverviewText" class="company-desc">
111
+ Loading profile information...
112
+ </p>
113
+ </section>
114
+
115
+ <!-- Zone 5: Price Action & Forecast Graph (Bottom Row Right) -->
116
+ <section class="zone-chart bento-card">
117
+ <div class="chart-header">
118
+ <h2>Price Action & AI Forecast</h2>
119
+ <button class="generate-btn" id="generateAnalysisBtn">
120
+ Run AI Analysis
121
+ </button>
122
+ </div>
123
+ <div class="chart-container">
124
+ <canvas id="priceForecastChart"></canvas>
125
+ </div>
126
+ </section>
127
+
128
+ </div>
129
+
130
+ <script src="dashboard.js"></script>
131
+ </body>
132
+ </html>
frontend/dashboard.js ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ // Artificial Latency
3
+ setTimeout(() => {
4
+ document.body.classList.remove('loading-state');
5
+ document.getElementById('loadingOverlay').classList.add('hidden');
6
+ renderDashboard();
7
+ }, 1200);
8
+ });
9
+
10
+ const generateMockData = () => {
11
+ return {
12
+ company: {
13
+ name: "Larsen & Toubro",
14
+ ticker: "LT.NS",
15
+ price: 3951.20,
16
+ change: 1.84,
17
+ marketCap: "₹5.42T",
18
+ reliability: 84
19
+ },
20
+ profile: "Larsen & Toubro Limited is an Indian multinational conglomerate with interests in engineering, construction, manufacturing, technology and financial services. It is counted among world's top contractors and has a massive footprint globally. Currently led by S. N. Subrahmanyan.",
21
+ news: [
22
+ { id: 1, headline: "L&T wins major infrastructure contract in Saudi Arabia worth $1.2B", time: "2 hours ago", sentiment: "Bullish" },
23
+ { id: 2, headline: "Margins remain pressured by raw material inflation this quarter", time: "5 hours ago", sentiment: "Bearish" },
24
+ { id: 3, headline: "LT confirms Q3 earnings call details for institutional investors", time: "1 day ago", sentiment: "Neutral" },
25
+ { id: 4, headline: "Defense sector boost drives massive order book influx for L&T", time: "1 day ago", sentiment: "Bullish" },
26
+ { id: 5, headline: "Analyst upgrade: Key strategic play for Indian capex cycle", time: "2 days ago", sentiment: "Bullish" }
27
+ ],
28
+ parameters: [
29
+ { label: "P/E Ratio", value: "34.5x", tip: "Price-to-Earnings Ratio. Indicates market expectations." },
30
+ { label: "EPS (TTM)", value: "₹112.4", tip: "Earnings Per Share over the trailing twelve months." },
31
+ { label: "Debt-to-Eq", value: "1.14", tip: "Total debt relative to shareholder equity limit." },
32
+ { label: "Free Cash", value: "₹91B", tip: "Free Cash Flow generated after capital expenditures." },
33
+ { label: "RSI (14d)", value: "62.4", tip: "Relative Strength Index. >70 is overbought." },
34
+ { label: "MACD", value: "+14.2", tip: "Trend-following momentum indicator." },
35
+ { label: "Q3 Targets", value: "Reached", tip: "Did the company hit its stated financial outcomes in the last quarter?" },
36
+ { label: "Beta", value: "1.05", tip: "Measures the volatility of the stock relative to the index." }
37
+ ],
38
+ chartData: {
39
+ // Last 20 days historical + 5 days forecast
40
+ labels: ["D-20", "D-19", "D-18", "D-17", "D-16", "D-15", "D-14", "D-13", "D-12", "D-11", "D-10", "D-9", "D-8", "D-7", "D-6", "D-5", "D-4", "D-3", "D-2", "D-1", "Today", "F+1", "F+2", "F+3", "F+4", "F+5"],
41
+ history: [3520, 3550, 3510, 3580, 3620, 3610, 3590, 3650, 3680, 3670, 3720, 3750, 3740, 3780, 3790, 3850, 3870, 3880, 3850, 3920, 3951, null, null, null, null, null],
42
+ forecast: [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3951, 3980, 4015, 3990, 4040, 4065]
43
+ }
44
+ };
45
+ };
46
+
47
+ function renderDashboard() {
48
+ const data = generateMockData();
49
+
50
+ // Header
51
+ document.getElementById('hdr-name').innerText = data.company.name;
52
+ document.getElementById('hdr-ticker').innerText = data.company.ticker;
53
+ document.getElementById('hdr-price').innerText = "₹" + data.company.price.toLocaleString();
54
+
55
+ const changeBox = document.getElementById('hdr-change-box');
56
+ const changeTxt = document.getElementById('hdr-change');
57
+
58
+ if (data.company.change > 0) {
59
+ changeTxt.innerText = "+" + data.company.change + "%";
60
+ changeTxt.classList.add('positive');
61
+ } else {
62
+ changeTxt.innerText = data.company.change + "%";
63
+ changeTxt.classList.add('negative');
64
+ }
65
+ document.getElementById('hdr-mcap').innerText = data.company.marketCap;
66
+
67
+ // Reliability Ring Animation
68
+ const score = data.company.reliability;
69
+ document.getElementById('ringText').textContent = score;
70
+ const ringPath = document.getElementById('ringPath');
71
+
72
+ // Set color logic
73
+ let ringColor = "#ef4444"; // red
74
+ if (score >= 80) ringColor = "#22c55e"; // green
75
+ else if (score >= 50) ringColor = "#eab308"; // yellow
76
+
77
+ ringPath.style.stroke = ringColor;
78
+
79
+ // Delay animation trigger slightly
80
+ setTimeout(() => {
81
+ ringPath.setAttribute('stroke-dasharray', `${score}, 100`);
82
+ }, 100);
83
+
84
+ // Profile
85
+ document.getElementById('companyOverviewText').innerText = data.profile;
86
+
87
+ // News
88
+ const newsContainer = document.getElementById('newsList');
89
+ newsContainer.innerHTML = '';
90
+ data.news.forEach(item => {
91
+ const div = document.createElement('div');
92
+ div.className = 'news-card';
93
+ div.setAttribute('data-sentiment', item.sentiment);
94
+ div.innerHTML = `
95
+ <h3>${item.headline}</h3>
96
+ <div class="news-meta">
97
+ <span>${item.time}</span>
98
+ <span class="sentiment-badge badge-${item.sentiment}">${item.sentiment}</span>
99
+ </div>
100
+ `;
101
+ newsContainer.appendChild(div);
102
+ });
103
+
104
+ // Params
105
+ const paramGrid = document.getElementById('paramsGrid');
106
+ paramGrid.innerHTML = '';
107
+ data.parameters.forEach(param => {
108
+ const div = document.createElement('div');
109
+ div.className = 'param-card';
110
+ div.title = param.tip;
111
+ div.innerHTML = `
112
+ <div class="param-label">${param.label}</div>
113
+ <div class="param-value">${param.value}</div>
114
+ `;
115
+ paramGrid.appendChild(div);
116
+ });
117
+
118
+ // Chart.js Area/Forecast rendering
119
+ renderGraph(data.chartData);
120
+ }
121
+
122
+ function renderGraph(chartData) {
123
+ const ctx = document.getElementById('priceForecastChart').getContext('2d');
124
+
125
+ // Create dark gradient for historical area
126
+ let gradient = ctx.createLinearGradient(0, 0, 0, 400);
127
+ gradient.addColorStop(0, 'rgba(6, 182, 212, 0.5)'); // Cyan top
128
+ gradient.addColorStop(1, 'rgba(6, 182, 212, 0.0)'); // Fade edge
129
+
130
+ new Chart(ctx, {
131
+ type: 'line',
132
+ data: {
133
+ labels: chartData.labels,
134
+ datasets: [
135
+ {
136
+ label: 'Historical Price',
137
+ data: chartData.history,
138
+ borderColor: '#06b6d4',
139
+ backgroundColor: gradient,
140
+ borderWidth: 2,
141
+ fill: true,
142
+ pointRadius: 0,
143
+ pointHoverRadius: 5,
144
+ tension: 0.3
145
+ },
146
+ {
147
+ label: 'AI Forecast',
148
+ data: chartData.forecast,
149
+ borderColor: '#a855f7',
150
+ borderDash: [5, 5],
151
+ borderWidth: 2,
152
+ fill: false,
153
+ pointRadius: 3,
154
+ pointBackgroundColor: '#1a1f2e',
155
+ tension: 0.3
156
+ }
157
+ ]
158
+ },
159
+ options: {
160
+ responsive: true,
161
+ maintainAspectRatio: false,
162
+ interaction: {
163
+ mode: 'index',
164
+ intersect: false,
165
+ },
166
+ plugins: {
167
+ legend: {
168
+ labels: { color: '#d1d5db', font: { family: 'monospace' } }
169
+ },
170
+ tooltip: {
171
+ backgroundColor: '#131720',
172
+ titleColor: '#fff',
173
+ bodyColor: '#d1d5db',
174
+ borderColor: '#242a38',
175
+ borderWidth: 1,
176
+ padding: 10,
177
+ displayColors: true
178
+ }
179
+ },
180
+ scales: {
181
+ x: {
182
+ grid: { color: '#1a1f2e' },
183
+ ticks: { color: '#6b7280', font: { family: 'monospace' } }
184
+ },
185
+ y: {
186
+ grid: { color: '#1a1f2e' },
187
+ ticks: { color: '#6b7280', font: { family: 'monospace' } },
188
+ // Zoom slightly by avoiding zero start explicitly
189
+ min: 3400,
190
+ max: 4200
191
+ }
192
+ }
193
+ }
194
+ });
195
+
196
+ // The Analyze button
197
+ document.getElementById('generateAnalysisBtn').addEventListener('click', (e) => {
198
+ const btn = e.currentTarget;
199
+ btn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Processing...';
200
+ btn.disabled = true;
201
+
202
+ setTimeout(() => {
203
+ btn.innerHTML = 'Run AI Analysis';
204
+ btn.disabled = false;
205
+ // Here you'd trigger backend recalculation
206
+ }, 1500);
207
+ });
208
+ }
frontend/debug_dashboard.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import traceback
2
+ from playwright.sync_api import sync_playwright
3
+
4
+ def run():
5
+ print("Starting playwright debugging...")
6
+ with sync_playwright() as p:
7
+ browser = p.chromium.launch(headless=True)
8
+ page = browser.new_page()
9
+ # Navigate to the local dashboard.html
10
+ url = "file:///c:/Lang/stuf/StockSense-AI/frontend/dashboard.html"
11
+ print(f"Loading {url}")
12
+ page.goto(url)
13
+ page.wait_for_timeout(3000) # Wait for animation
14
+
15
+ # Take a screenshot to verify chart
16
+ page.screenshot(path="c:/Lang/stuf/StockSense-AI/frontend/debug_screenshot.png")
17
+ print("Debugging screenshot saved.")
18
+
19
+ # Extract console logs if any errors existed
20
+ # We can also execute a JS query to get chart values
21
+ chart_points = page.evaluate('''() => {
22
+ const chartData = window.Chart.instances[0]?.chart?.data?.datasets[0]?.data;
23
+ const minScale = window.Chart.instances[0]?.chart?.scales?.y?.min;
24
+ return {data: chartData, minScale};
25
+ }''')
26
+ print(f"Chart debug data: {chart_points}")
27
+ browser.close()
28
+
29
+ if __name__ == "__main__":
30
+ try:
31
+ run()
32
+ except Exception as e:
33
+ traceback.print_exc()
frontend/index.html CHANGED
@@ -81,13 +81,11 @@
81
  <button id="analyzeBtn" onclick="loadTicker()">Analyze</button>
82
  </div>
83
  <div class="nav-tabs">
84
- <button class="nav-tab active" onclick="switchTab('charts')">📊 Charts</button>
85
- <button class="nav-tab" onclick="switchTab('trading')">🤖 Auto Trade</button>
86
- <button class="btn-wallet nav-btn" onclick="showWallet()">💰 Wallet</button>
87
- <button class="btn-trade nav-btn" onclick="executeManualTrade()">🛒 Trade</button>
88
- </div>
89
- <div class="live-badge" id="liveBadge">
90
- <span class="dot"></span> LIVE
91
  </div>
92
  </nav>
93
 
@@ -158,7 +156,7 @@
158
  <div class="chart-container volume-chart"><canvas id="volumeChart"></canvas></div>
159
 
160
  <div class="prediction-section hidden" id="predSection">
161
- <h3>🤖 Next 5-Day Price Forecast</h3>
162
 
163
  <div class="pred-loader" id="predLoader">
164
  <div class="pred-loader-inner">
@@ -197,7 +195,7 @@
197
 
198
  <aside class="sidebar">
199
  <div class="panel">
200
- <h3>🔥 High Potential Stocks</h3>
201
  <p class="panel-sub">Ranked by momentum + indicators</p>
202
  <div id="hpLoader" class="mini-loader">Loading scanner...</div>
203
  <div id="hpList" class="hp-list"></div>
@@ -260,9 +258,9 @@
260
  <span id="botStatus">Bot: OFF</span>
261
  </div>
262
  <div class="bot-buttons">
263
- <button class="btn-bot" id="toggleBotBtn" onclick="toggleBot()">⚡ Auto Bot</button>
264
- <button class="btn-scan" onclick="runAutoScan()">🔍 Auto Scan</button>
265
- <button class="btn-reset" onclick="resetPortfolio()">🔄 Reset</button>
266
  </div>
267
  </div>
268
 
 
81
  <button id="analyzeBtn" onclick="loadTicker()">Analyze</button>
82
  </div>
83
  <div class="nav-tabs">
84
+ <button class="nav-tab active" onclick="switchTab('charts')">Charts</button>
85
+ <button class="nav-tab" onclick="switchTab('trading')">Auto Trade</button>
86
+ <button class="nav-tab" onclick="window.location.href='dashboard.html'">Company Dashboard</button>
87
+ <button class="btn-wallet nav-btn" onclick="showWallet()">Wallet</button>
88
+ <button class="btn-trade nav-btn" onclick="executeManualTrade()">Trade</button>
 
 
89
  </div>
90
  </nav>
91
 
 
156
  <div class="chart-container volume-chart"><canvas id="volumeChart"></canvas></div>
157
 
158
  <div class="prediction-section hidden" id="predSection">
159
+ <h3>Next 5-Day Price Forecast</h3>
160
 
161
  <div class="pred-loader" id="predLoader">
162
  <div class="pred-loader-inner">
 
195
 
196
  <aside class="sidebar">
197
  <div class="panel">
198
+ <h3>High Potential Stocks</h3>
199
  <p class="panel-sub">Ranked by momentum + indicators</p>
200
  <div id="hpLoader" class="mini-loader">Loading scanner...</div>
201
  <div id="hpList" class="hp-list"></div>
 
258
  <span id="botStatus">Bot: OFF</span>
259
  </div>
260
  <div class="bot-buttons">
261
+ <button class="btn-bot" id="toggleBotBtn" onclick="toggleBot()">Auto Bot</button>
262
+ <button class="btn-scan" onclick="runAutoScan()">Auto Scan</button>
263
+ <button class="btn-reset" onclick="resetPortfolio()">Reset</button>
264
  </div>
265
  </div>
266
 
frontend/style.css CHANGED
@@ -8,12 +8,14 @@
8
  right: 0;
9
  height: 100vh;
10
  width: 440px;
11
- background: linear-gradient(165deg, #0f1219 0%, #161b28 40%, #1a1f2e 100%);
 
 
12
  box-shadow: -12px 0 60px rgba(0, 0, 0, 0.45), -2px 0 20px rgba(59, 130, 246, 0.06);
13
  z-index: 9999;
14
  transform: translateX(100%);
15
  transition: transform 0.38s cubic-bezier(.25, 1, .3, 1);
16
- border-left: 1px solid rgba(59, 130, 246, 0.12);
17
  }
18
 
19
  .wallet-panel:not(.hidden) {
@@ -574,8 +576,10 @@ body {
574
  align-items: center;
575
  justify-content: space-between;
576
  padding: 0.6rem 1.5rem;
577
- background: var(--bg2);
578
- border-bottom: 1px solid var(--border);
 
 
579
  position: sticky;
580
  top: 0;
581
  z-index: 100;
@@ -836,8 +840,10 @@ body {
836
 
837
 
838
  .market-bar {
839
- background: linear-gradient(90deg, #0d1117 0%, #131720 50%, #0d1117 100%);
840
- border-bottom: 1px solid var(--border);
 
 
841
  padding: 0.45rem 1.5rem;
842
  position: sticky;
843
  top: 42px;
@@ -899,8 +905,10 @@ body {
899
  justify-content: space-between;
900
  align-items: center;
901
  padding: 1rem 1.5rem;
902
- background: var(--bg2);
903
- border-bottom: 1px solid var(--border);
 
 
904
  }
905
 
906
  .price-main {
@@ -1018,8 +1026,10 @@ body {
1018
 
1019
 
1020
  .chart-container {
1021
- background: var(--bg2);
1022
- border: 1px solid var(--border);
 
 
1023
  border-radius: 8px;
1024
  padding: 0.8rem;
1025
  margin-bottom: 0.8rem;
@@ -1071,8 +1081,10 @@ body {
1071
 
1072
 
1073
  .panel {
1074
- background: var(--bg2);
1075
- border: 1px solid var(--border);
 
 
1076
  border-radius: 8px;
1077
  padding: 1rem;
1078
  margin-bottom: 0.8rem;
@@ -1279,8 +1291,10 @@ body {
1279
  }
1280
 
1281
  .port-card {
1282
- background: var(--bg2);
1283
- border: 1px solid var(--border);
 
 
1284
  border-radius: 8px;
1285
  padding: 1rem;
1286
  text-align: center;
@@ -1309,8 +1323,10 @@ body {
1309
  display: flex;
1310
  align-items: center;
1311
  justify-content: space-between;
1312
- background: var(--bg2);
1313
- border: 1px solid var(--border);
 
 
1314
  border-radius: 8px;
1315
  padding: 1rem 1.5rem;
1316
  }
@@ -1398,8 +1414,10 @@ body {
1398
 
1399
 
1400
  .trade-panel {
1401
- background: var(--bg2);
1402
- border: 1px solid var(--border);
 
 
1403
  border-radius: 8px;
1404
  padding: 1rem 1.5rem;
1405
  }
@@ -1825,8 +1843,10 @@ footer p+p {
1825
  }
1826
 
1827
  .insight-card {
1828
- background: var(--bg2);
1829
- border: 1px solid var(--border);
 
 
1830
  border-radius: 12px;
1831
  padding: 1.5rem;
1832
  transition: all 0.3s ease;
 
8
  right: 0;
9
  height: 100vh;
10
  width: 440px;
11
+ background: linear-gradient(165deg, rgba(15, 18, 25, 0.75) 0%, rgba(22, 27, 40, 0.75) 40%, rgba(26, 31, 46, 0.75) 100%);
12
+ backdrop-filter: blur(16px);
13
+ -webkit-backdrop-filter: blur(16px);
14
  box-shadow: -12px 0 60px rgba(0, 0, 0, 0.45), -2px 0 20px rgba(59, 130, 246, 0.06);
15
  z-index: 9999;
16
  transform: translateX(100%);
17
  transition: transform 0.38s cubic-bezier(.25, 1, .3, 1);
18
+ border-left: 1px solid rgba(255, 255, 255, 0.08);
19
  }
20
 
21
  .wallet-panel:not(.hidden) {
 
576
  align-items: center;
577
  justify-content: space-between;
578
  padding: 0.6rem 1.5rem;
579
+ background: rgba(19, 23, 32, 0.65);
580
+ backdrop-filter: blur(12px);
581
+ -webkit-backdrop-filter: blur(12px);
582
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
583
  position: sticky;
584
  top: 0;
585
  z-index: 100;
 
840
 
841
 
842
  .market-bar {
843
+ background: linear-gradient(90deg, rgba(13, 17, 23, 0.65) 0%, rgba(19, 23, 32, 0.65) 50%, rgba(13, 17, 23, 0.65) 100%);
844
+ backdrop-filter: blur(12px);
845
+ -webkit-backdrop-filter: blur(12px);
846
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
847
  padding: 0.45rem 1.5rem;
848
  position: sticky;
849
  top: 42px;
 
905
  justify-content: space-between;
906
  align-items: center;
907
  padding: 1rem 1.5rem;
908
+ background: rgba(19, 23, 32, 0.65);
909
+ backdrop-filter: blur(12px);
910
+ -webkit-backdrop-filter: blur(12px);
911
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
912
  }
913
 
914
  .price-main {
 
1026
 
1027
 
1028
  .chart-container {
1029
+ background: rgba(19, 23, 32, 0.65);
1030
+ backdrop-filter: blur(12px);
1031
+ -webkit-backdrop-filter: blur(12px);
1032
+ border: 1px solid rgba(255, 255, 255, 0.08);
1033
  border-radius: 8px;
1034
  padding: 0.8rem;
1035
  margin-bottom: 0.8rem;
 
1081
 
1082
 
1083
  .panel {
1084
+ background: rgba(19, 23, 32, 0.65);
1085
+ backdrop-filter: blur(12px);
1086
+ -webkit-backdrop-filter: blur(12px);
1087
+ border: 1px solid rgba(255, 255, 255, 0.08);
1088
  border-radius: 8px;
1089
  padding: 1rem;
1090
  margin-bottom: 0.8rem;
 
1291
  }
1292
 
1293
  .port-card {
1294
+ background: rgba(19, 23, 32, 0.65);
1295
+ backdrop-filter: blur(12px);
1296
+ -webkit-backdrop-filter: blur(12px);
1297
+ border: 1px solid rgba(255, 255, 255, 0.08);
1298
  border-radius: 8px;
1299
  padding: 1rem;
1300
  text-align: center;
 
1323
  display: flex;
1324
  align-items: center;
1325
  justify-content: space-between;
1326
+ background: rgba(19, 23, 32, 0.65);
1327
+ backdrop-filter: blur(12px);
1328
+ -webkit-backdrop-filter: blur(12px);
1329
+ border: 1px solid rgba(255, 255, 255, 0.08);
1330
  border-radius: 8px;
1331
  padding: 1rem 1.5rem;
1332
  }
 
1414
 
1415
 
1416
  .trade-panel {
1417
+ background: rgba(19, 23, 32, 0.65);
1418
+ backdrop-filter: blur(12px);
1419
+ -webkit-backdrop-filter: blur(12px);
1420
+ border: 1px solid rgba(255, 255, 255, 0.08);
1421
  border-radius: 8px;
1422
  padding: 1rem 1.5rem;
1423
  }
 
1843
  }
1844
 
1845
  .insight-card {
1846
+ background: rgba(19, 23, 32, 0.65);
1847
+ backdrop-filter: blur(12px);
1848
+ -webkit-backdrop-filter: blur(12px);
1849
+ border: 1px solid rgba(255, 255, 255, 0.08);
1850
  border-radius: 12px;
1851
  padding: 1.5rem;
1852
  transition: all 0.3s ease;