Add LAMP web dashboard: bot→MySQL publisher, PHP API, numbers-only page
- webapp/: deployable LAMP app for /var/www/ — ingest.php (token-gated writes), api.php (public read-only), schema.sql (live_price + signal_reports), vanilla-JS dashboard with plain-English indicator readings, .htaccess, deploy README - web_publisher.py: fire-and-forget publisher (bounded queue + daemon thread) with plain-English payload builder; public API contractually never raises; disabled unless WEBAPP_INGEST_URL/TOKEN are set - telegram_bot.py: publish hooks (tick in WS loop, report in _update_level_cache); _candle_loop per-iteration guard so a failing scan can never kill an auto-scan loop; quiet heartbeat teardown - test_all.py: Module 13 — 6 resilience tests (never-raise contract, worker survival, candle-loop survival); suite 189/189 - .gitignore: webapp/config.php (server-side secrets) Verified end-to-end on a scratch MariaDB 10.11 + PHP 8.3 built-in server incl. headless-Firefox render of the live page. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KYNEHBuwwy6sgRM9f9sPx5
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
-- ForexBot2 web dashboard schema (MySQL 8.0+ / MariaDB 10.5+)
|
||||
-- Load once: mysql -u root -p < schema.sql
|
||||
-- (edit the database/user names to taste; keep them in sync with config.php)
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS forexbot_web
|
||||
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE forexbot_web;
|
||||
|
||||
-- Latest tick per symbol — a single row upserted on every published tick
|
||||
-- (the bot throttles to 1/s). Tick history is deliberately NOT stored:
|
||||
-- XAU produces 100k+ ticks/day; add a separate append table with a purge
|
||||
-- job if charting is ever needed.
|
||||
CREATE TABLE IF NOT EXISTS live_price (
|
||||
symbol VARCHAR(16) NOT NULL PRIMARY KEY,
|
||||
price DECIMAL(12,5) NOT NULL,
|
||||
prev_price DECIMAL(12,5) NULL,
|
||||
tick_at DATETIME NOT NULL, -- UTC, set by the bot
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- One row per (symbol, timeframe, signal bar). Re-scans of the same bar
|
||||
-- (e.g. the bot's level-breach rescan) update the row in place, so the
|
||||
-- table is also a clean historical signal log (~400 rows/day for XAU on
|
||||
-- M5+M15+H1+H4 — no retention job needed).
|
||||
CREATE TABLE IF NOT EXISTS signal_reports (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
symbol VARCHAR(16) NOT NULL,
|
||||
timeframe VARCHAR(8) NOT NULL, -- '5min','15min','1h','4h'
|
||||
bar_ts DATETIME NOT NULL, -- signal bar timestamp (UTC)
|
||||
signal_name VARCHAR(12) NOT NULL, -- STRONG_BUY..STRONG_SELL
|
||||
quality VARCHAR(2) NOT NULL, -- A+, A, B, C, D, F
|
||||
score DECIMAL(6,2) NOT NULL,
|
||||
confidence DECIMAL(5,2) NOT NULL,
|
||||
payload JSON NOT NULL, -- full dashboard payload
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uq_bar (symbol, timeframe, bar_ts),
|
||||
KEY idx_latest (symbol, timeframe, id)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Dedicated app user with least privilege (adjust host/password!):
|
||||
-- CREATE USER 'forexbot'@'localhost' IDENTIFIED BY 'CHANGE-ME';
|
||||
-- GRANT SELECT, INSERT, UPDATE ON forexbot_web.* TO 'forexbot'@'localhost';
|
||||
-- FLUSH PRIVILEGES;
|
||||
Reference in New Issue
Block a user