create a manual backtesting app for testing stock trading strategies. keep the design functional for now.
Browse files- README.md +8 -5
- index.html +244 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: TradeWizard Backtester 🧙♂️
|
| 3 |
+
colorFrom: red
|
| 4 |
+
colorTo: green
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
index.html
CHANGED
|
@@ -1,19 +1,245 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
+
<!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>TradeWizard Backtester</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<script>
|
| 11 |
+
tailwind.config = {
|
| 12 |
+
theme: {
|
| 13 |
+
extend: {
|
| 14 |
+
colors: {
|
| 15 |
+
primary: '#3b82f6',
|
| 16 |
+
secondary: '#10b981',
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
</script>
|
| 22 |
+
</head>
|
| 23 |
+
<body class="bg-gray-50">
|
| 24 |
+
<div class="min-h-screen flex flex-col">
|
| 25 |
+
<!-- Header -->
|
| 26 |
+
<header class="bg-white shadow-sm py-4">
|
| 27 |
+
<div class="container mx-auto px-4 flex justify-between items-center">
|
| 28 |
+
<h1 class="text-2xl font-bold text-primary">TradeWizard 🧙♂️</h1>
|
| 29 |
+
<nav class="flex items-center space-x-6">
|
| 30 |
+
<a href="#" class="text-gray-600 hover:text-primary">Backtester</a>
|
| 31 |
+
<a href="#" class="text-gray-600 hover:text-primary">Strategies</a>
|
| 32 |
+
<a href="#" class="text-gray-600 hover:text-primary">Performance</a>
|
| 33 |
+
</nav>
|
| 34 |
+
</div>
|
| 35 |
+
</header>
|
| 36 |
+
|
| 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>
|
| 55 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Start Date</label>
|
| 56 |
+
<input type="date"
|
| 57 |
+
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">
|
| 58 |
+
</div>
|
| 59 |
+
<div>
|
| 60 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">End Date</label>
|
| 61 |
+
<input type="date"
|
| 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">
|
| 115 |
+
<div class="bg-gray-50 p-4 rounded">
|
| 116 |
+
<p class="text-sm text-gray-500">Total Return</p>
|
| 117 |
+
<p class="text-2xl font-bold text-primary">+24.5%</p>
|
| 118 |
+
</div>
|
| 119 |
+
<div class="bg-gray-50 p-4 rounded">
|
| 120 |
+
<p class="text-sm text-gray-500">Win Rate</p>
|
| 121 |
+
<p class="text-2xl font-bold text-primary">68%</p>
|
| 122 |
+
</div>
|
| 123 |
+
<div class="bg-gray-50 p-4 rounded">
|
| 124 |
+
<p class="text-sm text-gray-500">Max Drawdown</p>
|
| 125 |
+
<p class="text-2xl font-bold text-primary">-12.3%</p>
|
| 126 |
+
</div>
|
| 127 |
+
<div class="bg-gray-50 p-4 rounded">
|
| 128 |
+
<p class="text-sm text-gray-500">Sharpe Ratio</p>
|
| 129 |
+
<p class="text-2xl font-bold text-primary">1.45</p>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<!-- Trade Log -->
|
| 135 |
+
<div class="bg-white rounded-lg shadow p-6">
|
| 136 |
+
<h2 class="text-xl font-semibold mb-4 text-gray-800">Trade Log</h2>
|
| 137 |
+
<div class="overflow-x-auto">
|
| 138 |
+
<table class="min-w-full divide-y divide-gray-200">
|
| 139 |
+
<thead class="bg-gray-50">
|
| 140 |
+
<tr>
|
| 141 |
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
|
| 142 |
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Action</th>
|
| 143 |
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Price</th>
|
| 144 |
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Quantity</th>
|
| 145 |
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">PnL</th>
|
| 146 |
+
</tr>
|
| 147 |
+
</thead>
|
| 148 |
+
<tbody class="bg-white divide-y divide-gray-200">
|
| 149 |
+
<tr>
|
| 150 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">2023-01-15</td>
|
| 151 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm font-medium text-green-600">BUY</td>
|
| 152 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">$142.35</td>
|
| 153 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">100</td>
|
| 154 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">-</td>
|
| 155 |
+
</tr>
|
| 156 |
+
<tr>
|
| 157 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">2023-02-28</td>
|
| 158 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm font-medium text-red-600">SELL</td>
|
| 159 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">$158.72</td>
|
| 160 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">100</td>
|
| 161 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm font-medium text-green-600">+$1,637</td>
|
| 162 |
+
</tr>
|
| 163 |
+
<tr>
|
| 164 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">2023-03-10</td>
|
| 165 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm font-medium text-green-600">BUY</td>
|
| 166 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">$152.89</td>
|
| 167 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">100</td>
|
| 168 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">-</td>
|
| 169 |
+
</tr>
|
| 170 |
+
<tr>
|
| 171 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">2023-04-22</td>
|
| 172 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm font-medium text-red-600">SELL</td>
|
| 173 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">$168.34</td>
|
| 174 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">100</td>
|
| 175 |
+
<td class="px-4 py-2 whitespace-nowrap text-sm font-medium text-green-600">+$1,545</td>
|
| 176 |
+
</tr>
|
| 177 |
+
</tbody>
|
| 178 |
+
</table>
|
| 179 |
+
</div>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
</main>
|
| 184 |
+
|
| 185 |
+
<!-- Footer -->
|
| 186 |
+
<footer class="bg-white py-4 border-t">
|
| 187 |
+
<div class="container mx-auto px-4 text-center text-gray-500 text-sm">
|
| 188 |
+
<p>TradeWizard Backtester - Test your trading strategies with confidence</p>
|
| 189 |
+
</div>
|
| 190 |
+
</footer>
|
| 191 |
+
</div>
|
| 192 |
+
|
| 193 |
+
<script>
|
| 194 |
+
// Initialize Chart
|
| 195 |
+
const ctx = document.getElementById('priceChart').getContext('2d');
|
| 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,
|
| 228 |
+
plugins: {
|
| 229 |
+
legend: {
|
| 230 |
+
position: 'top',
|
| 231 |
+
}
|
| 232 |
+
},
|
| 233 |
+
scales: {
|
| 234 |
+
y: {
|
| 235 |
+
beginAtZero: false
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
// Initialize Feather Icons
|
| 242 |
+
feather.replace();
|
| 243 |
+
</script>
|
| 244 |
+
</body>
|
| 245 |
</html>
|