@@ -46,29 +46,59 @@ private String generateHtmlResponse() {
46
46
html .append ("<html>" );
47
47
html .append ("<head>" );
48
48
html .append ("<meta http-equiv='refresh' content='10'>" ); // Auto-refresh every 10 seconds
49
- html .append ("<title>Held Coins </title>" );
49
+ html .append ("<title>CoinbaseBot </title>" );
50
50
html .append ("<style>" );
51
- html .append ("table { border-collapse: collapse; width: 80%; margin: auto; }" );
52
- html .append ("th, td { border: 1px solid black; padding: 3px; text-align: center; }" );
51
+ html .append ("body { font-family: Arial, sans-serif; margin: 0; padding: 0; }" );
52
+ html .append ("table { border-collapse: collapse; width: 90%; margin: auto; }" );
53
+ html .append ("th, td { border: 1px solid black; padding: 8px; text-align: center; }" );
53
54
html .append ("th { background-color: #f2f2f2; }" );
54
55
html .append (".profit { color: green; }" );
55
56
html .append (".loss { color: red; }" );
57
+ html .append (".cash-info { text-align: center; font-size: 18px; margin-top: 20px; }" );
58
+ html .append (".datetime { position: absolute; top: 10px; left: 10px; font-size: 12px; color: gray; }" );
59
+ html .append (".collapsible { cursor: pointer; padding: 10px; text-align: left; background-color: #f2f2f2; border: none; outline: none; width: 90%; margin: auto; font-size: 16px; }" );
60
+ html .append (".content { padding: 10px 15px; display: none; background-color: #ffffff; width: 90%; margin: auto; }" );
61
+ html .append (".collapsible:after { content: '\\ 002B'; float: right; }" );
62
+ html .append (".active:after { content: '\\ 2212'; }" );
63
+ html .append ("@media screen and (max-width: 600px) { table { font-size: 12px; } th, td { padding: 5px; } }" );
56
64
html .append ("</style>" );
65
+ html .append ("<script>" );
66
+ html .append ("document.addEventListener('DOMContentLoaded', () => {" );
67
+ html .append (" const collapsibles = document.querySelectorAll('.collapsible');" );
68
+ html .append (" collapsibles.forEach(button => {" );
69
+ html .append (" button.addEventListener('click', () => {" );
70
+ html .append (" button.classList.toggle('active');" );
71
+ html .append (" const content = button.nextElementSibling;" );
72
+ html .append (" if (content.style.display === 'block') {" );
73
+ html .append (" content.style.display = 'none';" );
74
+ html .append (" } else {" );
75
+ html .append (" content.style.display = 'block';" );
76
+ html .append (" }" );
77
+ html .append (" });" );
78
+ html .append (" });" );
79
+ html .append ("});" );
80
+ html .append ("</script>" );
57
81
html .append ("</head>" );
58
82
html .append ("<body>" );
83
+
84
+ // Current Date and Time
85
+ html .append ("<div class='datetime'>" ).append (LocalDateTime .now ().format (DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm:ss" ))).append ("</div>" );
86
+
87
+ // Held Coins Table
59
88
html .append ("<h1 style='text-align:center;'>Held Coins</h1>" );
60
89
html .append ("<table>" );
61
90
html .append ("<tr>" );
62
91
html .append ("<th>Coin</th>" );
63
92
html .append ("<th>Purchase Date</th>" );
64
93
html .append ("<th>Days Held</th>" );
65
- html .append ("<th>Average Purchase Price</th>" );
66
- html .append ("<th>Current Price</th>" );
94
+ html .append ("<th>Avg. Purchase $</th>" );
95
+ html .append ("<th>Current coin $</th>" );
96
+ html .append ("<th>Total value</th>" );
67
97
html .append ("<th>Stop Loss at</th>" );
68
98
html .append ("<th>Win/Loss (%)</th>" );
69
- html .append ("<th>Win/Loss (USDC )</th>" );
70
- html .append ("<th>Highest Profit Level </th>" );
71
- html .append ("<th>Average Down Steps</th>" );
99
+ html .append ("<th>Win/Loss ($ )</th>" );
100
+ html .append ("<th>Highest Profit Lv. </th>" );
101
+ html .append ("<th>A/D Steps</th>" );
72
102
html .append ("</tr>" );
73
103
74
104
DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm:ss" );
@@ -82,49 +112,56 @@ private String generateHtmlResponse() {
82
112
currentPrice = 0.0 ; // Fallback if fetching fails
83
113
}
84
114
115
+ double currentValue = currentPrice * tradeInfo .getAmount ();
85
116
double winLossPercent = ((currentPrice - tradeInfo .getPurchasePrice ()) / tradeInfo .getPurchasePrice ()) * 100 ;
86
- double winLossUSDC = ( currentPrice - tradeInfo .getPurchasePrice ()) * tradeInfo .getAmount ( );
117
+ double winLossUSDC = currentValue - ( tradeInfo .getAmount () * tradeInfo .getPurchasePrice () );
87
118
long daysHeld = ChronoUnit .DAYS .between (tradeInfo .getPurchaseDate (), LocalDateTime .now ());
88
119
String profitLevel = String .format ("%d (%.2f%%)" , tradeInfo .getProfitLevelIndex (),
89
120
tb .config .profitLevels .get (tradeInfo .getProfitLevelIndex ()));
90
121
String averageDownStep = String .format ("%d (%.2f%%)" , tradeInfo .getAverageDownStepIndex (),
91
122
tb .config .averageDownSteps .get (tradeInfo .getAverageDownStepIndex ()));
92
-
123
+
93
124
html .append ("<tr>" );
94
125
html .append ("<td>" ).append (coin ).append ("</td>" );
95
126
html .append ("<td>" ).append (tradeInfo .getPurchaseDate ().format (formatter )).append ("</td>" );
96
127
html .append ("<td>" ).append (daysHeld ).append ("</td>" );
97
- html .append ("<td>" ).append (String .format ("%.6f" , tradeInfo .getPurchasePrice ()).replaceAll ("\\ .?0+$" , "" )).append ("</td>" );
98
- html .append ("<td>" ).append (String .format ("%.6f" , currentPrice ).replaceAll ("\\ .?0+$" , "" )).append ("</td>" );
99
- html .append ("<td>" ).append (String .format ("%.6f" , tradeInfo .getTrailingStopLoss ()).replaceAll ("\\ .?0+$" , "" )).append ("</td>" );
128
+ html .append ("<td>" ).append (String .format ("%.6f $" , tradeInfo .getPurchasePrice ()).replaceAll ("\\ .?0+$" , "" )).append ("</td>" );
129
+ html .append ("<td>" ).append (String .format ("%.6f $" , currentPrice ).replaceAll ("\\ .?0+$" , "" )).append ("</td>" );
130
+ html .append ("<td>" ).append (String .format ("%.2f $" , currentValue )).append ("</td>" );
131
+ html .append ("<td>" ).append (String .format ("%.6f $" , tradeInfo .getTrailingStopLoss ()).replaceAll ("\\ .?0+$" , "" )).append ("</td>" );
100
132
html .append ("<td class='" ).append (winLossPercent >= 0 ? "profit" : "loss" ).append ("'>" )
101
- .append (String .format ("%.2f%%" , winLossPercent )).append ("</td>" );
133
+ .append (String .format ("%.2f% %" , winLossPercent )).append ("</td>" );
102
134
html .append ("<td class='" ).append (winLossUSDC >= 0 ? "profit" : "loss" ).append ("'>" )
103
- .append (String .format ("%.2f USDC " , winLossUSDC )).append ("</td>" );
135
+ .append (String .format ("%.2f $ " , winLossUSDC )).append ("</td>" );
104
136
html .append ("<td>" ).append (tradeInfo .getProfitLevelIndex () > 0 ? profitLevel : "None" ).append ("</td>" );
105
137
html .append ("<td>" ).append (tradeInfo .getAverageDownStepIndex () > 0 ? averageDownStep : "None" ).append ("</td>" );
106
138
html .append ("</tr>" );
107
139
});
108
140
109
141
html .append ("</table>" );
110
142
111
- // Add Profit Levels Section
112
- html .append ("<h2 style='text-align:center;'>Profit Levels</h2>" );
113
- html .append ("<ul style='width: 80%; margin: auto;'>" );
143
+ // Display Current USDC Cash
144
+ html .append ("<div class='cash-info'>" );
145
+ html .append ("Current USDC Cash: " ).append (String .format ("%.2f $" , tb .usdcBalance ));
146
+ html .append ("</div>" );
147
+
148
+ // Collapsible Profit Levels Section
149
+ html .append ("<button class='collapsible'>Profit Levels</button>" );
150
+ html .append ("<div class='content'>" );
114
151
List <Double > profitLevels = tb .config .profitLevels ;
115
152
for (int i = 0 ; i < profitLevels .size (); i ++) {
116
- html .append ("<li >Level " ).append (i ).append (": " ).append (profitLevels .get (i )).append ("%</li >" );
153
+ html .append ("<p >Level " ).append (i ).append (": " ).append (profitLevels .get (i )).append ("%</p >" );
117
154
}
118
- html .append ("</ul >" );
155
+ html .append ("</div >" );
119
156
120
- // Add Average Down Steps Section
121
- html .append ("<h2 style='text-align:center; '>Average Down Levels</h2 >" );
122
- html .append ("<ul style='width: 80%; margin: auto; '>" );
157
+ // Collapsible Average Down Steps Section
158
+ html .append ("<button class='collapsible '>Average Down Levels</button >" );
159
+ html .append ("<div class='content '>" );
123
160
List <Double > averageDownSteps = tb .config .averageDownSteps ;
124
161
for (int i = 0 ; i < averageDownSteps .size (); i ++) {
125
- html .append ("<li >Step " ).append (i ).append (": " ).append (averageDownSteps .get (i )).append ("%</li >" );
162
+ html .append ("<p >Step " ).append (i ).append (": " ).append (averageDownSteps .get (i )).append ("%</p >" );
126
163
}
127
- html .append ("</ul >" );
164
+ html .append ("</div >" );
128
165
129
166
html .append ("</body>" );
130
167
html .append ("</html>" );
0 commit comments