deanpowers commited on
Commit
d4ed1d9
Β·
1 Parent(s): 1be7260

New public /algorithm page: all gates, score weights, Telegram blocking indicators

Browse files
Files changed (2) hide show
  1. local_app.py +7 -0
  2. templates/algorithm.html +181 -0
local_app.py CHANGED
@@ -144,6 +144,8 @@ PUBLIC_PATHS_EXACT = (
144
  '/regimes/',
145
  '/analytics',
146
  '/analytics/',
 
 
147
  '/upward',
148
  '/upward/',
149
  '/downward',
@@ -2581,6 +2583,11 @@ def cron_ai_visibility():
2581
  })
2582
 
2583
 
 
 
 
 
 
2584
  @app.route('/analytics')
2585
  def analytics_page():
2586
  # Read-only overview: public (Analytics for anonymous visitors).
 
144
  '/regimes/',
145
  '/analytics',
146
  '/analytics/',
147
+ '/algorithm',
148
+ '/algorithm/',
149
  '/upward',
150
  '/upward/',
151
  '/downward',
 
2583
  })
2584
 
2585
 
2586
+ @app.route('/algorithm')
2587
+ @app.route('/algorithm/')
2588
+ def algorithm_page():
2589
+ return render_template('algorithm.html')
2590
+
2591
  @app.route('/analytics')
2592
  def analytics_page():
2593
  # Read-only overview: public (Analytics for anonymous visitors).
templates/algorithm.html ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Algorithm β€” Blind Monkeys</title>
7
+ <meta name="description" content="Every gate, score weight, and blocking indicator used by the Blind Monkeys automated trading algorithm: scan criteria, grid-opportunity gates, futures gates, exit rules, and Telegram channel markers.">
8
+ <link rel="stylesheet" href="/css/nav.css?v=3">
9
+ <link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
10
+ <style>
11
+ * { box-sizing: border-box; }
12
+ body { background: #0d1117; color: #e6edf3; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 0; line-height: 1.65; }
13
+ .page-content { max-width: 860px; margin: 0 auto; padding: 48px 24px 80px; }
14
+ h1 { font-size: 32px; margin: 0 0 6px; letter-spacing: -0.5px; }
15
+ .tagline { color: #f0b90b; font-size: 16px; font-weight: 600; margin: 0 0 32px; }
16
+ .summary { background: #1e2329; border-left: 4px solid #f0b90b; padding: 18px 22px; border-radius: 8px; margin: 0 0 40px; font-size: 15px; color: #c9d1d9; }
17
+ .group { margin-bottom: 40px; }
18
+ .group h2 { font-size: 14px; color: #f0b90b; margin: 0 0 18px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid #21262d; }
19
+ table { width: 100%; border-collapse: collapse; margin: 0 0 14px; }
20
+ th { text-align: left; padding: 10px 8px; color: #8b949e; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #30363d; }
21
+ td { padding: 10px 8px; border-bottom: 1px solid #21262d; font-size: 14px; vertical-align: top; }
22
+ tr:last-child td { border-bottom: none; }
23
+ a { color: #f0b90b; text-decoration: none; }
24
+ a:hover { text-decoration: underline; }
25
+ code { font-family: 'SF Mono', Monaco, monospace; font-size: 13px; background: #1e2329; padding: 2px 6px; border-radius: 4px; }
26
+ .mut { color: #8b949e; }
27
+ .gold { color: #f0b90b; font-weight: 700; }
28
+ .green { color: #4ade80; }
29
+ .red { color: #f87171; }
30
+ .blue { color: #58a6ff; }
31
+ .note { color: #8b949e; font-size: 13px; font-style: italic; margin-top: 6px; }
32
+ .back { margin-top: 40px; padding-top: 24px; border-top: 1px solid #21262d; color: #8b949e; font-size: 13px; text-align: center; }
33
+ .breadcrumbs { margin: 0 0 14px 0; font-size: 13px; color: #8b949e; }
34
+ .breadcrumbs a { color: #8b949e; text-decoration: none; }
35
+ .breadcrumbs .bc-sep { margin: 0 6px; color: #484f58; }
36
+ .breadcrumbs .bc-current { color: #e6edf3; }
37
+ @media (max-width: 640px) { .breadcrumbs { display: none; } }
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <nav class="nav-bar">
42
+ <a href="/" class="nav-brand">πŸ™ˆ Blind Monkeys</a>
43
+ <div class="nav-links">
44
+ <a href="/scan/" class="nav-link">πŸ” Scan</a>
45
+ <a href="/settings/" class="nav-link">βš™οΈ Settings</a>
46
+ </div>
47
+ </nav>
48
+
49
+ <div class="page-content">
50
+ <div class="breadcrumbs">
51
+ <a href="/">Home</a><span class="bc-sep">β€Ί</span><span class="bc-current">Algorithm</span>
52
+ </div>
53
+
54
+ <h1>βš™οΈ Algorithm</h1>
55
+ <p class="tagline">Every gate, score weight, and blocking indicator the application uses.</p>
56
+
57
+ <div class="summary">
58
+ The system is defense-first: a coin (or a range) must pass every gate in its flow before any position opens. Scores rank candidates; gates are hard rules with no compensation. All weights below are learned from real trading outcomes via the feedback loop and update automatically.
59
+ </div>
60
+
61
+ <div class="group">
62
+ <h2>1. Scan Gates β€” Conservative &amp; Risk-Taker</h2>
63
+ <p>All four must pass simultaneously. A coin that fails any gate is listed in the scan message with the exact blocking indicator (πŸ”΄).</p>
64
+ <table>
65
+ <tr><th>Gate</th><th>Conservative</th><th>Risk-Taker</th><th>Blocking indicator (πŸ”΄ shown when)</th></tr>
66
+ <tr><td>Z-score (dip depth)</td><td>must be &lt; βˆ’1.0</td><td>must be &lt; βˆ’1.5</td><td><code>Z-score β‰₯ threshold</code></td></tr>
67
+ <tr><td>Momentum</td><td>must be &gt; 5.0</td><td>must be &gt; 10.0</td><td><code>momentum ≀ threshold</code></td></tr>
68
+ <tr><td>Volatility</td><td>must be &lt; 8.0</td><td>must be &lt; 25.0</td><td><code>volatility β‰₯ threshold</code></td></tr>
69
+ <tr><td>RSI</td><td>must be &lt; 70</td><td>must be &lt; 60</td><td><code>RSI β‰₯ threshold</code></td></tr>
70
+ </table>
71
+ <p class="note">Indicators are computed over a 20-day lookback. The score ranks how strongly a coin embodies "oversold but rebounding"; the gates are pass/fail.</p>
72
+ </div>
73
+
74
+ <div class="group">
75
+ <h2>2. Score Weights (Feedback-Learned)</h2>
76
+ <p>Each factor starts at an equal weight of 0.25 and is updated after every closed position: factors that predicted successful trades gain weight, factors that misled lose weight (multiplicative exponential update, normalized).</p>
77
+ <table>
78
+ <tr><th>Flow</th><th>Factors</th><th>Current weights</th></tr>
79
+ <tr>
80
+ <td><span class="gold">Futures</span> (upward / conservative / risk scans)</td>
81
+ <td>RSI Β· Momentum Β· Z-score Β· Volatility</td>
82
+ <td id="fut-weights">loading…</td>
83
+ </tr>
84
+ <tr>
85
+ <td><span class="gold">Grids</span> (sideways regime)</td>
86
+ <td>Oscillations Β· ADX Β· Drift Β· 24h width</td>
87
+ <td id="grid-weights">loading…</td>
88
+ </tr>
89
+ </table>
90
+ <p class="note">Futures weights refresh with every closed position; grid weights with every closed grid. History is snapshotted daily.</p>
91
+ </div>
92
+
93
+ <div class="group">
94
+ <h2>3. Grid-Opportunity Gates (Sideways Regime)</h2>
95
+ <table>
96
+ <tr><th>Gate</th><th>Rule</th></tr>
97
+ <tr><td>Market cap</td><td>Top 100 coins only</td></tr>
98
+ <tr><td>7-day range width</td><td>between 3% and 25%</td></tr>
99
+ <tr><td>Oscillations (bounces)</td><td>β‰₯ 4 crossings of the range midpoint over 7 days; Β±3% band touches over 24h</td></tr>
100
+ <tr><td>Low drift</td><td>net 7-day drift must be &lt; 60% of range width</td></tr>
101
+ <tr><td>Composite score</td><td>β‰₯ the score threshold in settings (auto-open at 15)</td></tr>
102
+ <tr><td>No duplicates</td><td>coins with a grid bot already running are excluded</td></tr>
103
+ <tr><td>Regime pause</td><td>no new grids (auto) while BTC 7-day drift ≀ βˆ’5% (configurable; manual opens stay free)</td></tr>
104
+ <tr><td>Daily cap</td><td>max $ invested in new grids per day (settings)</td></tr>
105
+ </table>
106
+ </div>
107
+
108
+ <div class="group">
109
+ <h2>4. Futures Gates (Upward &amp; Rising-Coin Flows)</h2>
110
+ <table>
111
+ <tr><th>Gate</th><th>Rule</th></tr>
112
+ <tr><td>Score threshold</td><td>score β‰₯ the auto-open value in futures settings</td></tr>
113
+ <tr><td>Regime gate (upward)</td><td>ETH must be &lt; 0.5% below its 24h high</td></tr>
114
+ <tr><td>Market gate (rising coins)</td><td>only fires when BTC + ETH are both declining (downward regime); rise β‰₯ 2% on $5M+ volume with relative strength β‰₯ 2.0Γ—</td></tr>
115
+ <tr><td>Funding gate</td><td>coin's funding rate ≀ Max Funding Rate (default 0% β€” longs get paid); skips like <code>skip BTCUSDT β€” funding 0.006% exceeds 0% (longs would pay)</code></td></tr>
116
+ <tr><td>Stablecoin exclusion</td><td>USDC, DAI, TUSD, FDUSD and other pegged pairs never open futures</td></tr>
117
+ <tr><td>Position limit</td><td>max 3 concurrent positions (shared across flows)</td></tr>
118
+ <tr><td>Per-run cap</td><td>1 new position per scan run</td></tr>
119
+ <tr><td>Daily cap</td><td>max $ invested per day (settings)</td></tr>
120
+ </table>
121
+ </div>
122
+
123
+ <div class="group">
124
+ <h2>5. Exit Gates (Every Position)</h2>
125
+ <table>
126
+ <tr><th>Gate</th><th>Rule</th></tr>
127
+ <tr><td>Take profit</td><td>TP % of invested margin (default 4%); triggers arm a trailing TP</td></tr>
128
+ <tr><td>Trailing retrenchment</td><td>once TP is armed, closes when profit retraces by the retrenchment setting (default 1%) from its peak β€” worst case is the TP level minus the retrenchment</td></tr>
129
+ <tr><td>Stop loss</td><td>hard close at SL % of invested margin (default 4%) β€” no trailing</td></tr>
130
+ <tr><td>Compounding</td><td>next order grows 25% after a TP, shrinks 25% after an SL ($10 floor, daily-cap ceiling); resets only when the Amount setting changes</td></tr>
131
+ </table>
132
+ </div>
133
+
134
+ <div class="group">
135
+ <h2>6. Telegram Channel Indicators</h2>
136
+ <table>
137
+ <tr><th>Channel</th><th>Events</th><th>Markers &amp; blocking indicators</th></tr>
138
+ <tr><td>Blind Monkey (Scanner)</td><td>Scan results</td><td>πŸ”΄ in front of every blocking criterion: <code>Z-score βˆ’0.59 (must be below βˆ’1.5)</code>, <code>momentum 6.16 (must be above 10.0)</code>, volatility, RSI</td></tr>
139
+ <tr><td>Futures New</td><td>Positions opened</td><td>🟒 <b>OPENED</b>; skips show the gate that blocked (funding, already holding, daily cap, stablecoin)</td></tr>
140
+ <tr><td>Futures Close</td><td>Positions closed</td><td>🟒 profit / πŸ”΄ loss on the P&amp;L line</td></tr>
141
+ <tr><td>Futures Funding</td><td>Funding events</td><td>β€”</td></tr>
142
+ <tr><td>Grid New</td><td>Grid bots opened</td><td>🟒 <b>OPENED</b></td></tr>
143
+ <tr><td>Grid Profit</td><td>Grid profit events</td><td>πŸ’° 🟒</td></tr>
144
+ <tr><td>Grid Closures</td><td>Grids closed</td><td>reason (take profit / stop loss / manual)</td></tr>
145
+ <tr><td>Ka-ching</td><td>Profit-only events</td><td>πŸ’° 🟒 β€” plays the ka-ching sound</td></tr>
146
+ <tr><td>Loss Events</td><td>Loss-only events</td><td>😒 with πŸ”΄ link to <a href="/performance">/performance</a> β€” plays the boohoo sound</td></tr>
147
+ </table>
148
+ </div>
149
+
150
+ <div class="back">
151
+ <a href="/">← Back to home</a> &middot; <a href="/glossary/learned_weights">Learned weights</a> &middot; <a href="/faq">FAQ</a> &middot; <a href="/regimes">Regimes</a>
152
+ </div>
153
+ </div>
154
+
155
+ <script src="/css/nav.js?v=11"></script>
156
+ <script>
157
+ (function () {
158
+ fetch('/api/futures-weights').then(function (r) { return r.json(); }).then(function (d) {
159
+ var w = (d && d.weights) || {};
160
+ var el = document.getElementById('fut-weights');
161
+ el.innerHTML = 'RSI <b>' + (w.rsi != null ? w.rsi.toFixed(2) : 'β€”') + '</b> Β· '
162
+ + 'Momentum <b>' + (w.momentum != null ? w.momentum.toFixed(2) : 'β€”') + '</b> Β· '
163
+ + 'Z-score <b>' + (w.zscore != null ? w.zscore.toFixed(2) : 'β€”') + '</b> Β· '
164
+ + 'Volatility <b>' + (w.volatility != null ? w.volatility.toFixed(2) : 'β€”') + '</b>'
165
+ + ((d && d.outcomes != null) ? ' <span class="mut">(' + d.outcomes + ' outcomes learned)</span>' : '');
166
+ }).catch(function () { document.getElementById('fut-weights').textContent = 'unavailable'; });
167
+ fetch('/api/grid-score-weights-history').then(function (r) { return r.json(); }).then(function (h) {
168
+ var keys = Object.keys(h || {}).sort().reverse();
169
+ var el = document.getElementById('grid-weights');
170
+ if (!keys.length) { el.textContent = 'β€”'; return; }
171
+ var w = h[keys[0]] || {};
172
+ el.innerHTML = 'OSC <b>' + (w.osc != null ? w.osc.toFixed(2) : 'β€”') + '</b> Β· '
173
+ + 'ADX <b>' + (w.adx != null ? w.adx.toFixed(2) : 'β€”') + '</b> Β· '
174
+ + 'Drift <b>' + (w.drift != null ? w.drift.toFixed(2) : 'β€”') + '</b> Β· '
175
+ + '24h width <b>' + (w.w24 != null ? w.w24.toFixed(2) : 'β€”') + '</b>'
176
+ + ' <span class="mut">(as of ' + keys[0] + ')</span>';
177
+ }).catch(function () { document.getElementById('grid-weights').textContent = 'unavailable'; });
178
+ })();
179
+ </script>
180
+ </body>
181
+ </html>