NautilusTrader Docs · ภาษาไทย

Betting Instrument

BettingInstrument แทนตัวเลือก (selection) หนึ่งตัวในตลาดกีฬาหรือเกม โดยเก็บ metadata ของ event, competition, market และ selection ไว้ เพื่อให้ Nautilus ปฏิบัติต่อ selection นั้นเหมือน instrument ที่มีราคา, ขนาด, ข้อจำกัด, margin และค่าธรรมเนียม

ตัวอย่างเช่น selection ในตลาด match odds และตลาด handicap ของ Betfair

ฟิลด์

ฟิลด์Rust typeจำเป็น/ค่าเริ่มต้นหมายเหตุ
instrument_idInstrumentIdRequiredใน Rust เก็บไว้ในชื่อ id
raw_symbolSymbolRequiredsymbol ดั้งเดิมของ venue หรือที่สร้างขึ้น
event_type_idu64Requiredตัวระบุชนิดของ event
event_type_nameUstrRequiredชื่อชนิดของ event เช่น ประเภทกีฬา
competition_idu64Requiredตัวระบุ competition
competition_nameUstrRequiredชื่อ competition
event_idu64Requiredตัวระบุ event
event_nameUstrRequiredชื่อ event
event_country_codeUstrRequiredรหัสประเทศของ event
event_open_dateUnixNanosRequiredเวลาเปิดของ event
betting_typeUstrRequiredประเภทการเดิมพันที่ venue เผยแพร่
market_idUstrRequiredตัวระบุ market
market_nameUstrRequiredชื่อ market
market_typeUstrRequiredชนิดของ market เช่น match odds
market_start_timeUnixNanosRequiredเวลาเริ่มของ market
selection_idu64Requiredตัวระบุ selection หรือ runner
selection_nameUstrRequiredชื่อ selection หรือ runner
selection_handicapf64Requiredค่า handicap สำหรับตลาด handicap
currencyCurrencyRequiredสกุลเงินของ quote และการชำระ
price_precisionu8Requiredจำนวนตำแหน่งทศนิยมที่อนุญาตสำหรับราคา
size_precisionu8Requiredจำนวนตำแหน่งทศนิยมที่อนุญาตสำหรับขนาด order
price_incrementPriceRequiredขั้นราคา มักกำหนดโดย tick scheme
size_incrementQuantityRequiredขั้นขนาดขั้นต่ำ
max_quantityOption<Quantity>Noneปริมาณ order สูงสุด
min_quantityOption<Quantity>Noneปริมาณ order ต่ำสุด
max_notionalOption<Money>Noneมูลค่า notional ของ order สูงสุด
min_notionalOption<Money>Noneมูลค่า notional ของ order ต่ำสุด
max_priceOption<Price>Noneราคา quote หรือ order สูงสุดที่ใช้ได้
min_priceOption<Price>Noneราคา quote หรือ order ต่ำสุดที่ใช้ได้
margin_initOption<Decimal>1อัตรา initial margin
margin_maintOption<Decimal>1อัตรา maintenance margin
tick_schemeOption<Ustr>Noneชื่อ tick scheme แบบแปรผันที่ลงทะเบียนไว้
infoOption<Params>Nonemetadata ของ adapter
ts_eventUnixNanosRequiredtimestamp ของ event หน่วยนาโนวินาที
ts_initUnixNanosRequiredtimestamp ตอนสร้าง หน่วยนาโนวินาที

พฤติกรรม

  • BettingInstrument มี asset class เป็น Alternative และ instrument class เป็น SportsBetting
  • แต่ละ selection หรือ runner ถูกจำลองเป็น instrument ของตัวเอง
  • betting instrument มักใช้ tick scheme ที่ลงทะเบียนไว้เพื่อกำหนดขั้นของ odds ที่ใช้ได้
  • margin มีค่าเริ่มต้นเป็นหนึ่ง เพราะการวางเดิมพันมักกันเงินเดิมพันไว้เต็มจำนวน

ตัวอย่าง

use jiff::Timestamp;
use nautilus_core::UnixNanos;
use nautilus_model::{
    identifiers::{InstrumentId, Symbol},
    instruments::BettingInstrument,
    types::{Currency, Money, Price, Quantity},
};
use rust_decimal_macros::dec;
use ustr::Ustr;

let event_open: Timestamp = "2022-02-07T23:30:00Z".parse().unwrap();
let market_start: Timestamp = "2022-02-07T23:30:00Z".parse().unwrap();

let selection = BettingInstrument::builder()
    .instrument_id(InstrumentId::from("1-123456789-50214.BETFAIR"))
    .raw_symbol(Symbol::from("1-123456789-50214"))
    .event_type_id(6423)
    .event_type_name(Ustr::from("American Football"))
    .competition_id(12_282_733)
    .competition_name(Ustr::from("NFL"))
    .event_id(29_678_534)
    .event_name(Ustr::from("NFL"))
    .event_country_code(Ustr::from("GB"))
    .event_open_date(UnixNanos::from(event_open))
    .betting_type(Ustr::from("ODDS"))
    .market_id(Ustr::from("1-123456789"))
    .market_name(Ustr::from("AFC Conference Winner"))
    .market_type(Ustr::from("SPECIAL"))
    .market_start_time(UnixNanos::from(market_start))
    .selection_id(50214)
    .selection_name(Ustr::from("Kansas City Chiefs"))
    .selection_handicap(0.0)
    .currency(Currency::from("GBP"))
    .price_precision(2)
    .size_precision(2)
    .price_increment(Price::from("0.01"))
    .size_increment(Quantity::from("0.01"))
    .max_quantity(Quantity::from("1000"))
    .min_quantity(Quantity::from("1"))
    .max_notional(Money::from("10000 GBP"))
    .min_notional(Money::from("10 GBP"))
    .max_price(Price::from("100.00"))
    .min_price(Price::from("1.00"))
    .margin_init(dec!(1))
    .margin_maint(dec!(1))
    .ts_event(UnixNanos::default())
    .ts_init(UnixNanos::default())
    .build()
    .unwrap();

Adapter

adapter Betfair สร้างหรือใช้ instrument แบบ BettingInstrument สำหรับตลาดเดิมพันกีฬา

  • Accounting อธิบายพฤติกรรมของ betting account
  • Data อธิบายข้อมูลตลาดที่อ้างอิงถึง instrument

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