ข้ามไปยังเนื้อหา

การเทรด

วงจรชีวิตออร์เดอร์

ออร์เดอร์เคลื่อนผ่านชุดสถานะที่กำหนดตั้งแต่ส่งจนกว่าจะ fill ยกเลิก หรือหมดอายุ ทุกสถานะสามารถสังเกตได้ผ่าน API

Endpoint ในบทนี้

สี่ endpoint ครอบคลุมวงจรชีวิตออร์เดอร์ทั้งหมด ทุก trading endpoint ต้องยืนยันตัวตนและมี scope ที่เหมาะสม

VerbPathวัตถุประสงค์
POST /orders ส่งออร์เดอร์ใหม่
GET /orders/:id อ่านออร์เดอร์เดียวตาม ID
GET /orders แสดงออร์เดอร์ที่เปิดอยู่และปิดล่าสุด
POST /orders/:id/cancel ยกเลิกออร์เดอร์ที่เปิดอยู่
ACTORClientACTORSatoriEx APIACTORRedis LISTACTORMatcherACTORLedgerACTORWebSocket Hub1POST /orders (validate, escrow funds)2202 Accepted (trades: [])3LPUSH order:pending4BRPOP (pull next order)5match by price-time priority6atomic debit / credit (double-entry)7broadcast trade event over /wsAll seven steps run in the same matcher tick — typical end-to-end latency from POST to WS event is under 500 ms.
The full async flow from a POST /orders call to a trade event delivered over WebSocket. The 202 Accepted (step 2, dashed) lands BEFORE matching runs — your client must await the trade event on /ws to learn the fill outcome.

สถานะออร์เดอร์

ทุกออร์เดอร์มีค่าสถานะหนึ่งในนี้ การเปลี่ยนสถานะเป็นทางเดียว ยกเว้น partial-then-cancelled

ENTRYSubmittedSTATEpendingSTATEopenSTATEpartialSTATEfilledEXITClosedSTATEcancelledPOST /ordersadded to booksome fillsmore fillsfully matchedvalidation failsuser cancelscancel remainder
Transitions are one-way except for the cancel branches: pending, open, and partial can all transition to cancelled by user or admin action. A circuit-breaker halt pauses the market but leaves resting orders intact — cancellation is still your decision. Cancelling a partial order removes only the unfilled remainder.
สถานะความหมาย
pendingรอดำเนินการในสมุดคำสั่งซื้อขายรอออร์เดอร์ตรงข้าม
openคำสั่งพักรอในสมุดคำสั่งซื้อขาย รอคำสั่งตรงข้าม
partialFill บางส่วน ส่วนที่เหลือยังรอดำเนินการ
filledจับคู่ครบ หุ้นอยู่ในตำแหน่งของคุณ
cancelledCancelled by the user or by an admin action. The circuit breaker halts the market on a 30%+ price move but does not automatically cancel resting orders — they are paused until trading resumes (or you cancel them yourself).

เหตุผลการปฏิเสธที่พบบ่อย

เมื่อออร์เดอร์ถูกปฏิเสธ response จะมี error code ที่คงที่เพื่อให้ client ตัดสินใจ

CodeSymbolความหมาย
3001 ErrInsufficientBalance ยอด USDC ของคุณต่ำเกินไปสำหรับออร์เดอร์ที่ราคาที่เสนอ
5002 ErrInvalidPrice ราคาอยู่นอกช่วง tick ที่ตลาดรับหรือต่ำกว่า 0 / เกิน 1
5004 ErrInvalidSide side must be 1 (buy) or 2 (sell) — any other value is rejected.
5007 ErrMarketNotTrading ตลาดหยุดชั่วคราว (circuit breaker, การตัดสิน หรือการบำรุงรักษา)
5008 ErrInsufficientPosition you do not hold enough shares of this outcome to place this sell order.
2025 ErrTwoFactorRequired 2FA is required for trading — enable it in Security settings before placing orders.

แยกสาขาบนฟิลด์ `code` แบบตัวเลข ไม่ใช่บนข้อความ — ข้อความหันหน้าสู่ผู้ใช้และเปลี่ยนตาม locale และ copy ของแพลตฟอร์ม

Subscribe กับ order event แทนการ poll

WebSocket order channel ส่ง state transition แบบ real time ใช้กับ bot ที่ต้องตอบสนองต่อ fill — การ poll เหมาะสำหรับ dashboard แต่สิ้นเปลืองสำหรับ trading loop