Skip to content
Obsidia-Real-time-intelligencePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Obsidia — Backend

The honest backtester for Solana traders. Real fees. No lookahead. AI co-pilot.

FastAPI + Supabase + Anthropic Claude + Telegram. Powers obsidia.fi.


Stack

  • FastAPI — REST + CORS for the frontend
  • PostgreSQL via Supabase — auth + RLS + realtime
  • Pandas + Parquet — OHLCV storage and backtest engine
  • Anthropic Claude — AI brief generation per alert
  • Telegram Bot API — alert + waitlist notifications

Architecture

┌─────────────────────────────────────────┐
│  FastAPI  (src/dashboard/app.py)        │
│  - POST /api/backtests   (DSL executor) │
│  - GET  /api/health                     │
└─────────────────────────────────────────┘
              │
              │  reads OHLCV + writes results
              ▼
┌─────────────────────────────────────────┐
│  Services  (src/services/)              │
│  - dsl_executor.py    DSL → trades      │
│  - ohlcv_reader.py    Parquet bars      │
│  - ai_brief.py        Claude briefs     │
│  - telegram.py        Bot delivery      │
│  - supabase_client.py Service-role DB   │
└─────────────────────────────────────────┘
              ▲
┌─────────────┴───────────────────────────┐
│  Workers  (src/workers/)                │
│  - alerts_worker.py   eval strategies   │
│                       per minute,       │
│                       insert alerts +   │
│                       deliver Telegram  │
└─────────────────────────────────────────┘
              ▲
┌─────────────┴───────────────────────────┐
│  Cron  (scripts/)                       │
│  - pull_ohlcv.py      daily refresh     │
│                       Binance → Parquet │
└─────────────────────────────────────────┘

Setup

# 1. Install
pip install -r requirements.txt

# 2. Configure
cp .env.example .env
# Fill in: SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY,
#          ANTHROPIC_API_KEY, TELEGRAM_BOT_TOKEN, TELEGRAM_ADMIN_CHAT_ID

# 3. Run database schema in Supabase
# Open Supabase SQL editor → paste docs/SCHEMA.sql → Run

# 4. Pull historical OHLCV (one-time, ~30 min)
python scripts/pull_ohlcv.py

# 5. Start FastAPI
uvicorn src.dashboard.app:app --host 0.0.0.0 --port 8000 --workers 2

# 6. Start live alerts worker (in another terminal)
python -m src.workers.alerts_worker --interval 60

Environment variables

Var Required Purpose
SUPABASE_URL yes Project URL
SUPABASE_SERVICE_ROLE_KEY yes Bypasses RLS — server-only
ANTHROPIC_API_KEY yes for real AI briefs (heuristic fallback otherwise) Claude Sonnet 4.6
TELEGRAM_BOT_TOKEN yes for alert delivery @BotFather
TELEGRAM_ADMIN_CHAT_ID yes for waitlist pings Founder chat
CORS_ORIGINS optional Extra origins (comma-separated)
BINANCE_FUTURES_API_KEY / _SECRET optional Live execution path

Endpoints

Method Path Purpose
POST /api/backtests Run a strategy DSL → returns equity curve + trades + stats. Persists to backtests table if user_id + strategy_id supplied
GET /api/health Uptime probe
(legacy) /api/ohlcv, /api/levels, /api/spike, etc. Existing dashboard endpoints

Strategy DSL

See docs/IMPLEMENTATION.md for the full spec. Quick example:

{
  "name": "SOL Bounce after -2%",
  "symbol": "SOL/USDT",
  "timeframe": "15m",
  "entry": {
    "side": "long",
    "conditions": [{"type": "bar_return", "operator": "<=", "value": -0.02}]
  },
  "exit": {"type": "time_or_target", "max_hold_bars": 4},
  "sizing": {"type": "fixed_notional", "notional_usd": 8500, "leverage": 1.0},
  "fees": {"venue": "jupiter_perps", "fee_per_fill_pct": 0.07, "slippage_pct": 0.05}
}

Deploy

See docs/DEPLOYMENT.md for full ops guide (Railway, Oracle Cloud Free, Hetzner, systemd).

# Railway:  push to main, set env vars in dashboard, done
# Oracle Cloud Free / Hetzner:  systemd recipe in docs/DEPLOYMENT.md

Frontend

Frontend (Next.js) lives in a separate repo: github.com/Obsidia-Real-time-intelligence/Frontend

Docs

License

MIT — open source by default.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages