-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx.html
108 lines (103 loc) · 3.79 KB
/
x.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Algorithmic Trading Demo</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
.container {
max-width: 800px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 10px;
}
input[type="text"], input[type="number"], select {
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
border: 1px solid #ccc;
}
.error-message {
color: red;
margin-top: -10px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Algorithmic Trading Demo</h1>
<form id="tradingForm">
<label for="symbol">Symbol:</label>
<input type="text" id="symbol" name="symbol" required>
<label for="quantity">Quantity:</label>
<input type="number" id="quantity" name="quantity" required>
<label for="price">Price:</label>
<input type="number" id="price" name="price" required>
<label for="orderType">Order Type:</label>
<select id="orderType" name="orderType" required>
<option value="">Select</option>
<option value="buy">Buy</option>
<option value="sell">Sell</option>
</select>
<button type="submit">Submit</button>
<p class="error-message" id="errorMessage"></p>
</form>
</div>
<script>
document.getElementById("tradingForm").addEventListener("submit", function(event) {
event.preventDefault();
const symbol = document.getElementById("symbol").value;
const quantity = document.getElementById("quantity").value;
const price = document.getElementById("price").value;
const orderType = document.getElementById("orderType").value;
// Basic validation
if (symbol === "" || quantity === "" || price === "" || orderType === "") {
document.getElementById("errorMessage").textContent = "Please fill out all fields.";
return;
}
// Additional validation (e.g., quantity and price should be positive numbers)
if (isNaN(quantity) || isNaN(price) || quantity <= 0 || price <= 0) {
document.getElementById("errorMessage").textContent = "Quantity and price must be positive numbers.";
return;
}
// Clear error message
document.getElementById("errorMessage").textContent = "";
// Here you can add code to execute trading logic or send data to a server
console.log("Submitted Symbol:", symbol);
console.log("Submitted Quantity:", quantity);
console.log("Submitted Price:", price);
console.log("Submitted Order Type:", orderType);
});
</script>
</body>
</html>