-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
232 lines (204 loc) · 8.76 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trading Calculator</title>
<!-- Latest Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
body {
background-color: #f8f9fa;
}
.container {
margin-top: 20px;
}
.card {
border: none;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.card-header {
background-color: #343a40;
color: #ffffff;
}
.btn-calculate {
background-color: #007bff;
color: #ffffff;
transition: background-color 0.2s;
}
.btn-calculate:hover {
background-color: #0056b3;
}
.btn-clear {
background-color: #6c757d;
color: #ffffff;
transition: background-color 0.2s;
}
.btn-clear:hover {
background-color: #495057;
}
h2 {
color: #343a40;
margin-top: 20px;
}
.table {
background-color: #ffffff;
}
.table td,
.table th {
border: 1px solid #dee2e6;
padding: 8px;
}
.table-bordered {
border: 2px solid #dee2e6;
}
.result-value {
font-weight: bold;
}
/* Styling for results based on value */
.negative-result {
color: red !important;
}
.positive-result {
color: green !important;
}
/* Radio buttons in one line */
.radio-inline {
display: flex;
align-items: center;
}
.radio-inline input[type="radio"] {
margin-right: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header">
<h4 class="mb-0">Future Leverage - Stop Loss & Take Profit Calculator</h4>
</div>
<div class="card-body">
<form>
<div class="row mb-3">
<div class="col-md-6">
<label for="amount" class="form-label">Amount</label>
<input type="number" step="0.01" class="form-control" id="amount" placeholder="Enter Amount"
required>
</div>
<div class="col-md-6">
<label for="leverage" class="form-label">Leverage</label>
<input type="number" class="form-control" id="leverage" min="2" max="50"
placeholder="Enter Leverage" required>
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="entryPrice" class="form-label">Entry Price</label>
<input type="number" step="0.01" class="form-control" id="entryPrice"
placeholder="Enter Entry Price" required>
</div>
<div class="col-md-6">
<label for="tradeType" class="form-label">Trade Type</label>
<div class="radio-inline">
<input type="radio" id="long" name="tradeType" value="long" checked>
<label for="long">Long</label>
<input type="radio" id="short" name="tradeType" value="short">
<label for="short">Short</label>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="stopLoss" class="form-label">Stop Loss At</label>
<input type="number" step="0.01" class="form-control" id="stopLoss"
placeholder="Enter Stop Loss" required>
</div>
<div class="col-md-6">
<label for="takeprofit" class="form-label">Take Profit At</label>
<input type="number" step="0.01" class="form-control" id="takeprofit"
placeholder="Enter Entry Price" required>
</div>
</div>
<div class="text-center mt-3">
<button type="button" class="btn btn-calculate mr-2" onclick="calculate()">Calculate</button>
<button type="button" class="btn btn-clear" onclick="clearFields()">Clear</button>
</div>
</form>
</div>
</div>
<div class="container mt-4">
<h2>Results</h2>
<table class="table table-bordered">
<tbody>
<tr>
<td>Amount (with Leverage)</td>
<td id="tradingInfo" class="result-value">-</td>
</tr>
<tr>
<td>Loss in USDT</td>
<td id="lossUSDT" class="result-value negative-result">-</td>
</tr>
<tr>
<td>Loss in %</td>
<td id="lossPercentage" class="result-value negative-result">-</td>
</tr>
<tr>
<td>Profit in USDT</td>
<td id="profitUSDT" class="result-value positive-result">-</td>
</tr>
<tr>
<td>Profit in %</td>
<td id="profitPercentage" class="result-value positive-result">-</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
function calculate() {
// Get input values
const amount = parseFloat(document.getElementById("amount").value);
const leverage = parseFloat(document.getElementById("leverage").value);
const entryPrice = parseFloat(document.getElementById("entryPrice").value);
const stopLoss = parseFloat(document.getElementById("stopLoss").value);
const takeProfit = parseFloat(document.getElementById("takeprofit").value);
// Get selected trade type
const tradeType = document.querySelector('input[name="tradeType"]:checked').value;
// Adjust calculations based on trade type
let lossUSDT, profitUSDT;
if (tradeType === "long") {
lossUSDT = (entryPrice - stopLoss) * ((amount * leverage) / entryPrice);
profitUSDT = (takeProfit - entryPrice) * ((amount * leverage) / entryPrice);
} else if (tradeType === "short") {
lossUSDT = (stopLoss - entryPrice) * ((amount * leverage) / entryPrice);
profitUSDT = (entryPrice - takeProfit) * ((amount * leverage) / entryPrice);
}
// Calculate trading information
const tradingInfo = amount * leverage;
const lossPercentage = (lossUSDT / amount) * 100;
const profitPercentage = (profitUSDT / amount) * 100;
// Set values in the results table
document.getElementById("tradingInfo").textContent = tradingInfo.toFixed(2);
document.getElementById("lossUSDT").textContent = "-" + lossUSDT.toFixed(2);
document.getElementById("lossPercentage").textContent = "-" + lossPercentage.toFixed(2) + "%";
document.getElementById("profitUSDT").textContent = "+" + profitUSDT.toFixed(2);
document.getElementById("profitPercentage").textContent = "+" + profitPercentage.toFixed(2) + "%";
}
function clearFields() {
// Clear input fields
document.getElementById("amount").value = "";
document.getElementById("leverage").value = "";
document.getElementById("entryPrice").value = "";
document.getElementById("stopLoss").value = "";
document.getElementById("takeprofit").value = "";
// Clear results
document.getElementById("tradingInfo").textContent = "-";
document.getElementById("lossUSDT").textContent = "-";
document.getElementById("lossPercentage").textContent = "-";
document.getElementById("profitUSDT").textContent = "-";
document.getElementById("profitPercentage").textContent = "-";
}
</script>
</body>
</html>