xiaohongshu
xiaohongshu
local-clickhouse
Install, configure, and validate local ClickHouse for gapless-crypto-clickhouse development and backtesting. Use when setting up local development environment, enabling offline mode, improving query performance for backtesting, or running E2E validation. Includes mise/Homebrew/apt installation, m...
Full skill instructions
Install, configure, and validate local ClickHouse as an alternative to ClickHouse Cloud for development and backtesting (ADR-0044, ADR-0045).
Enable local ClickHouse deployment for:
Use this skill when:
Triggers: User mentions "local ClickHouse", "install clickhouse", "backtesting setup", "offline mode", "GCCH_MODE=local"
System Requirements:
Network: Internet required for installation only (offline after setup)
macOS (Homebrew):
# Install ClickHouse
brew install clickhouse
# Verify installation
clickhouse --version
Linux (Ubuntu/Debian):
# Quick installer (recommended)
curl https://clickhouse.com/ | sh
./clickhouse --version
# Or via apt
sudo apt-get install -y apt-transport-https ca-certificates
curl -fsSL https://packages.clickhouse.com/deb/lts/clickhouse.gpg | sudo gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list
sudo apt-get update
sudo apt-get install -y clickhouse-server clickhouse-client
macOS (Homebrew):
# Start server in background
clickhouse server --daemon
# Verify server is running
clickhouse client --query "SELECT 1"
Linux (systemd):
# Start and enable service
sudo service clickhouse-server start
sudo systemctl enable clickhouse-server
# Verify server is running
clickhouse-client --query "SELECT 1"
Set Local Mode:
# Explicit local mode (recommended)
export GCCH_MODE=local
# Or rely on auto-detection (localhost triggers local mode)
export CLICKHOUSE_HOST=localhost
Environment Variables:
# Full local configuration
export GCCH_MODE=local
export CLICKHOUSE_HOST=localhost
export CLICKHOUSE_HTTP_PORT=8123
export CLICKHOUSE_DATABASE=default
export CLICKHOUSE_USER=default
export CLICKHOUSE_PASSWORD=
Using Python:
from gapless_crypto_clickhouse import probe
# Check local ClickHouse status
status = probe.check_local_clickhouse()
print(f"Installed: {status['installed']}")
print(f"Running: {status['running']}")
print(f"Version: {status['version']}")
# Get current mode
mode = probe.get_current_mode()
print(f"Mode: {mode}") # Should be "local"
Using CLI:
# Quick connection test
GCCH_MODE=local python -c "
from gapless_crypto_clickhouse.clickhouse.config import ClickHouseConfig
config = ClickHouseConfig.from_env()
print(f'Host: {config.host}')
print(f'Port: {config.http_port}')
print(f'Secure: {config.secure}')
"
Query with Auto-Ingestion:
import os
os.environ["GCCH_MODE"] = "local"
from gapless_crypto_clickhouse import query_ohlcv
# First query downloads and ingests data automatically
df = query_ohlcv(
"BTCUSDT",
"1h",
"2024-01-01",
"2024-01-07"
)
print(f"Rows: {len(df)}")
print(df.head())
The package auto-detects deployment mode based on environment:
GCCH_MODE=local → Local mode (explicit)
GCCH_MODE=cloud → Cloud mode (requires CLICKHOUSE_HOST)
GCCH_MODE=auto → Auto-detect:
CLICKHOUSE_HOST="" → Local mode
CLICKHOUSE_HOST="localhost" → Local mode
CLICKHOUSE_HOST="127.0.0.1" → Local mode
CLICKHOUSE_HOST="*.cloud" → Cloud mode
Introspection:
from gapless_crypto_clickhouse import probe
# Get available modes
modes = probe.get_deployment_modes()
print(modes["available_modes"]) # ["local", "cloud"]
# Get current mode
current = probe.get_current_mode() # "local" or "cloud"
# Get installation guide
guide = probe.get_local_installation_guide()
print(guide["macos"]["commands"])
probe.check_local_clickhouse() returns {"installed": True, "running": True}probe.get_current_mode() returns "local"query_ohlcv() executes without Cloud credentialsIssue: "Connection refused" on port 8123
Check: Is ClickHouse server running?
# macOS
ps aux | grep clickhouse
# Linux
sudo service clickhouse-server status
Action: Start server with clickhouse server --daemon
Issue: "Command not found: clickhouse"
brew install clickhousecurl https://clickhouse.com/ | shIssue: Mode detected as "cloud" instead of "local"
CLICKHOUSE_HOST set to a remote hostname?export GCCH_MODE=local explicitlyIssue: Server crashes with memory error
Issue: Permission denied errors
/var/lib/clickhouse (Linux)| Mode | HTTP Port | Native Port | Secure |
|---|---|---|---|
| Local | 8123 | 9000 | False |
| Cloud | 8443 | 9440 | True |
| Metric | Local | Cloud |
|---|---|---|
| Query latency | 50ms | 100-500ms |
| First query (cold) | 50ms | 5-10s (idle resume) |
| Network dependency | None | Required |
| Credentials | None | Required |
| Best for | Backtesting | Production |
Start Server:
# macOS
clickhouse server --daemon
# Linux
sudo service clickhouse-server start
Stop Server:
# macOS
pkill -f clickhouse-server
# Linux
sudo service clickhouse-server stop
Check Logs:
# macOS (Homebrew)
tail -f /opt/homebrew/var/log/clickhouse-server/clickhouse-server.log
# Linux
sudo tail -f /var/log/clickhouse-server/clickhouse-server.log
This skill includes executable scripts for end-to-end validation of local ClickHouse.
| Script | Purpose |
|---|---|
scripts/start-clickhouse.sh | Start mise-installed ClickHouse server |
scripts/deploy-schema.sh | Deploy production schema (calls existing script) |
scripts/ingest-sample-data.py | Ingest real Binance data via query_ohlcv() |
scripts/take-screenshot.py | Capture Play UI screenshot via Playwright |
scripts/validate-data.py | Validate data integrity, output JSON evidence |
Full workflow (manual):
# 1. Start ClickHouse
./skills/local-clickhouse/scripts/start-clickhouse.sh
# 2. Deploy schema
./skills/local-clickhouse/scripts/deploy-schema.sh
# 3. Ingest sample data
uv run python skills/local-clickhouse/scripts/ingest-sample-data.py
# 4. Capture screenshot
uv run python skills/local-clickhouse/scripts/take-screenshot.py
# 5. Validate data
uv run python skills/local-clickhouse/scripts/validate-data.py
Via pytest (automated):
# Run E2E tests (requires mise ClickHouse installed)
uv run pytest tests/test_local_clickhouse_e2e.py -v
# Tests will FAIL (not skip) if ClickHouse not available
Scripts output evidence to tests/screenshots/ (gitignored):
play-ui-{timestamp}.png - Playwright screenshotsvalidation-{timestamp}.json - Structured validation resultsget_deployment_modes(), check_local_clickhouse()After successful local setup:
query_ohlcv() with auto_ingest=Trueuv run pytest tests/test_local_clickhouse_e2e.py -vexport GCCH_MODE=cloudxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience