← กลับไปที่คู่มือการใช้งาน
คู่มือเชื่อมต่อ DB ภายนอก

เชื่อมข้อมูลของคุณด้วย Supabase

The easiest way to feed your own metrics (fear & greed, on-chain data) into strategies via ctx.data(). The Supabase free tier is enough, and the connection string is stored only on your agent machine — the soritrading server never sees your data or password.

Before you start — Your agent must be installed and paired (check the Assets screen). If your data already lives in another Postgres, start from step 3.
1

Create a Supabase project

Create a free project at supabase.com. Pick a region close to your agent (VPS).

2

Create a table and load data

Use the SQL editor or Table Editor. Minimum: a timestamp column and a value column. Example: fear_greed(ts bigint, v numeric) — epoch seconds recommended (ms/ISO auto-detected).

ยังไม่มีข้อมูลจะใส่? — คนส่วนใหญ่ติดตรงนี้

เริ่มจากข้อมูลสาธารณะฟรีเร็วที่สุด เรามีตัวดึงข้อมูลโอเพนซอร์สที่เติมฐานข้อมูลของคุณด้วย Fear & Greed, hash rate ของบิตคอยน์, อัตราดอกเบี้ยสหรัฐ, VIX และอื่น ๆ — ฟรีทั้งหมด ไม่ต้องใช้ API key ตัวดึงข้อมูล**สร้างตารางให้เอง** (ts, v) ขั้นตอนที่ 2 นี้จึงหายไปเลย — คำสั่งเดียวโหลดข้อมูล อีกคำสั่งติดตั้ง cron ★ การโหลดใช้บัญชีที่เขียนได้ ส่วนบัญชีอ่านอย่างเดียวในขั้นตอนที่ 3 เป็นคนละบัญชี ใช้สำหรับให้เอเจนต์อ่าน

ดูคู่มือใส่ข้อมูลสาธารณะ →
3

Create a READ-ONLY account (important)

Validation only needs reads. Paste the SQL below into the Supabase SQL editor — the real defense if the connection string ever leaks.

create role readonly_bot login password 'replace-with-strong-password';
grant usage on schema public to readonly_bot;
grant select on all tables in schema public to readonly_bot;
alter default privileges in schema public grant select on tables to readonly_bot;
4

คัดลอกสตริงการเชื่อมต่อ

เปิด Project Overview → Get connected ในแดชบอร์ดโปรเจกต์ คัดลอก URL ใต้ Direct แล้วเปลี่ยนเฉพาะชื่อผู้ใช้และรหัสผ่านเป็นบัญชีอ่านอย่างเดียวจากขั้นตอนที่ 3 ตัวเลือก pooler อยู่ที่เดียวกัน ★ Supabase อาจเปลี่ยนชื่อเมนูได้ — ตัว URL เองบอกว่าเป็นโหมดไหน: · โฮสต์เป็น db.your project ref.supabase.co (direct) → ชื่อผู้ใช้คือ readonly_bot · โฮสต์มี pooler.supabase.com → ชื่อผู้ใช้คือ readonly_bot.your project ref (ต้องคงส่วนหลังจุดไว้) ★ การเชื่อมต่อตรง (5432) ในแพ็กฟรีรองรับเฉพาะ IPv6 — ถ้าเซิร์ฟเวอร์เอเจนต์ไม่มี IPv6 ให้ใช้ URL แบบ Session mode (pooler)

5

Connect, then let the AI take over

Assets → External DB: enter an alias (main) and the URL — the connection is verified immediately. Then in chat: "use my fear_greed table in a strategy" — the AI registers the dataset, reads the verification report, writes a strategy using ctx.data('fg') and runs the backtest. ยังไม่มีข้อมูล? เริ่มจากชุดข้อมูลสาธารณะฟรีที่ /guide/datasets (เช่น ดัชนีความกลัวและความโลภ)

Good to know
  • Free projects pause after ~1 week of inactivity — the agent's 10-minute verification usually counts as activity and keeps it awake.
  • Live updates (notify mode) work only with Session-mode URLs (transaction pooling does not support LISTEN).
  • Backtest results carry a data fingerprint (rows, hash) — if your DB changes, fingerprints differ, and results with different fingerprints are not the same experiment.