lockylocks commited on
Commit
e82dbd4
·
verified ·
1 Parent(s): 4d4d02f

the left pain should be a list of tradable stocks that can be selected. it's a manual backtested so the trades should be entered by interacting with the stock chart. not buy selecting an automated strategy. multiple stocks can be held in the portfolio.

Browse files
Files changed (1) hide show
  1. index.html +108 -56
index.html CHANGED
@@ -37,18 +37,11 @@
37
  <!-- Main Content -->
38
  <main class="flex-grow container mx-auto px-4 py-8">
39
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
40
- <!-- Strategy Configuration -->
41
  <div class="lg:col-span-1 bg-white rounded-lg shadow p-6">
42
- <h2 class="text-xl font-semibold mb-4 text-gray-800">Strategy Configuration</h2>
43
 
44
  <div class="space-y-4">
45
- <!-- Stock Selection -->
46
- <div>
47
- <label class="block text-sm font-medium text-gray-700 mb-1">Stock Symbol</label>
48
- <input type="text" placeholder="e.g. AAPL"
49
- class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
50
- </div>
51
-
52
  <!-- Date Range -->
53
  <div class="grid grid-cols-2 gap-4">
54
  <div>
@@ -62,53 +55,97 @@
62
  class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
63
  </div>
64
  </div>
65
-
66
- <!-- Strategy Selection -->
67
  <div>
68
- <label class="block text-sm font-medium text-gray-700 mb-1">Strategy</label>
69
- <select class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
70
- <option>Moving Average Crossover</option>
71
- <option>Mean Reversion</option>
72
- <option>Breakout</option>
73
- <option>Custom...</option>
74
- </select>
 
75
  </div>
76
-
77
- <!-- Parameters -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  <div>
79
- <label class="block text-sm font-medium text-gray-700 mb-1">Parameters</label>
80
  <div class="space-y-2">
81
- <div class="flex items-center">
82
- <label class="w-24 text-sm text-gray-600">Short MA</label>
83
- <input type="number" value="50"
84
- class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
 
 
 
 
 
85
  </div>
86
- <div class="flex items-center">
87
- <label class="w-24 text-sm text-gray-600">Long MA</label>
88
- <input type="number" value="200"
89
- class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
 
 
 
 
 
90
  </div>
91
  </div>
92
  </div>
93
-
94
- <!-- Run Button -->
95
- <button class="w-full bg-primary hover:bg-blue-600 text-white py-2 px-4 rounded-md transition duration-200">
96
- Run Backtest
97
- </button>
98
  </div>
99
  </div>
100
-
101
- <!-- Results Display -->
102
  <div class="lg:col-span-2 space-y-6">
103
- <!-- Price Chart -->
104
  <div class="bg-white rounded-lg shadow p-6">
105
- <h2 class="text-xl font-semibold mb-4 text-gray-800">Price Chart with Signals</h2>
106
- <div class="h-80">
 
 
 
 
 
 
107
  <canvas id="priceChart"></canvas>
 
 
 
108
  </div>
109
  </div>
110
-
111
- <!-- Performance Metrics -->
112
  <div class="bg-white rounded-lg shadow p-6">
113
  <h2 class="text-xl font-semibold mb-4 text-gray-800">Performance Metrics</h2>
114
  <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
@@ -196,32 +233,34 @@
196
  const priceChart = new Chart(ctx, {
197
  type: 'line',
198
  data: {
199
- labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
200
  datasets: [
201
  {
202
- label: 'Stock Price',
203
- data: [140, 158, 153, 168, 175, 182],
204
  borderColor: '#3b82f6',
205
  backgroundColor: 'rgba(59, 130, 246, 0.1)',
206
  tension: 0.1,
207
  fill: true
208
  },
209
  {
210
- label: 'Short MA',
211
- data: [138, 148, 151, 162, 170, 178],
212
- borderColor: '#10b981',
213
- borderDash: [5, 5],
214
- tension: 0.1
 
215
  },
216
  {
217
- label: 'Long MA',
218
- data: [135, 142, 148, 155, 160, 165],
219
- borderColor: '#ef4444',
220
- borderDash: [5, 5],
221
- tension: 0.1
 
222
  }
223
  ]
224
- },
225
  options: {
226
  responsive: true,
227
  maintainAspectRatio: false,
@@ -237,9 +276,22 @@
237
  }
238
  }
239
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
  // Initialize Feather Icons
242
  feather.replace();
243
- </script>
244
  </body>
245
  </html>
 
37
  <!-- Main Content -->
38
  <main class="flex-grow container mx-auto px-4 py-8">
39
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
40
+ <!-- Stock Selection Panel -->
41
  <div class="lg:col-span-1 bg-white rounded-lg shadow p-6">
42
+ <h2 class="text-xl font-semibold mb-4 text-gray-800">Portfolio Stocks</h2>
43
 
44
  <div class="space-y-4">
 
 
 
 
 
 
 
45
  <!-- Date Range -->
46
  <div class="grid grid-cols-2 gap-4">
47
  <div>
 
55
  class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
56
  </div>
57
  </div>
58
+
59
+ <!-- Stock Search -->
60
  <div>
61
+ <label class="block text-sm font-medium text-gray-700 mb-1">Add Stock</label>
62
+ <div class="flex">
63
+ <input type="text" placeholder="Search symbol..."
64
+ class="flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
65
+ <button class="bg-primary hover:bg-blue-600 text-white px-4 rounded-r-md">
66
+ Add
67
+ </button>
68
+ </div>
69
  </div>
70
+
71
+ <!-- Stock List -->
72
+ <div class="border rounded-md divide-y">
73
+ <div class="p-3 flex justify-between items-center hover:bg-gray-50 cursor-pointer">
74
+ <div class="flex items-center space-x-3">
75
+ <span class="font-medium">AAPL</span>
76
+ <span class="text-sm text-gray-500">Apple Inc.</span>
77
+ </div>
78
+ <button class="text-red-500 hover:text-red-700">
79
+ <i data-feather="trash-2" class="w-4 h-4"></i>
80
+ </button>
81
+ </div>
82
+ <div class="p-3 flex justify-between items-center hover:bg-gray-50 cursor-pointer">
83
+ <div class="flex items-center space-x-3">
84
+ <span class="font-medium">MSFT</span>
85
+ <span class="text-sm text-gray-500">Microsoft</span>
86
+ </div>
87
+ <button class="text-red-500 hover:text-red-700">
88
+ <i data-feather="trash-2" class="w-4 h-4"></i>
89
+ </button>
90
+ </div>
91
+ <div class="p-3 flex justify-between items-center hover:bg-gray-50 cursor-pointer">
92
+ <div class="flex items-center space-x-3">
93
+ <span class="font-medium">TSLA</span>
94
+ <span class="text-sm text-gray-500">Tesla</span>
95
+ </div>
96
+ <button class="text-red-500 hover:text-red-700">
97
+ <i data-feather="trash-2" class="w-4 h-4"></i>
98
+ </button>
99
+ </div>
100
+ </div>
101
+
102
+ <!-- Active Positions -->
103
  <div>
104
+ <h3 class="text-sm font-medium text-gray-700 mb-2">Active Positions</h3>
105
  <div class="space-y-2">
106
+ <div class="p-2 bg-gray-50 rounded text-sm">
107
+ <div class="flex justify-between">
108
+ <span>AAPL</span>
109
+ <span class="font-medium">100 shares</span>
110
+ </div>
111
+ <div class="flex justify-between text-xs text-gray-500">
112
+ <span>Avg: $145.32</span>
113
+ <span>Current: $158.42</span>
114
+ </div>
115
  </div>
116
+ <div class="p-2 bg-gray-50 rounded text-sm">
117
+ <div class="flex justify-between">
118
+ <span>MSFT</span>
119
+ <span class="font-medium">75 shares</span>
120
+ </div>
121
+ <div class="flex justify-between text-xs text-gray-500">
122
+ <span>Avg: $256.78</span>
123
+ <span>Current: $268.15</span>
124
+ </div>
125
  </div>
126
  </div>
127
  </div>
 
 
 
 
 
128
  </div>
129
  </div>
130
+ <!-- Results Display -->
 
131
  <div class="lg:col-span-2 space-y-6">
132
+ <!-- Interactive Price Chart -->
133
  <div class="bg-white rounded-lg shadow p-6">
134
+ <div class="flex justify-between items-center mb-4">
135
+ <h2 class="text-xl font-semibold text-gray-800">Interactive Chart</h2>
136
+ <div class="flex space-x-2">
137
+ <button class="px-3 py-1 bg-primary text-white text-sm rounded hover:bg-blue-600">Buy</button>
138
+ <button class="px-3 py-1 bg-red-500 text-white text-sm rounded hover:bg-red-600">Sell</button>
139
+ </div>
140
+ </div>
141
+ <div class="h-80 relative">
142
  <canvas id="priceChart"></canvas>
143
+ <div class="absolute top-2 left-2 text-sm">
144
+ <span class="bg-white bg-opacity-90 px-2 py-1 rounded shadow text-gray-700">Click on chart to place trades</span>
145
+ </div>
146
  </div>
147
  </div>
148
+ <!-- Performance Metrics -->
 
149
  <div class="bg-white rounded-lg shadow p-6">
150
  <h2 class="text-xl font-semibold mb-4 text-gray-800">Performance Metrics</h2>
151
  <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
 
233
  const priceChart = new Chart(ctx, {
234
  type: 'line',
235
  data: {
236
+ labels: ['Jan 1', 'Jan 8', 'Jan 15', 'Jan 22', 'Jan 29', 'Feb 5', 'Feb 12', 'Feb 19', 'Feb 26'],
237
  datasets: [
238
  {
239
+ label: 'Price',
240
+ data: [142, 145, 138, 147, 152, 148, 155, 158, 162],
241
  borderColor: '#3b82f6',
242
  backgroundColor: 'rgba(59, 130, 246, 0.1)',
243
  tension: 0.1,
244
  fill: true
245
  },
246
  {
247
+ label: 'Buy Points',
248
+ data: [null, null, 138, null, null, null, 155, null, null],
249
+ pointBackgroundColor: '#10b981',
250
+ pointRadius: 6,
251
+ pointHoverRadius: 8,
252
+ showLine: false
253
  },
254
  {
255
+ label: 'Sell Points',
256
+ data: [null, 145, null, null, 152, null, null, 158, null],
257
+ pointBackgroundColor: '#ef4444',
258
+ pointRadius: 6,
259
+ pointHoverRadius: 8,
260
+ showLine: false
261
  }
262
  ]
263
+ },
264
  options: {
265
  responsive: true,
266
  maintainAspectRatio: false,
 
276
  }
277
  }
278
  });
279
+ // Chart click handler for placing trades
280
+ document.getElementById('priceChart').onclick = function(evt) {
281
+ const activePoints = priceChart.getElementsAtEventForMode(evt, 'nearest', { intersect: true }, true);
282
+ if (activePoints.length > 0) {
283
+ const clickedDatasetIndex = activePoints[0].datasetIndex;
284
+ const clickedIndex = activePoints[0].index;
285
+ const value = priceChart.data.datasets[0].data[clickedIndex];
286
+ const date = priceChart.data.labels[clickedIndex];
287
+
288
+ // In a real app, this would open a trade dialog
289
+ console.log(`Trade opportunity at ${date}: ${value}`);
290
+ }
291
+ };
292
 
293
  // Initialize Feather Icons
294
  feather.replace();
295
+ </script>
296
  </body>
297
  </html>