<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Quant Radar Telemetry]]></title><description><![CDATA[Quant Radar Telemetry]]></description><link>https://quantradar.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b06a4878d394c45b01748e5/ecabafa6-0c2f-4a30-8eff-cd9039c2a127.jpg</url><title>Quant Radar Telemetry</title><link>https://quantradar.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 12:28:36 GMT</lastBuildDate><atom:link href="https://quantradar.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Running a 24/7 Betfair Orderbook & Pinnacle Telemetry Collector on Android (Termux + Python + SQLite)]]></title><description><![CDATA[24/7 Python & SQLite WAL collector on Termux for Betfair orderbook & Pinnacle odds movement. Solves API -32099 via adaptive chunking.]]></description><link>https://quantradar.hashnode.dev/running-a-24-7-betfair-orderbook-pinnacle-telemetry-collector-on-android-termux-python-sqlite</link><guid isPermaLink="true">https://quantradar.hashnode.dev/running-a-24-7-betfair-orderbook-pinnacle-telemetry-collector-on-android-termux-python-sqlite</guid><category><![CDATA[Python]]></category><category><![CDATA[api]]></category><category><![CDATA[SQLite]]></category><category><![CDATA[Data Science]]></category><category><![CDATA[Android]]></category><category><![CDATA[termux]]></category><dc:creator><![CDATA[Quant Radar]]></dc:creator><pubDate>Wed, 25 Nov 2026 09:44:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b06a4878d394c45b01748e5/114c7611-ebcf-4f10-9bf2-7d55b86b32bc.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I wanted a lightweight, zero-cost pipeline that continuously captures L2 exchange orderbook snapshots (top-3 BACK/LAY depth) from the Betfair Exchange API, cross-references them against Pinnacle's sharp reference line, and logs pre-match football market microstructure data locally.</p>
<p>Instead of spinning up another cloud VPS, I deployed the entire collector on an everyday Android phone running <strong>Termux</strong> + <code>screen</code> + <strong>Python</strong> + <strong>SQLite</strong>. Here is how I solved SQLite concurrency, the <code>-32099 (TOO_MUCH_DATA)</code> API error, and raw volume noise.</p>
<h2>1. Preventing SQLite Locks on Mobile Storage</h2>
<p>The setup runs one main ingestion loop alongside two lightweight reader daemons that format filtered anomalies and publish raw telemetry logs externally. On a single SQLite file, concurrent reads and writes quickly trigger <code>sqlite3.OperationalError: database is locked</code>.</p>
<p>Switching SQLite into <strong>WAL (Write-Ahead Logging)</strong> mode completely resolved lock contention while keeping flash wear low:</p>
<pre><code class="language-python">import sqlite3

conn = sqlite3.connect("market_telemetry.db", timeout=15)
conn.execute("PRAGMA journal_mode=WAL;")
conn.execute("PRAGMA synchronous=NORMAL;")
conn.execute("PRAGMA temp_store=MEMORY;")
</code></pre>
<p>With WAL enabled, readers never block the writer, and the entire time-series history stays portable in one file.</p>
<h2>2. Solving Betfair API <code>-32099 (TOO_MUCH_DATA)</code></h2>
<p>When polling <code>listMarketBook</code> with <code>EX_BEST_OFFERS</code> and <code>EX_TRADED</code>, Betfair enforces a strict payload weight limit per response. If a batch of 30–40 market IDs hits one heavily traded match with deep orderbooks, the entire request fails with <code>-32099</code>.</p>
<p>The clean fix is <strong>adaptive chunking</strong>: halving the batch size on <code>-32099</code> and gradually ramping it back up on healthy responses:</p>
<pre><code class="language-python">import time

def fetch_market_books_adaptive(api_call, market_ids, initial_chunk=20):
    results = []
    chunk_size = initial_chunk
    idx = 0

    while idx &lt; len(market_ids):
        batch = market_ids[idx : idx + chunk_size]
        try:
            resp = api_call(
                marketIds=batch,
                priceProjection={"priceData": ["EX_BEST_OFFERS", "EX_TRADED"]},
            )
            results.extend(resp)
            idx += len(batch)
            chunk_size = min(initial_chunk, chunk_size + 2)
        except Exception as e:
            if "-32099" in str(e) or "TOO_MUCH_DATA" in str(e):
                if chunk_size == 1:
                    idx += 1  # Skip anomalously heavy market
                    continue
                chunk_size = max(1, chunk_size // 2)
                time.sleep(0.5)
            else:
                raise
    return results
</code></pre>
<p>The standalone snippet and setup notes are also archived in my GitHub repo: <a href="https://github.com/genesisquantum9-cmd/betfair-adaptive-chunker">betfair-adaptive-chunker</a>.</p>
<h2>3. Filtering False Volume Spikes</h2>
<p>Flat euro cutoffs (e.g., alerting on any <code>&gt; €20k</code> 5-minute inflow) generate mostly noise: €20k is negligible in a €900k Premier League pool, yet completely reshapes a €15k lower-tier fixture.</p>
<p>Three composite filters removed most false positives:</p>
<ol>
<li><strong>Relative pool delta:</strong> Measuring short-window inflows as a percentage of existing matched volume rather than a fixed currency threshold.</li>
<li><strong>Post-spike resting depth (Top-3 BACK vs LAY):</strong> Checking what liquidity remains immediately after a burst. If opposing resting walls immediately reload, price moves tend to stall or revert.</li>
<li><strong>Cross-book divergence (Betfair vs. Pinnacle):</strong> Tracking whether the sharp reference feed reprices alongside the exchange. Heavy exchange volume with zero movement on Pinnacle usually signals localized retail imbalance rather than informed order flow.</li>
</ol>
<h2>4. Two Real Snapshots from the SQLite Logs</h2>
<ul>
<li><strong>High-liquidity wall resistance (</strong><code>Liverpool v Man Utd</code><strong>):</strong> Total matched pool exceeded €904k with a <code>+€508k</code> short-window surge (76% concentration on one side). Despite the headline volume, resting top-3 depth stayed balanced (<code>BACK €75.8k</code> vs <code>LAY €65.5k</code>). Exchange pricing drifted (<code>1.74 -&gt; 1.87</code>) while Pinnacle barely moved (<code>1.71 -&gt; 1.72</code>, an <code>+8.7%</code> spread).</li>
<li><strong>Late inflow without sharp confirmation (</strong><code>Chapecoense v SE Palmeiras</code><strong>):</strong> Fifteen minutes before kickoff, <code>+€84k</code> entered the pool (<code>€99k -&gt; €183k</code>), pushing single-side share from <code>77.2%</code> to <code>83.8%</code> and compressing the exchange price (<code>2.28 -&gt; 2.14</code>). At that exact timestamp, Pinnacle did not move a single tick (<code>2.22 -&gt; 2.22</code>), flagging the late move as unconfirmed retail flow.</li>
</ul>
<h2>Live Automated Telemetry Output</h2>
<p>Rather than querying SQLite manually over SSH/Termux, two lightweight Python reader daemons format filtered pre-match orderbook anomalies into live public logs (strictly raw market-microstructure telemetry, not financial advice):</p>
<ul>
<li><strong>Live English Order-Flow Index (auto-updated):</strong> <a href="https://telegra.ph/Quant-Radar-Live-Betfair-Money-Flow--Pinnacle-Odds-Movement-Index-11-23">Quant Radar — Betfair Money Flow &amp; Pinnacle Movement Index</a></li>
<li><strong>Russian-language telemetry feed (Telegram):</strong> <a href="https://t.me/real_profit_signals">@real_profit_signals</a></li>
<li><strong>Code &amp; SQLite WAL snippet (GitHub):</strong> <a href="https://github.com/genesisquantum9-cmd/betfair-adaptive-chunker">genesisquantum9-cmd/betfair-adaptive-chunker</a></li>
</ul>
<p>For anyone else running event-driven exchange collectors: what confirmation window (<code>30s</code>, <code>60s</code>, <code>5m</code>) works best for separating genuine price discovery from temporary liquidity distortion?</p>
]]></content:encoded></item></channel></rss>