-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
187 lines (165 loc) · 6.54 KB
/
Copy pathindex.html
File metadata and controls
187 lines (165 loc) · 6.54 KB
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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Türkei 1J Staatsanleihe Tracker</title>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
body { font-family: 'Press Start 2P', monospace; margin: 20px; background-color: #111; color: #0f0; }
table { border-collapse: collapse; width: 100%; margin-top: 20px; }
th, td { border: 1px solid #0f0; padding: 8px; text-align: center; }
th { background-color: #222; }
.buy { background-color: #033; }
.sell { background-color: #300; }
.delete-btn { background-color: #ff6666; color: white; border: none; padding: 5px 10px; cursor: pointer; }
.dark-mode { background-color: black; color: white; }
.dark-mode th { background-color: #333; }
button { background-color: #222; color: #0f0; border: 3px solid #0f0; padding: 10px 20px; cursor: pointer; box-shadow: 4px 4px #0f0; }
button:hover { background-color: #0f0; color: #111; }
</style>
</head>
<body>
<h2>Türkei 1-jährige Staatsanleihe</h2>
<!-- Eingabeformular -->
<label>Summe (TL): <input type="number" id="sumTL" step="0.01"></label>
<label>Datum: <input type="date" id="date"></label>
<label>Kaufkurs (%): <input type="number" id="buyPrice" step="0.01"></label>
<label>Ticker: <input type="text" id="ticker"></label>
<label>Verkaufskurs (%): <input type="number" id="sellPrice" step="0.01"></label>
<button onclick="addEntry()">Eintrag hinzufügen</button>
<!-- Tabelle -->
<table id="bondTable">
<thead>
<tr>
<th>Datum</th>
<th>Summe (TL)</th>
<th class="buy">Kaufkurs (%)</th>
<th>Ticker</th>
<th class="sell">Verkaufskurs (%)</th>
<th>Nominal (%)</th>
<th>Unrealized Profit (TL)</th>
<th>Aktion</th>
</tr>
</thead>
<tbody></tbody>
</table>
<!-- Totals -->
<h3>Gesamt investiert: <span id="totalInvested">0</span> TL</h3>
<h3>Gesamt Unrealized Profit: <span id="totalProfit">0</span> TL</h3>
<h3>Total (Investiert + Profit): <span id="grandTotal">0</span> TL</h3>
<!-- Buttons -->
<button onclick="toggleMode()">☀️ / 🌛</button>
<a href="https://www.github.com/codexboru" target="_blank"><button>😶🌫️ Codexboru</button></a>
<a href="https://codexboru.github.io/bond/README.html" target="_blank"><button>🕹 README.md</button></a>
<a href="https://codexboru.github.io/bond/money.html" target="_blank"><button>🐈 M2/M3</button></a>
<a href="https://codexboru.github.io/bond/stats.html" target="_blank"><button>📊 Stats</button></a>
<a href="https://codexboru.github.io/bond/Wallet.html" target="_blank"><button>🎫 Wallet</button></a>
<button onclick="downloadData()">💾 download</button>
<input type="file" id="uploadFile"
accept=".json,.txt,.csv"
onchange="uploadData()" style="display:none;" />
<button onclick="document.getElementById('uploadFile').click()">💉 upload</button>
<script>
function addEntry() {
const sumTL = parseFloat(document.getElementById('sumTL').value) || 0;
const date = document.getElementById('date').value;
const buyPrice = parseFloat(document.getElementById('buyPrice').value) || 0;
const ticker = document.getElementById('ticker').value;
const sellPrice = parseFloat(document.getElementById('sellPrice').value);
const nominal = 100;
let profit = 0;
let invested = sumTL;
if (!isNaN(sellPrice) && sellPrice > 0) {
profit = ((sellPrice - buyPrice) / 100) * sumTL;
invested = 0;
} else {
profit = ((nominal - buyPrice) / 100) * sumTL;
}
const table = document.getElementById('bondTable').getElementsByTagName('tbody')[0];
const row = table.insertRow();
row.innerHTML = `
<td>${date}</td>
<td>${sumTL.toFixed(2)}</td>
<td>${buyPrice.toFixed(2)}</td>
<td>${ticker}</td>
<td>${sellPrice ? sellPrice.toFixed(2) : '-'}</td>
<td>${nominal}</td>
<td>${(!isNaN(sellPrice) && sellPrice > 0) ? '-' : profit.toFixed(2)}</td>
<td><button class="delete-btn" onclick="deleteRow(this)">Löschen</button></td>
`;
row.dataset.invested = invested;
row.dataset.profit = (!isNaN(sellPrice) && sellPrice > 0) ? 0 : profit;
updateTotals();
}
function deleteRow(btn) {
const row = btn.parentNode.parentNode;
row.parentNode.removeChild(row);
updateTotals();
}
function updateTotals() {
const table = document.getElementById('bondTable').getElementsByTagName('tbody')[0];
let totalInvested = 0;
let totalProfit = 0;
for (let row of table.rows) {
totalInvested += parseFloat(row.dataset.invested) || 0;
totalProfit += parseFloat(row.dataset.profit) || 0;
}
document.getElementById('totalInvested').innerText = totalInvested.toFixed(2);
document.getElementById('totalProfit').innerText = totalProfit.toFixed(2);
document.getElementById('grandTotal').innerText = (totalInvested + totalProfit).toFixed(2);
}
function toggleMode() {
document.body.classList.toggle("dark-mode");
}
function downloadData() {
const table = document.getElementById('bondTable').getElementsByTagName('tbody')[0];
const data = [];
for (let row of table.rows) {
data.push({
date: row.cells[0].innerText,
sumTL: row.cells[1].innerText,
buyPrice: row.cells[2].innerText,
ticker: row.cells[3].innerText,
sellPrice: row.cells[4].innerText,
nominal: row.cells[5].innerText,
profit: row.cells[6].innerText
});
}
const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "bonddata.json";
a.click();
URL.revokeObjectURL(url);
}
function uploadData() {
const file = document.getElementById('uploadFile').files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
const data = JSON.parse(e.target.result);
const table = document.getElementById('bondTable').getElementsByTagName('tbody')[0];
table.innerHTML = "";
data.forEach(entry => {
const row = table.insertRow();
row.innerHTML = `
<td>${entry.date}</td>
<td>${entry.sumTL}</td>
<td>${entry.buyPrice}</td>
<td>${entry.ticker}</td>
<td>${entry.sellPrice}</td>
<td>${entry.nominal}</td>
<td>${entry.profit}</td>
<td><button class="delete-btn" onclick="deleteRow(this)">Löschen</button></td>
`;
row.dataset.invested = parseFloat(entry.sellPrice) > 0 ? 0 : parseFloat(entry.sumTL);
row.dataset.profit = parseFloat(entry.sellPrice) > 0 ? 0 : parseFloat(entry.profit);
});
updateTotals();
};
reader.readAsText(file);
}
</script>
</body>
</html>