Data 数据
class Bar K线
class Bar(Data):
"""
Represents an aggregated bar.
表示聚合的K线。
Parameters:
参数:
bar_type (BarType) – The bar type for this bar.
bar_type (BarType) - 此K线的K线类型。
open (Price) – The bars open price.
open (Price) - K线的开盘价。
high (Price) – The bars high price.
high (Price) - K线的最高价。
low (Price) – The bars low price.
low (Price) - K线的最低价。
close (Price) – The bars close price.
close (Price) - K线的收盘价。
volume (Quantity) – The bars volume.
volume (Quantity) - K线的成交量。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the data event occurred.
ts_event (uint64_t) - 数据事件发生时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized.
ts_init (uint64_t) - 数据对象初始化时的 UNIX 时间戳(纳秒)。
is_revision (bool , default False) – If this bar is a revision of a previous bar with the same ts_event.
is_revision (bool,默认 False) - 如果此K线是对具有相同 ts_event 的先前K线的修订。
Raises:
引发:
ValueError – If high is not >= low.
ValueError - 如果 high 不大于等于 low。
ValueError – If high is not >= close.
ValueError - 如果 high 不大于等于 close。
ValueError – If low is not <= close.
ValueError - 如果 low 不小于等于 close。
"""
def __init__(self, bar_type: BarType, open: Price, high: Price, low: Price, close: Price, volume: Quantity, ts_event: int, ts_init: int, is_revision: bool=False) -> None:
...
@property
def bar_type(self) -> BarType:
"""
BarType
Return the bar type of bar.
返回K线的K线类型。
Return type: BarType
Type: Bar.bar_type
"""
...
@property
def close(self) -> Price:
"""
Price
Return the close price of the bar.
返回K线的收盘价。
Return type: Price
Type: Bar.close
"""
...
@property
def high(self) -> Price:
"""
Price
Return the high price of the bar.
返回K线的最高价。
Return type: Price
Type: Bar.high
"""
...
@property
def is_revision(self) -> bool:
"""
If this bar is a revision for a previous bar with the same ts_event.
如果此K线是对具有相同 ts_event 的先前K线的修订。
Returns:
bool
"""
...
@property
def low(self) -> Price:
"""
Price
Return the low price of the bar.
返回K线的最低价。
Return type: Price
Type: Bar.low
"""
...
@property
def open(self) -> Price:
"""
Price
Return the open price of the bar.
返回K线的开盘价。
Return type: Price
Type: Bar.open
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred.
数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: Bar.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: Bar.ts_init
"""
...
@property
def volume(self) -> Quantity:
"""
Quantity
Return the volume of the bar.
返回K线的成交量。
Return type: Quantity
Type: Bar.volume
"""
...
@staticmethod
def from_dict(values: dict) -> Bar:
"""
Return a bar parsed from the given values.
从给定值解析K线。
Parameters: values (dict *[*str , object ]) – The values for initialization.
参数:values (dict *[*str , object ]) - 用于初始化的值。
Return type: Bar
"""
...
@staticmethod
def from_pyo3(pyo3_bar) -> Bar:
"""
Return a legacy Cython bar converted from the given pyo3 Rust object.
从给定的 pyo3 Rust 对象转换旧版 Cython K线。
Parameters: pyo3_bar (nautilus_pyo3.Bar) – The pyo3 Rust bar to convert from.
参数:pyo3_bar (nautilus_pyo3.Bar) - 要转换的 pyo3 Rust K线。
Return type: Bar
"""
...
@staticmethod
def from_pyo3_list(pyo3_bars: list) -> list[Bar]:
"""
Return legacy Cython bars converted from the given pyo3 Rust objects.
从给定的 pyo3 Rust 对象转换旧版 Cython K线。
Parameters: pyo3_bars (list *[*nautilus_pyo3.Bar ]) – The pyo3 Rust bars to convert from.
参数:pyo3_bars (list *[*nautilus_pyo3.Bar ]) - 要转换的 pyo3 Rust K线。
Return type: list[Bar]
"""
...
@staticmethod
def from_raw(bar_type: BarType, open: int, high: int, low: int, close: int, price_prec: int, volume: int, size_prec: int, ts_event: int, ts_init: int) -> Bar:
"""
Return type: Bar
"""
...
@staticmethod
def from_raw_arrays_to_list(bar_type: BarType, price_prec: int, size_prec: int, opens, highs, lows, closes, volumes, ts_events, ts_inits) -> list[Bar]:
"""
Return type: list[Bar]
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str='') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name.
确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal.
参数:name (str,可选) - 要检查的特定信号名称。如果未提供名称或传递空字符串,则该方法将检查类名是否指示一般信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False.
返回值:如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
def is_single_price(self) -> bool:
"""
If the OHLC are all equal to a single price.
如果 OHLC 都等于单个价格。
Return type: bool
"""
...
@staticmethod
def to_dict(obj: Bar):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def to_pyo3(self) -> 'nautilus_pyo3.Bar':
"""
Return a pyo3 object from this legacy Cython instance.
从此旧版 Cython 实例返回一个 pyo3 对象。
Return type: nautilus_pyo3.Bar
"""
...
@staticmethod
def to_pyo3_list(bars: list) -> list['nautilus_pyo3.Bar']:
"""
Return pyo3 Rust bars converted from the given legacy Cython objects.
返回从给定的旧版 Cython 对象转换的 pyo3 Rust K线。
Parameters: bars (list [Bar ]) – The legacy Cython bars to convert from.
参数:bars (list [Bar ]) - 要转换的旧版 Cython K线。
Return type: list[nautilus_pyo3.Bar]
"""
...
class BarAggregation K线聚合
class BarAggregation(IntFlag):
"""
conjugate()
Returns self, the complex conjugate of any int.
返回自身,即任何 int 的复共轭。
bit_length()
Number of bits necessary to represent self in binary.
以二进制表示自身所需的位数。
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()
Number of ones in the binary representation of the absolute value of self.
自身绝对值的二进制表示中 1 的个数。
Also known as the population count.
也称为 population count。
>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)
Return an array of bytes representing an integer.
返回表示整数的字节数组。
length : Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
length:要使用的字节对象的长度。如果整数无法用给定的字节数表示,则会引发 OverflowError。默认长度为 1。
byteorder : The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use
byteorder:用于表示整数的字节顺序。如果 byteorder 为“big”,则最高有效字节位于字节数组的开头。如果 byteorder 为“little”,则最高有效字节位于字节数组的末尾。要请求主机系统的本机字节顺序,请使用
`sys.byteorder` as the byte order value. Default is to use ‘big’.
`sys.byteorder` 作为字节顺序值。默认使用“big”。
signed : Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
signed:确定是否使用二进制补码来表示整数。如果 signed 为 False 且给定负整数,则会引发 OverflowError。
from_bytes(byteorder='big', *, signed=False)
Return the integer represented by the given array of bytes.
返回给定字节数组表示的整数。
bytes : Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
bytes:保存要转换的字节数组。参数必须支持缓冲区协议或可生成字节的可迭代对象。Bytes 和 bytearray 是支持缓冲区协议的内置对象的示例。
byteorder : The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use
byteorder:用于表示整数的字节顺序。如果 byteorder 为“big”,则最高有效字节位于字节数组的开头。如果 byteorder 为“little”,则最高有效字节位于字节数组的末尾。要请求主机系统的本机字节顺序,请使用
`sys.byteorder` as the byte order value. Default is to use ‘big’.
`sys.byteorder` 作为字节顺序值。默认使用“big”。
signed : Indicates whether two’s complement is used to represent the integer.
signed:指示是否使用二进制补码来表示整数。
as_integer_ratio()
Return integer ratio.
返回整数比率。
Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.
返回一对整数,它们的比率正好等于原始 int,并且分母为正数。
>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real
the real part of a complex number
复数的实部
imag
the imaginary part of a complex number
复数的虚部
numerator
the numerator of a rational number in lowest terms
有理数的最简分数形式的分子
denominator
the denominator of a rational number in lowest terms
有理数的最简分数形式的分母
"""
TICK = 1
TICK_IMBALANCE = 2
TICK_RUNS = 3
VOLUME = 4
VOLUME_IMBALANCE = 5
VOLUME_RUNS = 6
VALUE = 7
VALUE_IMBALANCE = 8
VALUE_RUNS = 9
MILLISECOND = 10
SECOND = 11
MINUTE = 12
HOUR = 13
DAY = 14
WEEK = 15
MONTH = 16
class BarSpecification K线规格
class BarSpecification(object):
"""
Represents a bar aggregation specification including a step, aggregation method/rule and price type.
表示K线聚合规范,包括步长、聚合方法/规则和价格类型。
Parameters:
参数:
step (int) – The step for binning samples for bar aggregation (> 0).
step (int) - 用于对样本进行分箱以进行K线聚合的步长 (> 0)。
aggregation (BarAggregation) – The type of bar aggregation.
aggregation (BarAggregation) - K线聚合的类型。
price_type (PriceType) – The price type to use for aggregation.
price_type (PriceType) - 用于聚合的价格类型。
Raises: ValueError – If step is not positive (> 0).
引发:ValueError - 如果 step 不为正数 (> 0)。
"""
def __init__(self, step: int, aggregation: BarAggregation, price_type: PriceType) -> None:
...
@property
def aggregation(self) -> BarAggregation:
"""
BarAggregation
Return the aggregation for the specification.
返回规范的聚合。
Return type: BarAggregation
Type: BarSpecification.aggregation
"""
...
@property
def price_type(self) -> PriceType:
"""
PriceType
Return the price type for the specification.
返回规范的价格类型。
Return type: PriceType
Type: BarSpecification.price_type
"""
...
@property
def step(self) -> int:
"""
int
Return the step size for the specification.
返回规范的步长。
Return type: int
Type: BarSpecification.step
"""
...
@property
def timedelta(self) -> timedelta:
"""
timedelta
Return the timedelta for the specification.
返回规范的时间增量。
Return type: timedelta
Raises: ValueError – If aggregation is not a time aggregation, or is``MONTH`` (which is ambiguous).
引发:ValueError - 如果聚合不是时间聚合,或者是 ``MONTH``(这是不明确的)。
Type: BarSpecification.timedelta
"""
...
@staticmethod
def check_information_aggregated(aggregation: BarAggregation):
"""
Check the given aggregation is a type of information aggregation.
检查给定的聚合是否是信息聚合的一种类型。
Parameters: aggregation (BarAggregation) – The aggregation type to check.
参数:aggregation (BarAggregation) - 要检查的聚合类型。
Returns: True if information aggregated, else False.
返回值:如果信息已聚合,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def check_threshold_aggregated(aggregation: BarAggregation):
"""
Check the given aggregation is a type of threshold aggregation.
检查给定的聚合是否是阈值聚合的一种类型。
Parameters: aggregation (BarAggregation) – The aggregation type to check.
参数:aggregation (BarAggregation) - 要检查的聚合类型。
Returns: True if threshold aggregated, else False.
返回值:如果阈值已聚合,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def check_time_aggregated(aggregation: BarAggregation):
"""
Check the given aggregation is a type of time aggregation.
检查给定的聚合是否是时间聚合的一种类型。
Parameters: aggregation (BarAggregation) – The aggregation type to check.
参数:aggregation (BarAggregation) - 要检查的聚合类型。
Returns: True if time aggregated, else False.
返回值:如果时间已聚合,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def from_str(value: str) -> BarSpecification:
"""
Return a bar specification parsed from the given string.
从给定字符串解析K线规范。
Parameters: value (str) – The bar specification string to parse.
参数:value (str) - 要解析的K线规范字符串。
Return type: BarSpecification
Raises: ValueError – If value is not a valid string.
引发:ValueError - 如果 value 不是有效的字符串。
"""
...
@staticmethod
def from_timedelta(duration: timedelta, price_type: PriceType) -> BarSpecification:
"""
Return a bar specification parsed from the given timedelta and price_type.
从给定的 timedelta 和 price_type 解析K线规范。
Parameters:
参数:
duration (timedelta) – The bar specification timedelta to parse.
duration (timedelta) - 要解析的K线规范 timedelta。
price_type (PriceType) – The bar specification price_type.
price_type (PriceType) - K线规范 price_type。
Return type: BarSpecification
Raises: ValueError – If duration is not rounded step of aggregation.
引发:ValueError - 如果 duration 不是聚合的舍入步长。
"""
...
def is_information_aggregated(self) -> bool:
"""
Return a value indicating whether the aggregation method is information-driven.
返回值指示聚合方法是否由信息驱动。
TICK_RUNS
VOLUME_RUNS
VALUE_RUNS
Return type: bool
"""
...
def is_threshold_aggregated(self) -> bool:
"""
Return a value indicating whether the bar aggregation method is threshold-driven.
返回值指示K线聚合方法是否由阈值驱动。
TICK
TICK_IMBALANCE
VOLUME
VOLUME_IMBALANCE
VALUE
VALUE_IMBALANCE
Return type: bool
"""
...
def is_time_aggregated(self) -> bool:
"""
Return a value indicating whether the aggregation method is time-driven.
返回值指示聚合方法是否由时间驱动。
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
Return type: bool
"""
...
class BarType K线类型
class BarType(object):
"""
Represents a bar type including the instrument ID, bar specification and aggregation source.
表示K线类型,包括金融工具 ID、K线规范和聚合来源。
Parameters:
参数:
instrument_id (InstrumentId) – The bar type’s instrument ID.
instrument_id (InstrumentId) - K线类型的金融工具 ID。
bar_spec (BarSpecification) – The bar type’s specification.
bar_spec (BarSpecification) - K线类型的规范。
aggregation_source (AggregationSource , default EXTERNAL) – The bar type aggregation source. If INTERNAL the DataEngine will subscribe to the necessary ticks and aggregate bars accordingly. Else if EXTERNAL then bars will be subscribed to directly from the venue / data provider.
aggregation_source (AggregationSource,默认 EXTERNAL) - K线类型聚合来源。如果为 INTERNAL,则 DataEngine 将订阅必要的 tick 并相应地聚合K线。否则,如果为 EXTERNAL,则将直接从交易场所/数据提供者订阅K线。
"""
def __init__(self, instrument_id: InstrumentId, bar_spec: BarSpecification, aggregation_source: AggregationSource=AggregationSource.EXTERNAL) -> None:
...
@property
def aggregation_source(self) -> AggregationSource:
"""
AggregationSource
Return the aggregation source for the bar type.
返回K线类型的聚合来源。
Return type: AggregationSource
Type: BarType.aggregation_source
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
InstrumentId
Return the instrument ID for the bar type.
返回K线类型的金融工具 ID。
Return type: InstrumentId
Type: BarType.instrument_id
"""
...
@property
def spec(self) -> BarSpecification:
"""
BarSpecification
Return the specification for the bar type.
返回K线类型的规范。
Return type: BarSpecification
Type: BarType.spec
"""
...
def composite(self) -> BarType:
"""
Return type: BarType
"""
...
@staticmethod
def from_str(value: str) -> BarType:
"""
Return a bar type parsed from the given string.
从给定字符串解析K线类型。
Parameters: value (str) – The bar type string to parse.
参数:value (str) - 要解析的K线类型字符串。
Return type: BarType
Raises: ValueError – If value is not a valid string.
引发:ValueError - 如果 value 不是有效的字符串。
"""
...
def is_composite(self) -> bool:
"""
Return a value indicating whether the bar type corresponds to BarType::Composite in rust.
返回值指示K线类型是否与 rust 中的 BarType::Composite 对应。
Return type: bool
"""
...
def is_externally_aggregated(self) -> bool:
"""
Return a value indicating whether the bar aggregation source is EXTERNAL.
返回值指示K线聚合源是否为 EXTERNAL。
Return type: bool
"""
...
def is_internally_aggregated(self) -> bool:
"""
Return a value indicating whether the bar aggregation source is INTERNAL.
返回值指示K线聚合源是否为 INTERNAL。
Return type: bool
"""
...
def is_standard(self) -> bool:
"""
Return a value indicating whether the bar type corresponds to BarType::Standard in rust.
返回值指示K线类型是否与 rust 中的 BarType::Standard 对应。
Return type: bool
"""
...
@staticmethod
def new_composite(instrument_id: InstrumentId, bar_spec: BarSpecification, aggregation_source: AggregationSource, composite_step: int, composite_aggregation: BarAggregation, composite_aggregation_source: AggregationSource) -> BarType:
"""
Return type: BarType
"""
...
def standard(self) -> BarType:
"""
Return type: BarType
"""
...
class BookOrder 订单簿订单
class BookOrder(object):
"""
Represents an order in a book.
表示订单簿中的订单。
Parameters:
参数:
side (OrderSide {BUY, SELL}) – The order side.
side (OrderSide {BUY, SELL}) - 订单方向。
price (Price) – The order price.
price (Price) - 订单价格。
size (Quantity) – The order size.
size (Quantity) - 订单数量。
order_id (uint64_t) – The order ID.
order_id (uint64_t) - 订单 ID。
"""
def __init__(self, side: OrderSide, price: Price, size: Quantity, order_id: int) -> None:
...
@property
def order_id(self) -> int:
"""
uint64_t
Return the book orders side.
返回订单簿订单方向。
Return type: uint64_t
Type: BookOrder.order_id
"""
...
@property
def price(self) -> Price:
"""
Price
Return the book orders price.
返回订单簿订单价格。
Return type: Price
Type: BookOrder.price
"""
...
@property
def side(self) -> OrderSide:
"""
OrderSide
Return the book orders side.
返回订单簿订单方向。
Return type: OrderSide
Type: BookOrder.side
"""
...
@property
def size(self) -> Quantity:
"""
Price
Return the book orders size.
返回订单簿订单数量。
Return type: Quantity
Type: BookOrder.size
"""
...
def exposure(self) -> float:
"""
Return the total exposure for this order (price * size).
返回此订单的总风险敞口(价格 * 数量)。
Return type: double
"""
...
@staticmethod
def from_dict(values: dict) -> BookOrder:
"""
Return an order from the given dict values.
从给定的字典值返回订单。
Parameters: values (dict *[*str , object ]) – The values for initialization.
参数:values (dict *[*str , object ]) - 用于初始化的值。
Return type: BookOrder
"""
...
@staticmethod
def from_raw(side: OrderSide, price_raw: int, price_prec: int, size_raw: int, size_prec: int, order_id: int) -> BookOrder:
"""
Return an book order from the given raw values.
从给定的原始值返回订单簿订单。
Parameters:
参数:
side (OrderSide {BUY, SELL}) – The order side.
side (OrderSide {BUY, SELL}) - 订单方向。
price_raw (int64_t) – The order raw price (as a scaled fixed-point integer).
price_raw (int64_t) - 订单原始价格(作为缩放的定点整数)。
price_prec (uint8_t) – The order price precision.
price_prec (uint8_t) - 订单价格精度。
size_raw (uint64_t) – The order raw size (as a scaled fixed-point integer).
size_raw (uint64_t) - 订单原始数量(作为缩放的定点整数)。
size_prec (uint8_t) – The order size precision.
size_prec (uint8_t) - 订单数量精度。
order_id (uint64_t) – The order ID.
order_id (uint64_t) - 订单 ID。
Return type: BookOrder
"""
...
def signed_size(self) -> float:
"""
Return the signed size of the order (negative for SELL).
返回订单的带符号数量(卖出为负数)。
Return type: double
"""
...
@staticmethod
def to_dict(obj: BookOrder):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
class CustomData 自定义数据
class CustomData(Data):
"""
Provides a wrapper for custom data which includes data type information.
为自定义数据提供包装器,其中包括数据类型信息。
Parameters:
参数:
data_type (DataType) – The data type.
data_type (DataType) - 数据类型。
data (Data) – The data object to wrap.
data (Data) - 要包装的数据对象。
"""
def __init__(self, data_type: DataType, data: Data) -> None:
...
@property
def data(self) :
"""
The data.
数据。
Returns:
Data
"""
...
@property
def data_type(self):
"""
The data type.
数据类型。
Returns:
DataType
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred.
数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: CustomData.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: CustomData.ts_init
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str='') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name.
确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal.
参数:name (str,可选) - 要检查的特定信号名称。如果未提供名称或传递空字符串,则该方法将检查类名是否指示一般信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False.
返回值:如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
class DataType 数据类型
class DataType(object):
"""
Represents a data type including metadata.
表示数据类型,包括元数据。
Parameters:
参数:
type (type) – The Data type of the data.
type (type) - 数据的数据类型。
metadata (dict) – The data types metadata.
metadata (dict) - 数据类型的元数据。
Raises:
引发:
ValueError – If type is not either a subclass of Data or meets the Data contract.
ValueError - 如果 type 不是 Data 的子类或不符合 Data 协定。
TypeError – If metadata contains a key or value which is not hashable.
TypeError - 如果元数据包含不可散列的键或值。
Warning:
This class may be used as a key in hash maps throughout the system, thus the key and value contents of metadata must themselves be hashable.
此类可以在整个系统的哈希映射中用作键,因此元数据的键和值内容本身必须是可散列的。
"""
def __init__(self, type, metadata: dict=None) -> None:
...
@property
def metadata(self):
"""
The data types metadata.
数据类型的元数据。
Returns:
dict[str, object]
"""
...
@property
def topic(self) -> str:
"""
The data types topic string.
数据类型的主题字符串。
Returns:
str
"""
...
@property
def type(self):
"""
The Data type of the data.
数据的数据类型。
Returns:
type
"""
...
class InstrumentClose | 工具收盘价
class InstrumentClose(Data):
"""
Represents an instrument close at a venue. 表示某个场所的工具收盘。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID. 工具 ID。
close_price (Price) – The closing price for the instrument. 工具的收盘价。
close_type (InstrumentCloseType) – The type of closing price. 收盘价的类型。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the close price event occurred. 发生收盘价事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
"""
def __init__(
self,
instrument_id: InstrumentId,
close_price: Price,
close_type: InstrumentCloseType,
ts_event: int,
ts_init: int
) -> None:
...
Properties | 属性
@property
def close_price(self) -> Price:
"""
The instrument close price. 工具的收盘价。
Returns: Price
"""
...
@property
def close_type(self) -> InstrumentCloseType:
"""
The instrument close type. 工具的收盘类型。
Returns: InstrumentCloseType
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
The event instrument ID. 事件工具 ID。
Returns: InstrumentId
"""
...
@property
def ts_event(self) -> int:
"""
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Returns: uint64_t
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Returns: uint64_t
"""
...
Methods | 方法
@staticmethod
def from_dict(values: dict) -> InstrumentClose:
"""
Return an instrument close price event from the given dict values. 从给定的字典值返回工具收盘价事件。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: InstrumentClose
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def to_dict(obj: InstrumentClose):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
class InstrumentStatus | 工具状态
class InstrumentStatus(Data):
"""
Represents an event that indicates a change in an instrument market status. 表示指示工具市场状态变化的事件。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the status change. 状态变化的工具 ID。
action (MarketStatusAction) – The instrument market status action. 工具市场状态操作。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the status event occurred. 状态事件发生时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
reason (str , optional) – Additional details about the cause of the status change. 有关状态变化原因的更多详细信息。
trading_event (str , optional) – Further information about the status change (if provided). 有关状态变化的更多信息(如果提供)。
is_trading (bool , optional) – The state of trading in the instrument. 工具的交易状态。
is_quoting (bool , optional) – The state of quoting in the instrument. 工具的报价状态。
is_short_sell_restricted (bool , optional) – The state of short sell restrictions for the instrument (if applicable). 工具的卖空限制状态(如果适用)。
"""
def __init__(
self,
instrument_id: InstrumentId,
action: MarketStatusAction,
ts_event: int,
ts_init: int,
reason: str | None = None,
trading_event: str | None = None,
is_trading: bool | None = None,
is_quoting: bool | None = None,
is_short_sell_restricted: bool | None = None
) -> None:
...
Properties | 属性
@property
def action(self) -> MarketStatusAction:
"""
The instrument market status action. 工具市场状态操作。
Returns: MarketStatusAction
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
The instrument ID. 工具 ID。
Returns: InstrumentId
"""
...
@property
def is_quoting(self) -> bool | None:
"""
bool | None
Return the state of quoting in the instrument (if known). 返回工具的报价状态(如果已知)。
Return type: bool or None
Type: InstrumentStatus.is_quoting
"""
...
@property
def is_short_sell_restricted(self) -> bool | None:
"""
bool | None
Return the state of short sell restrictions for the instrument (if known and applicable). 返回工具的卖空限制状态(如果已知且适用)。
Return type: bool or None
Type: InstrumentStatus.is_short_sell_restricted
"""
...
@property
def is_trading(self) -> bool | None:
"""
bool | None
Return the state of trading in the instrument (if known). 返回工具的交易状态(如果已知)。
Return type: bool or None
Type: InstrumentStatus.is_trading
"""
...
@property
def reason(self) -> str | None:
"""
Additional details about the cause of the status change. 有关状态变化原因的更多详细信息。
Returns: str or None
"""
...
@property
def trading_event(self) -> str | None:
"""
Further information about the status change (if provided). 有关状态变化的更多信息(如果提供)。
Returns: str or None
"""
...
@property
def ts_event(self) -> int:
"""
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Returns: uint64_t
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Returns: uint64_t
"""
...
Methods | 方法
@staticmethod
def from_dict(values: dict) -> InstrumentStatus:
"""
Return an instrument status update from the given dict values. 从给定的字典值返回工具状态更新。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: InstrumentStatus
"""
...
@staticmethod
def from_pyo3(pyo3_status) -> InstrumentStatus:
"""
Return a legacy Cython quote tick converted from the given pyo3 Rust object. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 报价行情。
Parameters: pyo3_status (nautilus_pyo3.InstrumentStatus) – The pyo3 Rust instrument status to convert from. 要转换的 pyo3 Rust 工具状态。
Return type: InstrumentStatus
"""
...
@staticmethod
def from_pyo3_list(pyo3_status_list: list) -> list:
"""
Return legacy Cython instrument status converted from the given pyo3 Rust objects. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 工具状态。
Parameters: pyo3_status_list (list *[*nautilus_pyo3.InstrumentStatus ]) – The pyo3 Rust instrument status list to convert from. 要转换的 pyo3 Rust 工具状态列表。
Return type: list[QuoteTick]
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def to_dict(obj: InstrumentStatus):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def to_pyo3(self):
"""
Return a pyo3 object from this legacy Cython instance. 从此旧版 Cython 实例返回一个 pyo3 对象。
Return type: nautilus_pyo3.InstrumentStatus
"""
...
class OrderBookDelta | 订单簿增量
class OrderBookDelta(Data):
"""
Represents a single update/difference on an OrderBook. 表示订单簿上的单个更新/差异。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the book. 订单簿的工具 ID。
action (BookAction {ADD, UPDATE, DELETE, CLEAR}) – The order book delta action. 订单簿增量操作。
order (BookOrder, optional with no default so None must be passed explicitly) – The book order for the delta. 增量的订单簿订单。
flags (uint8_t) – The record flags bit field, indicating event end and data information. A value of zero indicates no flags. 记录标志位字段,指示事件结束和数据信息。值为零表示没有标志。
sequence (uint64_t) – The unique sequence number for the update. If no sequence number provided in the source data then use a value of zero. 更新的唯一序列号。如果源数据中没有提供序列号,则使用值零。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
"""
def __init__(
self,
instrument_id: InstrumentId,
action: BookAction,
order: BookOrder | None,
flags: int,
sequence: int,
ts_event: int,
ts_init: int
) -> None:
...
Properties | 属性
@property
def action(self) -> BookAction:
"""
BookAction
Return the deltas book action {ADD, UPDATE, DELETE, CLEAR} 返回增量的订单簿操作 {ADD, UPDATE, DELETE, CLEAR}
Return type: BookAction
Type: OrderBookDelta.action
"""
...
@property
def flags(self) -> int:
"""
uint8_t
Return the flags for the delta. 返回增量的标志。
Return type: uint8_t
Type: OrderBookDelta.flags
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
InstrumentId
Return the deltas book instrument ID. 返回增量的订单簿工具 ID。
Return type: InstrumentId
Type: OrderBookDelta.instrument_id
"""
...
@property
def is_add(self) -> BookAction:
"""
BookAction
If the deltas book action is an ADD. 如果增量的订单簿操作是 ADD。
Return type: bool
Type: OrderBookDelta.is_add
"""
...
@property
def is_clear(self) -> BookAction:
"""
BookAction
If the deltas book action is a CLEAR. 如果增量的订单簿操作是 CLEAR。
Return type: bool
Type: OrderBookDelta.is_clear
"""
...
@property
def is_delete(self) -> BookAction:
"""
BookAction
If the deltas book action is a DELETE. 如果增量的订单簿操作是 DELETE。
Return type: bool
Type: OrderBookDelta.is_delete
"""
...
@property
def is_update(self) -> BookAction:
"""
BookAction
If the deltas book action is an UPDATE. 如果增量的订单簿操作是 UPDATE。
Return type: bool
Type: OrderBookDelta.is_update
"""
...
@property
def order(self) -> BookOrder | None:
"""
BookOrder | None
Return the deltas book order for the action. 返回操作的增量订单簿订单。
Return type: BookOrder
Type: OrderBookDelta.order
"""
...
@property
def sequence(self) -> int:
"""
uint64_t
Return the sequence number for the delta. 返回增量的序列号。
Return type: uint64_t
Type: OrderBookDelta.sequence
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: OrderBookDelta.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: OrderBookDelta.ts_init
"""
...
Methods | 方法
@staticmethod
def capsule_from_list(items: list):
...
@staticmethod
def clear(
instrument_id: InstrumentId,
sequence: int,
ts_event: int,
ts_init: int
):
"""
Return an order book delta which acts as an initial CLEAR. 返回一个订单簿增量,它充当初始的 CLEAR。
Return type: OrderBookDelta
"""
...
@staticmethod
def from_dict(values: dict) -> OrderBookDelta:
"""
Return an order book delta from the given dict values. 从给定的字典值返回订单簿增量。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: OrderBookDelta
"""
...
@staticmethod
def from_pyo3(pyo3_delta) -> OrderBookDelta:
"""
Return a legacy Cython order book delta converted from the given pyo3 Rust object. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 订单簿增量。
Parameters: pyo3_delta (nautilus_pyo3.OrderBookDelta) – The pyo3 Rust order book delta to convert from. 要转换的 pyo3 Rust 订单簿增量。
Return type: OrderBookDelta
"""
...
@staticmethod
def from_pyo3_list(pyo3_deltas: list) -> list:
"""
Return legacy Cython order book deltas converted from the given pyo3 Rust objects. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 订单簿增量。
Parameters: pyo3_deltas (list *[*nautilus_pyo3.OrderBookDelta ]) – The pyo3 Rust order book deltas to convert from. 要转换的 pyo3 Rust 订单簿增量。
Return type: list[OrderBookDelta]
"""
...
@staticmethod
def from_raw(
instrument_id: InstrumentId,
action: BookAction,
side: OrderSide,
price_raw: int,
price_prec: int,
size_raw: int,
size_prec: int,
order_id: int,
flags: int,
sequence: int,
ts_event: int,
ts_init: int
) -> OrderBookDelta:
"""
Return an order book delta from the given raw values. 从给定的原始值返回订单簿增量。
Parameters:
参数:
instrument_id (InstrumentId) – The trade instrument ID. 交易工具 ID。
action (BookAction {ADD, UPDATE, DELETE, CLEAR}) – The order book delta action. 订单簿增量操作。
side (OrderSide {BUY, SELL}) – The order side. 订单方向。
price_raw (int64_t) – The order raw price (as a scaled fixed-point integer). 订单原始价格(作为缩放的定点整数)。
price_prec (uint8_t) – The order price precision. 订单价格精度。
size_raw (uint64_t) – The order raw size (as a scaled fixed-point integer). 订单原始大小(作为缩放的定点整数)。
size_prec (uint8_t) – The order size precision. 订单大小精度。
order_id (uint64_t) – The order ID. 订单 ID。
flags (uint8_t) – The record flags bit field, indicating event end and data information. A value of zero indicates no flags. 记录标志位字段,指示事件结束和数据信息。值为零表示没有标志。
sequence (uint64_t) – The unique sequence number for the update. If no sequence number provided in the source data then use a value of zero. 更新的唯一序列号。如果源数据中没有提供序列号,则使用值零。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred. 发生行情事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
Return type: OrderBookDelta
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def list_from_capsule(capsule) -> list:
...
@staticmethod
def to_dict(obj: OrderBookDelta):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@staticmethod
def to_pyo3_list(deltas: list) -> list:
"""
Return pyo3 Rust order book deltas converted from the given legacy Cython objects. 返回从给定的旧版 Cython 对象转换而来的 pyo3 Rust 订单簿增量。
Parameters: pyo3_deltas (list [OrderBookDelta ]) – The pyo3 Rust order book deltas to convert from. 要转换的 pyo3 Rust 订单簿增量。
Return type: list[nautilus_pyo3.OrderBookDelta]
"""
...
class OrderBookDeltas | 订单簿增量
class OrderBookDeltas(Data):
"""
Represents a grouped batch of OrderBookDelta updates for an OrderBook. 表示订单簿的 OrderBookDelta 更新的分组批次。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the book. 订单簿的工具 ID。
deltas (list [OrderBookDelta ]) – The list of order book changes. 订单簿更改列表。
Raises: ValueError – If deltas is an empty list. 如果 deltas 是一个空列表。
"""
def __init__(self, instrument_id: InstrumentId, deltas: list) -> None:
...
Properties | 属性
@property
def deltas(self) -> list:
"""
list[OrderBookDelta]
Return the contained deltas. 返回包含的增量。
Return type: list[OrderBookDeltas]
Type: OrderBookDeltas.deltas
"""
...
@property
def flags(self) -> int:
"""
uint8_t
Return the flags for the last delta. 返回最后一个增量的标志。
Return type: uint8_t
Type: OrderBookDeltas.flags
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
InstrumentId
Return the deltas book instrument ID. 返回增量订单簿工具 ID。
Return type: InstrumentId
Type: OrderBookDeltas.instrument_id
"""
...
@property
def is_snapshot(self) -> bool:
"""
bool
If the deltas is a snapshot. 如果增量是快照。
Return type: bool
Type: OrderBookDeltas.is_snapshot
"""
...
@property
def sequence(self) -> int:
"""
uint64_t
Return the sequence number for the last delta. 返回最后一个增量的序列号。
Return type: uint64_t
Type: OrderBookDeltas.sequence
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: OrderBookDeltas.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: OrderBookDeltas.ts_init
"""
...
Methods | 方法
@staticmethod
def batch(data: list) -> list:
"""
Return a list of OrderBookDeltas from the given list of OrderBookDelta. 从给定的 OrderBookDelta 列表返回 OrderBookDeltas 列表。
Parameters: data (list: list[OrderBookDelta]) - The list of OrderBookDelta to batch. 要批处理的 OrderBookDelta 列表。
Return type: list[OrderBookDeltas]
"""
...
@staticmethod
def from_dict(values: dict) -> OrderBookDeltas:
"""
Return order book deltas from the given dict values. 从给定的字典值返回订单簿增量。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: OrderBookDeltas
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
def to_capsule(self):
...
@staticmethod
def to_dict(obj: OrderBookDeltas):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def to_pyo3(self):
"""
Return a pyo3 object from this legacy Cython instance. 从此旧版 Cython 实例返回一个 pyo3 对象。
Return type: nautilus_pyo3.OrderBookDeltas
"""
...
class OrderBookDepth10 | 订单簿深度10
class OrderBookDepth10(Data):
"""
Represents a self-contained order book update with a fixed depth of 10 levels per side. 表示每边固定深度为 10 个级别的自包含订单簿更新。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the book. 订单簿的工具 ID。
bids (list [BookOrder ]) – The bid side orders for the update. 更新的买方订单。
asks (list [BookOrder ]) – The ask side orders for the update. 更新的卖方订单。
bid_counts (list *[*uint32_t ]) – The count of bid orders per level for the update. Can be zeros if data not available. 更新中每个级别的买单数量。如果数据不可用,则可以为零。
ask_counts (list *[*uint32_t ]) – The count of ask orders per level for the update. Can be zeros if data not available. 更新中每个级别的卖单数量。如果数据不可用,则可以为零。
flags (uint8_t) – The record flags bit field, indicating event end and data information. A value of zero indicates no flags. 记录标志位字段,指示事件结束和数据信息。值为零表示没有标志。
sequence (uint64_t) – The unique sequence number for the update. If no sequence number provided in the source data then use a value of zero. 更新的唯一序列号。如果源数据中没有提供序列号,则使用值零。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred. 发生行情事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
Raises:
引发:
ValueError – If bids is empty. 如果买单为空。
ValueError – If asks is empty. 如果卖单为空。
ValueError – If bids length is not equal to 10. 如果买单长度不等于 10。
ValueError – If asks length is not equal to 10. 如果卖单长度不等于 10。
ValueError – If bid_counts length is not equal to 10. 如果买单计数长度不等于 10。
ValueError – If ask_counts length is not equal to 10. 如果卖单计数长度不等于 10。
"""
def __init__(
self,
instrument_id: InstrumentId,
bids: list,
asks: list,
bid_counts: list,
ask_counts: list,
flags: int,
sequence: int,
ts_event: int,
ts_init: int
) -> None:
...
Properties | 属性
@property
def ask_counts(self) -> list:
"""
list[uint32_t]
Return the count of ask orders level for the update. 返回更新的卖单级别计数。
Return type: list[uint32_t]
Type: OrderBookDepth10.ask_counts
"""
...
@property
def asks(self) -> list:
"""
list[BookOrder]
Return the ask orders for the update. 返回更新的卖单。
Return type: list[BookOrder]
Type: OrderBookDepth10.asks
"""
...
@property
def bid_counts(self) -> list:
"""
list[uint32_t]
Return the count of bid orders per level for the update. 返回更新中每个级别的买单数量。
Return type: list[uint32_t]
Type: OrderBookDepth10.bid_counts
"""
...
@property
def bids(self) -> list:
"""
list[BookOrder]
Return the bid orders for the update. 返回更新的买单。
Return type: list[BookOrder]
Type: OrderBookDepth10.bids
"""
...
@property
def flags(self) -> int:
"""
uint8_t
Return the flags for the depth update. 返回深度更新的标志。
Return type: uint8_t
Type: OrderBookDepth10.flags
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
InstrumentId
Return the depth updates book instrument ID. 返回深度更新的订单簿工具 ID。
Return type: InstrumentId
Type: OrderBookDepth10.instrument_id
"""
...
@property
def sequence(self) -> int:
"""
uint64_t
Return the sequence number for the depth update. 返回深度更新的序列号。
Return type: uint64_t
Type: OrderBookDepth10.sequence
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: OrderBookDepth10.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: OrderBookDepth10.ts_init
"""
...
Methods | 方法
@staticmethod
def capsule_from_list(items: list):
...
@staticmethod
def from_dict(values: dict) -> OrderBookDepth10:
"""
Return order book depth from the given dict values. 从给定的字典值返回订单簿深度。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: OrderBookDepth10
"""
...
@staticmethod
def from_pyo3(pyo3_depth) -> OrderBookDepth10:
"""
Return a legacy Cython order book depth converted from the given pyo3 Rust object. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 订单簿深度。
Parameters: pyo3_depth (nautilus_pyo3.OrderBookDepth10) – The pyo3 Rust order book depth to convert from.
Return type: [OrderBookDepth10]
"""
...
@staticmethod
def from_pyo3_list(pyo3_depths) -> list:
"""
Return legacy Cython order book depths converted from the given pyo3 Rust objects. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 订单簿深度。
Parameters: pyo3_depths (nautilus_pyo3.OrderBookDepth10) – The pyo3 Rust order book depths to convert from. 要转换的 pyo3 Rust 订单簿深度。
Return type: list[OrderBookDepth10]
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def list_from_capsule(capsule) -> list:
...
@staticmethod
def to_dict(obj: OrderBookDepth10):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
class QuoteTick | 报价行情
class QuoteTick(Data):
"""
Represents a single quote tick in a market. 表示市场中的单个报价行情。
Contains information about the best top-of-book bid and ask. 包含有关最佳买卖报价的信息。
Parameters:
参数:
instrument_id (InstrumentId) – The quotes instrument ID. 报价工具 ID。
bid_price (Price) – The top-of-book bid price. 买一价。
ask_price (Price) – The top-of-book ask price. 卖一价。
bid_size (Quantity) – The top-of-book bid size. 买一量。
ask_size (Quantity) – The top-of-book ask size. 卖一量。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred. 发生行情事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
Raises:
引发:
ValueError – If bid.precision != ask.precision. 如果 bid.precision != ask.precision。
ValueError – If bid_size.precision != ask_size.precision. 如果 bid_size.precision != ask_size.precision。
"""
def __init__(
self,
instrument_id: InstrumentId,
bid_price: Price,
ask_price: Price,
bid_size: Quantity,
ask_size: Quantity,
ts_event: int,
ts_init: int
) -> None:
...
Properties | 属性
@property
def ask_price(self) -> Price:
"""
Price
Return the top-of-book ask price. 返回卖一价。
Return type: Price
Type: QuoteTick.ask_price
"""
...
@property
def ask_size(self) -> Quantity:
"""
Quantity
Return the top-of-book ask size. 返回卖一量。
Return type: Quantity
Type: QuoteTick.ask_size
"""
...
@property
def bid_price(self) -> Price:
"""
Price
Return the top-of-book bid price. 返回买一价。
Return type: Price
Type: QuoteTick.bid_price
"""
...
@property
def bid_size(self) -> Quantity:
"""
Quantity
Return the top-of-book bid size. 返回买一量。
Return type: Quantity
Type: QuoteTick.bid_size
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
InstrumentId
Return the tick instrument ID. 返回行情工具 ID。
Return type: InstrumentId
Type: QuoteTick.instrument_id
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: QuoteTick.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: QuoteTick.ts_init
"""
...
Methods | 方法
@staticmethod
def capsule_from_list(items: list):
...
def extract_price(self, price_type: PriceType) -> Price:
"""
Extract the price for the given price type. 提取给定价格类型的价格。
Parameters: price_type (PriceType) – The price type to extract. 要提取的价格类型。
Return type: Price
"""
...
def extract_size(self, price_type: PriceType) -> Quantity:
"""
Extract the size for the given price type. 提取给定价格类型的大小。
Parameters: price_type (PriceType) – The price type to extract. 要提取的价格类型。
Return type: Quantity
"""
...
@staticmethod
def from_dict(values: dict) -> QuoteTick:
"""
Return a quote tick parsed from the given values. 从给定的值返回解析的报价行情。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: QuoteTick
"""
...
@staticmethod
def from_pyo3(pyo3_quote) -> QuoteTick:
"""
Return a legacy Cython quote tick converted from the given pyo3 Rust object. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 报价行情。
Parameters: pyo3_quote (nautilus_pyo3.QuoteTick) – The pyo3 Rust quote tick to convert from. 要转换的 pyo3 Rust 报价行情。
Return type: QuoteTick
"""
...
@staticmethod
def from_pyo3_list(pyo3_quotes: list) -> list:
"""
Return legacy Cython quote ticks converted from the given pyo3 Rust objects. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 报价行情。
Parameters: pyo3_quotes (list *[*nautilus_pyo3.QuoteTick ]) – The pyo3 Rust quote ticks to convert from. 要转换的 pyo3 Rust 报价行情。
Return type: list[QuoteTick]
"""
...
@staticmethod
def from_raw(
instrument_id: InstrumentId,
bid_price_raw: int,
ask_price_raw: int,
bid_price_prec: int,
ask_price_prec: int,
bid_size_raw: int,
ask_size_raw: int,
bid_size_prec: int,
ask_size_prec: int,
ts_event: int,
ts_init: int
) -> QuoteTick:
"""
Return a quote tick from the given raw values. 从给定的原始值返回报价行情。
Parameters:
参数:
instrument_id (InstrumentId) – The quotes instrument ID. 报价工具 ID。
bid_price_raw (int64_t) – The raw top-of-book bid price (as a scaled fixed-point integer). 原始买一价(作为缩放的定点整数)。
ask_price_raw (int64_t) – The raw top-of-book ask price (as a scaled fixed-point integer). 原始卖一价(作为缩放的定点整数)。
bid_price_prec (uint8_t) – The bid price precision. 买一价精度。
ask_price_prec (uint8_t) – The ask price precision. 卖一价精度。
bid_size_raw (uint64_t) – The raw top-of-book bid size (as a scaled fixed-point integer). 原始买一量(作为缩放的定点整数)。
ask_size_raw (uint64_t) – The raw top-of-book ask size (as a scaled fixed-point integer). 原始卖一量(作为缩放的定点整数)。
bid_size_prec (uint8_t) – The bid size precision. 买一量精度。
ask_size_prec (uint8_t) – The ask size precision. 卖一量精度。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred. 发生行情事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
Return type: QuoteTick
Raises:
引发:
ValueError – If bid_price_prec != ask_price_prec. 如果 bid_price_prec != ask_price_prec。
ValueError – If bid_size_prec != ask_size_prec. 如果 bid_size_prec != ask_size_prec。
"""
...
@staticmethod
def from_raw_arrays_to_list(
instrument_id: InstrumentId,
price_prec: int,
size_prec: int,
bid_prices_raw,
ask_prices_raw,
bid_sizes_raw,
ask_sizes_raw,
ts_events,
ts_inits
) -> list:
"""
Convert raw arrays to a list of QuoteTick objects. 将原始数组转换为 QuoteTick 对象列表。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for all quote ticks. 所有报价行情的工具 ID。
price_prec (int) – The price precision for all quote ticks. 所有报价行情的价格精度。
size_prec (int) – The size precision for all quote ticks. 所有报价行情的大小精度。
bid_prices_raw (np.ndarray) – The raw bid prices as a NumPy array. 原始买入价格,以 NumPy 数组形式提供。
ask_prices_raw (np.ndarray) – The raw ask prices as a NumPy array. 原始卖出价格,以 NumPy 数组形式提供。
bid_sizes_raw (np.ndarray) – The raw bid sizes as a NumPy array. 原始买入数量,以 NumPy 数组形式提供。
ask_sizes_raw (np.ndarray) – The raw ask sizes as a NumPy array. 原始卖出数量,以 NumPy 数组形式提供。
ts_events (np.ndarray) – The event timestamps as a NumPy array. 事件时间戳,以 NumPy 数组形式提供。
ts_inits (np.ndarray) – The initialization timestamps as a NumPy array. 初始化时间戳,以 NumPy 数组形式提供。
Return type: list[QuoteTick]
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def list_from_capsule(capsule) -> list:
...
@staticmethod
def to_dict(obj: QuoteTick):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def to_pyo3(self):
"""
Return a pyo3 object from this legacy Cython instance. 从此旧版 Cython 实例返回一个 pyo3 对象。
Return type: nautilus_pyo3.QuoteTick
"""
...
@staticmethod
def to_pyo3_list(quotes: list) -> list:
"""
Return pyo3 Rust quote ticks converted from the given legacy Cython objects. 返回从给定的旧版 Cython 对象转换而来的 pyo3 Rust 报价行情。
Parameters: quotes (list [QuoteTick ]) – The legacy Cython quote ticks to convert from. 要转换的旧版 Cython 报价行情。
Return type: list[nautilus_pyo3.QuoteTick]
"""
...
class TradeTick | 成交行情
class TradeTick(Data):
"""
Represents a single trade tick in a market. 表示市场中的单个成交行情。
Contains information about a single unique trade which matched buyer and seller counterparties. 包含有关匹配买卖双方的单个唯一交易的信息。
Parameters:
参数:
instrument_id (InstrumentId) – The trade instrument ID. 交易工具 ID。
price (Price) – The traded price. 成交价格。
size (Quantity) – The traded size. 成交数量。
aggressor_side (AggressorSide) – The trade aggressor side. 交易侵略方。
trade_id (TradeId) – The trade match ID (assigned by the venue). 交易匹配 ID(由交易所分配)。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred. 发生行情事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
Raises: ValueError – If trade_id is not a valid string. 如果 trade_id 不是有效的字符串。
"""
def __init__(
self,
instrument_id: InstrumentId,
price: Price,
size: Quantity,
aggressor_side: AggressorSide,
trade_id: TradeId,
ts_event: int,
ts_init: int
) -> None:
...
Properties | 属性
@property
def aggressor_side(self) -> AggressorSide:
"""
AggressorSide
Return the ticks aggressor side. 返回行情的侵略方。
Return type: AggressorSide
Type: TradeTick.aggressor_side
"""
...
@property
def instrument_id(self) -> InstrumentId:
"""
InstrumentId
Return the ticks instrument ID. 返回行情的工具 ID。
Return type: InstrumentId
Type: TradeTick.instrument_id
"""
...
@property
def price(self) -> Price:
"""
Price
Return the ticks price. 返回行情的价格。
Return type: Price
Type: TradeTick.price
"""
...
@property
def size(self) -> Quantity:
"""
Price
Return the ticks size. 返回行情的大小。
Return type: Quantity
Type: TradeTick.size
"""
...
@property
def trade_id(self) -> TradeId:
"""
InstrumentId
Return the ticks trade match ID. 返回行情的交易匹配 ID。
Return type: Price
Type: TradeTick.trade_id
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred. 数据事件发生时的 UNIX 时间戳(纳秒)。
Return type: int
Type: TradeTick.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized. 对象初始化时的 UNIX 时间戳(纳秒)。
Return type: int
Type: TradeTick.ts_init
"""
...
Methods | 方法
@staticmethod
def capsule_from_list(items: list):
...
@staticmethod
def from_dict(values: dict) -> TradeTick:
"""
Return a trade tick from the given dict values. 从给定的字典值返回交易行情。
Parameters: values (dict *[*str , object ]) – The values for initialization. 用于初始化的值。
Return type: TradeTick
"""
...
@staticmethod
def from_pyo3(pyo3_trade) -> TradeTick:
"""
Return a legacy Cython trade tick converted from the given pyo3 Rust object. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 交易行情。
Parameters: pyo3_trade (nautilus_pyo3.TradeTick) – The pyo3 Rust trade tick to convert from. 要转换的 pyo3 Rust 交易行情。
Return type: TradeTick
"""
...
@staticmethod
def from_pyo3_list(pyo3_trades: list) -> list:
"""
Return legacy Cython trade ticks converted from the given pyo3 Rust objects. 返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 交易行情。
Parameters: pyo3_trades (list *[*nautilus_pyo3.TradeTick ]) – The pyo3 Rust trade ticks to convert from. 要转换的 pyo3 Rust 交易行情。
Return type: list[TradeTick]
"""
...
@staticmethod
def from_raw(
instrument_id: InstrumentId,
price_raw: int,
price_prec: int,
size_raw: int,
size_prec: int,
aggressor_side: AggressorSide,
trade_id: TradeId,
ts_event: int,
ts_init: int
) -> TradeTick:
"""
Return a trade tick from the given raw values. 从给定的原始值返回交易行情。
Parameters:
参数:
instrument_id (InstrumentId) – The trade instrument ID. 交易工具 ID。
price_raw (int64_t) – The traded raw price (as a scaled fixed-point integer). 交易的原始价格(作为缩放的定点整数)。
price_prec (uint8_t) – The traded price precision. 交易价格精度。
size_raw (uint64_t) – The traded raw size (as a scaled fixed-point integer). 交易的原始大小(作为缩放的定点整数)。
size_prec (uint8_t) – The traded size precision. 交易大小精度。
aggressor_side (AggressorSide) – The trade aggressor side. 交易侵略方。
trade_id (TradeId) – The trade match ID (assigned by the venue). 交易匹配 ID(由交易所分配)。
ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred. 发生行情事件时的 UNIX 时间戳(纳秒)。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized. 数据对象初始化时的 UNIX 时间戳(纳秒)。
Return type: TradeTick
"""
...
@staticmethod
def from_raw_arrays_to_list(
instrument_id: InstrumentId,
price_prec: int,
size_prec: int,
prices_raw,
sizes_raw,
aggressor_sides,
trade_ids: list,
ts_events,
ts_inits
) -> list:
"""
Convert raw arrays to a list of TradeTick objects. 将原始数组转换为 TradeTick 对象列表。
Parameters:
参数:
instrument_id (InstrumentId): The instrument ID for all trade ticks. 所有成交行情的工具 ID。
price_prec (uint8_t): The price precision for all trade ticks. 所有成交行情的价格精度。
size_prec (uint8_t): The size precision for all trade ticks. 所有成交行情的大小精度。
prices_raw (int64_t[:]): The raw prices as a NumPy array. 原始价格,以 NumPy 数组形式提供。
sizes_raw (uint64_t[:]): The raw sizes as a NumPy array. 原始数量,以 NumPy 数组形式提供。
aggressor_sides (uint8_t[:]): The raw aggressor sides as a NumPy array. 原始侵略方,以 NumPy 数组形式提供。
trade_ids (list): The trade IDs as a list. 交易 ID,以列表形式提供。
ts_events (uint64_t[:]): The event timestamps as a NumPy array. 事件时间戳,以 NumPy 数组形式提供。
ts_inits (uint64_t[:]): The initialization timestamps as a NumPy array. 初始化时间戳,以 NumPy 数组形式提供。
Return type: list[TradeTick]
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class. 返回数据类的完全限定名称。
Return type: str
"""
...
@classmethod
def is_signal(cls, name: str = '') -> bool:
"""
Determine if the current class is a signal type, optionally checking for a specific signal name. 确定当前类是否为信号类型,可以选择检查特定的信号名称。
Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal. 要检查的特定信号名称。如果未提供名称或传递了空字符串,则该方法将检查类名是否指示了常规信号类型。如果提供了名称,则该方法将检查类名是否与该特定信号相对应。
Returns: True if the class name matches the signal type or the specific signal name, otherwise False. 如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type: bool
"""
...
@staticmethod
def list_from_capsule(capsule) -> list:
...
@staticmethod
def to_dict(obj: TradeTick):
"""
Return a dictionary representation of this object. 返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def to_pyo3(self):
"""
Return a pyo3 object from this legacy Cython instance. 从此旧版 Cython 实例返回一个 pyo3 对象。
Return type: nautilus_pyo3.TradeTick
"""
...
@staticmethod
def to_pyo3_list(trades: list) -> list:
"""
Return pyo3 Rust trade ticks converted from the given legacy Cython objects. 返回从给定的旧版 Cython 对象转换而来的 pyo3 Rust 交易行情。
Parameters: ticks (list [TradeTick ]) – The legacy Cython Rust trade ticks to convert from. 要转换的旧版 Cython Rust 交易行情。
Return type: list[nautilus_pyo3.TradeTick]
"""
...
def capsule_to_data(capsule) -> Data:
...
def capsule_to_list(capsule) -> list:
...