OREStats

OREStats API v1

Endpoint แบบจ่ายเงินอยู่ภายใต้ /api/v1/*. ทั้งหมดต้องใช้ Authorization: Bearer ore_…. สมัครสมาชิกที่ /pricing.

การสมัครสมาชิกผ่าน API

  1. POST /api/v1/subscribe ด้วย { ownerPubkey } — เซิร์ฟเวอร์คืน nonce และจำนวน ORE
  2. ส่ง ORE จำนวน priceOre จากขั้นตอนที่ 1 ไปยังที่อยู่ treasury (คืนใน response เดียวกัน) โดยแนบ nonce เป็น SPL Memo instruction
  3. PUT /api/v1/subscribe ด้วย { nonce, txSig, ownerPubkey } — เซิร์ฟเวอร์ตรวจสอบบนเชน เปิดใช้งานการสมัครสมาชิก และคืน API key
  4. ใช้ Authorization: Bearer ore_… header ในทุกการเรียก /api/v1/*

รายละเอียดการชำระเงิน

กระเป๋าเงิน Treasury: A9HLwE6wCm7Hedo7771nwsX8TyArv7rgdVQMo9dgDGZF
ORE mint: oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp
เครือข่าย: Solana mainnet-beta
GET/api/v1/pricingสาธารณะ

วัตถุประสงค์: ราคาปัจจุบัน (เป็น ORE) สำหรับการเข้าถึงหนึ่งเดือน ราคาเลื่อนขึ้นเมื่อมีสมาชิกเข้าร่วม — response ยังบอกขั้นถัดไปและราคาขั้นต่อไปด้วย

response:
{
  "activeSubs": 17,
  "oreNow": 0.1,
  "nextThreshold": 100,
  "oreAtNextThreshold": 0.2,
  "treasury": "...",
  "oreMint": "..."
}
POST/api/v1/subscribeสาธารณะ

วัตถุประสงค์: ขั้นตอนที่ 1 ของการสมัครสมาชิก คืน instruction SPL transfer ครั้งเดียว (memo + amount) ที่คุณต้องเซ็นด้วยกระเป๋าเงินเจ้าของและ broadcast บน Solana

พารามิเตอร์:
  • ownerPubkeySolana pubkey แบบ base58 ที่จะเป็นเจ้าของ API key
request body:
{ "ownerPubkey": "..." }
response:
{
  "nonce": "ore-pay-...",
  "priceOre": 0.1,
  "instructions": { "to": "...", "memo": "ore-pay-...", "amountBaseUnits": "10000000000", "mint": "..." },
  "expiresAt": "..."
}
PUT/api/v1/subscribeสาธารณะ

วัตถุประสงค์: ขั้นตอนที่ 2 ของการสมัครสมาชิก หลังจาก SPL transfer ยืนยันแล้ว ส่งลายเซ็น tx เพื่อรับ API key ค่า plaintext จะแสดงเพียงครั้งเดียว

พารามิเตอร์:
  • nonceค่าที่คืนจาก POST /subscribe
  • txSigลายเซ็น SPL transfer ที่ยืนยันแล้วซึ่งมี memo จากขั้นตอนที่ 1
  • ownerPubkeyต้องตรงกับกระเป๋าเงินที่จ่าย (และส่งผ่าน POST)
request body:
{ "nonce": "...", "txSig": "...", "ownerPubkey": "..." }
response:
{
  "apiKey": "ore_xxx (shown ONCE)",
  "subscriberId": "sub_...",
  "paidUntil": "..."
}
GET/api/v1/liveจ่ายเงิน (Bearer)

วัตถุประสงค์: Snapshot ของรอบปัจจุบัน — แต่ละช่องมีอะไรอยู่ตอนนี้, วินาทีที่เหลือ และผลของรอบล่าสุด ราคาถูก; ปลอดภัยที่จะ poll ทุก 1-2 วินาที

response:
snapshot ของรอบปัจจุบัน (deployed, count, secondsLeft, prevRound)
GET/api/v1/streamจ่ายเงิน (Bearer)

วัตถุประสงค์: SSE feed ของ /live ส่ง snapshot ใหม่ทุกครั้งที่ board หรือ round account บนเชนเปลี่ยน เชื่อมต่อใหม่ได้ตลอด — event ถัดไปคือ state ล่าสุดเสมอ

response:
server-sent events; ส่ง snapshot ทุกครั้งที่ board / round account บนเชนเปลี่ยน
GET/api/v1/statsจ่ายเงิน (Bearer)

วัตถุประสงค์: สถิติกริดแบบรวม: ไคสแควร์ของ hits สะสม, จำนวน hit ต่อช่อง & SOL ที่เดิมพัน, SOL ทั้งหมดที่เคยเดิมพัน, edge เจ้ามือที่มีผลจริง

response:
aggregate (chi-squared, perGrid, totalDeployedSol, effectiveHouseEdge)
GET/api/v1/rounds?limit=100จ่ายเงิน (Bearer)

วัตถุประสงค์: N รอบล่าสุดที่จัดทำดัชนี ใหม่สุดก่อน ใช้สำหรับการ ingest แบบ batch; สำหรับการแจ้งเตือนรอบใหม่แบบ low-latency ใช้ /events/stream

พารามิเตอร์:
  • limitจำนวนรอบที่จะคืน; ค่าเริ่มต้น 100, สูงสุด 10000
response:
N รอบล่าสุดที่จัดทำดัชนี (id, deployed[25], count[25], winningSquare, totalDeployed, totalWinnings)
GET/api/v1/rounds/{id}จ่ายเงิน (Bearer)

วัตถุประสงค์: รายละเอียดรอบเดียวพร้อม id ก่อนหน้า/ถัดไปสำหรับการเดิน cursor ของประวัติ

พารามิเตอร์:
  • idround id (path segment)
response:
รอบเดียว + id ก่อนหน้า/ถัดไป
GET/api/v1/grid/{n}?limit=200จ่ายเงิน (Bearer)

วัตถุประสงค์: สถิติต่อช่องบวกซีรีส์ hit/miss ล่าสุด (1 = hit, 0 = miss) สำหรับการ render แผนภูมิ

พารามิเตอร์:
  • nดัชนีช่อง 0..24 (path segment)
  • limitความยาวซีรีส์; ค่าเริ่มต้น 200
response:
สถิติต่อกริด + ซีรีส์ hit/miss ล่าสุด (1 ≤ n ≤ 25)
GET/api/v1/events?since=N&limit=M&kind=Xจ่ายเงิน (Bearer)

วัตถุประสงค์: Event log แบบ poll รวม drought-broken, big-round, tier-crossing, milestones, การเปลี่ยนแปลงการสมัครสมาชิก ดึง event ที่ใหม่กว่า cursor `since`

พารามิเตอร์:
  • sincecursor ของ id; คืนเฉพาะ event ที่ id > since
  • limitevent สูงสุดต่อการเรียก; ค่าเริ่มต้น 100
  • kindfilter เสริม: drought_broken | big_round | tier | milestone | subscription
response:
{
  "count": 12,
  "lastId": 47,
  "events": [
    { "id": 47, "ts": "...", "kind": "drought_broken", "grid": 8, "drought": 91, "roundId": 247101 },
    { "id": 48, "ts": "...", "kind": "big_round", "roundId": 247155, "deployedSol": 8.94, "thresholdSol": 8.15, "multiplier": 1.10, "winningSquare": 12, "totalMiners": 209 },
    ...
  ]
}
GET/api/v1/events/stream?since=N&kind=Xจ่ายเงิน (Bearer)

วัตถุประสงค์: SSE feed ของ event log เดียวกับ /events เล่นซ้ำ 50 event ล่าสุด (หรือ event ตั้งแต่ cursor) ตอนเชื่อมต่อ แล้วส่ง event ใหม่แบบสด

พารามิเตอร์:
  • sincecursor สำหรับการเล่นซ้ำเสริม; ถ้าไม่ระบุจะเล่น 50 ล่าสุด
  • kindfilter เสริม (ชุดเดียวกับ /events)
response:
server-sent events; replays last 50 (or events since cursor) on connect, then pushes each new event as it fires (drought / streak / big round / tier / milestone / subscription).
GET/api/v1/dump?from=X&to=Y&limit=10000จ่ายเงิน (Bearer)

วัตถุประสงค์: การส่งออกประวัติแบบ bulk — เปิดหน้าทุกรอบที่จัดทำดัชนีผ่าน cursor `from` / `nextFrom` ใช้สำหรับ bootstrap ฐานข้อมูลของคุณ จากนั้นเปลี่ยนไปใช้ /events/stream สำหรับการอัปเดตเชิงเพิ่ม

พารามิเตอร์:
  • fromround id เริ่มต้น (รวม)
  • toround id สิ้นสุดเสริม (รวม)
  • limitขนาดหน้า; ค่าเริ่มต้น 5000, สูงสุด 10000
response:
{
  "count": 5000,
  "from": 228237,
  "to": 233236,
  "hasMore": true,
  "nextFrom": 233237,
  "rounds": [ { id, deployed[25], count[25], winningSquare, totalDeployed, totalWinnings }, ... ]
}
POST/api/v1/reissueสาธารณะ

วัตถุประสงค์: ขั้นตอนที่ 1 ของการหมุน API key คืนข้อความที่คุณต้องเซ็นด้วยกระเป๋าเงินที่เป็นเจ้าของการสมัครสมาชิกที่ใช้งานอยู่

พารามิเตอร์:
  • ownerPubkeyกระเป๋าเงินที่สมัครสมาชิกแต่แรก
request body:
{ "ownerPubkey": "..." }
response:
{ "nonce": "ore-reissue-...", "message": "OREStats reissue ... @ ...", "expiresAt": "..." }
PUT/api/v1/reissueสาธารณะ

วัตถุประสงค์: ขั้นตอนที่ 2 ของการหมุน ส่งลายเซ็นกระเป๋าเงิน; key เก่าจะถูกเพิกถอนทันทีและ key ใหม่จะถูกคืน (แสดงเพียงครั้งเดียวเช่นกัน)

พารามิเตอร์:
  • nonceค่าที่คืนจาก POST /reissue
  • ownerPubkeyกระเป๋าเงินเดียวกับ POST
  • signatureBase64ลายเซ็น ed25519 ที่เข้ารหัส base64 ของสตริงข้อความ
request body:
{ "nonce": "...", "ownerPubkey": "...", "signatureBase64": "..." }
response:
{ "apiKey": "ore_xxx (NEW, old key revoked)", "subscriberId": "sub_...", "paidUntil": "..." }

Strategy Lab

สร้าง, backtest และ forward-test กลยุทธ์ที่มีพารามิเตอร์ Endpoint create / backtest / analytics ใช้ DSL shape เดียวกัน — ดูค่าอ้างอิงที่ด้านล่างของส่วนนี้

POST/api/v1/lab/strategiesจ่ายเงิน (Bearer)

วัตถุประสงค์: สร้างกลยุทธ์ เมื่อ active แล้ว OREStats จะบันทึก paper-trading prediction อัตโนมัติสำหรับทุกรอบใหม่และแสดงสถิติ forward-test

พารามิเตอร์:
  • nameป้ายชื่อแสดงผล, สตริงไม่ว่าง
  • dslStrategy DSL ฉบับเต็ม — base_strategy, params, filters[] เสริม ดูค่าอ้างอิงด้านล่าง
request body:
{
  "name": "my cold-5",
  "dsl": {
    "base_strategy": "cold",
    "params": {
      "bet_size_lamports": 200000,
      "num_squares": 5,
      "sizing_mode": "flat",
      "max_bet_per_square_lamports": 5000000,
      "tx_fee_lamports": 10000
    },
    "filters": [
      { "metric": "current_drought_min", "op": ">=", "value": 30 }
    ]
  }
}
response:
{
  "strategy": {
    "id": "...", "owner": "...", "name": "...",
    "dsl": { "base_strategy": "...", "params": { ... }, "filters": [ ... ] },
    "createdAt": "...", "updatedAt": "...", "active": true
  }
}
GET/api/v1/lab/strategiesจ่ายเงิน (Bearer)

วัตถุประสงค์: แสดงรายการกลยุทธ์ที่คุณเป็นเจ้าของพร้อมสถิติ forward-test สด (รอบที่ settle แล้ว, จำนวนชนะ, ROI ตามผลรอบจริง)

response:
{
  "count": 3,
  "strategies": [
    {
      "id": "...", "name": "...", "dsl": { ... }, "active": true,
      "stats": { "roundsSettled": 412, "roundsWon": 88, "netProfitSol": 0.123, "roiPercent": 4.7 }
    },
    ...
  ]
}
GET/api/v1/lab/strategies/{id}จ่ายเงิน (Bearer)

วัตถุประสงค์: ดึงกลยุทธ์เดียวที่คุณเป็นเจ้าของ พร้อมจำนวน prediction

พารามิเตอร์:
  • idstrategy id (path segment)
response:
{ "strategy": { ... }, "predictionCount": 412 }
PATCH/api/v1/lab/strategies/{id}จ่ายเงิน (Bearer)

วัตถุประสงค์: เปลี่ยนชื่อกลยุทธ์หรือเปิด/ปิด flag active กลยุทธ์ที่ไม่ active จะหยุด prediction บนรอบใหม่แต่ประวัติยังคงอยู่

พารามิเตอร์:
  • nameชื่อแสดงผลใหม่ (เสริม)
  • activetrue เพื่อกลับมา predict, false เพื่อหยุดพัก (เสริม)
request body:
{ "name": "renamed", "active": false }
response:
{ "strategy": { ... } }
DELETE/api/v1/lab/strategies/{id}จ่ายเงิน (Bearer)

วัตถุประสงค์: ลบกลยุทธ์ที่คุณเป็นเจ้าของแบบถาวร prediction ที่เชื่อมต่อทั้งหมดจะถูกลบ; entry ใน leaderboard (ถ้ามี) จะหายไป

พารามิเตอร์:
  • idstrategy id (path segment)
response:
{ "ok": true }
GET/api/v1/lab/strategies/{id}/forwardจ่ายเงิน (Bearer)

วัตถุประสงค์: สถิติ forward-test สำหรับกลยุทธ์เดียว: net SOL, ROI, win rate, equity curve, max drawdown, losing streak สูงสุด, รอบที่ยัง pending

พารามิเตอร์:
  • idstrategy id (path segment)
response:
{
  "strategyId": "...",
  "roundsObserved": 432,
  "roundsBet": 412, "roundsWon": 88,
  "squaresBet": 2060, "squaresWon": 92,
  "netProfitSol": 0.12, "totalStakeSol": 2.6,
  "roiPercent": 4.7, "winRate": 0.21, "perSquareWinRate": 0.045,
  "maxDrawdownSol": 0.08, "maxStreak": 12,
  "equityCurve": [{ "round": 247001, "balanceLamports": 0 }, ...],
  "pendingCount": 1
}
POST/api/v1/lab/backtestจ่ายเงิน (Bearer)

วัตถุประสงค์: เล่นซ้ำ DSL กับรอบประวัติที่จัดทำดัชนี คืน BacktestResult เต็มรวม PnL ต่อรอบ, contribution ต่อช่อง, equity curve และเหตุผลการออกก่อนกำหนด

พารามิเตอร์:
  • dslStrategy DSL (shape เดียวกับ create)
  • fromRoundIdขอบล่างของหน้าต่างเล่นซ้ำแบบรวมเสริม
  • toRoundIdขอบบนแบบรวมเสริม
request body:
{
  "dsl": { "base_strategy": "...", "params": { ... }, "filters": [ ... ] },
  "fromRoundId": 200000,
  "toRoundId": 247000
}
response:
{
  "result": {
    "totalRounds": 47000, "roundsBet": 9200, "roundsWon": 1800,
    "squaresBet": 46000, "squaresWonOn": 1900,
    "netProfitLamports": ..., "netProfitSol": ...,
    "totalStakeLamports": ..., "totalStakeSol": ...,
    "totalRecoveryLamports": ..., "totalRecoverySol": ...,
    "roiPercent": ..., "winRate": ..., "perSquareWinRate": ...,
    "maxStreak": ..., "capHits": ..., "totalCapLossSol": ...,
    "minWalletSol": ..., "maxDrawdownSol": ...,
    "rangeMin": 200000, "rangeMax": 247000,
    "exitedEarly": null,
    "exitRoundId": 0,
    "equityCurve":   [{ "round": ..., "balanceLamports": ... }, ...],
    "perSquare":     [{ "square": 0, "betCount": ..., "winCount": ..., "netLamports": ... }, ...],
    "perRoundPnlLamports": [...],
    "streakRunLengths":    [...]
  }
}
POST/api/v1/lab/analyticsจ่ายเงิน (Bearer)

วัตถุประสงค์: ชุด analytics หนัก — Monte-Carlo confidence interval บวก backtest ซ้อนสี่ครั้งใน parameter sweep คาดว่า 3-6 วินาทีในการเรียกแรก, ต่ำกว่าวินาทีใน warm cache cache key คือ DSL

พารามิเตอร์:
  • dslStrategy DSL (shape เดียวกับ backtest)
request body:
{ "dsl": { ... } }
response:
{ "analytics": { ... } }
GET/api/v1/lab/leaderboardสาธารณะ

วัตถุประสงค์: รายการกลยุทธ์ยอดนิยมสาธารณะ เปิดเผยเฉพาะ ROI / ขนาดตัวอย่าง; DSL ซ่อนจนกว่าสมาชิกจะดู endpoint รายละเอียด

response:
{
  "generatedAt": "...",
  "minRoundsToQualify": 1000,
  "count": 14,
  "entries": [
    { "id": "...", "name": "...", "ownerShort": "abcd...wxyz", "roiPercent": ..., "roundsSettled": ... },
    ...
  ]
}
GET/api/v1/lab/leaderboard/{id}จ่ายเงิน (Bearer)

วัตถุประสงค์: DSL เต็มของ entry leaderboard เดียว บวกสรุป forward-test และ equity curve จำกัดเฉพาะสมาชิก — ผู้ใช้สาธารณะเห็นเฉพาะ ROI หลัก

พารามิเตอร์:
  • idstrategy id (path segment)
response:
{
  "strategy": {
    "id": "...", "name": "...", "ownerShort": "abcd...wxyz",
    "dsl": { ... },
    "createdAt": "..."
  },
  "forwardTest": {
    "roundsSettled": ...,
    "netProfitSol": ...,
    "equityCurve": [{ "round": ..., "balanceLamports": ... }, ...]
  }
}

Strategy DSL — ค่าที่รับ

base_strategy cold, spread, drought, custom_squares, hot, top_hit_rate, bottom_hit_rate, recent_winners, anti_spread, min_miners, corners, edges, center_block, diagonal_main, diagonal_anti, row, column, checkerboard, all_25

params.sizing_mode flat, martingale, reverse_martingale, fibonacci, dalembert, kelly

filters[].metric rounds_since_last_big, consecutive_losses, current_drought_min, current_drought_max, total_deployed_pctile, total_miners, rounds_since_big_round, chi_square_p_recent

filters[].op < , <= , > , >= , ==

ช่วงตัวเลข params.* (เซิร์ฟเวอร์จะ clamp ค่าที่อยู่นอกช่วง):
  bet_size_lamports             required, (0, 1e8]
  num_squares                   1..25
  drought_threshold             1..1000
  custom_squares                int[] in 0..24
  hit_rate_lookback             50..20000
  row_index, column_index       0..4
  martingale_multiplier         1..10
  loss_streak_threshold         1..100
  dalembert_step_lamports       1..1e6
  kelly_fraction                0.0001..1
  kelly_bankroll_lamports       >= 1
  max_bet_per_square_lamports   1..1e8
  tx_fee_lamports               0..1e7
  stop_loss_streak              1..1000
  cooldown_after_loss_rounds    0..500
  take_profit_lamports          >= 0
  session_stop_loss_lamports    >= 0

quotas:
  max 100 strategies per account

ขีดจำกัด & การใช้งานที่เป็นธรรม

  • ต่อ API key: 5 req/วินาที (burst 60) ส่ง 429 พร้อม Retry-After เมื่อเกิน
  • API key ใน header เป็น plaintext แบบใช้ครั้งเดียว: เก็บไว้ — เก็บเฉพาะ hash เท่านั้น
  • การแชร์ key ตรวจจับได้ (IP พร้อมกัน) และอาจทำให้ถูกเพิกถอน
  • Endpoint ของแดชบอร์ด (/api/live*) ต้องใช้ session ในเบราว์เซอร์ + Origin ที่ตรงกัน — ไม่ได้ออกแบบสำหรับการใช้งานเชิงโปรแกรม