Certainly! Below is a simple HTML trading journal you can use to log your trades. It includes fields for date, ticker symbol, entry price, exit price, position size, and notes. Additionally, it has some basic JavaScript to add entries to a table dynamically and save the data locally in your browser so you don’t lose your journal when refreshing.
You can save this as trading-journal.html and open it in any modern browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Trading Journal</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 2rem;
background-color: #f7f9fc;
}
h1 {
text-align: center;
margin-bottom: 1rem;
}
form {
max-width: 600px;
margin: 0 auto 2rem auto;
background: white;
padding: 1rem 1.5rem;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
label {
display: block;
margin-top: 1rem;
font-weight: bold;
}
input[type="text"], input[type="number"], input[type="date"], textarea {
width: 100%;
padding: 0.5rem;
margin-top: 0.3rem;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 1rem;
}
textarea {
resize: vertical;
}
button {
margin-top: 1.5rem;
background-color: #007bff;
border: none;
color: white;
padding: 0.6rem 1.5rem;
font-size: 1rem;
cursor: pointer;
border-radius: 4px;
}
button:hover {
background-color: #0056b3;
}
table {
width: 100%;
border-collapse: collapse;
background: white;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
max-width: 900px;
margin: 0 auto;
border-radius: 8px;
overflow: hidden;
}
th, td {
text-align: left;
padding: 0.75rem 1rem;
border-bottom: 1px solid #ddd;
font-size: 0.95rem;
}
th {
background-color: #007bff;
color: white;
}
tbody tr:hover {
background-color: #f1f7ff;
}
.delete-btn {
background-color: #dc3545;
border: none;
color: white;
padding: 0.3rem 0.7rem;
font-size: 0.85rem;
border-radius: 4px;
cursor: pointer;
}
.delete-btn:hover {
background-color: #a71d2a;
}
@media (max-width: 700px) {
form, table {
width: 95%;
}
table, th, td {
font-size: 0.85rem;
}
}
</style>
</head>
<body>
<h1>Trading Journal</h1>
<form id="tradeForm">
<label for="date">Date</label>
<input type="date" id="date" required />
<label for="ticker">Ticker Symbol</label>
<input type="text" id="ticker" placeholder="e.g. AAPL" maxlength="10" required />
<label for="entryPrice">Entry Price ($)</label>
<input type="number" id="entryPrice" placeholder="e.g. 130.00" step="0.01" min="0" required />
<label for="exitPrice">Exit Price ($)</label>
<input type="number" id="exitPrice" placeholder="e.g. 135.50" step="0.01" min="0" required />
<label for="positionSize">Position Size (shares/contracts)</label>
<input type="number" id="positionSize" placeholder="e.g. 100" min="1" required />
<label for="notes">Notes</label>
<textarea id="notes" rows="3" placeholder="Optional notes about the trade..."></textarea>
<button type="submit">Add Trade</button>
</form>
<table id="tradeTable" aria-label="Trade Journal Table">
<thead>
<tr>
<th>Date</th>
<th>Ticker</th>
<th>Entry Price</th>
<th>Exit Price</th>
<th>Position Size</th>
<th>Profit / Loss ($)</th>
<th>Notes</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- Trades will appear here -->
</tbody>
</table>
<script>
const tradeForm = document.getElementById('tradeForm');
const tradeTableBody = document.querySelector('#tradeTable tbody');
// Load saved trades from localStorage
let trades = JSON.parse(localStorage.getItem('tradingJournalTrades') || '[]');
function saveTrades() {
localStorage.setItem('tradingJournalTrades', JSON.stringify(trades));
}
function renderTrades() {
tradeTableBody.innerHTML = '';
trades.forEach((trade, index) => {
const row = document.createElement('tr');
const profitLoss = (trade.exitPrice - trade.entryPrice) * trade.positionSize;
const profitLossFormatted = profitLoss.toFixed(2);
const profitLossClass = profitLoss >= 0 ? 'positive' : 'negative';
row.innerHTML = `
<td>${trade.date}</td>
<td>${trade.ticker.toUpperCase()}</td>
<td>$${trade.entryPrice.toFixed(2)}</td>
<td>$${trade.exitPrice.toFixed(2)}</td>
<td>${trade.positionSize}</td>
<td style="color: ${profitLoss >= 0 ? 'green' : 'red'};">${profitLossFormatted}</td>
<td>${trade.notes ? trade.notes.replace(/</g, "<").replace(/>/g, ">") : ''}</td>
<td><button aria-label="Delete Trade" class="delete-btn" data-index="${index}">Delete</button></td>
`;
tradeTableBody.appendChild(row);
});
}
// Initial render
renderTrades();
tradeForm.addEventListener('submit', (e) => {
e.preventDefault();
const date = tradeForm.date.value;
const ticker = tradeForm.ticker.value.trim();
const entryPrice = parseFloat(tradeForm.entryPrice.value);
const exitPrice = parseFloat(tradeForm.exitPrice.value);
const positionSize = parseInt(tradeForm.positionSize.value, 10);
const notes = tradeForm.notes.value.trim();
// Basic validation
if (!date || !ticker || isNaN(entryPrice) || isNaN(exitPrice) || isNaN(positionSize) || positionSize < 1) {
alert('Please fill in all required fields with valid values.');
return;
}
trades.push({
date,
ticker,
entryPrice,
exitPrice,
positionSize,
notes
});
saveTrades();
renderTrades();
tradeForm.reset();
});
// Delete trade
tradeTableBody.addEventListener('click', (e) => {
if (e.target.classList.contains('delete-btn')) {
const index = parseInt(e.target.getAttribute('data-index'), 10);
if (index >= 0 && index < trades.length) {
if (confirm('Are you sure you want to delete this trade?')) {
trades.splice(index, 1);
saveTrades();
renderTrades();
}
}
}
});
</script>
</body>
</html>
Features:
- Input form for trade details.
- Table listing all trades.
- Shows profit/loss per trade.
- Data saved in browser localStorage.
- Delete individual trades.
- Responsive and clean UI.
You can extend or modify this however you'd like! If you want me to add features like filtering, exporting CSV, charts, or anything else, just ask!