blind-monkeys / static /settings /index.html
deanpowers's picture
Sync workspace source: rank tracker module + routes, Grid DB admin page, flaskfactory AI probe + analytics zone, nav.js v16 Blog pill, template refresh
c8c30b4
Raw History Blame Contribute Delete
31.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings β€” Blind Monkeys</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: system-ui, -apple-system, sans-serif;
background: #0d1117;
color: #e6edf3;
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 640px;
margin: 0 auto;
}
h1 {
color: #f0b90b;
font-size: 28px;
margin-bottom: 8px;
}
.subtitle {
color: #8b949e;
font-size: 14px;
margin-bottom: 24px;
}
.card {
background: #1e2329;
border-radius: 12px;
padding: 24px;
margin-bottom: 20px;
border: 1px solid #2a3138;
}
.field {
margin-bottom: 20px;
}
.field:last-child {
margin-bottom: 0;
}
label {
display: block;
font-size: 14px;
font-weight: 600;
margin-bottom: 8px;
color: #e6edf3;
}
.hint {
font-size: 12px;
color: #8b949e;
margin-top: 6px;
}
input[type="number"] {
width: 100%;
padding: 12px 14px;
background: #0d1117;
border: 1px solid #30363d;
border-radius: 8px;
color: #e6edf3;
font-size: 16px;
font-family: inherit;
transition: border-color 0.2s;
}
input[type="number"]:focus {
outline: none;
border-color: #f0b90b;
}
.buttons {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-bottom: 20px;
}
button {
padding: 12px 20px;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
font-family: inherit;
transition: opacity 0.2s, transform 0.1s;
}
button:hover:not(:disabled) {
opacity: 0.9;
transform: translateY(-1px);
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-primary {
background: #f0b90b;
color: #0d1117;
flex: 1;
min-width: 140px;
}
.btn-secondary {
background: #30363d;
color: #e6edf3;
flex: 1;
min-width: 140px;
}
.btn-danger {
background: #da3633;
color: white;
flex: 1;
min-width: 140px;
}
.status {
padding: 14px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
display: none;
}
.status.success {
background: #1a3a1a;
color: #4ade80;
border: 1px solid #238636;
display: block;
}
.status.error {
background: #3a1a1a;
color: #f87171;
border: 1px solid #da3633;
display: block;
}
.info {
background: #161b22;
padding: 16px;
border-radius: 8px;
margin-top: 16px;
font-size: 13px;
color: #8b949e;
line-height: 1.8;
border: 1px solid #2a3138;
}
.info strong {
color: #e6edf3;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 4px 0;
}
.footer-links {
display: flex;
gap: 16px;
flex-wrap: wrap;
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #2a3138;
}
.link {
color: #f0b90b;
text-decoration: none;
font-size: 14px;
font-weight: 500;
}
.link:hover {
text-decoration: underline;
}
.presets {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-top: 12px;
}
.preset-btn {
padding: 6px 12px;
background: #0d1117;
color: #e6edf3;
border: 1px solid #30363d;
border-radius: 6px;
font-size: 12px;
cursor: pointer;
}
.preset-btn:hover {
border-color: #f0b90b;
color: #f0b90b;
}
.panel-title {
color: #f0b90b;
font-size: 20px;
font-weight: 700;
margin-bottom: 6px;
}
.panel-sub {
color: #8b949e;
font-size: 13px;
margin-bottom: 20px;
}
.spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid #0d1117;
border-top-color: transparent;
border-radius: 50%;
animation: spin 0.6s linear infinite;
margin-right: 6px;
vertical-align: middle;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
<link rel="stylesheet" href="/css/nav.css?v=4">
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
</head>
<body>
<nav class="nav-bar">
<a href="/" class="nav-brand">πŸ™ˆ Blind Monkeys</a>
<div class="nav-links">
<a href="/scan/" class="nav-link">πŸ” Scan</a>
<a href="/positions/" class="nav-link">πŸ’Ό Positions</a>
<a href="/price/" class="nav-link">πŸ’΅ ETH Price</a>
<a href="/portfolio/" class="nav-link">πŸ’Ό Portfolio</a>
<a href="/settings/" class="nav-link">βš™οΈ Settings</a>
</div>
</nav>
<div class="container">
<h1>βš™οΈ Settings</h1>
<p class="subtitle">Automated trading settings β€” changes apply immediately</p>
<div class="status" id="status"></div>
<div id="access-note" class="hint" style="display:none; margin:0 0 16px; color:#f0b90b;">πŸ‘οΈ View-only mode β€” sign in as an admin to edit settings.</div>
<div class="card">
<div class="panel-title">πŸ€– Grid Settings</div>
<div class="panel-sub">Defaults for newly opened futures grid bots</div>
<div class="field">
<label for="g-lev">Leverage (1–10)</label>
<input type="number" id="g-lev" min="1" max="10" step="1">
<div class="hint">Leverage applied when opening a grid</div>
</div>
<div class="field">
<label for="g-rng">Range Β±% (2–10)</label>
<input type="number" id="g-rng" min="2" max="10" step="1">
<div class="hint">Grid band above and below the entry price</div>
</div>
<div class="field">
<label for="g-amt">Amount $ (100–99999)</label>
<input type="number" id="g-amt" min="100" max="99999" step="50">
<div class="hint">Capital allocated to each new grid</div>
</div>
<div class="field">
<label for="g-lines">Grid lines (5–20)</label>
<input type="number" id="g-lines" min="5" max="20" step="1">
<div class="hint">Number of grid levels within the range</div>
</div>
<div class="field">
<label for="g-cap">Daily cap $ (100–99999)</label>
<input type="number" id="g-cap" min="100" max="99999" step="500">
<div class="hint">Maximum total invested in new grids per day</div>
</div>
<div class="field">
<label for="g-tp">Take profit %</label>
<input type="number" id="g-tp" min="0.1" max="500" step="1">
<div class="hint">Take-profit target for the grid</div>
</div>
<div class="field">
<label for="g-sl">Stop loss %</label>
<input type="number" id="g-sl" min="0.1" max="100" step="1">
<div class="hint">Stop-loss threshold for the grid</div>
</div>
<div class="field">
<label for="g-score">Auto open score β‰₯</label>
<input type="number" id="g-score" min="0" max="50" step="1">
<div class="hint">Minimum composite score to auto-open a grid</div>
</div>
<div class="field">
<label for="g-trail">Trailing TP retrenchment (%)</label>
<input type="number" id="g-trail" min="0.05" max="2.2" step="0.05" value="1">
<div class="hint">After grid profit reaches the TP level, the bot runs until profit retraces this % of invested (0.05–2.2%)</div>
</div>
<div class="field">
<label for="g-regime">Pause in downtrend: BTC 7d drift ≀ (%)</label>
<input type="number" id="g-regime" min="-100" max="0" step="1" value="-5">
<div class="hint">No new grids while BTC's 7-day drift is at or below this (set -100 to disable)</div>
</div>
<div class="buttons">
<button class="btn-primary" id="grid-save-btn">πŸ’Ύ Save Grid Settings</button>
</div>
<div id="grid-msg" class="hint"></div>
</div>
<div class="card">
<div class="panel-title">πŸ“ˆ Futures Settings</div>
<div class="panel-sub">Leverage, order size and risk limits for futures positions</div>
<div class="field">
<label for="f-lev">Leverage (x)</label>
<input type="number" id="f-lev" min="1" max="10" step="1" value="3">
<div class="hint">Leverage applied to new futures positions (1–10x)</div>
</div>
<div class="field">
<label for="f-amt">Amount ($)</label>
<input type="number" id="f-amt" min="100" max="500" step="1" value="100">
<div class="hint">Investment per new futures position ($100–500)</div>
</div>
<div class="field">
<label for="f-tp">TP (%)</label>
<input type="number" id="f-tp" min="3" max="10" step="1" value="3">
<div class="hint">Take-profit target (3–10%)</div>
</div>
<div class="field">
<label for="f-sl">SL (%)</label>
<input type="number" id="f-sl" min="3" max="10" step="1" value="3">
<div class="hint">Stop-loss threshold (3–10%)</div>
</div>
<div class="field">
<label for="f-auto">Auto-open score threshold</label>
<input type="number" id="f-auto" min="1" max="10" step="1" value="1">
<div class="hint">Minimum coin score to auto-open a futures position (1–10)</div>
</div>
<div class="field">
<label for="f-trail">Trailing TP retrenchment (%)</label>
<input type="number" id="f-trail" min="0.1" max="10" step="0.1" value="1">
<div class="hint">After profit reaches the TP level, the position runs until price retraces this % (0.1–10%)</div>
</div>
<div class="field">
<label for="f-fund">Max Funding Rate (%)</label>
<input type="number" id="f-fund" min="-1" max="100" step="0.01" value="0">
<div class="hint">Futures auto-open only when the coin's funding rate is at or below this (0 = longs are paid; 99 = gate off)</div>
</div>
<div class="field">
<label for="f-cap">Daily Cap ($)</label>
<input type="number" id="f-cap" min="100" max="1000" step="10" value="500">
<div class="hint">Maximum total invested in new futures positions per day</div>
</div>
<div class="field">
<label for="f-up">Increase order on TP (%)</label>
<input type="number" id="f-up" min="0" max="1000" step="1" value="25">
<div class="hint">Order compounding: after a winning close, the next order grows by this % (e.g. 25 β†’ $100 becomes $125)</div>
</div>
<div class="field">
<label for="f-down">Decrease order on SL (%)</label>
<input type="number" id="f-down" min="0" max="1000" step="1" value="25">
<div class="hint">Order compounding: after a losing close, the next order shrinks by this % (e.g. 25 β†’ $100 becomes $75)</div>
</div>
<div class="field">
<label>Next order size (algorithm)</label>
<input type="text" id="f-current" value="β€”" readonly style="background:#161b22;color:#f0b90b;font-weight:700;">
<div class="hint">Current compounded order size β€” changes after every close; changing the Amount field above resets it</div>
</div>
<div class="buttons">
<button class="btn-primary" id="futures-save-btn">πŸ’Ύ Save Futures Settings</button>
</div>
<div id="futures-msg" class="hint"></div>
</div>
<div class="card">
<div class="panel-title">πŸ”Ί Rising Coins Trading Settings</div>
<div class="panel-sub">Rules for trading coins identified by the rising coins scanner</div>
<div class="field">
<label for="r-amt">Amount ($)</label>
<input type="number" id="r-amt" min="10" max="100000" step="10" value="100">
<div class="hint">Fallback order size β€” new rising-coin positions use the compounded β€œNext order size” below</div>
</div>
<div class="field">
<label for="r-lev">Leverage (x)</label>
<input type="number" id="r-lev" min="1" max="20" step="1" value="3">
<div class="hint">Leverage applied when opening a position</div>
</div>
<div class="field">
<label for="r-tp">Take Profit (%)</label>
<input type="number" id="r-tp" min="1" max="100" step="1" value="3">
<div class="hint">Take-profit target for the position</div>
</div>
<div class="field">
<label for="r-sl">Stop Loss (%)</label>
<input type="number" id="r-sl" min="1" max="100" step="1" value="3">
<div class="hint">Stop-loss threshold for the position</div>
</div>
<div class="field">
<label for="r-trail">TP Retrenchment (%)</label>
<input type="number" id="r-trail" min="0.1" max="10" step="0.1" value="1">
<div class="hint">After profit reaches the TP level, the position runs until price retraces this % of margin (0.1–10%)</div>
</div>
<div class="field">
<label for="r-fund">Max Funding Rate (%)</label>
<input type="number" id="r-fund" min="-1" max="100" step="0.01" value="0">
<div class="hint">Auto-open only when the coin's funding rate is at or below this (0 = longs are paid; 99 = gate off)</div>
</div>
<div class="field">
<label for="r-cap">Daily Cap ($)</label>
<input type="number" id="r-cap" min="100" max="100000" step="100" value="1000">
<div class="hint">Maximum total invested in rising-coin positions per day</div>
</div>
<div class="field">
<label for="r-up">Increase order on TP (%)</label>
<input type="number" id="r-up" min="0" max="1000" step="1" value="25">
<div class="hint">Order compounding: after a winning close, the next order grows by this % (e.g. 25 β†’ $100 becomes $125)</div>
</div>
<div class="field">
<label for="r-down">Decrease order on SL (%)</label>
<input type="number" id="r-down" min="0" max="1000" step="1" value="25">
<div class="hint">Order compounding: after a losing close, the next order shrinks by this % (e.g. 25 β†’ $100 becomes $75)</div>
</div>
<div class="field">
<label>Next order size (algorithm)</label>
<input type="text" id="r-current" value="β€”" readonly style="background:#161b22;color:#f0b90b;font-weight:700;">
<div class="hint">Current compounded order size β€” changes after every close (shared with the futures chain)</div>
</div>
<div class="buttons">
<button class="btn-primary" id="riser-save-btn">πŸ’Ύ Save Rising Coins Settings</button>
</div>
<div id="riser-msg" class="hint"></div>
</div>
<div class="nav-links">
<a href="/" class="link">← Back to Blind Monkeys</a>
<a href="/api/settings" class="link" target="_blank">View Raw Settings JSON</a>
<a href="/api/coins" class="link" target="_blank">View Coin List JSON</a>
</div>
</div>
<script>
const API_BASE = '';
function showStatus(message, type) {
const el = document.getElementById('status');
el.innerHTML = message;
el.className = `status ${type}`;
setTimeout(() => {
el.className = 'status';
}, 5000);
}
// Grid Settings
async function loadGridSettings() {
try {
const res = await fetch(`${API_BASE}/api/grid-config`);
const s = await res.json();
if (s.leverage != null) document.getElementById('g-lev').value = s.leverage;
if (s.range_percent != null) document.getElementById('g-rng').value = s.range_percent;
if (s.amount != null) document.getElementById('g-amt').value = s.amount;
if (s.grid_lines != null) document.getElementById('g-lines').value = s.grid_lines;
if (s.daily_cap != null) document.getElementById('g-cap').value = s.daily_cap;
if (s.tp_percent != null) document.getElementById('g-tp').value = s.tp_percent;
if (s.stop_loss_percent != null) document.getElementById('g-sl').value = s.stop_loss_percent;
if (s.auto_min_score != null) document.getElementById('g-score').value = s.auto_min_score;
if (s.trailing_retrench != null) document.getElementById('g-trail').value = s.trailing_retrench;
if (s.regime_pause_drift != null) document.getElementById('g-regime').value = s.regime_pause_drift;
} catch (err) {
// grid settings unavailable β€” leave defaults
}
}
async function saveGridSettings() {
const btn = document.getElementById('grid-save-btn');
const msg = document.getElementById('grid-msg');
const original = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<span class="spinner"></span>Saving...';
const payload = {
leverage: Number(document.getElementById('g-lev').value),
range_percent: Number(document.getElementById('g-rng').value),
amount: Number(document.getElementById('g-amt').value),
grid_lines: Number(document.getElementById('g-lines').value),
daily_cap: Number(document.getElementById('g-cap').value),
tp_percent: Number(document.getElementById('g-tp').value),
stop_loss_percent: Number(document.getElementById('g-sl').value),
auto_min_score: Number(document.getElementById('g-score').value),
trailing_retrench: Number(document.getElementById('g-trail').value),
regime_pause_drift: Number(document.getElementById('g-regime').value)
};
try {
const res = await fetch(`${API_BASE}/api/grid-config`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (res.ok) {
msg.textContent = 'βœ“ saved';
msg.style.color = '#4ade80';
} else {
msg.textContent = '❌ save failed';
msg.style.color = '#f87171';
}
} catch (err) {
msg.textContent = '❌ ' + err.message;
msg.style.color = '#f87171';
} finally {
btn.disabled = false;
btn.innerHTML = original;
}
}
document.getElementById('grid-save-btn').addEventListener('click', saveGridSettings);
// Futures Settings
async function loadFuturesSettings() {
try {
const res = await fetch(`${API_BASE}/api/futures-config`);
const s = await res.json();
if (s.leverage != null) document.getElementById('f-lev').value = s.leverage;
if (s.base_amount != null) document.getElementById('f-amt').value = s.base_amount;
if (s.fut_tp != null) document.getElementById('f-tp').value = s.fut_tp;
if (s.fut_sl != null) document.getElementById('f-sl').value = s.fut_sl;
if (s.fut_auto_open != null) document.getElementById('f-auto').value = s.fut_auto_open;
if (s.fut_trail != null) document.getElementById('f-trail').value = s.fut_trail;
if (s.daily_cap != null) document.getElementById('f-cap').value = s.daily_cap;
if (s.increase_pct != null) document.getElementById('f-up').value = s.increase_pct;
if (s.decrease_pct != null) document.getElementById('f-down').value = s.decrease_pct;
if (s.current_amount != null) document.getElementById('f-current').value = '$' + Number(s.current_amount).toFixed(2);
} catch (err) {
// futures settings unavailable β€” leave defaults
}
// Max Funding Rate lives in the riser rules β€” load it here too
try {
const res2 = await fetch(`${API_BASE}/api/riser-config`);
const r = await res2.json();
if (r.min_funding != null) document.getElementById('f-fund').value = r.min_funding;
} catch (err) { /* leave default */ }
}
async function saveFuturesSettings() {
const btn = document.getElementById('futures-save-btn');
const msg = document.getElementById('futures-msg');
const original = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<span class="spinner"></span>Saving...';
const payload = {
combo_leverage: Number(document.getElementById('f-lev').value),
base_amount: Number(document.getElementById('f-amt').value),
fut_tp: Number(document.getElementById('f-tp').value),
fut_sl: Number(document.getElementById('f-sl').value),
fut_auto_open: Number(document.getElementById('f-auto').value),
fut_trail: Number(document.getElementById('f-trail').value),
daily_cap: Number(document.getElementById('f-cap').value),
increase_pct: Number(document.getElementById('f-up').value),
decrease_pct: Number(document.getElementById('f-down').value)
};
if (!payload.combo_leverage || !payload.base_amount ||
!payload.fut_tp || !payload.fut_sl || !payload.fut_auto_open ||
!payload.daily_cap) {
msg.textContent = '❌ all fields are required';
msg.style.color = '#f87171';
btn.disabled = false;
btn.innerHTML = original;
return;
}
try {
const res = await fetch(`${API_BASE}/api/futures-config`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (res.ok) {
// Max Funding Rate lives in the riser rules β€” save it too
try {
await fetch(`${API_BASE}/api/riser-config`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ min_funding: Number(document.getElementById('f-fund').value) })
});
} catch (err2) { /* funding gate unchanged */ }
msg.textContent = 'βœ“ saved';
msg.style.color = '#4ade80';
} else {
msg.textContent = '❌ save failed';
msg.style.color = '#f87171';
}
} catch (err) {
msg.textContent = '❌ ' + err.message;
msg.style.color = '#f87171';
} finally {
btn.disabled = false;
btn.innerHTML = original;
}
}
document.getElementById('futures-save-btn').addEventListener('click', saveFuturesSettings);
// Rising Coins Trading Settings
async function loadRiserSettings() {
try {
const res = await fetch(`${API_BASE}/api/riser-config`);
const s = await res.json();
if (s.amount != null) document.getElementById('r-amt').value = s.amount;
if (s.leverage != null) document.getElementById('r-lev').value = s.leverage;
if (s.tp_percent != null) document.getElementById('r-tp').value = s.tp_percent;
if (s.stop_loss_percent != null) document.getElementById('r-sl').value = s.stop_loss_percent;
if (s.trailing_retrench != null) document.getElementById('r-trail').value = s.trailing_retrench;
if (s.min_funding != null) document.getElementById('r-fund').value = s.min_funding;
if (s.daily_cap != null) document.getElementById('r-cap').value = s.daily_cap;
} catch (err) {
// riser settings unavailable β€” leave defaults
}
// Compounding fields are shared with the futures chain β€” load here too
try {
const res2 = await fetch(`${API_BASE}/api/futures-config`);
const f = await res2.json();
if (f.increase_pct != null) document.getElementById('r-up').value = f.increase_pct;
if (f.decrease_pct != null) document.getElementById('r-down').value = f.decrease_pct;
if (f.current_amount != null) document.getElementById('r-current').value = '$' + Number(f.current_amount).toFixed(2);
} catch (err2) { /* leave default */ }
}
async function saveRiserSettings() {
const btn = document.getElementById('riser-save-btn');
const msg = document.getElementById('riser-msg');
const original = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<span class="spinner"></span>Saving...';
const payload = {
amount: Number(document.getElementById('r-amt').value),
leverage: Number(document.getElementById('r-lev').value),
tp_percent: Number(document.getElementById('r-tp').value),
stop_loss_percent: Number(document.getElementById('r-sl').value),
trailing_retrench: Number(document.getElementById('r-trail').value),
min_funding: Number(document.getElementById('r-fund').value),
daily_cap: Number(document.getElementById('r-cap').value)
};
try {
const res = await fetch(`${API_BASE}/api/riser-config`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (res.ok) {
// Compounding percentages are shared with the futures
// chain β€” save them via the futures-config endpoint.
try {
await fetch(`${API_BASE}/api/futures-config`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
increase_pct: Number(document.getElementById('r-up').value),
decrease_pct: Number(document.getElementById('r-down').value)
})
});
} catch (err2) { /* compounding unchanged */ }
msg.textContent = 'βœ“ saved';
msg.style.color = '#4ade80';
await loadRiserSettings();
} else {
msg.textContent = '❌ save failed (admin only)';
msg.style.color = '#f87171';
}
} catch (err) {
msg.textContent = '❌ ' + err.message;
msg.style.color = '#f87171';
} finally {
btn.disabled = false;
btn.innerHTML = original;
}
}
document.getElementById('riser-save-btn').addEventListener('click', saveRiserSettings);
// View-only enforcement: hide write controls for non-admin users
async function applyAccess() {
try {
const res = await fetch(`${API_BASE}/api/whoami`);
const w = await res.json();
if (w.logged_in && w.role !== 'admin') {
['grid-save-btn', 'futures-save-btn', 'riser-save-btn'].forEach(id => {
const b = document.getElementById(id);
if (b) b.style.display = 'none';
});
const note = document.getElementById('access-note');
if (note) note.style.display = 'block';
}
} catch (err) {}
}
// Initial load
loadGridSettings();
loadFuturesSettings();
loadRiserSettings();
applyAccess();
</script>
<script src="/css/nav.js?v=16"></script>
<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/6ad326872ab00434d21793a2/1k54ic9h0';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
</body>
</html>