Spaces:
Running
Running
garder soit amount soit buy price et mettre les multiplicateurs de risque
Browse files- simulator.html +27 -18
simulator.html
CHANGED
|
@@ -203,36 +203,36 @@
|
|
| 203 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
| 204 |
<div>
|
| 205 |
<label class="block text-sm font-medium text-gray-300 mb-1">Buy Price (USDT)</label>
|
| 206 |
-
<input type="number" class="bg-gray-700 border border-gray-600 text-white rounded-lg px-4 py-2 w-full focus:ring-2 focus:ring-violet-500 focus:border-transparent" placeholder="0.00" id="buyPrice">
|
| 207 |
</div>
|
| 208 |
<div>
|
| 209 |
-
<label class="block text-sm font-medium text-gray-300 mb-1">Amount (
|
| 210 |
-
<input type="number" class="bg-gray-700 border border-gray-600 text-white rounded-lg px-4 py-2 w-full focus:ring-2 focus:ring-violet-500 focus:border-transparent" placeholder="0.00" id="buyAmount">
|
| 211 |
</div>
|
| 212 |
-
|
| 213 |
<div class="grid grid-cols-4 gap-2 mb-4">
|
| 214 |
<div class="relative">
|
| 215 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(1)">1x</button>
|
| 216 |
-
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">
|
| 217 |
</div>
|
| 218 |
<div class="relative">
|
| 219 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(5)">5x</button>
|
| 220 |
-
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">
|
| 221 |
</div>
|
| 222 |
<div class="relative">
|
| 223 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(10)">10x</button>
|
| 224 |
-
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">
|
| 225 |
</div>
|
| 226 |
<div class="relative">
|
| 227 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(25)">25x</button>
|
| 228 |
-
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">
|
| 229 |
</div>
|
| 230 |
</div>
|
| 231 |
<div class="flex justify-between items-center mb-2">
|
| 232 |
-
<span id="
|
| 233 |
<span id="riskLevel" class="text-sm text-gray-400">Risk: Low</span>
|
| 234 |
</div>
|
| 235 |
-
|
| 236 |
</div>
|
| 237 |
|
| 238 |
<!-- Sell Section (hidden by default) -->
|
|
@@ -508,24 +508,33 @@ try {
|
|
| 508 |
});
|
| 509 |
});
|
| 510 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
// Set leverage multiplier
|
| 512 |
let currentLeverage = 1;
|
| 513 |
-
let currentFee = 0;
|
| 514 |
function setLeverage(multiplier) {
|
| 515 |
currentLeverage = multiplier;
|
| 516 |
-
currentFee = {
|
| 517 |
-
1: 0,
|
| 518 |
-
5: 5,
|
| 519 |
-
10: 10,
|
| 520 |
-
25: 25
|
| 521 |
-
}[multiplier] || 0;
|
| 522 |
|
| 523 |
document.querySelectorAll('#buySection button').forEach(btn => {
|
| 524 |
btn.classList.toggle('bg-violet-500', btn.textContent.includes(`${multiplier}x`));
|
| 525 |
btn.classList.toggle('bg-gray-700', !btn.textContent.includes(`${multiplier}x`));
|
| 526 |
});
|
| 527 |
|
| 528 |
-
|
| 529 |
}
|
| 530 |
// Execute buy/sell order
|
| 531 |
function executeOrder(type) {
|
|
|
|
| 203 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
| 204 |
<div>
|
| 205 |
<label class="block text-sm font-medium text-gray-300 mb-1">Buy Price (USDT)</label>
|
| 206 |
+
<input type="number" class="bg-gray-700 border border-gray-600 text-white rounded-lg px-4 py-2 w-full focus:ring-2 focus:ring-violet-500 focus:border-transparent" placeholder="0.00" id="buyPrice" oninput="calculateRisk()">
|
| 207 |
</div>
|
| 208 |
<div>
|
| 209 |
+
<label class="block text-sm font-medium text-gray-300 mb-1">Amount (BTC)</label>
|
| 210 |
+
<input type="number" class="bg-gray-700 border border-gray-600 text-white rounded-lg px-4 py-2 w-full focus:ring-2 focus:ring-violet-500 focus:border-transparent" placeholder="0.00" id="buyAmount" oninput="calculateRisk()">
|
| 211 |
</div>
|
| 212 |
+
</div>
|
| 213 |
<div class="grid grid-cols-4 gap-2 mb-4">
|
| 214 |
<div class="relative">
|
| 215 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(1)">1x</button>
|
| 216 |
+
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">Low Risk</div>
|
| 217 |
</div>
|
| 218 |
<div class="relative">
|
| 219 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(5)">5x</button>
|
| 220 |
+
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">Medium Risk</div>
|
| 221 |
</div>
|
| 222 |
<div class="relative">
|
| 223 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(10)">10x</button>
|
| 224 |
+
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">High Risk</div>
|
| 225 |
</div>
|
| 226 |
<div class="relative">
|
| 227 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 rounded-lg text-sm w-full" onclick="setLeverage(25)">25x</button>
|
| 228 |
+
<div class="absolute -bottom-6 left-0 right-0 text-xs text-center text-gray-400">Extreme Risk</div>
|
| 229 |
</div>
|
| 230 |
</div>
|
| 231 |
<div class="flex justify-between items-center mb-2">
|
| 232 |
+
<span id="positionSize" class="text-sm text-gray-400">Position: $0</span>
|
| 233 |
<span id="riskLevel" class="text-sm text-gray-400">Risk: Low</span>
|
| 234 |
</div>
|
| 235 |
+
<button class="w-full bg-green-500 hover:bg-green-600 text-white py-2 rounded-lg font-medium" onclick="executeOrder('buy')">Buy BTC</button>
|
| 236 |
</div>
|
| 237 |
|
| 238 |
<!-- Sell Section (hidden by default) -->
|
|
|
|
| 508 |
});
|
| 509 |
});
|
| 510 |
});
|
| 511 |
+
// Calculate position size and risk
|
| 512 |
+
function calculateRisk() {
|
| 513 |
+
const price = parseFloat(document.getElementById('buyPrice').value) || 0;
|
| 514 |
+
const amount = parseFloat(document.getElementById('buyAmount').value) || 0;
|
| 515 |
+
const positionSize = price * amount * currentLeverage;
|
| 516 |
+
|
| 517 |
+
document.getElementById('positionSize').textContent = `Position: ${positionSize.toFixed(2)}`;
|
| 518 |
+
|
| 519 |
+
let riskLevel = 'Low';
|
| 520 |
+
if (currentLeverage >= 25) riskLevel = 'Extreme';
|
| 521 |
+
else if (currentLeverage >= 10) riskLevel = 'High';
|
| 522 |
+
else if (currentLeverage >= 5) riskLevel = 'Medium';
|
| 523 |
+
|
| 524 |
+
document.getElementById('riskLevel').textContent = `Risk: ${riskLevel}`;
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
// Set leverage multiplier
|
| 528 |
let currentLeverage = 1;
|
|
|
|
| 529 |
function setLeverage(multiplier) {
|
| 530 |
currentLeverage = multiplier;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
|
| 532 |
document.querySelectorAll('#buySection button').forEach(btn => {
|
| 533 |
btn.classList.toggle('bg-violet-500', btn.textContent.includes(`${multiplier}x`));
|
| 534 |
btn.classList.toggle('bg-gray-700', !btn.textContent.includes(`${multiplier}x`));
|
| 535 |
});
|
| 536 |
|
| 537 |
+
calculateRisk();
|
| 538 |
}
|
| 539 |
// Execute buy/sell order
|
| 540 |
function executeOrder(type) {
|