NautilusTrader Docs · ภาษาไทย

TradeTick

TradeTick แทน trade หรือ match event หนึ่งครั้งจาก venue โดยเก็บราคาที่ซื้อขาย size, ฝั่ง aggressor และ trade identifier ของ venue

ฟิลด์

FieldRust typeRequired/defaultNotes
instrument_idInstrumentIdRequiredinstrument ของ trade
pricePriceRequiredราคาที่ execute
sizeQuantityRequiredปริมาณที่ execute
aggressor_sideAggressorSideRequiredBUY, SELL หรือ NO_AGGRESSOR
trade_idTradeIdRequiredmatch ID ที่ venue กำหนด
ts_eventUnixNanosRequiredtimestamp ของ event หน่วยนาโนวินาที
ts_initUnixNanosRequiredtimestamp ตอน initialize หน่วยนาโนวินาที

พฤติกรรม

  • size ต้องเป็นค่าบวก
  • information-driven bar ต้องใช้ข้อมูล TradeTick เพราะใช้ aggressor_side
  • trade bar ใช้ price type แบบ LAST
  • trade_id ควรคงที่สำหรับ event เดียวกันของ venue เมื่อ venue ให้ค่านี้มา
  • การ parse และ deserialize ยอมรับค่า BUYER/SELLER ที่ deprecated แล้ว แต่ string ที่ output ออกมาจะเป็นค่า canonical BUY/SELL เสมอ

ตัวอย่าง

use nautilus_core::UnixNanos;
use nautilus_model::{
    data::TradeTick,
    enums::AggressorSide,
    identifiers::{InstrumentId, TradeId},
    types::{Price, Quantity},
};

let trade = TradeTick::new(
    InstrumentId::from("BTCUSDT.BINANCE"),
    Price::from("65000.10"),
    Quantity::from("0.25"),
    AggressorSide::Buy,
    TradeId::from("123456789"),
    UnixNanos::from(1_000_000_000),
    UnixNanos::from(1_000_000_100),
);
  • Bar อธิบายการ aggregate trade เป็น bar
  • Information-driven bars อธิบายการใช้ฝั่ง aggressor
  • Rust API reference แสดงรายละเอียด API ฝั่ง Rust

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