diff --git a/halt/index.html b/halt/index.html
index ccf5c2c..853a0a6 100644
--- a/halt/index.html
+++ b/halt/index.html
@@ -3,30 +3,38 @@
- Time Price Calculator
+ Halt Reopen Band Estimator
@@ -46,16 +54,25 @@ Halt Reopen Band Estimator
+
+
+
+
+
+
+
+
Time |
- Price |
+ Lower Band Price |
+ Upper Band Price |
diff --git a/halt/script.js b/halt/script.js
index 8fed6c5..e33cb44 100644
--- a/halt/script.js
+++ b/halt/script.js
@@ -43,18 +43,28 @@ $(document).ready(function() {
return now.toTimeString().slice(0, 8);
}
+ function calculateLowerPrice(haltPrice, percentDecrease) {
+ const lowerPrice = haltPrice - (haltPrice * percentDecrease);
+ return Math.max(0, lowerPrice).toFixed(2);
+ }
+
+ function checkPriceInBand(indicativePrice, lowerBand, upperBand) {
+ return indicativePrice >= parseFloat(lowerBand) && indicativePrice <= parseFloat(upperBand);
+ }
+
function generateTable(e) {
e.preventDefault();
const startTime = $('#timeInput').val();
- const startPrice = parseFloat($('#priceInput').val());
+ const haltPrice = parseFloat($('#priceInput').val());
+ const indicativePrice = parseFloat($('#indicativePriceInput').val());
// Validation
if (!validateTime(startTime)) {
showError('Please enter a valid time in HH:MM:SS format');
return;
}
- if (isNaN(startPrice) || startPrice <= 0) {
+ if (isNaN(haltPrice) || haltPrice <= 0) {
showError('Please enter a valid positive price');
return;
}
@@ -65,40 +75,77 @@ $(document).ready(function() {
const endTime = '15:49:59';
let rowCount = 0;
const currentTimeStr = getCurrentTime();
+ let firstValidTime = null;
+
+ // Start with first increment
+ currentTime = addMinutesToTime(currentTime, 5);
- // Generate regular rows
while (isTimeGreater(currentTime, endTime)) {
- const price = (startPrice + (startPrice * 0.05 * rowCount)).toFixed(2);
+ const upperBandPrice = (haltPrice + (haltPrice * 0.05 * (rowCount + 1))).toFixed(2);
+ const lowerBandPrice = calculateLowerPrice(haltPrice, 0.05 * (rowCount + 1));
const isPastTime = isTimePast(currentTime, currentTimeStr);
- const classes = isPastTime ? 'past-time' : '';
+ // Check if indicative price is within bands
+ const isPriceValid = !isNaN(indicativePrice) &&
+ checkPriceInBand(indicativePrice, lowerBandPrice, upperBandPrice) &&
+ !firstValidTime; // Only mark as valid if it's the first valid time
+
+ if (isPriceValid) {
+ firstValidTime = currentTime;
+ }
+
+ const classes = [];
+ if (isPastTime) classes.push('past-time');
+ if (isPriceValid) classes.push('valid-price-row');
+
tableRows.push(`
-
+
${currentTime} |
- $${price} |
+ $${lowerBandPrice} |
+ $${upperBandPrice} |
`);
currentTime = addMinutesToTime(currentTime, 5);
rowCount++;
}
- // Add final row with 10% increase
+ // Add final row with 10% increase/decrease
if (tableRows.length > 0) {
- const lastPrice = parseFloat((startPrice + (startPrice * 0.05 * (rowCount - 1))).toFixed(2));
- const finalPrice = (lastPrice * 1.10).toFixed(2);
+ const lastUpperPrice = parseFloat((haltPrice + (haltPrice * 0.05 * rowCount)).toFixed(2));
+ const finalUpperPrice = (lastUpperPrice * 1.10).toFixed(2);
+ const finalLowerPrice = calculateLowerPrice(haltPrice, 0.05 * rowCount * 1.10);
const isPastTime = isTimePast('15:50:00', currentTimeStr);
+ const isPriceValid = !isNaN(indicativePrice) &&
+ checkPriceInBand(indicativePrice, finalLowerPrice, finalUpperPrice) &&
+ !firstValidTime; // Only mark as valid if it's the first valid time
+
+ if (isPriceValid && !firstValidTime) {
+ firstValidTime = '15:50:00';
+ }
const classes = ['final-row'];
if (isPastTime) classes.push('past-time');
+ if (isPriceValid) classes.push('valid-price-row');
tableRows.push(`
15:50:00 |
- $${finalPrice} |
+ $${finalLowerPrice} |
+ $${finalUpperPrice} |
`);
}
+ // Show valid time message if applicable
+ const validTimeMessage = $('#validTimeMessage');
+ if (!isNaN(indicativePrice) && firstValidTime) {
+ validTimeMessage
+ .html(`The earliest time the indicative price ($${indicativePrice.toFixed(2)}) falls within the bands is: ${firstValidTime}`)
+ .removeClass('d-none');
+ } else {
+ validTimeMessage.addClass('d-none');
+ }
+
// Update table
const tbody = $('#resultTable tbody');
tbody.html(tableRows.join(''));
@@ -112,7 +159,7 @@ $(document).ready(function() {
const isPastTime = isTimePast(rowTime, newCurrentTime);
$(this).toggleClass('past-time', isPastTime);
});
- }, 1000); // Update every second
+ }, 1000);
}
// Handle form submission (both button click and Enter key)
diff --git a/muts/index.html b/muts/index.html
new file mode 100644
index 0000000..f333b0b
--- /dev/null
+++ b/muts/index.html
@@ -0,0 +1,53 @@
+
+
+
+ Time to Milliseconds Calculator
+
+
+
+
+
Milliseconds Since Midnight Calculator
+
+
+
+
+
+
+