Tech debt and version
Open items only: what is missing, wrong or waiting for a decision. The dashboard shows this file on its Tech debt page. The dated history of changes and studies is in CHANGELOG.md, a short summary in Spanish.
For the owner (cannot be done by Claude)
.envleft git on 2026-11-24: rotate what was committed and give the web app its variables. The tokens committed before (DATABRICKS_TOKEN,FRED_API_KEY,GLASSNODEAPI_KEY, theDB_*user and password) are still in the GitHub history: revoke and replace them. The web app that deploys from this repository no longer gets a.envfrom git; set the same variables in its host (names in.env.example) before the next deploy.The unattended debrief (
debrief_flow/) has not done a full run yet. It is served on the Bloomberg server since 2026-11-24 (scheduled taskgold_debrief, Prefect deploymentgold_debrief_daily); the first run is due aftertrading_desk_gold_dailyon 2026-11-25. It depends on the personal Databricks token of.env(see below) and on the Claude subscription tokenCLAUDE_CODE_OAUTH_TOKEN. After agit pullrestart the task (Stop-ScheduledTask gold_debrief, end its python.exe,Start-ScheduledTask gold_debrief): the serve keeps the code it started with.Proposed red flag I1 "London full" (not active). The Gold Inventories Study found one inventory reading that held in both halves: London vault holdings in the top third of their 5-year range were followed by flat gold over 6 months. It rests on about two episodes since 2019. Decide whether to add it to
knowledge-base/kb/thesis_rules.jsonas an amber-only context flag (seekb/house_notes/house_inventories.md).Merge the Databricks branch and check the web app. Since 2026-11-18 the dashboard, its notebooks and the Bloomberg step of
scripts/build_caches.pyread everything from Databricks, on the branchft/databricks-sources(docs/DATABRICKS_MIGRATION.md). It was pushed on 2026-11-19 but is not merged:main, and so the deployed web app, still read SQL Server. Before the merge check that the web app's host can reach the Databricks workspace; it was tested on one machine only.SQL Server is no longer read by this branch.
[XAU].[bronze]can stop receiving data once the branch is merged and deployed. The debrief of 2026-11-19 rebuilt the research caches from Databricks for the first time. On the two cache sets of 2026-11-18 the model answered 60.3% from SQL Server and 60.5% from Databricks: the change of source moves it by 0.2 points.The model's answer log lacks the answers published from 6 to 18 November.
knowledge-base/gold_knowledge_base/model/bull_bear_log.csvgoes from 2026-11-05 (65.7%) to 2026-11-19 (57.2%). The debrief of 2026-11-13 published 59.5% with gold at $3,881 (reports/Gold Debrief/2026-11-13.html, not versioned), but what that run wrote was never committed and the working tree was reset toorigin/mainon 2026-11-18. The log is a record that is only appended: decide whether to add the missing rows, from the notes or from another clone that still has them.The debrief skill does not check at what time of day a move happened. On 2026-11-19 the first draft said gold fell 3.2% on the Fed minutes; the hourly data (
gold_sessions_hourly,cache/gold_spot_hourly.parquet) showed 2.9 of those points gone before the minutes came out, and an independent check caught it. Proposal for.claude/skills/gold-debrief/references/sections.md, Overnight summary: before naming the cause of a day's move, read the session split and the hourly bars around the event.Three more database variables are still in
.env:DB_TIMEOUT,DB_USER_NAME_CONSULTandDB_USER_PASSWORD_CONSULT. No file of the repository reads them (2026-11-18). They were left because their use is not known; remove them if nothing outside needs them.Branch
databricks-migration(not merged; it leftmainon 2026-10-19 and has 2 commits of its own) moves the data notebooks toetl/with SQL and Databricks versions and addssrc/dbx.py. Itsconnect()andread_sql()do whatsrc/databricks_sql.pynow does on the branchft/databricks-sources. Its write helpers (merge_into,write_csv) exist only there and write to a catalog,trading_gold, that the token of.envdoes not see in the workspace (2026-11-18); the gold tables are inproduction.bronze. A merge conflicts in.gitignore,pyproject.toml,CLAUDE.md,README.md,TECH_DEBT.md,dashboard/sections/crash.py,dashboard/sections/overview.pyand the old Equity Crash notebook, and the branch deletes.env(it adds.env.exampleinstead), whichmainalso did on 2026-11-24. Decide whether its ETL is rebuilt onmainor dropped.The Databricks token in
.envis personal and is not read-only.DATABRICKS_TOKEN(added 2026-11-18) is one user's personal access token, the one in alphinity-backtest's.env: it acts with that user's permissions, which go beyond reading the gold tables. It expires on 2027-08-28:read_sqlstops working then, or earlier if it is revoked, and revoking it also stops alphinity-backtest. This repository is visible to the whole GitHub organisation (visibility internal, secret scanning and push protection off). The standard fix is a service principal that can only read the tables in use.COMEX open interest needs a field in the Bloomberg load. Ask whoever runs the
production.bronze.gold_bloombergload to addFUT_AGGTE_OPEN_INTforGC1 COMB COMDTY, with history. The field name is unconfirmed: check it with FLDS, and if it differs change it inbuild_caches.pyandmarket_gauges.py. The first rows should be close to the CFTC futures-only open interest (396,810 on 2026-10-27).Plotly Cloud. The "Share chart" button is disabled. Check cloud.plotly.com for charts uploaded on 2026-10-14.
The worker's check keeps the Databricks cluster in use. While the dashboard server runs it sends one query every 10 minutes (
CHECK_MINUTESindashboard/jobs.py), and the cluster stops itself only after 30 idle minutes: with the server up, the dashboard alone may keep it from stopping. Not measured: the cluster is shared and has not had an idle stop since 2026-11-11. Decide whether to accept it, to check less often than every 30 minutes, or to send the check to the serverless SQL warehouse (docs/DATABRICKS_NEXT_STEPS.md, row 10).Two ways into Databricks. Both use the
.envtoken since 2026-11-24, but on different compute:src/databricks_sql.pyreadsproduction.bronzeon the all-purpose cluster for the dashboard and the Bloomberg caches;src/dbx.pyreads the desk tableproduction.silver.gold_general_trading_deskon the SQL warehouse for the FRED series of the knowledge base and the hourly gold bars. Decide whether the desk table is read throughdatabricks_sql.pytoo, or whether the hourly bars and the missing FRED series get tables inproduction.bronze(2026-11-23).
Dashboard sections
- Fiscal Dominance score direction contradicts the Fiscal Cycles study. The page labels a high score (more fiscal dominance) as bullish for gold, but in
Gold Fiscal Cyclesthe fiscal-dominance cell (deficit >= 4% of GDP and real fed funds < 0) was followed by the worst gold returns (F7 failed); only a widening deficit and the excess deficit held, weakly. Logic not changed; decide whether to re-label, re-weight or drop the score. - Strategy Pool: what its numbers rest on. (1) The Forecast history is rewritten by every run of
notebooks/Backtestings/FORECAST/Gold Forecast.ipynb, whose simulation has no seed: two runs on 2026-11-24 moved one month of 323 and the strategy from 16.3x to 15.4x. A seed in that notebook, or keeping the first value written for a closed month, would stop it; and the notebook still has no cell that sends its run to Databricks (the call is in appendix G ofdocs/DATABRICKS_MIGRATION.md), so the table holds the run made on 2026-11-24. (2) Before November 2010 Aurum is Incrementum's own series, which is the backtest it publishes and not a live signal. (3) The AI Debrief joins two sources: month ends of the replay with strict publication lags, and after them the answers of the live model, which uses its own lags (on 2026-10-29 the two read 63.8% and 63.0%). The October 2026 month end was replayed on 29 October, with the month in progress;scripts/upload_house_view.py --replayafter a new replay corrects it. (4) The four signal strategies pay no trading cost, a signal of a month in progress counts as soon as it is read while the backtest only has month ends, and every rule was chosen looking at this same history. Picking other dates on the page starts the curves again at 1 and works the metrics out again, but no strategy is started again: the CPPI keeps the portfolio it started in 2000, and its result depends on that start. (5) The pool itself, how the five gold shares are combined into one, is not built: the card on the home page shows their plain mean. - Incrementum Signal is a replica, and its cycle half turns on a point or two. The page copies the Incrementum Active Aurum Signal from market data and does not hold Incrementum's own series, so it cannot show when the two disagree. In the study (
notebooks/Backtestings/Incrementum/LOG.md, 2026-11-19) the fundamental half matched 95.9% of weeks over 50 years, but the cycle half buys and sells on a point or two of the score: near-equal variants agreed with the seven target dates on 43% to 89% of days. Kept by hand in the notebook and the section: the table of CFTC reports published late (LATE_CFTC; after a future US shutdown add its rows, or the backtest dates those reports three days after their data) and the cycle state of the first week (sell, November 2010). The backtest up to October 2021 covers the weeks the replica was fitted on. The study has no report inreports/and no house note in the knowledge base yet (2026-11-23). - Regime look-ahead. The pchip interpolation of OPHNFB, IMF reserves and CPI uses later data points; the central-bank quadrant is shifted only 30 days (use ffill and a 60-90 day lag). The IMF also misses about 72% of post-2022 central-bank buying.
- Forecast underperforms a naive rule. In the back-test (11 report dates) the most likely zone was right 66.3% of the time, against 81.3% for always picking the most common zone (2026-11-17).
- Options is a mock-up. Only the 1M and 2M GLD implied-volatility tenors exist in the database (deltas 10, 25, 50 and 75 since 2008; the 90-delta points only from 2026-02-18 in Databricks, so the page leaves them out). Three days have one point printed at 171% to 513% (2012-07-19, 2026-03-13, 2026-03-16);
Gold Optionsdrops any day where a point is more than 3 times that day's median. - Notebook outputs predate the translation. The Phase1 notebooks were translated on 2026-10-26 without re-running them, so their saved outputs still show the old Spanish labels until each notebook is run again.
Data
- MetalCharts retired its annual CSVs.
gold-price-annual.csv,silver-price-annual.csvandgold-silver-ratio-annual.csvanswer HTTP 410 Gone since at least 2026-11-24 (knowledge-base/kb/sources/metalcharts.py); the knowledge base keeps its last copies. Find where they moved or drop them. - Consensus pipeline (
data/Consensus Pipeline.ipynb), kept as is:- Consensus Economics asks for quarterly averages ("Nominal Quarterly Averages"), but the pipeline dates each one at the quarter end. The 3-month point of a September report is the Q4 average, centred in mid-November.
- The annual forecasts for 2028, 2029 and 2030 are dropped (25, 21 and 18 banks in September 2026). Their headers are numbers, and
find_positionsonly keeps dates and text with a '-'. - The long-term forecast is the 2031-2035 average, but it is placed 5 years after the report date.
- Month 0 is the XAU close at the month end (4,177 in September 2026), not the spot on the survey date (4,324 on 21 September).
- The months between survey points are pchip interpolation.
- WGC demand by category (
ds): technology demand is not among the tickers (Gold Marketsshows the 70-93 t a quarter gap as "other");Gold Bar FabricationandGold Retail Investmentare the same series; total demand equals total supply by construction. - SHFE warrants (
SFGDTOTL Index) come in kilograms and are converted at 32.1507466 troy ounces per kg. SGLDWD*Qmapping was inferred by matching 2025 totals to IGWT; confirm the names in Bloomberg (DES).fund_lib.int_receiptsstill uses gross NIPA interest (includes imputed pension interest, 33.7%); the Fiscal Cycles study and the Fiscal page use OMB/MTS net interest. Not changed to keep the earlier studies reproducible.- Forecast log (
cache/forecast_log/) holds the 12 monthly forecasts of the selector, recomputed as of each date on every refresh, plus each day's release since 2026-10-12. The record of forecasts actually published at the time starts on 2026-10-12. - Ticker groups (
TICKER_GROUPSinsrc/datasources.py) are a hand-kept dictionary, as the catalogue CSV was: a ticker added toproduction.bronze.gold_tickers_parametersjoins a page only when it is added there. - The Positioning and demand charts of Markets change colours between refreshes (found 2026-11-18):
plot_cftc_positionsgives each category a colour in the order of a Python set, which changes from run to run. Cosmetic; the notebook does the same. - One Databricks outage stops every section's refresh at once (all sources are there since 2026-11-18). Pages keep their last good result and the worker tries again at its next check; a refresh fails within seconds with a plain message. What a read does while the cluster is stopped was not tested: the cluster has not stopped since 2026-11-11. The deployed web app was not tested either: its host must be able to reach the Databricks workspace.
- Old option history is not in Databricks. Eight fields of
GLD US Equity(the four 90-delta implied volatilities and four open-interest fields) start on 2026-02-18 there; SQL Server had them from 2008 and 2011. The Options page does not use them. - Gold Shadow Price data stops 60 days after the last BOGMBASE observation (
resample('D').ffill()ends there andshift(60)carries the gap), so the page ends earlier than the others. Left for a change in the notebook first. - Knowledge-base store is versioned (
knowledge-base/gold_knowledge_base/, about 14 MB) so a fresh clone answers immediately. Each daily rebuild changes the CSVs; commit them with the code changes, or decide to version onlymodel/and rebuild the rest. On 2026-11-19 one debrief changed 53 files: 44 CSVs ofdata/, the catalogue, the snapshot, three notes and the model files. A store older than the code breaks the tools: until that day the repository held the store of 2026-11-05 with the code of 2026-11-13, andtest_mcp_client.pyfailed atmarket_diagnosis. With the store committed on 2026-11-19 it prints "All checks passed." - CFTC positioning in the knowledge base comes from MetalCharts, which can lag. On 2026-11-19 it still served the report of 3 November, while
production.bronze.gold_bloombergheld the CFTC series to 10 November (CFCDUMMN Indexand the other tickers by group, already incache/swing_bbg_raw.parquet). The debrief wrote its positioning paragraph on the older report. Option: use the Bloomberg series when MetalCharts is behind. They are net positions by group;cot_positioningalso uses longs and shorts, so check what it can still compute before switching.
Notebook methodology (not changed; owner decides)
- Gold Regime Strategy
- The signal is shifted twice, a 2-day lag. With one shift the maximum drawdown is -60% instead of -52%.
avg_risk_free_rateis the T-bill on the first day of each 5-year bucket, not an average.- The markdown says
cbincludes hidden Chinese purchases; the code does not add them. - "Neutral" is both a central bank state and the default of
np.select.
- Gold Forecast
- The ordered logit only runs for the last 12 report dates (
dates[-12:]). It could run for every date with enough history, giving a longer track record. forecast_shortcompounds log returns as simple returns, which biases the cone about 1.5% low.- The last price is left out of the fit.
- It uses a single bucket (d=365), and the anchor probabilities differ between cells.
- The expected +13.3% comes mostly from the GARCH drift; the cone median is +9.9%.
- Consensus counts months by calendar, but the notebook cell that builds
pstill usesdays // 30;pno longer feeds any chart.
- The ordered logit only runs for the last 12 report dates (
- Equity Crash
- Section 2 of the notebook (margin endurance) is not on the page since 2026-10-14, but the notebook still has it, with position placeholders (
POSITION_OZand the margin inputs) far from the real position. - The episode names for 1976 and 2011 never match an episode's peak year.
- The notebook still calls
warnings.filterwarnings('ignore').
- Section 2 of the notebook (margin endurance) is not on the page since 2026-10-14, but the notebook still has it, with position placeholders (
- Markets
- The US premium annualizes calendar days with /252.
plot_cftc_positionsassigns colours throughlist(set(...)), so they change from one kernel session to the next.- The trading-session windows overlap.
- With plotly.py 7.1, the right axis of a two-axis chart aligns its ticks with the left axis and shows uneven values;
tickmode='auto'fixes it.
- Bull Market Analysis
dates_endis not used.- The
ffill(limit=3)trick leaves gaps where the price does not change for more than 3 days. - The
add_hline(y=1)on the drawdown chart is outside its y-range.
Thesis Monitor and Fiscal Dominance (found by the merge review, 2026-10-15)
- The same metric differs between pages. IMF 12-month change: +358 t on Markets (sum of countries) vs +513 t on Thesis (World 001.046). Gold over 12 months: calendar year on Gold today vs 252 trading days on Thesis.
- The thesis state card overflows when the state is "Under review" or "Invalidated": the " (provisional)" suffix makes it too long.
- Fiscal and the thesis disagree on C4. Interest/receipts is 19.6% on Fiscal (MTS, net) and 34% on Thesis (NIPA, gross); the knowledge-base check uses the MTS figure.
- The thesis story has fixed wording. Long Treasuries are always "falling faster than gold", whatever the data.
- An unreachable FiscalData API holds the refresh for about 12 minutes before Fiscal fails (the timeout and retries in
fd()). - Gold today > Data health leaves out some inputs: WGC
SGLDWD*Q, GTII10 and FiscalData. - C2 reads differently on the Thesis Monitor and in the knowledge base (found 2026-11-23). The page takes the 6-month change of
GTII10 Govtas 126 rows, and Bloomberg keeps a row on US bond-market holidays (8 so far in 2026), so its window is about 121 trading days. The knowledge base counts 126 Treasury market days on FREDDFII10. On 23 November the page gave +0.73 pp and the knowledge base +0.63 pp, with amber above +0.60: the two can show different colours. The owner decides which window is the rule; a change goes in the notebook, the section and the doc. - The premium estimate drifts when the WGC workbook is old (found 2026-11-23). With
gold-premiums.xlsxthree weeks old, our estimate for 20 November was +0.31% for China and +1.04% for India, both rising; the WGC series, once downloaded, gave +0.19% and +0.46%, with China falling all week. The debrief had read the estimate as Eastern buying. Download the workbook from gold.org/goldhub/data/gold-premium before each debrief (the build picks it up from Downloads), and read a rising estimate with care when the WGC series is more than a few days old.
Research (Phase 2)
- Gold Swing Score: the ingredient lists come from the full sample (in-sample selection); the real-time top trigger has only 5 deep events; CFTC/ETF/vol ingredients start in 2003-2008.
- Gold Fundamentals Regimes: only 5-6 bull endings for anything that starts after 2003; IMF reserve history is revised (China 2015 lump).
- Gold Score Backtest: version 2 is pre-registered but not run; to be scored on the next bottom.
- Gold Inventories Study: COMEX registered stock (28 months), SHFE warrants (7 months) are too short to test; no free source extends them. The LBMA lag (62 days after the stamp) is conservative because the stamp convention is ambiguous.
- 12-month changes in
fund_libcompare with 13 months earlier since November 2025 (found 2026-11-18, left as it is). FRED never published October 2025, the research cache has no row for it, andfund_libtakes the 12-month change of CPI and of unemployment by position. CPI year on year reads 0.03 to 0.44 points too high and the unemployment change is off by up to 0.2. CPI year on year feeds the bull/bear model; the effect on the published probability was not measured. Putting both series on their monthly calendar fixes it and changes the model's inputs from November 2025 on. The owner's note for that fix: carry the CPI index forward over the missing month, then take the change. On 2026-11-19 the model ran with CPI at 4.02% year on year where the 12-month change is 3.72%; a reviewer's rough estimate of the effect on the published 57.2% is half a point. - House bull/bear model: out-of-sample skill is modest (published core Brier 0.261 vs 0.240 for the base rate, 1985-2023). The live log has no resolved answer yet; the first resolves by 2029 unless gold regains its high sooner.
Infrastructure
- Refresh inside the web process. A refresh peaks at about 520 MB and leaves about 430 MB in use; memory grew 13 to 26 MB per refresh in a test of 3 refreshes. A separate process would return that memory. Not needed yet.
- Page-only features with no notebook counterpart: curves that restart at 1 when zooming, range buttons and sliders (JavaScript), the lenses, the past-forecast selector, the collapsible panels, and the "today" line on the Bull Cycle drawdown histogram. Two features differ between page and notebook: the report picker of "Forecasts by bank" is
report_datein the notebook, and the box that adds any backing band on the Shadow Price page is theextra_bandslist in the notebook. The Bull Cycle notebook still draws that histogram with seaborn and its long charts without the 3,600-day limit. docs/gold-bull-thesis.mdcarries a static snapshot. Section 0 and the "As of" columns are readings from 2026-10-13/14; the live state is on the Thesis Monitor page. Refresh or drop them at the annual review.