<div class="card p-4 mb-4">
<h5>Stratégie</h5>
<select class="form-select mb-3" id="strategySelect">
- <option value="hold">Always HOLD</option>
- <option value="ma_cross">MA Cross</option>
+ <option value="STANDARD">Standard (RSI + SMA)</option>
+ <option value="GREEDY">Greedy (Agressif)</option>
</select>
<button class="btn btn-primary">
Appliquer la stratégie
// ─────────────────────────────────────────────────────────────
// BOUTONS
// ─────────────────────────────────────────────────────────────
+
+// Bouton "Appliquer la stratégie"
+document.querySelectorAll('button').forEach(btn => {
+ if (btn.textContent.trim() === 'Appliquer la stratégie') {
+ btn.addEventListener('click', async () => {
+ try {
+ const mode = document.getElementById("strategySelect")?.value || "SAFE";
+ const res = await fetch(`${SERVER_URL}/api/strategy/select`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ userId, pairId: 1, mode })
+ });
+ const data = await res.json();
+ if (data.ok) alert("✅ Stratégie appliquée !");
+ else alert("Erreur : " + (data.message || 'inconnue'));
+ } catch (err) {
+ console.error("Erreur stratégie :", err);
+ alert("Erreur de connexion");
+ }
+ });
+ }
+});
+
document.getElementById("saveUserBtn")?.addEventListener("click", () => {
const input = document.getElementById("userIdInput");
if (input?.value.trim()) {