NautilusTrader Docs · ภาษาไทย

OrderUpdated

OrderUpdated บันทึกการเปลี่ยนแปลง quantity, price, trigger price หรือ protection price ที่คำนวณได้ ของ order execution pipeline จะ apply event นี้กับ order อัปเดต Cache และ publish ลงบน MessageBus การเปลี่ยนแปลงอาจมาจาก trading venue, simulated matching engine, order emulator ในเครื่อง หรือ reconciliation

transition ที่พบบ่อย: PENDING_UPDATE -> สถานะก่อนหน้า (เช่น ACCEPTED) handler: on_order_updated

สัญญา (contract)

quantity คือ quantity แบบ gross ของ order: รวม filled quantity และ voided quantity ที่ไม่ได้ reopen (ดู OrderFillVoided) Nautilus คำนวณ leaves ที่ยังทำงานอยู่เป็น

leaves_qty = max(quantity - filled_qty - non_reopened_voided_qty, 0)

ดังนั้น void ที่ไม่ได้ reopen จะถูกตัดออกจาก leaves เสมอแม้มีการ update ครั้งต่อ ๆ ไป โดย adapter ไม่ต้อง หักออกจาก quantity เอง adapter ที่รายงาน quantity แบบหัก void ที่ไม่ได้ reopen ออกแล้ว จะทำให้ leaves ถูกหัก quantity นั้นซ้ำสองครั้ง

Terminal reconciliation เป็นข้อยกเว้น reconciliation update (reconciliation=True) ที่ quantity เท่ากับ filled_qty ที่ไม่เป็นศูนย์ของ order จะปิด order เป็น FILLED ในกรณีนี้ quantity คือ filled quantity ที่มีผลจริง หลังหัก voided quantity แล้ว ดังนั้น adapter ที่ปิด order ตามจำนวนที่ fill ได้จะรายงาน filled_qty แทน gross quantity

ฟิลด์

นอกจากฟิลด์ทั่วไปของ order event แล้ว OrderUpdated ยังมี:

ฟิลด์Required/defaultคำอธิบาย
venue_order_idNoneorder identifier ที่ venue กำหนด (ถ้าทราบ)
account_idNoneaccount ที่ผูกกับ order (ถ้าทราบ)
quantityRequiredquantity ปัจจุบันของ order
priceNoneราคาปัจจุบันของ order
trigger_priceNonetrigger price ปัจจุบันของ order
protection_priceNoneprotection price ที่คำนวณได้ของ order
is_quote_quantityFalseorder quantity เป็นหน่วยของ quote currency หรือไม่
reconciliationRequiredสร้างขึ้นระหว่าง reconciliation หรือไม่

หมายเหตุ: ต้นฉบับมีเฉพาะตัวอย่าง Python จึงตัดออก

  • Events - หมวดหมู่ของ event, การ dispatch และฟิลด์ทั่วไปของ order event
  • Orders - ประเภทของ order และ state machine

แปลจาก เอกสาร NautilusTrader © Nautech Systems Pty Ltd และผู้ร่วมพัฒนา เผยแพร่ภายใต้ LGPL-3.0 ฉบับแปลนี้ตัดเนื้อหาเฉพาะ Python ออกและเน้น Rust