drkasi commited on
Commit
dab97b7
·
verified ·
1 Parent(s): 3ca4bf3

Add 1 files

Browse files
Files changed (1) hide show
  1. index.html +220 -105
index.html CHANGED
@@ -5,6 +5,13 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Dr. KKR's EOD Bull Bear Crossover Screener</title>
7
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
 
 
 
 
 
 
 
8
  <style>
9
  :root {
10
  --primary-color: #2c3e50;
@@ -90,7 +97,7 @@
90
 
91
  .sidebar-title {
92
  font-size: 1.1rem;
93
- font-weight: 600;
94
  margin-bottom: 1rem;
95
  color: var(--secondary-color);
96
  display: flex;
@@ -146,7 +153,7 @@
146
  -webkit-appearance: none;
147
  -moz-appearance: none;
148
  appearance: none;
149
- background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23D4AF37%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
150
  background-repeat: no-repeat;
151
  background-position: right 0.7rem top 50%;
152
  background-size: 0.65rem auto;
@@ -840,7 +847,7 @@
840
 
841
  <div class="sidebar-divider"></div>
842
 
843
- <button class="btn btn-secondary btn-lg" style="width: 100%;">
844
  <i class="fas fa-rocket"></i> Analyze Stocks
845
  </button>
846
  </div>
@@ -857,7 +864,7 @@
857
  <div class="header-subtitle">Identify potential entry points based on moving average crossovers and price proximity analysis</div>
858
  <div class="last-refreshed">Last Refreshed: <span id="lastRefreshed">Loading...</span></div>
859
  </div>
860
- <button class="refresh-btn">
861
  <i class="fas fa-sync-alt"></i> Refresh Data
862
  </button>
863
  </div>
@@ -878,7 +885,7 @@
878
  <i class="fas fa-list-ul"></i>
879
  Selected Stocks Summary
880
  </div>
881
- <span class="badge">42 tickers</span>
882
  </div>
883
  <div class="card-body">
884
  <div class="alert alert-warning">
@@ -891,11 +898,11 @@
891
 
892
  <div class="expandable">
893
  <div class="expandable-header">
894
- <span>View Full Ticker List (42 tickers)</span>
895
  <i class="fas fa-chevron-down"></i>
896
  </div>
897
  <div class="expandable-content" style="display: none;">
898
- <div class="ticker-list">
899
  RELIANCE.NS, TCS.NS, HDFCBANK.NS, INFY.NS, HINDUNILVR.NS, ICICIBANK.NS, ITC.NS, SBIN.NS,
900
  BHARTIARTL.NS, KOTAKBANK.NS, ASIANPAINT.NS, LT.NS, HDFC.NS, BAJFINANCE.NS, HCLTECH.NS,
901
  MARUTI.NS, NTPC.NS, ONGC.NS, TECHM.NS, SUNPHARMA.NS, AXISBANK.NS, TITAN.NS, ULTRACEMCO.NS,
@@ -907,10 +914,10 @@
907
  </div>
908
 
909
  <div class="progress-container">
910
- <div class="progress-bar" style="width: 0%;"></div>
911
  </div>
912
 
913
- <button class="btn btn-primary">
914
  <i class="fas fa-eye"></i> Preview Analysis
915
  </button>
916
  </div>
@@ -924,7 +931,7 @@
924
  </div>
925
  </div>
926
  <div class="card-body">
927
- <div class="alert alert-danger">
928
  <i class="fas fa-exclamation-triangle"></i>
929
  <div class="alert-content">
930
  <div class="alert-title">No Results Yet</div>
@@ -933,7 +940,7 @@
933
  </div>
934
 
935
  <div class="table-container">
936
- <table>
937
  <thead>
938
  <tr>
939
  <th>Ticker</th>
@@ -946,40 +953,14 @@
946
  </tr>
947
  </thead>
948
  <tbody>
949
- <tr class="bullish">
950
- <td>RELIANCE.NS</td>
951
- <td>2,415.75</td>
952
- <td>2,428.45</td>
953
- <td>2,402.30</td>
954
- <td><i class="fas fa-check-circle text-success"></i> 2023-05-15</td>
955
- <td>-</td>
956
- <td>1.02%</td>
957
- </tr>
958
- <tr class="bearish">
959
- <td>INFY.NS</td>
960
- <td>1,321.20</td>
961
- <td>1,334.50</td>
962
- <td>1,315.80</td>
963
- <td>-</td>
964
- <td><i class="fas fa-check-circle text-danger"></i> 2023-05-18</td>
965
- <td>0.84%</td>
966
- </tr>
967
- <tr class="bullish">
968
- <td>HDFCBANK.NS</td>
969
- <td>1,645.30</td>
970
- <td>1,654.25</td>
971
- <td>1,638.40</td>
972
- <td><i class="fas fa-check-circle text-success"></i> 2023-05-20</td>
973
- <td>-</td>
974
- <td>0.93%</td>
975
- </tr>
976
  </tbody>
977
  </table>
978
  </div>
979
  </div>
980
  </div>
981
 
982
- <div class="card fade-in">
983
  <div class="card-header">
984
  <div class="card-title">
985
  <i class="fas fa-download"></i>
@@ -992,16 +973,16 @@
992
  Export your screening results in various formats for further analysis or record keeping.
993
  </div>
994
 
995
- <button class="btn btn-primary">
996
  <i class="fas fa-file-csv"></i> Download as CSV
997
  </button>
998
- <button class="btn btn-primary" style="margin-left: 0.5rem;">
999
  <i class="fas fa-file-excel"></i> Excel
1000
  </button>
1001
- <button class="btn btn-primary" style="margin-left: 0.5rem;">
1002
  <i class="fas fa-file-pdf"></i> PDF Report
1003
  </button>
1004
- <button class="btn btn-primary" style="margin-left: 0.5rem;">
1005
  <i class="fas fa-image"></i> Screenshot
1006
  </button>
1007
  </div>
@@ -1010,6 +991,63 @@
1010
  </div>
1011
 
1012
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1013
  // Update the last refreshed time
1014
  document.getElementById('lastRefreshed').textContent = new Date().toLocaleString();
1015
 
@@ -1049,19 +1087,19 @@
1049
  });
1050
 
1051
  // Simulate analysis button click
1052
- document.querySelector('.btn-secondary').addEventListener('click', function() {
1053
- const progressBar = document.querySelector('.progress-bar');
1054
  let width = 0;
1055
 
1056
  // Hide the warning alert
1057
- document.querySelector('.alert-danger').style.display = 'none';
1058
 
1059
  // Show progress bar animation
1060
  progressBar.parentElement.style.display = 'block';
1061
  progressBar.style.width = '0%';
1062
 
1063
  // Reset table to empty
1064
- document.querySelector('table tbody').innerHTML = '<tr><td colspan="7" style="text-align: center;">Analyzing stocks...</td></tr>';
1065
 
1066
  const progressInterval = setInterval(function() {
1067
  if (width >= 100) {
@@ -1077,61 +1115,7 @@
1077
 
1078
  // Function to show sample results
1079
  function showResults() {
1080
- // Create some sample data
1081
- const sampleData = [
1082
- {
1083
- ticker: "RELIANCE.NS",
1084
- close: "2,415.75",
1085
- bullishEntry: "2,428.45",
1086
- bearishEntry: "2,402.30",
1087
- bullishSignal: "2023-05-15",
1088
- bearishSignal: null,
1089
- proximity: "1.02%",
1090
- signal: "bullish"
1091
- },
1092
- {
1093
- ticker: "INFY.NS",
1094
- close: "1,321.20",
1095
- bullishEntry: "1,334.50",
1096
- bearishEntry: "1,315.80",
1097
- bullishSignal: null,
1098
- bearishSignal: "2023-05-18",
1099
- proximity: "0.84%",
1100
- signal: "bearish"
1101
- },
1102
- {
1103
- ticker: "HDFCBANK.NS",
1104
- close: "1,645.30",
1105
- bullishEntry: "1,654.25",
1106
- bearishEntry: "1,638.40",
1107
- bullishSignal: "2023-05-20",
1108
- bearishSignal: null,
1109
- proximity: "0.93%",
1110
- signal: "bullish"
1111
- },
1112
- {
1113
- ticker: "TCS.NS",
1114
- close: "3,245.50",
1115
- bullishEntry: "3,260.75",
1116
- bearishEntry: "3,230.25",
1117
- bullishSignal: "2023-05-10",
1118
- bearishSignal: null,
1119
- proximity: "1.15%",
1120
- signal: "bullish"
1121
- },
1122
- {
1123
- ticker: "BHARTIARTL.NS",
1124
- close: "782.15",
1125
- bullishEntry: "791.30",
1126
- bearishEntry: "774.90",
1127
- bullishSignal: null,
1128
- bearishSignal: "2023-05-22",
1129
- proximity: "0.97%",
1130
- signal: "bearish"
1131
- }
1132
- ];
1133
-
1134
- const tableBody = document.querySelector('table tbody');
1135
  tableBody.innerHTML = '';
1136
 
1137
  sampleData.forEach(stock => {
@@ -1152,7 +1136,7 @@
1152
  });
1153
 
1154
  // Show success message
1155
- const alertDiv = document.querySelector('.alert-danger');
1156
  alertDiv.className = 'alert alert-success';
1157
  alertDiv.style.display = 'flex';
1158
  alertDiv.innerHTML = `
@@ -1164,9 +1148,140 @@
1164
  `;
1165
 
1166
  // Auto-scroll to results
1167
- document.querySelector('.card:nth-child(3)').scrollIntoView({ behavior: 'smooth' });
1168
  }
1169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1170
  // Highlight rows on hover
1171
  document.addEventListener('mouseover', function(e) {
1172
  if (e.target.tagName === 'TD' || e.target.tagName === 'TH') {
@@ -1211,5 +1326,5 @@
1211
  });
1212
  });
1213
  </script>
1214
- <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
1215
  </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Dr. KKR's EOD Bull Bear Crossover Screener</title>
7
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
8
+ <!-- Include jsPDF for PDF export -->
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
10
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
11
+ <!-- Include SheetJS for Excel export -->
12
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
13
+ <!-- Include html2canvas for screenshot export -->
14
+ <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
15
  <style>
16
  :root {
17
  --primary-color: #2c3e50;
 
97
 
98
  .sidebar-title {
99
  font-size: 1.1rem;
100
+ font-weight: 6#ffffff;
101
  margin-bottom: 1rem;
102
  color: var(--secondary-color);
103
  display: flex;
 
153
  -webkit-appearance: none;
154
  -moz-appearance: none;
155
  appearance: none;
156
+ background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23D4AF37%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%201127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
157
  background-repeat: no-repeat;
158
  background-position: right 0.7rem top 50%;
159
  background-size: 0.65rem auto;
 
847
 
848
  <div class="sidebar-divider"></div>
849
 
850
+ <button class="btn btn-secondary btn-lg" style="width: 100%;" id="analyzeBtn">
851
  <i class="fas fa-rocket"></i> Analyze Stocks
852
  </button>
853
  </div>
 
864
  <div class="header-subtitle">Identify potential entry points based on moving average crossovers and price proximity analysis</div>
865
  <div class="last-refreshed">Last Refreshed: <span id="lastRefreshed">Loading...</span></div>
866
  </div>
867
+ <button class="refresh-btn" id="refreshBtn">
868
  <i class="fas fa-sync-alt"></i> Refresh Data
869
  </button>
870
  </div>
 
885
  <i class="fas fa-list-ul"></i>
886
  Selected Stocks Summary
887
  </div>
888
+ <span class="badge" id="tickerCount">42 tickers</span>
889
  </div>
890
  <div class="card-body">
891
  <div class="alert alert-warning">
 
898
 
899
  <div class="expandable">
900
  <div class="expandable-header">
901
+ <span id="tickerListText">View Full Ticker List (42 tickers)</span>
902
  <i class="fas fa-chevron-down"></i>
903
  </div>
904
  <div class="expandable-content" style="display: none;">
905
+ <div class="ticker-list" id="tickerListContent">
906
  RELIANCE.NS, TCS.NS, HDFCBANK.NS, INFY.NS, HINDUNILVR.NS, ICICIBANK.NS, ITC.NS, SBIN.NS,
907
  BHARTIARTL.NS, KOTAKBANK.NS, ASIANPAINT.NS, LT.NS, HDFC.NS, BAJFINANCE.NS, HCLTECH.NS,
908
  MARUTI.NS, NTPC.NS, ONGC.NS, TECHM.NS, SUNPHARMA.NS, AXISBANK.NS, TITAN.NS, ULTRACEMCO.NS,
 
914
  </div>
915
 
916
  <div class="progress-container">
917
+ <div class="progress-bar" id="progressBar" style="width: 0%;"></div>
918
  </div>
919
 
920
+ <button class="btn btn-primary" id="previewBtn">
921
  <i class="fas fa-eye"></i> Preview Analysis
922
  </button>
923
  </div>
 
931
  </div>
932
  </div>
933
  <div class="card-body">
934
+ <div class="alert alert-danger" id="resultsAlert">
935
  <i class="fas fa-exclamation-triangle"></i>
936
  <div class="alert-content">
937
  <div class="alert-title">No Results Yet</div>
 
940
  </div>
941
 
942
  <div class="table-container">
943
+ <table id="resultsTable">
944
  <thead>
945
  <tr>
946
  <th>Ticker</th>
 
953
  </tr>
954
  </thead>
955
  <tbody>
956
+ <!-- Results will be inserted here by JavaScript -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
957
  </tbody>
958
  </table>
959
  </div>
960
  </div>
961
  </div>
962
 
963
+ <div class="card fade-in" id="resultsSection">
964
  <div class="card-header">
965
  <div class="card-title">
966
  <i class="fas fa-download"></i>
 
973
  Export your screening results in various formats for further analysis or record keeping.
974
  </div>
975
 
976
+ <button class="btn btn-primary" id="exportCsvBtn">
977
  <i class="fas fa-file-csv"></i> Download as CSV
978
  </button>
979
+ <button class="btn btn-primary" id="exportExcelBtn" style="margin-left: 0.5rem;">
980
  <i class="fas fa-file-excel"></i> Excel
981
  </button>
982
+ <button class="btn btn-primary" id="exportPdfBtn" style="margin-left: 0.5rem;">
983
  <i class="fas fa-file-pdf"></i> PDF Report
984
  </button>
985
+ <button class="btn btn-primary" id="exportScreenshotBtn" style="margin-left: 0.5rem;">
986
  <i class="fas fa-image"></i> Screenshot
987
  </button>
988
  </div>
 
991
  </div>
992
 
993
  <script>
994
+ // Initialize jsPDF
995
+ const { jsPDF } = window.jspdf;
996
+
997
+ // Sample data
998
+ const sampleData = [
999
+ {
1000
+ ticker: "RELIANCE.NS",
1001
+ close: "2,415.75",
1002
+ bullishEntry: "2,428.45",
1003
+ bearishEntry: "2,402.30",
1004
+ bullishSignal: "2023-05-15",
1005
+ bearishSignal: null,
1006
+ proximity: "1.02%",
1007
+ signal: "bullish"
1008
+ },
1009
+ {
1010
+ ticker: "INFY.NS",
1011
+ close: "1,321.20",
1012
+ bullishEntry: "1,334.50",
1013
+ bearishEntry: "1,315.80",
1014
+ bullishSignal: null,
1015
+ bearishSignal: "2023-05-18",
1016
+ proximity: "0.84%",
1017
+ signal: "bearish"
1018
+ },
1019
+ {
1020
+ ticker: "HDFCBANK.NS",
1021
+ close: "1,645.30",
1022
+ bullishEntry: "1,654.25",
1023
+ bearishEntry: "1,638.40",
1024
+ bullishSignal: "2023-05-20",
1025
+ bearishSignal: null,
1026
+ proximity: "0.93%",
1027
+ signal: "bullish"
1028
+ },
1029
+ {
1030
+ ticker: "TCS.NS",
1031
+ close: "3,245.50",
1032
+ bullishEntry: "3,260.75",
1033
+ bearishEntry: "3,230.25",
1034
+ bullishSignal: "2023-05-10",
1035
+ bearishSignal: null,
1036
+ proximity: "1.15%",
1037
+ signal: "bullish"
1038
+ },
1039
+ {
1040
+ ticker: "BHARTIARTL.NS",
1041
+ close: "782.15",
1042
+ bullishEntry: "791.30",
1043
+ bearishEntry: "774.90",
1044
+ bullishSignal: null,
1045
+ bearishSignal: "2023-05-22",
1046
+ proximity: "0.97%",
1047
+ signal: "bearish"
1048
+ }
1049
+ ];
1050
+
1051
  // Update the last refreshed time
1052
  document.getElementById('lastRefreshed').textContent = new Date().toLocaleString();
1053
 
 
1087
  });
1088
 
1089
  // Simulate analysis button click
1090
+ document.getElementById('analyzeBtn').addEventListener('click', function() {
1091
+ const progressBar = document.getElementById('progressBar');
1092
  let width = 0;
1093
 
1094
  // Hide the warning alert
1095
+ document.getElementById('resultsAlert').style.display = 'none';
1096
 
1097
  // Show progress bar animation
1098
  progressBar.parentElement.style.display = 'block';
1099
  progressBar.style.width = '0%';
1100
 
1101
  // Reset table to empty
1102
+ document.querySelector('#resultsTable tbody').innerHTML = '<tr><td colspan="7" style="text-align: center;">Analyzing stocks...</td></tr>';
1103
 
1104
  const progressInterval = setInterval(function() {
1105
  if (width >= 100) {
 
1115
 
1116
  // Function to show sample results
1117
  function showResults() {
1118
+ const tableBody = document.querySelector('#resultsTable tbody');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1119
  tableBody.innerHTML = '';
1120
 
1121
  sampleData.forEach(stock => {
 
1136
  });
1137
 
1138
  // Show success message
1139
+ const alertDiv = document.getElementById('resultsAlert');
1140
  alertDiv.className = 'alert alert-success';
1141
  alertDiv.style.display = 'flex';
1142
  alertDiv.innerHTML = `
 
1148
  `;
1149
 
1150
  // Auto-scroll to results
1151
+ document.getElementById('resultsSection').scrollIntoView({ behavior: 'smooth' });
1152
  }
1153
 
1154
+ // Export to CSV
1155
+ document.getElementById('exportCsvBtn').addEventListener('click', function() {
1156
+ // Prepare CSV content
1157
+ let csvContent = "Ticker,Last Close,Bullish Entry,Bearish Entry,Bullish Signal,Bearish Signal,Proximity\n";
1158
+
1159
+ sampleData.forEach(stock => {
1160
+ csvContent += `${stock.ticker},${stock.close.replace(',', '')},${stock.bullishEntry.replace(',', '')},${stock.bearishEntry.replace(',', '')},`;
1161
+ csvContent += `${stock.bullishSignal || ''},${stock.bearishSignal || ''},${stock.proximity}\n`;
1162
+ });
1163
+
1164
+ // Create download link
1165
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
1166
+ const url = URL.createObjectURL(blob);
1167
+ const link = document.createElement('a');
1168
+ link.href = url;
1169
+ link.download = `bull_bear_crossover_${new Date().toISOString().slice(0,10)}.csv`;
1170
+ document.body.appendChild(link);
1171
+ link.click();
1172
+ document.body.removeChild(link);
1173
+ });
1174
+
1175
+ // Export to Excel
1176
+ document.getElementById('exportExcelBtn').addEventListener('click', function() {
1177
+ // Convert data to worksheet
1178
+ const headers = [
1179
+ "Ticker", "Last Close", "Bullish Entry", "Bearish Entry",
1180
+ "Bullish Signal", "Bearish Signal", "Proximity"
1181
+ ];
1182
+
1183
+ const excelData = sampleData.map(stock => [
1184
+ stock.ticker,
1185
+ stock.close.replace(',', ''),
1186
+ stock.bullishEntry.replace(',', ''),
1187
+ stock.bearishEntry.replace(',', ''),
1188
+ stock.bullishSignal || '',
1189
+ stock.bearishSignal || '',
1190
+ stock.proximity
1191
+ ]);
1192
+
1193
+ // Create workbook
1194
+ const wb = XLSX.utils.book_new();
1195
+ const ws = XLSX.utils.aoa_to_sheet([headers, ...excelData]);
1196
+ XLSX.utils.book_append_sheet(wb, ws, "BullBearAnalysis");
1197
+
1198
+ // Export to file
1199
+ XLSX.writeFile(wb, `bull_bear_crossover_${new Date().toISOString().slice(0,10)}.xlsx`);
1200
+ });
1201
+
1202
+ // Export to PDF
1203
+ document.getElementById('exportPdfBtn').addEventListener('click', function() {
1204
+ // Create new PDF
1205
+ const doc = new jsPDF();
1206
+
1207
+ // Add title
1208
+ doc.setFontSize(18);
1209
+ doc.setTextColor(44, 62, 80);
1210
+ doc.text('Bull Bear Crossover Analysis', 105, 15, null, null, 'center');
1211
+
1212
+ doc.setFontSize(12);
1213
+ doc.setTextColor(100, 100, 100);
1214
+ doc.text(`Generated on: ${new Date().toLocaleString()}`, 105, 22, null, null, 'center');
1215
+
1216
+ // Add table
1217
+ const headers = [
1218
+ {title: "Ticker", dataKey: "ticker"},
1219
+ {title: "Last Close", dataKey: "close"},
1220
+ {title: "Bullish Entry", dataKey: "bullishEntry"},
1221
+ {title: "Bearish Entry", dataKey: "bearishEntry"},
1222
+ {title: "Bullish Signal", dataKey: "bullishSignal"},
1223
+ {title: "Bearish Signal", dataKey: "bearishSignal"},
1224
+ {title: "Proximity", dataKey: "proximity"}
1225
+ ];
1226
+
1227
+ // Prepare data (replace null with empty string)
1228
+ const pdfData = sampleData.map(stock => ({
1229
+ ...stock,
1230
+ bullishSignal: stock.bullishSignal || '-',
1231
+ bearishSignal: stock.bearishSignal || '-'
1232
+ }));
1233
+
1234
+ doc.autoTable({
1235
+ head: [headers.map(h => h.title)],
1236
+ body: pdfData.map(row => [
1237
+ row.ticker,
1238
+ row.close,
1239
+ row.bullishEntry,
1240
+ row.bearishEntry,
1241
+ row.bullishSignal,
1242
+ row.bearishSignal,
1243
+ row.proximity
1244
+ ]),
1245
+ margin: { top: 30 },
1246
+ styles: {
1247
+ fontSize: 9,
1248
+ cellPadding: 4,
1249
+ overflow: 'linebreak'
1250
+ },
1251
+ headStyles: {
1252
+ fillColor: [44, 62, 80]
1253
+ },
1254
+ didDrawPage: function (data) {
1255
+ // Footer
1256
+ doc.setFontSize(10);
1257
+ doc.setTextColor(150);
1258
+ doc.text('Page ' + data.pageCount, data.settings.margin.left, doc.internal.pageSize.height - 10);
1259
+ }
1260
+ });
1261
+
1262
+ // Save the PDF
1263
+ doc.save(`bull_bear_crossover_${new Date().toISOString().slice(0,10)}.pdf`);
1264
+ });
1265
+
1266
+ // Export Screenshot
1267
+ document.getElementById('exportScreenshotBtn').addEventListener('click', function() {
1268
+ // Take screenshot of the results table
1269
+ const element = document.getElementById('resultsTable');
1270
+
1271
+ html2canvas(element, {
1272
+ scale: 2,
1273
+ logging: false,
1274
+ useCORS: true,
1275
+ allowTaint: true
1276
+ }).then(canvas => {
1277
+ // Convert canvas to image and download
1278
+ const link = document.createElement('a');
1279
+ link.download = `bull_bear_screenshot_${new Date().toISOString().slice(0,10)}.png`;
1280
+ link.href = canvas.toDataURL('image/png');
1281
+ link.click();
1282
+ });
1283
+ });
1284
+
1285
  // Highlight rows on hover
1286
  document.addEventListener('mouseover', function(e) {
1287
  if (e.target.tagName === 'TD' || e.target.tagName === 'TH') {
 
1326
  });
1327
  });
1328
  </script>
1329
+ </body>
1330
  </html>