-
Notifications
You must be signed in to change notification settings - Fork 0
Instruments 金融工具
Loren1166 edited this page Sep 25, 2024
·
7 revisions
Defines tradable asset/contract instruments with specific properties dependent on the asset class and instrument class.
定义可交易资产/合约工具,其具体属性取决于资产类别和工具类别。
class Instrument(Data):
"""
Instrument(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, InstrumentClass instrument_class, Currency quote_currency, bool is_inverse, int price_precision, int size_precision, Quantity size_increment, Quantity multiplier, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, Price price_increment: Price | None = None, Quantity lot_size: Quantity | None = None, Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, unicode tick_scheme_name=None, dict info=None)
The base class for all instruments.
所有金融工具的基类。
Represents a tradable instrument. This class can be used to define an instrument, or act as a parent class for more specific instruments.
表示一个可交易的金融工具。此类可用于定义金融工具,或作为更特定金融工具的父类。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The instrument asset class.
asset_class (AssetClass) - 金融工具的资产类别。
instrument_class (InstrumentClass) – The instrument class.
instrument_class (InstrumentClass) - 金融工具的类别。
quote_currency (Currency) – The quote currency.
quote_currency (Currency) - 报价货币。
is_inverse (bool) – If the instrument costing is inverse (quantity expressed in quote currency units).
is_inverse (bool) - 如果金融工具的成本是反向的(数量以报价货币单位表示)。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
size_increment (Price) – The minimum size increment.
size_increment (Price) - 最小规模增量。
multiplier (Decimal) – The contract value multiplier (determines tick value).
multiplier (Decimal) - 合约价值乘数(决定 tick 值)。
lot_size (Quantity , optional) – The rounded lot unit size (standard/board).
lot_size (Quantity,可选) - 舍入后的 lot 单位规模(标准/板)。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
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 时间戳(纳秒)。
price_increment (Price , optional) – The minimum price increment (tick size).
price_increment (Price,可选) - 最小价格增量(tick 规模)。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity,可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity,可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money,可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money,可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price,可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price,可选) - 最小允许报价。
tick_scheme_name (str , optional) – The name of the tick scheme.
tick_scheme_name (str,可选) - tick 方案的名称。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If tick_scheme_name is not a valid string.
ValueError - 如果 tick_scheme_name 不是有效的字符串。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If lot size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
instrument_class: "InstrumentClass",
quote_currency: "Currency",
is_inverse: bool,
price_precision: int,
size_precision: int,
size_increment: "Quantity",
multiplier: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
price_increment: "Price" | None = None,
lot_size: "Quantity" | None = None,
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
tick_scheme_name: str = None,
info: dict | None = None,
) -> None:
...
@property
def asset_class(self) -> "AssetClass":
"""
The asset class of the instrument.
金融工具的资产类别。
Returns:
AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> "Instrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Instrument
"""
...
@staticmethod
def base_to_dict(obj: "Instrument"):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: "Quantity", last_px: "Price") -> "Quantity":
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
quantity (Quantity) – The quantity to convert from.
quantity (Quantity) - 要转换的数量。
last_px (Price) – The last price for the instrument.
last_px (Price) - 金融工具的最新价格。
Return type:
Quantity
"""
...
def get_base_currency(self) -> "Currency" or None:
"""
Return the instruments base currency (if applicable).
返回金融工具的基础货币(如果适用)。
Return type:
Currency or None
"""
...
def get_settlement_currency(self) -> "Currency":
"""
Return the currency used to settle a trade of the instrument.
返回用于结算金融工具交易的货币。
Standard linear instruments = quote_currency
标准线性金融工具 = quote_currency
Inverse instruments = base_currency
反向金融工具 = base_currency
Quanto instruments = settlement_currency
Quanto 金融工具 = settlement_currency
Return type:
Currency
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def info(self) -> dict[str, object]:
"""
The raw info for the instrument.
金融工具的原始信息。
Returns:
dict[str, object]
"""
...
@property
def instrument_class(self) -> "InstrumentClass":
"""
The class of the instrument.
金融工具的类别。
Returns:
InstrumentClass
"""
...
@property
def is_inverse(self) -> "Currency":
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns:
Currency
"""
...
@property
def lot_size(self) -> "Quantity" or None:
"""
The rounded lot unit size (standard/board) for the instrument.
金融工具的舍入后的 lot 单位规模(标准/板)。
Returns:
Quantity or None
"""
...
def make_price(self, value) -> "Price":
"""
Return a new price from the given value using the instruments price precision.
使用金融工具的价格精度从给定值返回一个新的价格。
Parameters:
value (integer , float , str or Decimal) – The value of the price.
value (integer , float , str 或 Decimal) - 价格的值。
Return type:
Price
"""
...
def make_qty(self, value) -> "Quantity":
"""
Return a new quantity from the given value using the instruments size precision.
使用金融工具的规模精度从给定值返回一个新的数量。
Parameters:
value (integer , float , str or Decimal) – The value of the quantity.
value (integer , float , str 或 Decimal) - 数量的值。
Return type:
Quantity
Raises:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
ValueError - 如果由于金融工具的规模增量或规模精度,非零值被舍入为零。
"""
...
@property
def maker_fee(self) -> "Decimal":
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def margin_init(self) -> "Decimal":
"""
The initial (order) margin rate for the instrument.
金融工具的初始(订单)保证金率。
Returns:
Decimal
"""
...
@property
def margin_maint(self) -> "Decimal":
"""
The maintenance (position) margin rate for the instrument.
金融工具的维持(头寸)保证金率。
Returns:
Decimal
"""
...
@property
def max_notional(self) -> "Money" or None:
"""
The maximum notional order value for the instrument.
金融工具的最大名义订单价值。
Returns:
Money or None
"""
...
@property
def max_price(self) -> "Price" or None:
"""
The maximum printable price for the instrument.
金融工具的最大可打印价格。
Returns:
Price or None
"""
...
@property
def max_quantity(self) -> "Quantity" or None:
"""
The maximum order quantity for the instrument.
金融工具的最大订单数量。
Returns:
Quantity or None
"""
...
@property
def min_notional(self) -> "Money" or None:
"""
The minimum notional order value for the instrument.
金融工具的最小名义订单价值。
Returns:
Money or None
"""
...
@property
def min_price(self) -> "Price" or None:
"""
The minimum printable price for the instrument.
金融工具的最小可打印价格。
Returns:
Price or None
"""
...
@property
def min_quantity(self) -> "Quantity" or None:
"""
The minimum order quantity for the instrument.
金融工具的最小订单数量。
Returns:
Quantity or None
"""
...
@property
def multiplier(self) -> "Quantity":
"""
The contract multiplier for the instrument (determines tick value).
金融工具的合约乘数(决定 tick 值)。
Returns:
Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n ask ticks away from value.
返回距离 value n 个 ask ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 ask tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n bid ticks away from value.
返回距离 value n 个 bid ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 bid tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def notional_value(
self, quantity: "Quantity", price: "Price", use_quote_for_inverse: bool = False
) -> "Money":
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
结果将以标准工具的报价货币或反向工具的基础货币表示。
Parameters:
quantity (Quantity) – The total quantity.
quantity (Quantity) - 总数量。
price (Price) – The price for the calculation.
price (Price) - 用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
use_quote_for_inverse (bool) - 如果反向工具计算使用报价货币(而不是基础货币)。
Return type:
Money
"""
...
@property
def price_increment(self) -> "Price":
"""
The minimum price increment or tick size for the instrument.
金融工具的最小价格增量或 tick 规模。
Returns:
Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
金融工具的价格精度。
Returns:
int
"""
...
@property
def quote_currency(self) -> "Currency":
"""
The quote currency for the instrument.
金融工具的报价货币。
Returns:
Currency
"""
...
@property
def raw_symbol(self) -> "Symbol":
"""
The raw/local/native symbol for the instrument, assigned by the venue.
金融工具的原始/本地/原生代码,由交易场所分配。
Returns:
Symbol
"""
...
@property
def size_increment(self) -> "Quantity":
"""
The minimum size increment for the instrument.
金融工具的最小规模增量。
Returns:
Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
金融工具的规模精度。
Returns:
int
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the instruments ticker symbol.
返回金融工具的代码。
Return type:
Symbol
"""
...
@property
def taker_fee(self) -> "Decimal":
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def tick_scheme_name(self) -> str or None:
"""
The tick scheme name.
tick 方案的名称。
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
"""
...
@property
def venue(self) -> "Venue":
"""
Return the instruments trading venue.
返回金融工具的交易场所。
Return type:
Venue
"""
...
@staticmethod
def instruments_from_pyo3(pyo3_instruments: list) -> list:
...
class BettingInstrument(Instrument):
"""
BettingInstrument(unicode venue_name, int event_type_id, unicode event_type_name, int competition_id, unicode competition_name, int event_id, unicode event_name, unicode event_country_code, datetime event_open_date, unicode betting_type, unicode market_id, unicode market_name, datetime market_start_time, unicode market_type, int selection_id, unicode selection_name, unicode currency, float selection_handicap, int8_t price_precision, int8_t size_precision, uint64_t ts_event, uint64_t ts_init, unicode tick_scheme_name=None, Price min_price=None, Price max_price=None, dict info=None)
Represents an instrument in a betting market.
表示博彩市场中的一个金融工具。
"""
def __init__(
self,
venue_name: str,
event_type_id: int,
event_type_name: str,
competition_id: int,
competition_name: str,
event_id: int,
event_name: str,
event_country_code: str,
event_open_date: "datetime",
betting_type: str,
market_id: str,
market_name: str,
market_start_time: "datetime",
market_type: str,
selection_id: int,
selection_name: str,
currency: str,
selection_handicap: float,
price_precision: int,
size_precision: int,
ts_event: int,
ts_init: int,
tick_scheme_name: str = None,
min_price: "Price" = None,
max_price: "Price" = None,
info: dict | None = None,
) -> None:
...
@property
def asset_class(self) -> "AssetClass":
"""
The asset class of the instrument.
金融工具的资产类别。
Returns:
AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> "Instrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Instrument
"""
...
@staticmethod
def base_to_dict(obj: "Instrument"):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def betting_type(self):
...
def calculate_base_quantity(self, quantity: "Quantity", last_px: "Price") -> "Quantity":
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
quantity (Quantity) – The quantity to convert from.
quantity (Quantity) - 要转换的数量。
last_px (Price) – The last price for the instrument.
last_px (Price) - 金融工具的最新价格。
Return type:
Quantity
"""
...
@property
def competition_id(self):
...
@property
def competition_name(self):
...
@property
def event_country_code(self):
...
@property
def event_id(self):
...
@property
def event_name(self):
...
@property
def event_open_date(self):
...
@property
def event_type_id(self):
...
@property
def event_type_name(self):
...
@staticmethod
def from_dict(values: dict) -> "BettingInstrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
BettingInstrument
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type:
str
"""
...
def get_base_currency(self) -> "Currency" or None:
"""
Return the instruments base currency (if applicable).
返回金融工具的基础货币(如果适用)。
Return type:
Currency or None
"""
...
def get_settlement_currency(self) -> "Currency":
"""
Return the currency used to settle a trade of the instrument.
返回用于结算金融工具交易的货币。
Standard linear instruments = quote_currency
标准线性金融工具 = quote_currency
Inverse instruments = base_currency
反向金融工具 = base_currency
Quanto instruments = settlement_currency
Quanto 金融工具 = settlement_currency
Return type:
Currency
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def info(self) -> dict[str, object]:
"""
The raw info for the instrument.
金融工具的原始信息。
Returns:
dict[str, object]
"""
...
@property
def instrument_class(self) -> "InstrumentClass":
"""
The class of the instrument.
金融工具的类别。
Returns:
InstrumentClass
"""
...
@property
def is_inverse(self) -> "Currency":
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns:
Currency
"""
...
@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
"""
...
@property
def lot_size(self) -> "Quantity" or None:
"""
The rounded lot unit size (standard/board) for the instrument.
金融工具的舍入后的 lot 单位规模(标准/板)。
Returns:
Quantity or None
"""
...
def make_price(self, value) -> "Price":
"""
Return a new price from the given value using the instruments price precision.
使用金融工具的价格精度从给定值返回一个新的价格。
Parameters:
value (integer , float , str or Decimal) – The value of the price.
value (integer , float , str 或 Decimal) - 价格的值。
Return type:
Price
"""
...
def make_qty(self, value) -> "Quantity":
"""
Return a new quantity from the given value using the instruments size precision.
使用金融工具的规模精度从给定值返回一个新的数量。
Parameters:
value (integer , float , str or Decimal) – The value of the quantity.
value (integer , float , str 或 Decimal) - 数量的值。
Return type:
Quantity
Raises:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
ValueError - 如果由于金融工具的规模增量或规模精度,非零值被舍入为零。
"""
...
@property
def maker_fee(self) -> "Decimal":
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def margin_init(self) -> "Decimal":
"""
The initial (order) margin rate for the instrument.
金融工具的初始(订单)保证金率。
Returns:
Decimal
"""
...
@property
def margin_maint(self) -> "Decimal":
"""
The maintenance (position) margin rate for the instrument.
金融工具的维持(头寸)保证金率。
Returns:
Decimal
"""
...
@property
def market_id(self):
...
@property
def market_name(self):
...
@property
def market_start_time(self):
...
@property
def market_type(self):
...
@property
def max_notional(self) -> "Money" or None:
"""
The maximum notional order value for the instrument.
金融工具的最大名义订单价值。
Returns:
Money or None
"""
...
@property
def max_price(self) -> "Price" or None:
"""
The maximum printable price for the instrument.
金融工具的最大可打印价格。
Returns:
Price or None
"""
...
@property
def max_quantity(self) -> "Quantity" or None:
"""
The maximum order quantity for the instrument.
金融工具的最大订单数量。
Returns:
Quantity or None
"""
...
@property
def min_notional(self) -> "Money" or None:
"""
The minimum notional order value for the instrument.
金融工具的最小名义订单价值。
Returns:
Money or None
"""
...
@property
def min_price(self) -> "Price" or None:
"""
The minimum printable price for the instrument.
金融工具的最小可打印价格。
Returns:
Price or None
"""
...
@property
def min_quantity(self) -> "Quantity" or None:
"""
The minimum order quantity for the instrument.
金融工具的最小订单数量。
Returns:
Quantity or None
"""
...
@property
def multiplier(self) -> "Quantity":
"""
The contract multiplier for the instrument (determines tick value).
金融工具的合约乘数(决定 tick 值)。
Returns:
Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n ask ticks away from value.
返回距离 value n 个 ask ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 ask tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n bid ticks away from value.
返回距离 value n 个 bid ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 bid tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def notional_value(
self, quantity: "Quantity", price: "Price", use_quote_for_inverse: bool = False
) -> "Money":
...
@property
def price_increment(self) -> "Price":
"""
The minimum price increment or tick size for the instrument.
金融工具的最小价格增量或 tick 规模。
Returns:
Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
金融工具的价格精度。
Returns:
int
"""
...
@property
def quote_currency(self) -> "Currency":
"""
The quote currency for the instrument.
金融工具的报价货币。
Returns:
Currency
"""
...
@property
def raw_symbol(self) -> "Symbol":
"""
The raw/local/native symbol for the instrument, assigned by the venue.
金融工具的原始/本地/原生代码,由交易场所分配。
Returns:
Symbol
"""
...
@property
def selection_handicap(self):
...
@property
def selection_id(self):
...
@property
def selection_name(self):
...
@property
def size_increment(self) -> "Quantity":
"""
The minimum size increment for the instrument.
金融工具的最小规模增量。
Returns:
Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
金融工具的规模精度。
Returns:
int
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the instruments ticker symbol.
返回金融工具的代码。
Return type:
Symbol
"""
...
@property
def taker_fee(self) -> "Decimal":
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def tick_scheme_name(self) -> str or None:
"""
The tick scheme name.
tick 方案的名称。
Returns:
str or None
"""
...
@staticmethod
def to_dict(obj: "BettingInstrument") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@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
"""
...
@property
def venue(self) -> "Venue":
"""
Return the instruments trading venue.
返回金融工具的交易场所。
Return type:
Venue
"""
...
@staticmethod
def make_symbol(market_id: str, selection_id: int, selection_handicap: float) -> "Symbol":
"""
Make symbol.
生成代码。
>>> make_symbol(market_id="1.201070830", selection_id=123456, selection_handicap=null_handicap())
Symbol('1.201070830-123456-None')
"""
...
@staticmethod
def null_handicap() -> float:
...
class Cfd(Instrument):
"""
Cfd(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency quote_currency, int price_precision, int size_precision, Price price_increment, Quantity size_increment, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, Currency base_currency: Currency | None = None, Quantity lot_size: Quantity | None = None, Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, unicode tick_scheme_name=None, dict info=None)
Represents a Contract for Difference (CFD) instrument.
表示一个差价合约(CFD)金融工具。
Can represent both Fiat FX and Cryptocurrency pairs.
可以表示法定货币外汇和加密货币对。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The CFD contract asset class.
asset_class (AssetClass) - CFD 合约的资产类别。
base_currency (Currency) – The base currency.
base_currency (Currency) - 基础货币。
quote_currency (Currency) – The quote currency.
quote_currency (Currency) - 报价货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
size_increment (Quantity) – The minimum size increment.
size_increment (Quantity) - 最小规模增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
base_currency – The base currency.
base_currency - 基础货币。
lot_size (Quantity , optional) – The rounded lot unit size.
lot_size (Quantity,可选) - 舍入后的 lot 单位规模。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity,可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity,可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money,可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money,可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price,可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price,可选) - 最小允许报价。
tick_scheme_name (str , optional) – The name of the tick scheme.
tick_scheme_name (str,可选) - tick 方案的名称。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If tick_scheme_name is not a valid string.
ValueError - 如果 tick_scheme_name 不是有效的字符串。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
quote_currency: "Currency",
price_precision: int,
size_precision: int,
price_increment: "Price",
size_increment: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
base_currency: "Currency" | None = None,
lot_size: "Quantity" | None = None,
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
tick_scheme_name: str = None,
info: dict | None = None,
) -> None:
...
@property
def base_currency(self) -> "Currency" or None:
"""
The base currency for the instrument.
金融工具的基础货币。
Returns:
Currency or None
"""
...
@staticmethod
def from_dict(values: dict) -> "Cfd":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Cfd
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
@property
def isin(self) -> str or None:
"""
The instruments International Securities Identification Number (ISIN).
金融工具的国际证券识别码(ISIN)。
Returns:
str or None
"""
...
@staticmethod
def to_dict(obj: "Cfd") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
class Commodity(Instrument):
"""
Commodity(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency quote_currency, int price_precision, int size_precision, Price price_increment, Quantity size_increment, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, Currency base_currency: Currency | None = None, Quantity lot_size: Quantity | None = None, Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, unicode tick_scheme_name=None, dict info=None)
Represents a commodity instrument in a spot/cash market.
表示现货/现金市场中的商品金融工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The Commodity contract asset class.
asset_class (AssetClass) - 商品合约的资产类别。
quote_currency (Currency) – The quote currency.
quote_currency (Currency) - 报价货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
size_increment (Quantity) – The minimum size increment.
size_increment (Quantity) - 最小规模增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
lot_size (Quantity , optional) – The rounded lot unit size.
lot_size (Quantity,可选) - 舍入后的 lot 单位规模。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity,可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity,可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money,可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money,可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price,可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price,可选) - 最小允许报价。
tick_scheme_name (str , optional) – The name of the tick scheme.
tick_scheme_name (str,可选) - tick 方案的名称。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If tick_scheme_name is not a valid string.
ValueError - 如果 tick_scheme_name 不是有效的字符串。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
quote_currency: "Currency",
price_precision: int,
size_precision: int,
price_increment: "Price",
size_increment: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
base_currency: "Currency" | None = None,
lot_size: "Quantity" | None = None,
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
tick_scheme_name: str = None,
info: dict | None = None,
) -> None:
...
@staticmethod
def from_dict(values: dict) -> "Commodity":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Commodity
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
@property
def isin(self) -> str or None:
"""
The instruments International Securities Identification Number (ISIN).
金融工具的国际证券识别码(ISIN)。
Returns:
str or None
"""
...
@staticmethod
def to_dict(obj: "Commodity") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
class CryptoFuture(Instrument):
"""
CryptoFuture(InstrumentId instrument_id, Symbol raw_symbol, Currency underlying, Currency quote_currency, Currency settlement_currency, bool is_inverse, uint64_t activation_ns, uint64_t expiration_ns, int price_precision, int size_precision, Price price_increment, Quantity size_increment, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, multiplier=Quantity.from_int_c(1), lot_size=Quantity.from_int_c(1), Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, dict info=None)
Represents a Deliverable Futures Contract instrument, with crypto assets as underlying and for settlement.
表示一个可交割期货合约工具,以加密资产作为标的和结算货币。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
underlying (Currency) – The underlying asset.
underlying (Currency) - 标的资产。
quote_currency (Currency) – The contract quote currency.
quote_currency (Currency) - 合约报价货币。
settlement_currency (Currency) – The settlement currency.
settlement_currency (Currency) - 结算货币。
is_inverse (bool) – If the instrument costing is inverse (quantity expressed in quote currency units).
is_inverse (bool) - 如果金融工具的成本是反向的(数量以报价货币单位表示)。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
size_increment (Quantity) – The minimum size increment.
size_increment (Quantity) - 最小规模增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
multiplier (Quantity , default 1) – The contract multiplier.
multiplier (Quantity,默认 1) - 合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity,可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity,可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money,可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money,可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price,可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price,可选) - 最小允许报价。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If lot size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
underlying: "Currency",
quote_currency: "Currency",
settlement_currency: "Currency",
is_inverse: bool,
activation_ns: int,
expiration_ns: int,
price_precision: int,
size_precision: int,
price_increment: "Price",
size_increment: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
multiplier: "Quantity" = Quantity.from_int_c(1),
lot_size: "Quantity" = Quantity.from_int_c(1),
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
CryptoFuture.activation_utc
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
CryptoFuture.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "CryptoFuture":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
CryptoFuture
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
def get_base_currency(self) -> "Currency":
"""
Return the instruments base currency.
返回金融工具的基础货币。
Return type:
Currency
"""
...
@property
def settlement_currency(self) -> "Currency":
"""
The settlement currency for the contract.
合约的结算货币。
Returns:
Currency
"""
...
@staticmethod
def to_dict(obj: "CryptoFuture") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def underlying(self) -> "Currency":
"""
The underlying asset for the contract.
合约的标的资产。
Returns:
Currency
"""
...
class CryptoPerpetual(Instrument):
"""
CryptoPerpetual(InstrumentId instrument_id, Symbol raw_symbol, Currency base_currency, Currency quote_currency, Currency settlement_currency, bool is_inverse, int price_precision, int size_precision, Price price_increment, Quantity size_increment, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, multiplier=Quantity.from_int_c(1), Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, dict info=None)
Represents a Crypto Perpetual Futures contract instrument (a.k.a. Perpetual Swap).
表示一个加密货币永续期货合约工具(也称为永续掉期)。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
base_currency (Currency , optional) – The base currency.
base_currency (Currency,可选) - 基础货币。
quote_currency (Currency) – The quote currency.
quote_currency (Currency) - 报价货币。
settlement_currency (Currency) – The settlement currency.
settlement_currency (Currency) - 结算货币。
is_inverse (bool) – If the instrument costing is inverse (quantity expressed in quote currency units).
is_inverse (bool) - 如果金融工具的成本是反向的(数量以报价货币单位表示)。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
size_increment (Quantity) – The minimum size increment.
size_increment (Quantity) - 最小规模增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
multiplier (Quantity , default 1) – The contract multiplier.
multiplier (Quantity,默认 1) - 合约乘数。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity,可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity,可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money,可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money,可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price,可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price,可选) - 最小允许报价。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
base_currency: "Currency",
quote_currency: "Currency",
settlement_currency: "Currency",
is_inverse: bool,
price_precision: int,
size_precision: int,
price_increment: "Price",
size_increment: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
multiplier: "Quantity" = Quantity.from_int_c(1),
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
info: dict | None = None,
) -> None:
...
@property
def base_currency(self) -> "Currency":
"""
The base currency for the instrument.
金融工具的基础货币。
Returns:
Currency
"""
...
@staticmethod
def from_dict(values: dict) -> "CryptoPerpetual":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
CryptoPerpetual
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
def get_base_currency(self) -> "Currency":
"""
Return the instruments base currency.
返回金融工具的基础货币。
Return type:
Currency
"""
...
@property
def is_quanto(self) -> bool:
"""
If the instrument is quanto.
如果金融工具是 quanto。
Returns:
bool
"""
...
@property
def settlement_currency(self) -> "Currency":
"""
The settlement currency for the instrument.
金融工具的结算货币。
Returns:
Currency
"""
...
@staticmethod
def to_dict(obj: "CryptoPerpetual") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
class CurrencyPair(Instrument):
"""
CurrencyPair(InstrumentId instrument_id, Symbol raw_symbol, Currency base_currency, Currency quote_currency, int price_precision, int size_precision, Price price_increment, Quantity size_increment, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, Quantity lot_size: Quantity | None = None, Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, unicode tick_scheme_name=None, dict info=None)
Represents a generic currency pair instrument in a spot/cash market.
表示现货/现金市场中的一个通用货币对金融工具。
Can represent both Fiat FX and Cryptocurrency pairs.
可以表示法定货币外汇和加密货币对。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
base_currency (Currency) – The base currency.
base_currency (Currency) - 基础货币。
quote_currency (Currency) – The quote currency.
quote_currency (Currency) - 报价货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
size_increment (Quantity) – The minimum size increment.
size_increment (Quantity) - 最小规模增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
lot_size (Quantity , optional) – The rounded lot unit size.
lot_size (Quantity,可选) - 舍入后的 lot 单位规模。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity,可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity,可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money,可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money,可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price,可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price,可选) - 最小允许报价。
tick_scheme_name (str , optional) – The name of the tick scheme.
tick_scheme_name (str,可选) - tick 方案的名称。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If tick_scheme_name is not a valid string.
ValueError - 如果 tick_scheme_name 不是有效的字符串。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
base_currency: "Currency",
quote_currency: "Currency",
price_precision: int,
size_precision: int,
price_increment: "Price",
size_increment: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
lot_size: "Quantity" | None = None,
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
tick_scheme_name: str = None,
info: dict | None = None,
) -> None:
...
@property
def base_currency(self) -> "Currency":
"""
The base currency for the instrument.
金融工具的基础货币。
Returns:
Currency
"""
...
@staticmethod
def from_dict(values: dict) -> "CurrencyPair":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
CurrencyPair
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
def get_base_currency(self) -> "Currency":
"""
Return the instruments base currency.
返回金融工具的基础货币。
Return type:
Currency
"""
...
@staticmethod
def to_dict(obj: "CurrencyPair") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
class Equity(Instrument):
"""
Equity(InstrumentId instrument_id, Symbol raw_symbol, Currency currency, int price_precision, Price price_increment, Quantity lot_size, uint64_t ts_event, uint64_t ts_init, unicode isin: str | None = None, margin_init: Decimal | None = None, margin_maint: Decimal | None = None, maker_fee: Decimal | None = None, taker_fee: Decimal | None = None, max_quantity: Quantity | None = None, min_quantity: Quantity | None = None, dict info=None)
Represents a generic Equity instrument.
表示一个通用的股票工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
currency (Currency) – The futures contract currency.
currency (Currency) - 期货合约货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Decimal) – The minimum price increment (tick size).
price_increment (Decimal) - 最小价格增量(tick 规模)。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
isin (str , optional) – The instruments International Securities Identification Number (ISIN).
isin (str,可选) - 金融工具的国际证券识别码(ISIN)。
margin_init (Decimal , optional) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal,可选) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal , optional) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal,可选) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal , optional) – The fee rate for liquidity makers as a percentage of order value.
maker_fee (Decimal,可选) - 流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal , optional) – The fee rate for liquidity takers as a percentage of order value.
taker_fee (Decimal,可选) - 流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If isin is not None and not a valid string.
ValueError - 如果 isin 不为 None 且不是有效的字符串。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
currency: "Currency",
price_precision: int,
price_increment: "Price",
lot_size: "Quantity",
ts_event: int,
ts_init: int,
isin: str | None = None,
margin_init: "Decimal" | None = None,
margin_maint: "Decimal" | None = None,
maker_fee: "Decimal" | None = None,
taker_fee: "Decimal" | None = None,
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
info: dict | None = None,
) -> None:
...
@property
def asset_class(self) -> "AssetClass":
"""
The asset class of the instrument.
金融工具的资产类别。
Returns:
AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> "Instrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Instrument
"""
...
@staticmethod
def base_to_dict(obj: "Instrument"):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: "Quantity", last_px: "Price") -> "Quantity":
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
quantity (Quantity) – The quantity to convert from.
quantity (Quantity) - 要转换的数量。
last_px (Price) – The last price for the instrument.
last_px (Price) - 金融工具的最新价格。
Return type:
Quantity
"""
...
@staticmethod
def from_dict(values: dict) -> "Instrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Equity
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "Equity":
"""
Return legacy Cython equity instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 股票工具。
Parameters:
pyo3_instrument (nautilus_pyo3.Equity) – The pyo3 Rust equity instrument to convert from.
pyo3_instrument (nautilus_pyo3.Equity) - 要转换的 pyo3 Rust 股票工具。
Return type:
Equity
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type:
str
"""
...
def get_base_currency(self) -> "Currency" or None:
"""
Return the instruments base currency (if applicable).
返回金融工具的基础货币(如果适用)。
Return type:
Currency or None
"""
...
def get_settlement_currency(self) -> "Currency":
"""
Return the currency used to settle a trade of the instrument.
返回用于结算金融工具交易的货币。
Standard linear instruments = quote_currency
标准线性金融工具 = quote_currency
Inverse instruments = base_currency
反向金融工具 = base_currency
Quanto instruments = settlement_currency
Quanto 金融工具 = settlement_currency
Return type:
Currency
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def info(self) -> dict[str, object]:
"""
The raw info for the instrument.
金融工具的原始信息。
Returns:
dict[str, object]
"""
...
@property
def instrument_class(self) -> "InstrumentClass":
"""
The class of the instrument.
金融工具的类别。
Returns:
InstrumentClass
"""
...
@property
def is_inverse(self) -> "Currency":
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns:
Currency
"""
...
@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
"""
...
@property
def isin(self) -> str or None:
"""
The instruments International Securities Identification Number (ISIN).
金融工具的国际证券识别码(ISIN)。
Returns:
str or None
"""
...
@property
def lot_size(self) -> "Quantity" or None:
"""
The rounded lot unit size (standard/board) for the instrument.
金融工具的舍入后的 lot 单位规模(标准/板)。
Returns:
Quantity or None
"""
...
def make_price(self, value) -> "Price":
"""
Return a new price from the given value using the instruments price precision.
使用金融工具的价格精度从给定值返回一个新的价格。
Parameters:
value (integer , float , str or Decimal) – The value of the price.
value (integer , float , str 或 Decimal) - 价格的值。
Return type:
Price
"""
...
def make_qty(self, value) -> "Quantity":
"""
Return a new quantity from the given value using the instruments size precision.
使用金融工具的规模精度从给定值返回一个新的数量。
Parameters:
value (integer , float , str or Decimal) – The value of the quantity.
value (integer , float , str 或 Decimal) - 数量的值。
Return type:
Quantity
Raises:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
ValueError - 如果由于金融工具的规模增量或规模精度,非零值被舍入为零。
"""
...
@property
def maker_fee(self) -> "Decimal":
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def margin_init(self) -> "Decimal":
"""
The initial (order) margin rate for the instrument.
金融工具的初始(订单)保证金率。
Returns:
Decimal
"""
...
@property
def margin_maint(self) -> "Decimal":
"""
The maintenance (position) margin rate for the instrument.
金融工具的维持(头寸)保证金率。
Returns:
Decimal
"""
...
@property
def max_notional(self) -> "Money" or None:
"""
The maximum notional order value for the instrument.
金融工具的最大名义订单价值。
Returns:
Money or None
"""
...
@property
def max_price(self) -> "Price" or None:
"""
The maximum printable price for the instrument.
金融工具的最大可打印价格。
Returns:
Price or None
"""
...
@property
def max_quantity(self) -> "Quantity" or None:
"""
The maximum order quantity for the instrument.
金融工具的最大订单数量。
Returns:
Quantity or None
"""
...
@property
def min_notional(self) -> "Money" or None:
"""
The minimum notional order value for the instrument.
金融工具的最小名义订单价值。
Returns:
Money or None
"""
...
@property
def min_price(self) -> "Price" or None:
"""
The minimum printable price for the instrument.
金融工具的最小可打印价格。
Returns:
Price or None
"""
...
@property
def min_quantity(self) -> "Quantity" or None:
"""
The minimum order quantity for the instrument.
金融工具的最小订单数量。
Returns:
Quantity or None
"""
...
@property
def multiplier(self) -> "Quantity":
"""
The contract multiplier for the instrument (determines tick value).
金融工具的合约乘数(决定 tick 值)。
Returns:
Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n ask ticks away from value.
返回距离 value n 个 ask ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 ask tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n bid ticks away from value.
返回距离 value n 个 bid ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 bid tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def notional_value(
self, quantity: "Quantity", price: "Price", use_quote_for_inverse: bool = False
) -> "Money":
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
结果将以标准工具的报价货币或反向工具的基础货币表示。
Parameters:
quantity (Quantity) – The total quantity.
quantity (Quantity) - 总数量。
price (Price) – The price for the calculation.
price (Price) - 用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
use_quote_for_inverse (bool) - 如果反向工具计算使用报价货币(而不是基础货币)。
Return type:
Money
"""
...
@property
def price_increment(self) -> "Price":
"""
The minimum price increment or tick size for the instrument.
金融工具的最小价格增量或 tick 规模。
Returns:
Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
金融工具的价格精度。
Returns:
int
"""
...
@property
def quote_currency(self) -> "Currency":
"""
The quote currency for the instrument.
金融工具的报价货币。
Returns:
Currency
"""
...
@property
def raw_symbol(self) -> "Symbol":
"""
The raw/local/native symbol for the instrument, assigned by the venue.
金融工具的原始/本地/原生代码,由交易场所分配。
Returns:
Symbol
"""
...
@property
def size_increment(self) -> "Quantity":
"""
The minimum size increment for the instrument.
金融工具的最小规模增量。
Returns:
Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
金融工具的规模精度。
Returns:
int
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the instruments ticker symbol.
返回金融工具的代码。
Return type:
Symbol
"""
...
@property
def taker_fee(self) -> "Decimal":
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def tick_scheme_name(self) -> str or None:
"""
The tick scheme name.
tick 方案的名称。
Returns:
str or None
"""
...
@staticmethod
def to_dict(obj: "Instrument") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@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
"""
...
@property
def venue(self) -> "Venue":
"""
Return the instruments trading venue.
返回金融工具的交易场所。
Return type:
Venue
"""
...
class FuturesContract(Instrument):
"""
FuturesContract(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency currency, int price_precision, Price price_increment, Quantity multiplier, Quantity lot_size, unicode underlying, uint64_t activation_ns, uint64_t expiration_ns, uint64_t ts_event, uint64_t ts_init, unicode exchange=None, dict info=None)
Represents a generic deliverable futures contract instrument.
表示一个通用的可交割期货合约工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The futures contract asset class.
asset_class (AssetClass) - 期货合约的资产类别。
currency (Currency) – The futures contract currency.
currency (Currency) - 期货合约货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Decimal) – The minimum price increment (tick size).
price_increment (Decimal) - 最小价格增量(tick 规模)。
multiplier (Quantity) – The contract multiplier.
multiplier (Quantity) - 合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
underlying (str) – The underlying asset.
underlying (str) - 标的资产。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
exchange (str,可选) - 金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
ValueError - 如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot_size 不为正数 (> 0)。
ValueError – If exchange is not None and not a valid string.
ValueError - 如果 exchange 不为 None 且不是有效的字符串。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
currency: "Currency",
price_precision: int,
price_increment: "Price",
multiplier: "Quantity",
lot_size: "Quantity",
underlying: str,
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesContract.activation_utc
"""
...
@property
def exchange(self) -> str or None:
"""
The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
Returns:
str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesContract.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "FuturesContract":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
FuturesContract
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "FuturesContract":
"""
Return legacy Cython futures contract instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期货合约工具。
Parameters:
pyo3_instrument (nautilus_pyo3.FuturesContract) – The pyo3 Rust futures contract instrument to convert from.
pyo3_instrument (nautilus_pyo3.FuturesContract) - 要转换的 pyo3 Rust 期货合约工具。
Return type:
FuturesContract
"""
...
@staticmethod
def to_dict(obj: "FuturesContract") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the contract.
合约的标的资产。
Returns:
str
"""
...
class FuturesSpread(Instrument):
"""
FuturesSpread(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency currency, int price_precision, Price price_increment, Quantity multiplier, Quantity lot_size, unicode underlying, unicode strategy_type, uint64_t activation_ns, uint64_t expiration_ns, uint64_t ts_event, uint64_t ts_init, unicode exchange=None, dict info=None)
Represents a generic deliverable futures spread instrument.
表示一个通用的可交割期货价差工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The futures spread asset class.
asset_class (AssetClass) - 期货价差的资产类别。
currency (Currency) – The futures spread currency.
currency (Currency) - 期货价差货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Decimal) – The minimum price increment (tick size).
price_increment (Decimal) - 最小价格增量(tick 规模)。
multiplier (Quantity) – The contract multiplier.
multiplier (Quantity) - 合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
underlying (str) – The underlying asset.
underlying (str) - 标的资产。
strategy_type (str) – The strategy type for the spread.
strategy_type (str) - 价差的策略类型。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
exchange (str,可选) - 金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If underlying is not a valid string.
ValueError - 如果 underlying 不是有效的字符串。
ValueError – If strategy_type is not a valid string.
ValueError - 如果 strategy_type 不是有效的字符串。
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
ValueError - 如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot_size 不为正数 (> 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
currency: "Currency",
price_precision: int,
price_increment: "Price",
multiplier: "Quantity",
lot_size: "Quantity",
underlying: str,
strategy_type: str,
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesSpread.activation_utc
"""
...
@property
def exchange(self) -> str or None:
"""
The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
Returns:
str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesSpread.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "FuturesSpread":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
FuturesSpread
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "FuturesSpread":
"""
Return legacy Cython futures spread instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期货价差工具。
Parameters:
pyo3_instrument (nautilus_pyo3.FuturesSpread) – The pyo3 Rust futures spread instrument to convert from.
pyo3_instrument (nautilus_pyo3.FuturesSpread) - 要转换的 pyo3 Rust 期货价差工具。
Return type:
FuturesSpread
"""
...
@property
def strategy_type(self) -> str:
"""
The strategy type of the spread.
价差的策略类型。
Returns:
str
"""
...
@staticmethod
def to_dict(obj: "FuturesSpread") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the spread.
价差的标的资产。
Returns:
str
"""
...
class FuturesContract(Instrument):
"""
FuturesContract(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency currency, int price_precision, Price price_increment, Quantity multiplier, Quantity lot_size, unicode underlying, uint64_t activation_ns, uint64_t expiration_ns, uint64_t ts_event, uint64_t ts_init, unicode exchange=None, dict info=None)
Represents a generic deliverable futures contract instrument.
表示一个通用的可交割期货合约工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The futures contract asset class.
asset_class (AssetClass) - 期货合约的资产类别。
currency (Currency) – The futures contract currency.
currency (Currency) - 期货合约货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Decimal) – The minimum price increment (tick size).
price_increment (Decimal) - 最小价格增量(tick 规模)。
multiplier (Quantity) – The contract multiplier.
multiplier (Quantity) - 合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
underlying (str) – The underlying asset.
underlying (str) - 标的资产。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
exchange (str,可选) - 金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
ValueError - 如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot_size 不为正数 (> 0)。
ValueError – If exchange is not None and not a valid string.
ValueError - 如果 exchange 不为 None 且不是有效的字符串。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
currency: "Currency",
price_precision: int,
price_increment: "Price",
multiplier: "Quantity",
lot_size: "Quantity",
underlying: str,
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesContract.activation_utc
"""
...
@property
def exchange(self) -> str or None:
"""
The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
Returns:
str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesContract.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "FuturesContract":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
FuturesContract
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "FuturesContract":
"""
Return legacy Cython futures contract instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期货合约工具。
Parameters:
pyo3_instrument (nautilus_pyo3.FuturesContract) – The pyo3 Rust futures contract instrument to convert from.
pyo3_instrument (nautilus_pyo3.FuturesContract) - 要转换的 pyo3 Rust 期货合约工具。
Return type:
FuturesContract
"""
...
@staticmethod
def to_dict(obj: "FuturesContract") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the contract.
合约的标的资产。
Returns:
str
"""
...
class FuturesSpread(Instrument):
"""
FuturesSpread(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency currency, int price_precision, Price price_increment, Quantity multiplier, Quantity lot_size, unicode underlying, unicode strategy_type, uint64_t activation_ns, uint64_t expiration_ns, uint64_t ts_event, uint64_t ts_init, unicode exchange=None, dict info=None)
Represents a generic deliverable futures spread instrument.
表示一个通用的可交割期货价差工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The futures spread asset class.
asset_class (AssetClass) - 期货价差的资产类别。
currency (Currency) – The futures spread currency.
currency (Currency) - 期货价差货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Decimal) – The minimum price increment (tick size).
price_increment (Decimal) - 最小价格增量(tick 规模)。
multiplier (Quantity) – The contract multiplier.
multiplier (Quantity) - 合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
underlying (str) – The underlying asset.
underlying (str) - 标的资产。
strategy_type (str) – The strategy type for the spread.
strategy_type (str) - 价差的策略类型。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
exchange (str,可选) - 金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If underlying is not a valid string.
ValueError - 如果 underlying 不是有效的字符串。
ValueError – If strategy_type is not a valid string.
ValueError - 如果 strategy_type 不是有效的字符串。
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
ValueError - 如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot_size 不为正数 (> 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
currency: "Currency",
price_precision: int,
price_increment: "Price",
multiplier: "Quantity",
lot_size: "Quantity",
underlying: str,
strategy_type: str,
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesSpread.activation_utc
"""
...
@property
def exchange(self) -> str or None:
"""
The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
Returns:
str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
FuturesSpread.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "FuturesSpread":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
FuturesSpread
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "FuturesSpread":
"""
Return legacy Cython futures spread instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期货价差工具。
Parameters:
pyo3_instrument (nautilus_pyo3.FuturesSpread) – The pyo3 Rust futures spread instrument to convert from.
pyo3_instrument (nautilus_pyo3.FuturesSpread) - 要转换的 pyo3 Rust 期货价差工具。
Return type:
FuturesSpread
"""
...
@property
def strategy_type(self) -> str:
"""
The strategy type of the spread.
价差的策略类型。
Returns:
str
"""
...
@staticmethod
def to_dict(obj: "FuturesSpread") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the spread.
价差的标的资产。
Returns:
str
"""
...
class OptionsSpread(Instrument):
"""
OptionsSpread(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency currency, int price_precision, Price price_increment, Quantity multiplier, Quantity lot_size, unicode underlying, unicode strategy_type, uint64_t activation_ns, uint64_t expiration_ns, uint64_t ts_event, uint64_t ts_init, unicode exchange=None, dict info=None)
Represents a generic options spread instrument.
表示一个通用的期权价差工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The options contract asset class.
asset_class (AssetClass) - 期权合约的资产类别。
currency (Currency) – The options contract currency.
currency (Currency) - 期权合约货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
multiplier (Quantity) – The option multiplier.
multiplier (Quantity) - 期权乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
underlying (str) – The underlying asset.
underlying (str) - 标的资产。
strategy_type (str) – The strategy type of the spread.
strategy_type (str) - 价差的策略类型。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
exchange (str,可选) - 金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If underlying is not a valid string.
ValueError - 如果 underlying 不是有效的字符串。
ValueError – If strategy_type is not a valid string.
ValueError - 如果 strategy_type 不是有效的字符串。
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
ValueError - 如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot_size 不为正数 (> 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
currency: "Currency",
price_precision: int,
price_increment: "Price",
multiplier: "Quantity",
lot_size: "Quantity",
underlying: str,
strategy_type: str,
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
OptionsSpread.activation_utc
"""
...
@property
def exchange(self) -> str or None:
"""
The exchang ISO 10383 Market Identifier Code (MIC) where the instrument trades.
金融工具交易的交易所 ISO 10383 市场标识符代码 (MIC)。
Returns:
str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
OptionsSpread.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "OptionsSpread":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
OptionsSpread
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "OptionsSpread":
"""
Return legacy Cython options contract instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期权合约工具。
Parameters:
pyo3_instrument (nautilus_pyo3.OptionsSpread) – The pyo3 Rust options contract instrument to convert from.
pyo3_instrument (nautilus_pyo3.OptionsSpread) - 要转换的 pyo3 Rust 期权合约工具。
Return type:
OptionsSpread
"""
...
@property
def strategy_type(self) -> str:
"""
The strategy type of the spread.
价差的策略类型。
Returns:
str
"""
...
@staticmethod
def to_dict(obj: "OptionsSpread") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the contract.
合约的标的资产。
Returns:
str
"""
...
class SyntheticInstrument(Data):
"""
SyntheticInstrument(Symbol symbol, uint8_t price_precision, list components, unicode formula, uint64_t ts_event, uint64_t ts_init)
Represents a synthetic instrument with prices derived from component instruments using a formula.
表示一个合成金融工具,其价格使用公式从成分金融工具中得出。
The id for the synthetic will become {symbol}.{SYNTH}.
合成工具的 ID 将变为 {symbol}.{SYNTH}。
Parameters:
symbol (Symbol) – The symbol for the synethic instrument.
symbol (Symbol) - 合成工具的代码。
price_precision (uint8_t) – The price precision for the synthetic instrument.
price_precision (uint8_t) - 合成工具的价格精度。
components (list [InstrumentId ]) – The component instruments for the synthetic instrument.
components (list [InstrumentId ]) - 合成工具的成分金融工具。
formula (str) – The derivation formula for the synthetic instrument.
formula (str) - 合成工具的推导公式。
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 时间戳(纳秒)。
Raises:
ValueError – If price_precision is greater than 9.
ValueError - 如果 price_precision 大于 9。
OverflowError – If price_precision is negative (< 0).
OverflowError - 如果 price_precision 为负数 (< 0)。
ValueError – If the components list does not contain at least 2 instrument IDs.
ValueError - 如果成分列表中不包含至少 2 个金融工具 ID。
ValueError – If the formula is not a valid string.
ValueError - 如果公式不是有效的字符串。
ValueError – If the formula is not a valid expression.
ValueError - 如果公式不是有效的表达式。
WARNING
All component instruments should already be defined and exist in the cache prior to defining a new synthetic instrument.
在定义新的合成工具之前,所有成分工具都应该已经定义并存在于缓存中。
"""
def __init__(
self,
symbol: "Symbol",
price_precision: int,
components: list["InstrumentId"],
formula: str,
ts_event: int,
ts_init: int,
) -> None:
...
def calculate(self, inputs: list) -> "Price":
"""
Calculate the price of the synthetic instrument from the given inputs.
根据给定的输入计算合成工具的价格。
Parameters:
inputs (list *[*double ])
inputs (list *[*double ])
Return type:
Price
Raises:
ValueError – If inputs is empty, contains a NaN value, or length is different from components count.
ValueError - 如果 inputs 为空、包含 NaN 值或长度与成分数量不同。
RuntimeError – If an internal error occurs when calculating the price.
RuntimeError - 如果在计算价格时发生内部错误。
"""
...
def change_formula(self, formula: str) -> None:
"""
Change the internal derivation formula for the synthetic instrument.
更改合成工具的内部推导公式。
Parameters:
formula (str) – The derivation formula to change to.
formula (str) - 要更改的推导公式。
Raises:
ValueError – If the formula is not a valid string.
ValueError - 如果公式不是有效的字符串。
ValueError – If the formula is not a valid expression.
ValueError - 如果公式不是有效的表达式。
"""
...
@property
def components(self) -> list["InstrumentId"]:
"""
list[InstrumentId]
Return the components of the synthetic instrument.
返回合成工具的成分。
Return type:
list[InstrumentId]
Type:
SyntheticInstrument.components
"""
...
@property
def formula(self) -> str:
"""
str
Return the synthetic instrument internal derivation formula.
返回合成工具的内部推导公式。
Return type:
str
Type:
SyntheticInstrument.formula
"""
...
@staticmethod
def from_dict(values: dict) -> "SyntheticInstrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
SyntheticInstrument
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type:
str
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具 ID。
Returns:
InstrumentId
"""
...
@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
"""
...
@property
def price_increment(self) -> "Price":
"""
Price
Return the minimum price increment (tick size) for the synthetic instrument.
返回合成工具的最小价格增量(tick 规模)。
Return type:
Price
Type:
SyntheticInstrument.price_increment
"""
...
@property
def price_precision(self) -> int:
"""
int
Return the precision for the synthetic instrument.
返回合成工具的精度。
Return type:
int
Type:
SyntheticInstrument.price_precision
"""
...
@staticmethod
def to_dict(obj: "SyntheticInstrument") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred.
数据事件发生时的 UNIX 时间戳(纳秒)。
Return type:
int
Type:
SyntheticInstrument.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Return type:
int
Type:
SyntheticInstrument.ts_init
"""
...
class BettingInstrument(Instrument):
"""
Represents an instrument in a betting market.
表示博彩市场中的工具。
Parameters:
参数:
venue_name (unicode) – The venue name. 场所名称。
event_type_id (int) – The event type ID. 事件类型 ID。
event_type_name (unicode) – The event type name. 事件类型名称。
competition_id (int) – The competition ID. 比赛 ID。
competition_name (unicode) – The competition name. 比赛名称。
event_id (int) – The event ID. 事件 ID。
event_name (unicode) – The event name. 事件名称。
event_country_code (unicode) – The event country code. 事件国家/地区代码。
event_open_date (datetime) – The event open date. 事件开始日期。
betting_type (unicode) – The betting type. 投注类型。
market_id (unicode) – The market ID. 市场 ID。
market_name (unicode) – The market name. 市场名称。
market_start_time (datetime) – The market start time. 市场开始时间。
market_type (unicode) – The market type. 市场类型。
selection_id (int) – The selection ID. 选择 ID。
selection_name (unicode) – The selection name. 选择名称。
currency (unicode) – The currency. 货币。
selection_handicap (float) – The selection handicap. 选择让分。
price_precision (int8_t) – The price precision. 价格精度。
size_precision (int8_t) – The size precision. 大小精度。
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 时间戳(纳秒)。
tick_scheme_name (unicode, optional) – The tick scheme name. 跳动方案名称。
min_price (Price, optional) – The minimum price. 最低价格。
max_price (Price, optional) – The maximum price. 最高价格。
info (dict, optional) – The raw info for the instrument. 工具的原始信息。
"""
def __init__(
self,
venue_name: str,
event_type_id: int,
event_type_name: str,
competition_id: int,
competition_name: str,
event_id: int,
event_name: str,
event_country_code: str,
event_open_date: datetime,
betting_type: str,
market_id: str,
market_name: str,
market_start_time: datetime,
market_type: str,
selection_id: int,
selection_name: str,
currency: str,
selection_handicap: float,
price_precision: int,
size_precision: int,
ts_event: int,
ts_init: int,
tick_scheme_name: str | None = None,
min_price: Price | None = None,
max_price: Price | None = None,
info: dict | None = None
):
...
@property
def asset_class(self) -> AssetClass:
"""
The asset class of the instrument.
工具的资产类别。
Returns: AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Instrument
"""
...
@staticmethod
def base_to_dict(obj: Instrument):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@property
def betting_type(self):
...
def calculate_base_quantity(self, quantity: Quantity, last_px: Price) -> Quantity:
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
参数:
quantity (Quantity) – The quantity to convert from.
要转换的数量。
last_px (Price) – The last price for the instrument.
工具的最新价格。
Return type: Quantity
"""
...
@property
def competition_id(self):
...
@property
def competition_name(self):
...
@property
def event_country_code(self):
...
@property
def event_id(self):
...
@property
def event_name(self):
...
@property
def event_open_date(self):
...
@property
def event_type_id(self):
...
@property
def event_type_name(self):
...
@staticmethod
def from_dict(values: dict) -> BettingInstrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: BettingInstrument
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
def get_base_currency(self) -> Currency:
"""
Return the instruments base currency (if applicable).
返回工具的基础货币(如果适用)。
Return type: Currency or None
"""
...
def get_settlement_currency(self) -> Currency:
"""
Return the currency used to settle a trade of the instrument.
返回用于结算工具交易的货币。
Standard linear instruments = quote_currency
Inverse instruments = base_currency
Quanto instruments = settlement_currency
Return type: Currency
"""
...
@property
def id(self) -> InstrumentId:
"""
The instrument ID.
工具 ID。
Returns: InstrumentId
"""
...
@property
def info(self):
"""
The raw info for the instrument.
工具的原始信息。
Returns: dict[str, object]
"""
...
@property
def instrument_class(self) -> InstrumentClass:
"""
The class of the instrument.
工具的类别。
Returns: InstrumentClass
"""
...
@property
def is_inverse(self) -> Currency:
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns: Currency
"""
...
@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
"""
...
@property
def lot_size(self) -> Quantity:
"""
The rounded lot unit size (standard/board) for the instrument.
工具的舍入 lot 单位大小(标准/板)。
Returns: Quantity or None
"""
...
def make_price(self, value) -> Price:
"""
Return a new price from the given value using the instruments price precision.
使用工具的价格精度从给定值返回新价格。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the price.
价格的值。
Return type: Price
"""
...
def make_qty(self, value) -> Quantity:
"""
Return a new quantity from the given value using the instruments size precision.
使用工具的大小精度从给定值返回新数量。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the quantity.
数量的值。
Return type: Quantity
Raises:
引发:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
如果由于工具的大小增量或大小精度而将非零值舍入为零,则引发 ValueError。
"""
...
@property
def maker_fee(self) -> Decimal:
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def margin_init(self) -> Decimal:
"""
The initial (order) margin rate for the instrument.
工具的初始(订单)保证金率。
Returns: Decimal
"""
...
@property
def margin_maint(self) -> Decimal:
"""
The maintenance (position) margin rate for the instrument.
工具的维持(仓位)保证金率。
Returns: Decimal
"""
...
@property
def market_id(self):
...
@property
def market_name(self):
...
@property
def market_start_time(self):
...
@property
def market_type(self):
...
@property
def max_notional(self) -> Money:
"""
The maximum notional order value for the instrument.
工具的最大名义订单价值。
Returns: Money or None
"""
...
@property
def max_price(self) -> Price:
"""
The maximum printable price for the instrument.
工具的最大可打印价格。
Returns: Price or None
"""
...
@property
def max_quantity(self) -> Quantity:
"""
The maximum order quantity for the instrument.
工具的最大订单数量。
Returns: Quantity or None
"""
...
@property
def min_notional(self) -> Money:
"""
The minimum notional order value for the instrument.
工具的最小名义订单价值。
Returns: Money or None
"""
...
@property
def min_price(self) -> Price:
"""
The minimum printable price for the instrument.
工具的最小可打印价格。
Returns: Price or None
"""
...
@property
def min_quantity(self) -> Quantity:
"""
The minimum order quantity for the instrument.
工具的最小订单数量。
Returns: Quantity or None
"""
...
@property
def multiplier(self) -> Quantity:
"""
The contract multiplier for the instrument (determines tick value).
工具的合约乘数(决定跳动值)。
Returns: Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n ask ticks away from value.
返回距离 value n 个卖出跳动的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的卖出跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n bid ticks away from value.
返回距离 value n 个买入跳动的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的买入跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def notional_value(self, quantity: Quantity, price: Price, use_quote_for_inverse: bool = False) -> Money:
...
@property
def price_increment(self) -> Price:
"""
The minimum price increment or tick size for the instrument.
工具的最小价格增量或跳动大小。
Returns: Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
工具的价格精度。
Returns: int
"""
...
@property
def quote_currency(self) -> Currency:
"""
The quote currency for the instrument.
工具的报价货币。
Returns: Currency
"""
...
@property
def raw_symbol(self) -> Symbol:
"""
The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
Returns: Symbol
"""
...
@property
def selection_handicap(self):
...
@property
def selection_id(self):
...
@property
def selection_name(self):
...
@property
def size_increment(self) -> Quantity:
"""
The minimum size increment for the instrument.
工具的最小大小增量。
Returns: Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
工具的大小精度。
Returns: int
"""
...
@property
def symbol(self) -> Symbol:
"""
Return the instruments ticker symbol.
返回工具的股票代码。
Return type: Symbol
"""
...
@property
def taker_fee(self) -> Decimal:
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def tick_scheme_name(self) -> str:
"""
The tick scheme name.
跳动方案名称。
Returns: str or None
"""
...
@staticmethod
def to_dict(obj: BettingInstrument) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@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
"""
...
@property
def venue(self) -> Venue:
"""
Return the instruments trading venue.
返回工具的交易场所。
Return type: Venue
"""
...
def make_symbol(market_id: str, selection_id: int, selection_handicap: float) -> Symbol:
"""
Make symbol.
制作代码。
>>> make_symbol(market_id="1.201070830", selection_id=123456, selection_handicap=null_handicap())
Symbol('1.201070830-123456-None')
"""
...
def null_handicap() -> float:
...
class CryptoPerpetual(Instrument):
"""
Represents a Crypto Perpetual Futures contract instrument (a.k.a. Perpetual Swap).
表示加密货币永续期货合约工具(也称为永续掉期)。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the instrument.
工具的工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
base_currency (Currency , optional) – The base currency.
基础货币。
quote_currency (Currency) – The quote currency.
报价货币。
settlement_currency (Currency) – The settlement currency.
结算货币。
is_inverse (bool) – If the instrument costing is inverse (quantity expressed in quote currency units).
如果工具成本是反向的(数量以报价货币单位表示),则为 True。
price_precision (int) – The price decimal precision.
价格十进制精度。
size_precision (int) – The trading size decimal precision.
交易大小十进制精度。
price_increment (Price) – The minimum price increment (tick size).
最小价格增量(跳动大小)。
size_increment (Quantity) – The minimum size increment.
最小大小增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
维持(仓位)保证金,以仓位价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
multiplier (Quantity , default 1) – The contract multiplier.
合约乘数。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
允许的最大订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
允许的最小订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
允许的最大订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
允许的最小订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
允许的最大报价价格。
min_price (Price , optional) – The minimum allowable quoted price.
允许的最小报价价格。
info (dict *[*str , object ] , optional) – The additional instrument information.
附加工具信息。
Raises:
引发:
ValueError – If price_precision is negative (< 0).
如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
如果 size_increment 不等于 size_increment.precision。
ValueError – If multiplier is not positive (> 0).
如果 multiplier 不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: InstrumentId,
raw_symbol: Symbol,
base_currency: Currency,
quote_currency: Currency,
settlement_currency: Currency,
is_inverse: bool,
price_precision: int,
size_precision: int,
price_increment: Price,
size_increment: Quantity,
margin_init: Decimal,
margin_maint: Decimal,
maker_fee: Decimal,
taker_fee: Decimal,
ts_event: int,
ts_init: int,
multiplier: Quantity = Quantity.from_int_c(1),
max_quantity: Quantity | None = None,
min_quantity: Quantity | None = None,
max_notional: Money | None = None,
min_notional: Money | None = None,
max_price: Price | None = None,
min_price: Price | None = None,
info: dict | None = None
):
...
@property
def asset_class(self) -> AssetClass:
"""
The asset class of the instrument.
工具的资产类别。
Returns: AssetClass
"""
...
@property
def base_currency(self) -> Currency:
"""
The base currency for the instrument.
工具的基础货币。
Returns: Currency
"""
...
@staticmethod
def base_from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Instrument
"""
...
@staticmethod
def base_to_dict(obj: Instrument):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: Quantity, last_px: Price) -> Quantity:
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
参数:
quantity (Quantity) – The quantity to convert from.
要转换的数量。
last_px (Price) – The last price for the instrument.
工具的最新价格。
Return type: Quantity
"""
...
@staticmethod
def from_dict(values: dict) -> CryptoPerpetual:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: CryptoPerpetual
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
def get_base_currency(self) -> Currency:
"""
Return the instruments base currency.
返回工具的基础货币。
Return type: Currency
"""
...
def get_settlement_currency(self) -> Currency:
"""
Return the currency used to settle a trade of the instrument.
返回用于结算工具交易的货币。
Standard linear instruments = quote_currency
Inverse instruments = base_currency
Quanto instruments = settlement_currency
Return type: Currency
"""
...
@property
def id(self) -> InstrumentId:
"""
The instrument ID.
工具 ID。
Returns: InstrumentId
"""
...
@property
def info(self) -> dict:
"""
The raw info for the instrument.
工具的原始信息。
Returns: dict[str, object]
"""
...
@property
def instrument_class(self) -> InstrumentClass:
"""
The class of the instrument.
工具的类别。
Returns: InstrumentClass
"""
...
@property
def is_inverse(self) -> Currency:
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns: Currency
"""
...
@property
def is_quanto(self) -> bool:
"""
If the instrument is quanto.
如果工具是 quanto。
Returns: bool
"""
...
@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
"""
...
@property
def lot_size(self) -> Quantity:
"""
The rounded lot unit size (standard/board) for the instrument.
工具的舍入 lot 单位大小(标准/板)。
Returns: Quantity or None
"""
...
def make_price(self, value) -> Price:
"""
Return a new price from the given value using the instruments price precision.
使用工具的价格精度从给定值返回新价格。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the price.
价格的值。
Return type: Price
"""
...
def make_qty(self, value) -> Quantity:
"""
Return a new quantity from the given value using the instruments size precision.
使用工具的大小精度从给定值返回新数量。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the quantity.
数量的值。
Return type: Quantity
Raises:
引发:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
如果由于工具的大小增量或大小精度而将非零值舍入为零,则引发 ValueError。
"""
...
@property
def maker_fee(self) -> Decimal:
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def margin_init(self) -> Decimal:
"""
The initial (order) margin rate for the instrument.
工具的初始(订单)保证金率。
Returns: Decimal
"""
...
@property
def margin_maint(self) -> Decimal:
"""
The maintenance (position) margin rate for the instrument.
工具的维持(仓位)保证金率。
Returns: Decimal
"""
...
@property
def max_notional(self) -> Money:
"""
The maximum notional order value for the instrument.
工具的最大名义订单价值。
Returns: Money or None
"""
...
@property
def max_price(self) -> Price:
"""
The maximum printable price for the instrument.
工具的最大可打印价格。
Returns: Price or None
"""
...
@property
def max_quantity(self) -> Quantity:
"""
The maximum order quantity for the instrument.
工具的最大订单数量。
Returns: Quantity or None
"""
...
@property
def min_notional(self) -> Money:
"""
The minimum notional order value for the instrument.
工具的最小名义订单价值。
Returns: Money or None
"""
...
@property
def min_price(self) -> Price:
"""
The minimum printable price for the instrument.
工具的最小可打印价格。
Returns: Price or None
"""
...
@property
def min_quantity(self) -> Quantity:
"""
The minimum order quantity for the instrument.
工具的最小订单数量。
Returns: Quantity or None
"""
...
@property
def multiplier(self) -> Quantity:
"""
The contract multiplier for the instrument (determines tick value).
工具的合约乘数(决定跳动值)。
Returns: Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n ask ticks away from value.
返回距离 value n 个卖出跳动的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的卖出跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n bid ticks away from value.
返回距离 value n 个买入跳动的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的买入跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def notional_value(
self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: bool = False
) -> Money:
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
对于标准工具,结果将以报价货币表示,对于反向工具,结果将以基础货币表示。
Parameters:
参数:
quantity (Quantity) – The total quantity.
总数量。
price (Price) – The price for the calculation.
用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
如果反向工具计算使用报价货币(而不是基础货币),则为 True。
Return type: Money
"""
...
@property
def price_increment(self) -> Price:
"""
The minimum price increment or tick size for the instrument.
工具的最小价格增量或跳动大小。
Returns: Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
工具的价格精度。
Returns: int
"""
...
@property
def quote_currency(self) -> Currency:
"""
The quote currency for the instrument.
工具的报价货币。
Returns: Currency
"""
...
@property
def raw_symbol(self) -> Symbol:
"""
The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
Returns: Symbol
"""
...
@property
def settlement_currency(self) -> Currency:
"""
The settlement currency for the instrument.
工具的结算货币。
Returns: Currency
"""
...
@property
def size_increment(self) -> Quantity:
"""
The minimum size increment for the instrument.
工具的最小大小增量。
Returns: Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
工具的大小精度。
Returns: int
"""
...
@property
def symbol(self) -> Symbol:
"""
Return the instruments ticker symbol.
返回工具的股票代码。
Return type: Symbol
"""
...
@property
def taker_fee(self) -> Decimal:
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def tick_scheme_name(self) -> str:
"""
The tick scheme name.
跳动方案名称。
Returns: str or None
"""
...
@staticmethod
def to_dict(obj: CryptoPerpetual) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@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
"""
...
@property
def venue(self) -> Venue:
"""
Return the instruments trading venue.
返回工具的交易场所。
Return type: Venue
"""
...
class CryptoFuture(Instrument):
"""
Represents a Deliverable Futures Contract instrument, with crypto assets as underlying and for settlement.
表示可交割期货合约工具,以加密资产作为标的和结算。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the instrument.
工具的工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
underlying (Currency) – The underlying asset.
标的资产。
quote_currency (Currency) – The contract quote currency.
合约报价货币。
settlement_currency (Currency) – The settlement currency.
结算货币。
is_inverse (bool) – If the instrument costing is inverse (quantity expressed in quote currency units).
如果工具成本是反向的(数量以报价货币单位表示),则为 True。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
price_precision (int) – The price decimal precision.
价格十进制精度。
size_precision (int) – The trading size decimal precision.
交易大小十进制精度。
price_increment (Price) – The minimum price increment (tick size).
最小价格增量(跳动大小)。
size_increment (Quantity) – The minimum size increment.
最小大小增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
维持(仓位)保证金,以仓位价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
multiplier (Quantity , default 1) – The contract multiplier.
合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
舍入 lot 单位大小(标准/板)。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
允许的最大订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
允许的最小订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
允许的最大订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
允许的最小订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
允许的最大报价价格。
min_price (Price , optional) – The minimum allowable quoted price.
允许的最小报价价格。
info (dict *[*str , object ] , optional) – The additional instrument information.
附加工具信息。
Raises:
引发:
ValueError – If price_precision is negative (< 0).
如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
如果 size_increment 不等于 size_increment.precision。
ValueError – If lot size is not positive (> 0).
如果 lot size 不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: InstrumentId,
raw_symbol: Symbol,
underlying: Currency,
quote_currency: Currency,
settlement_currency: Currency,
is_inverse: bool,
activation_ns: int,
expiration_ns: int,
price_precision: int,
size_precision: int,
price_increment: Price,
size_increment: Quantity,
margin_init: Decimal,
margin_maint: Decimal,
maker_fee: Decimal,
taker_fee: Decimal,
ts_event: int,
ts_init: int,
multiplier: Quantity = Quantity.from_int_c(1),
lot_size: Quantity = Quantity.from_int_c(1),
max_quantity: Quantity | None = None,
min_quantity: Quantity | None = None,
max_notional: Money | None = None,
min_notional: Money | None = None,
max_price: Price | None = None,
min_price: Price | None = None,
info: dict | None = None
):
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns: unit64_t
"""
...
@property
def activation_utc(self) -> pd.Timestamp:
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳 (UTC)。
Returns:
返回值:
tz-aware UTC.
时区感知 UTC。
Return type: pd.Timestamp
Type: CryptoFuture.activation_utc
"""
...
@property
def asset_class(self) -> AssetClass:
"""
The asset class of the instrument.
工具的资产类别。
Returns: AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Instrument
"""
...
@staticmethod
def base_to_dict(obj: Instrument):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: Quantity, last_px: Price) -> Quantity:
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
参数:
quantity (Quantity) – The quantity to convert from.
要转换的数量。
last_px (Price) – The last price for the instrument.
工具的最新价格。
Return type: Quantity
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns: unit64_t
"""
...
@property
def expiration_utc(self) -> pd.Timestamp:
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳 (UTC)。
Returns:
返回值:
tz-aware UTC.
时区感知 UTC。
Return type: pd.Timestamp
Type: CryptoFuture.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> CryptoFuture:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: CryptoFuture
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
def get_base_currency(self) -> Currency:
"""
Return the instruments base currency.
返回工具的基础货币。
Return type: Currency
"""
...
def get_settlement_currency(self) -> Currency:
"""
Return the currency used to settle a trade of the instrument.
返回用于结算工具交易的货币。
Standard linear instruments = quote_currency
Inverse instruments = base_currency
Quanto instruments = settlement_currency
Return type: Currency
"""
...
@property
def id(self) -> InstrumentId:
"""
The instrument ID.
工具 ID。
Returns: InstrumentId
"""
...
@property
def info(self) -> dict:
"""
The raw info for the instrument.
工具的原始信息。
Returns: dict[str, object]
"""
...
@property
def instrument_class(self) -> InstrumentClass:
"""
The class of the instrument.
工具的类别。
Returns: InstrumentClass
"""
...
@property
def is_inverse(self) -> Currency:
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns: Currency
"""
...
@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
"""
...
@property
def lot_size(self) -> Quantity:
"""
The rounded lot unit size (standard/board) for the instrument.
工具的舍入 lot 单位大小(标准/板)。
Returns: Quantity or None
"""
...
def make_price(self, value) -> Price:
"""
Return a new price from the given value using the instruments price precision.
使用工具的价格精度从给定值返回新价格。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the price.
价格的值。
Return type: Price
"""
...
def make_qty(self, value) -> Quantity:
"""
Return a new quantity from the given value using the instruments size precision.
使用工具的大小精度从给定值返回新数量。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the quantity.
数量的值。
Return type: Quantity
Raises:
引发:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
如果由于工具的大小增量或大小精度而将非零值舍入为零,则引发 ValueError。
"""
...
@property
def maker_fee(self) -> Decimal:
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def margin_init(self) -> Decimal:
"""
The initial (order) margin rate for the instrument.
工具的初始(订单)保证金率。
Returns: Decimal
"""
...
@property
def margin_maint(self) -> Decimal:
"""
The maintenance (position) margin rate for the instrument.
工具的维持(仓位)保证金率。
Returns: Decimal
"""
...
@property
def max_notional(self) -> Money:
"""
The maximum notional order value for the instrument.
工具的最大名义订单价值。
Returns: Money or None
"""
...
@property
def max_price(self) -> Price:
"""
The maximum printable price for the instrument.
工具的最大可打印价格。
Returns: Price or None
"""
...
@property
def max_quantity(self) -> Quantity:
"""
The maximum order quantity for the instrument.
工具的最大订单数量。
Returns: Quantity or None
"""
...
@property
def min_notional(self) -> Money:
"""
The minimum notional order value for the instrument.
工具的最小名义订单价值。
Returns: Money or None
"""
...
@property
def min_price(self) -> Price:
"""
The minimum printable price for the instrument.
工具的最小可打印价格。
Returns: Price or None
"""
...
@property
def min_quantity(self) -> Quantity:
"""
The minimum order quantity for the instrument.
工具的最小订单数量。
Returns: Quantity or None
"""
...
@property
def multiplier(self) -> Quantity:
"""
The contract multiplier for the instrument (determines tick value).
工具的合约乘数(决定跳动值)。
Returns: Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n ask ticks away from value.
返回距离 value n 个卖出跳动的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的卖出跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n bid ticks away from value.
返回距离 value n 个买入跳动的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的买入跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def notional_value(
self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: bool = False
) -> Money:
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
对于标准工具,结果将以报价货币表示,对于反向工具,结果将以基础货币表示。
Parameters:
参数:
quantity (Quantity) – The total quantity.
总数量。
price (Price) – The price for the calculation.
用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
如果反向工具计算使用报价货币(而不是基础货币),则为 True。
Return type: Money
"""
...
@property
def price_increment(self) -> Price:
"""
The minimum price increment or tick size for the instrument.
工具的最小价格增量或跳动大小。
Returns: Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
工具的价格精度。
Returns: int
"""
...
@property
def quote_currency(self) -> Currency:
"""
The quote currency for the instrument.
工具的报价货币。
Returns: Currency
"""
...
@property
def raw_symbol(self) -> Symbol:
"""
The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
Returns: Symbol
"""
...
@property
def settlement_currency(self) -> Currency:
"""
The settlement currency for the contract.
合约的结算货币。
Returns: Currency
"""
...
@property
def size_increment(self) -> Quantity:
"""
The minimum size increment for the instrument.
工具的最小大小增量。
Returns: Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
工具的大小精度。
Returns: int
"""
...
@property
def symbol(self) -> Symbol:
"""
Return the instruments ticker symbol.
返回工具的股票代码。
Return type: Symbol
"""
...
@property
def taker_fee(self) -> Decimal:
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def tick_scheme_name(self) -> str:
"""
The tick scheme name.
跳动方案名称。
Returns: str or None
"""
...
@staticmethod
def to_dict(obj: CryptoFuture) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@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
"""
...
@property
def underlying(self) -> Currency:
"""
The underlying asset for the contract.
合约的标的资产。
Returns: Currency
"""
...
@property
def venue(self) -> Venue:
"""
Return the instruments trading venue.
返回工具的交易场所。
Return type: Venue
"""
...
class CurrencyPair(Instrument):
"""
Represents a generic currency pair instrument in a spot/cash market.
表示现货/现金市场中的通用货币对工具。
Can represent both Fiat FX and Cryptocurrency pairs.
可以表示法定货币外汇和加密货币对。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID for the instrument.
工具的工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
base_currency (Currency) – The base currency.
基础货币。
quote_currency (Currency) – The quote currency.
报价货币。
price_precision (int) – The price decimal precision.
价格十进制精度。
size_precision (int) – The trading size decimal precision.
交易大小十进制精度。
price_increment (Price) – The minimum price increment (tick size).
最小价格增量(跳动大小)。
size_increment (Quantity) – The minimum size increment.
最小大小增量。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
维持(仓位)保证金,以仓位价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value.
流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value.
流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
lot_size (Quantity , optional) – The rounded lot unit size.
舍入 lot 单位大小。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
允许的最大订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
允许的最小订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
允许的最大订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
允许的最小订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
允许的最大报价价格。
min_price (Price , optional) – The minimum allowable quoted price.
允许的最小报价价格。
tick_scheme_name (str , optional) – The name of the tick scheme.
跳动方案的名称。
info (dict *[*str , object ] , optional) – The additional instrument information.
附加工具信息。
Raises:
引发:
ValueError – If tick_scheme_name is not a valid string.
如果 tick_scheme_name 不是有效的字符串。
ValueError – If price_precision is negative (< 0).
如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
如果 size_increment 不等于 size_increment.precision。
ValueError – If lot_size is not positive (> 0).
如果 lot_size 不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: InstrumentId,
raw_symbol: Symbol,
base_currency: Currency,
quote_currency: Currency,
price_precision: int,
size_precision: int,
price_increment: Price,
size_increment: Quantity,
margin_init: Decimal,
margin_maint: Decimal,
maker_fee: Decimal,
taker_fee: Decimal,
ts_event: int,
ts_init: int,
lot_size: Quantity | None = None,
max_quantity: Quantity | None = None,
min_quantity: Quantity | None = None,
max_notional: Money | None = None,
min_notional: Money | None = None,
max_price: Price | None = None,
min_price: Price | None = None,
tick_scheme_name: str | None = None,
info: dict | None = None
):
...
@property
def asset_class(self) -> AssetClass:
"""
The asset class of the instrument.
工具的资产类别。
Returns: AssetClass
"""
...
@property
def base_currency(self) -> Currency:
"""
The base currency for the instrument.
工具的基础货币。
Returns: Currency
"""
...
@staticmethod
def base_from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Instrument
"""
...
@staticmethod
def base_to_dict(obj: Instrument):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: Quantity, last_px: Price) -> Quantity:
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
参数:
quantity (Quantity) – The quantity to convert from.
要转换的数量。
last_px (Price) – The last price for the instrument.
工具的最新价格。
Return type: Quantity
"""
...
@staticmethod
def from_dict(values: dict) -> CurrencyPair:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: CurrencyPair
"""
...
@staticmethod
def from_pyo3(pyo3_instrument):
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
def get_base_currency(self) -> Currency:
"""
Return the instruments base currency.
返回工具的基础货币。
Return type: Currency
"""
...
def get_settlement_currency(self) -> Currency:
"""
Return the currency used to settle a trade of the instrument.
返回用于结算工具交易的货币。
Standard linear instruments = quote_currency
Inverse instruments = base_currency
Quanto instruments = settlement_currency
Return type: Currency
"""
...
@property
def id(self) -> InstrumentId:
"""
The instrument ID.
工具 ID。
Returns: InstrumentId
"""
...
@property
def info(self) -> dict:
"""
The raw info for the instrument.
工具的原始信息。
Returns: dict[str, object]
"""
...
@property
def instrument_class(self) -> InstrumentClass:
"""
The class of the instrument.
工具的类别。
Returns: InstrumentClass
"""
...
@property
def is_inverse(self) -> Currency:
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns: Currency
"""
...
@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
"""
...
@property
def lot_size(self) -> Quantity:
"""
The rounded lot unit size (standard/board) for the instrument.
工具的舍入 lot 单位大小(标准/板)。
Returns: Quantity or None
"""
...
def make_price(self, value) -> Price:
"""
Return a new price from the given value using the instruments price precision.
使用工具的价格精度从给定值返回新价格。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the price.
价格的值。
Return type: Price
"""
...
def make_qty(self, value) -> Quantity:
"""
Return a new quantity from the given value using the instruments size precision.
使用工具的大小精度从给定值返回新数量。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the quantity.
数量的值。
Return type: Quantity
Raises:
引发:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
如果由于工具的大小增量或大小精度而将非零值舍入为零,则引发 ValueError。
"""
...
@property
def maker_fee(self) -> Decimal:
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def margin_init(self) -> Decimal:
"""
The initial (order) margin rate for the instrument.
工具的初始(订单)保证金率。
Returns: Decimal
"""
...
@property
def margin_maint(self) -> Decimal:
"""
The maintenance (position) margin rate for the instrument.
工具的维持(仓位)保证金率。
Returns: Decimal
"""
...
@property
def max_notional(self) -> Money:
"""
The maximum notional order value for the instrument.
工具的最大名义订单价值。
Returns: Money or None
"""
...
@property
def max_price(self) -> Price:
"""
The maximum printable price for the instrument.
工具的最大可打印价格。
Returns: Price or None
"""
...
@property
def max_quantity(self) -> Quantity:
"""
The maximum order quantity for the instrument.
工具的最大订单数量。
Returns: Quantity or None
"""
...
@property
def min_notional(self) -> Money:
"""
The minimum notional order value for the instrument.
工具的最小名义订单价值。
Returns: Money or None
"""
...
@property
def min_price(self) -> Price:
"""
The minimum printable price for the instrument.
工具的最小可打印价格。
Returns: Price or None
"""
...
@property
def min_quantity(self) -> Quantity:
"""
The minimum order quantity for the instrument.
工具的最小订单数量。
Returns: Quantity or None
"""
...
@property
def multiplier(self) -> Quantity:
"""
The contract multiplier for the instrument (determines tick value).
工具的合约乘数(决定跳动值)。
Returns: Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n ask ticks away from value.
返回距离 value n 个卖出跳动的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的卖出跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n bid ticks away from value.
返回距离 value n 个买入跳动的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的买入跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def notional_value(
self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: bool = False
) -> Money:
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
对于标准工具,结果将以报价货币表示,对于反向工具,结果将以基础货币表示。
Parameters:
参数:
quantity (Quantity) – The total quantity.
总数量。
price (Price) – The price for the calculation.
用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
如果反向工具计算使用报价货币(而不是基础货币),则为 True。
Return type: Money
"""
...
@property
def price_increment(self) -> Price:
"""
The minimum price increment or tick size for the instrument.
工具的最小价格增量或跳动大小。
Returns: Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
工具的价格精度。
Returns: int
"""
...
@property
def quote_currency(self) -> Currency:
"""
The quote currency for the instrument.
工具的报价货币。
Returns: Currency
"""
...
@property
def raw_symbol(self) -> Symbol:
"""
The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
Returns: Symbol
"""
...
@property
def size_increment(self) -> Quantity:
"""
The minimum size increment for the instrument.
工具的最小大小增量。
Returns: Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
工具的大小精度。
Returns: int
"""
...
@property
def symbol(self) -> Symbol:
"""
Return the instruments ticker symbol.
返回工具的股票代码。
Return type: Symbol
"""
...
@property
def taker_fee(self) -> Decimal:
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def tick_scheme_name(self) -> str:
"""
The tick scheme name.
跳动方案名称。
Returns: str or None
"""
...
@staticmethod
def to_dict(obj: CurrencyPair) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@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
"""
...
@property
def venue(self) -> Venue:
"""
Return the instruments trading venue.
返回工具的交易场所。
Return type: Venue
"""
...
class Equity(Instrument):
"""
Represents a generic Equity instrument.
表示通用的股票工具。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID.
工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
currency (Currency) – The futures contract currency.
期货合约货币。
price_precision (int) – The price decimal precision.
价格十进制精度。
price_increment (Decimal) – The minimum price increment (tick size).
最小价格增量(跳动大小)。
lot_size (Quantity) – The rounded lot unit size (standard/board).
舍入 lot 单位大小(标准/板)。
isin (str , optional) – The instruments International Securities Identification Number (ISIN).
工具的国际证券识别码 (ISIN)。
margin_init (Decimal , optional) – The initial (order) margin requirement in percentage of order value.
初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal , optional) – The maintenance (position) margin in percentage of position value.
维持(仓位)保证金,以仓位价值的百分比表示。
maker_fee (Decimal , optional) – The fee rate for liquidity makers as a percentage of order value.
流动性提供者的费用率,以订单价值的百分比表示。
taker_fee (Decimal , optional) – The fee rate for liquidity takers as a percentage of order value.
流动性接受者的费用率,以订单价值的百分比表示。
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 时间戳(纳秒)。
info (dict *[*str , object ] , optional) – The additional instrument information.
附加工具信息。
Raises:
引发:
ValueError – If price_precision is negative (< 0).
如果 price_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
如果 price_increment 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
如果 lot_size 不为正数 (> 0)。
ValueError – If isin is not None and not a valid string.
如果 isin 不为 None 且不是有效的字符串。
"""
def __init__(
self,
instrument_id: InstrumentId,
raw_symbol: Symbol,
currency: Currency,
price_precision: int,
price_increment: Decimal,
lot_size: Quantity,
ts_event: int,
ts_init: int,
isin: str | None = None,
margin_init: Decimal | None = None,
margin_maint: Decimal | None = None,
maker_fee: Decimal | None = None,
taker_fee: Decimal | None = None,
max_quantity: Quantity | None = None,
min_quantity: Quantity | None = None,
info: dict | None = None
):
...
@property
def asset_class(self) -> AssetClass:
"""
The asset class of the instrument.
工具的资产类别。
Returns: AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Instrument
"""
...
@staticmethod
def base_to_dict(obj: Instrument):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: Quantity, last_px: Price) -> Quantity:
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
参数:
quantity (Quantity) – The quantity to convert from.
要转换的数量。
last_px (Price) – The last price for the instrument.
工具的最新价格。
Return type: Quantity
"""
...
@staticmethod
def from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Equity
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> Equity:
"""
Return legacy Cython equity instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 股票工具。
Parameters:
参数:
pyo3_instrument (nautilus_pyo3.Equity) – The pyo3 Rust equity instrument to convert from.
要转换的 pyo3 Rust 股票工具。
Return type: Equity
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
def get_base_currency(self) -> Currency:
"""
Return the instruments base currency (if applicable).
返回工具的基础货币(如果适用)。
Return type: Currency or None
"""
...
def get_settlement_currency(self) -> Currency:
"""
Return the currency used to settle a trade of the instrument.
返回用于结算工具交易的货币。
Standard linear instruments = quote_currency
Inverse instruments = base_currency
Quanto instruments = settlement_currency
Return type: Currency
"""
...
@property
def id(self) -> InstrumentId:
"""
The instrument ID.
工具 ID。
Returns: InstrumentId
"""
...
@property
def info(self) -> dict:
"""
The raw info for the instrument.
工具的原始信息。
Returns: dict[str, object]
"""
...
@property
def instrument_class(self) -> InstrumentClass:
"""
The class of the instrument.
工具的类别。
Returns: InstrumentClass
"""
...
@property
def is_inverse(self) -> Currency:
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns: Currency
"""
...
@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
"""
...
@property
def isin(self) -> str:
"""
The instruments International Securities Identification Number (ISIN).
工具的国际证券识别码 (ISIN)。
Returns: str or None
"""
...
@property
def lot_size(self) -> Quantity:
"""
The rounded lot unit size (standard/board) for the instrument.
工具的舍入 lot 单位大小(标准/板)。
Returns: Quantity or None
"""
...
def make_price(self, value) -> Price:
"""
Return a new price from the given value using the instruments price precision.
使用工具的价格精度从给定值返回新价格。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the price.
价格的值。
Return type: Price
"""
...
def make_qty(self, value) -> Quantity:
"""
Return a new quantity from the given value using the instruments size precision.
使用工具的大小精度从给定值返回新数量。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the quantity.
数量的值。
Return type: Quantity
Raises:
引发:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
如果由于工具的大小增量或大小精度而将非零值舍入为零,则引发 ValueError。
"""
...
@property
def maker_fee(self) -> Decimal:
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def margin_init(self) -> Decimal:
"""
The initial (order) margin rate for the instrument.
工具的初始(订单)保证金率。
Returns: Decimal
"""
...
@property
def margin_maint(self) -> Decimal:
"""
The maintenance (position) margin rate for the instrument.
工具的维持(仓位)保证金率。
Returns: Decimal
"""
...
@property
def max_notional(self) -> Money:
"""
The maximum notional order value for the instrument.
工具的最大名义订单价值。
Returns: Money or None
"""
...
@property
def max_price(self) -> Price:
"""
The maximum printable price for the instrument.
工具的最大可打印价格。
Returns: Price or None
"""
...
@property
def max_quantity(self) -> Quantity:
"""
The maximum order quantity for the instrument.
工具的最大订单数量。
Returns: Quantity or None
"""
...
@property
def min_notional(self) -> Money:
"""
The minimum notional order value for the instrument.
工具的最小名义订单价值。
Returns: Money or None
"""
...
@property
def min_price(self) -> Price:
"""
The minimum printable price for the instrument.
工具的最小可打印价格。
Returns: Price or None
"""
...
@property
def min_quantity(self) -> Quantity:
"""
The minimum order quantity for the instrument.
工具的最小订单数量。
Returns: Quantity or None
"""
...
@property
def multiplier(self) -> Quantity:
"""
The contract multiplier for the instrument (determines tick value).
工具的合约乘数(决定跳动值)。
Returns: Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n ask ticks away from value.
返回距离 value n 个卖出跳动的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的卖出跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n bid ticks away from value.
返回距离 value n 个买入跳动的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的买入跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def notional_value(
self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: bool = False
) -> Money:
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
对于标准工具,结果将以报价货币表示,对于反向工具,结果将以基础货币表示。
Parameters:
参数:
quantity (Quantity) – The total quantity.
总数量。
price (Price) – The price for the calculation.
用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
如果反向工具计算使用报价货币(而不是基础货币),则为 True。
Return type: Money
"""
...
@property
def price_increment(self) -> Price:
"""
The minimum price increment or tick size for the instrument.
工具的最小价格增量或跳动大小。
Returns: Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
工具的价格精度。
Returns: int
"""
...
@property
def quote_currency(self) -> Currency:
"""
The quote currency for the instrument.
工具的报价货币。
Returns: Currency
"""
...
@property
def raw_symbol(self) -> Symbol:
"""
The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
Returns: Symbol
"""
...
@property
def size_increment(self) -> Quantity:
"""
The minimum size increment for the instrument.
工具的最小大小增量。
Returns: Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
工具的大小精度。
Returns: int
"""
...
@property
def symbol(self) -> Symbol:
"""
Return the instruments ticker symbol.
返回工具的股票代码。
Return type: Symbol
"""
...
@property
def taker_fee(self) -> Decimal:
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def tick_scheme_name(self) -> str:
"""
The tick scheme name.
跳动方案名称。
Returns: str or None
"""
...
@staticmethod
def to_dict(obj: Instrument) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@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
"""
...
@property
def venue(self) -> Venue:
"""
Return the instruments trading venue.
返回工具的交易场所。
Return type: Venue
"""
...
class FuturesContract(Instrument):
"""
Represents a generic deliverable futures contract instrument.
表示通用的可交割期货合约工具。
Parameters:
参数:
instrument_id (InstrumentId) – The instrument ID.
工具 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
asset_class (AssetClass) – The futures contract asset class.
期货合约资产类别。
currency (Currency) – The futures contract currency.
期货合约货币。
price_precision (int) – The price decimal precision.
价格十进制精度。
price_increment (Decimal) – The minimum price increment (tick size).
最小价格增量(跳动大小)。
multiplier (Quantity) – The contract multiplier.
合约乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
舍入 lot 单位大小(标准/板)。
underlying (str) – The underlying asset.
标的资产。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
交易该工具的交易所 ISO 10383 市场标识符代码 (MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
附加工具信息。
Raises:
引发:
ValueError – If multiplier is not positive (> 0).
如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
如果 lot_size 不为正数 (> 0)。
ValueError – If exchange is not None and not a valid string.
如果 exchange 不为 None 且不是有效的字符串。
"""
def __init__(
self,
instrument_id: InstrumentId,
raw_symbol: Symbol,
asset_class: AssetClass,
currency: Currency,
price_precision: int,
price_increment: Decimal,
multiplier: Quantity,
lot_size: Quantity,
underlying: str,
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str | None = None,
info: dict | None = None
):
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns: unit64_t
"""
...
@property
def activation_utc(self) -> pd.Timestamp:
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳 (UTC)。
Returns:
返回值:
tz-aware UTC.
时区感知 UTC。
Return type: pd.Timestamp
Type: FuturesContract.activation_utc
"""
...
@property
def asset_class(self) -> AssetClass:
"""
The asset class of the instrument.
工具的资产类别。
Returns: AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> Instrument:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: Instrument
"""
...
@staticmethod
def base_to_dict(obj: Instrument):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: Quantity, last_px: Price) -> Quantity:
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
参数:
quantity (Quantity) – The quantity to convert from.
要转换的数量。
last_px (Price) – The last price for the instrument.
工具的最新价格。
Return type: Quantity
"""
...
@property
def exchange(self) -> str:
"""
The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
交易该工具的交易所 ISO 10383 市场标识符代码 (MIC)。
Returns: str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns: unit64_t
"""
...
@property
def expiration_utc(self) -> pd.Timestamp:
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳 (UTC)。
Returns:
返回值:
tz-aware UTC.
时区感知 UTC。
Return type: pd.Timestamp
Type: FuturesContract.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> FuturesContract:
"""
Return an instrument from the given initialization values.
从给定的初始化值返回工具。
Parameters:
参数:
values (dict *[*str , object ]) – The values to initialize the instrument with.
用于初始化工具的值。
Return type: FuturesContract
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> FuturesContract:
"""
Return legacy Cython futures contract instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期货合约工具。
Parameters:
参数:
pyo3_instrument (nautilus_pyo3.FuturesContract) – The pyo3 Rust futures contract instrument to convert from.
要转换的 pyo3 Rust 期货合约工具。
Return type: FuturesContract
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type: str
"""
...
def get_base_currency(self) -> Currency:
"""
Return the instruments base currency (if applicable).
返回工具的基础货币(如果适用)。
Return type: Currency or None
"""
...
def get_settlement_currency(self) -> Currency:
"""
Return the currency used to settle a trade of the instrument.
返回用于结算工具交易的货币。
Standard linear instruments = quote_currency
Inverse instruments = base_currency
Quanto instruments = settlement_currency
Return type: Currency
"""
...
@property
def id(self) -> InstrumentId:
"""
The instrument ID.
工具 ID。
Returns: InstrumentId
"""
...
@property
def info(self) -> dict:
"""
The raw info for the instrument.
工具的原始信息。
Returns: dict[str, object]
"""
...
@property
def instrument_class(self) -> InstrumentClass:
"""
The class of the instrument.
工具的类别。
Returns: InstrumentClass
"""
...
@property
def is_inverse(self) -> Currency:
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns: Currency
"""
...
@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
"""
...
@property
def lot_size(self) -> Quantity:
"""
The rounded lot unit size (standard/board) for the instrument.
工具的舍入 lot 单位大小(标准/板)。
Returns: Quantity or None
"""
...
def make_price(self, value) -> Price:
"""
Return a new price from the given value using the instruments price precision.
使用工具的价格精度从给定值返回新价格。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the price.
价格的值。
Return type: Price
"""
...
def make_qty(self, value) -> Quantity:
"""
Return a new quantity from the given value using the instruments size precision.
使用工具的大小精度从给定值返回新数量。
Parameters:
参数:
value (integer , float , str or Decimal) – The value of the quantity.
数量的值。
Return type: Quantity
Raises:
引发:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
如果由于工具的大小增量或大小精度而将非零值舍入为零,则引发 ValueError。
"""
...
@property
def maker_fee(self) -> Decimal:
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def margin_init(self) -> Decimal:
"""
The initial (order) margin rate for the instrument.
工具的初始(订单)保证金率。
Returns: Decimal
"""
...
@property
def margin_maint(self) -> Decimal:
"""
The maintenance (position) margin rate for the instrument.
工具的维持(仓位)保证金率。
Returns: Decimal
"""
...
@property
def max_notional(self) -> Money:
"""
The maximum notional order value for the instrument.
工具的最大名义订单价值。
Returns: Money or None
"""
...
@property
def max_price(self) -> Price:
"""
The maximum printable price for the instrument.
工具的最大可打印价格。
Returns: Price or None
"""
...
@property
def max_quantity(self) -> Quantity:
"""
The maximum order quantity for the instrument.
工具的最大订单数量。
Returns: Quantity or None
"""
...
@property
def min_notional(self) -> Money:
"""
The minimum notional order value for the instrument.
工具的最小名义订单价值。
Returns: Money or None
"""
...
@property
def min_price(self) -> Price:
"""
The minimum printable price for the instrument.
工具的最小可打印价格。
Returns: Price or None
"""
...
@property
def min_quantity(self) -> Quantity:
"""
The minimum order quantity for the instrument.
工具的最小订单数量。
Returns: Quantity or None
"""
...
@property
def multiplier(self) -> Quantity:
"""
The contract multiplier for the instrument (determines tick value).
工具的合约乘数(决定跳动值)。
Returns: Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n ask ticks away from value.
返回距离 value n 个卖出跳动的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的卖出跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> Price:
"""
Return the price n bid ticks away from value.
返回距离 value n 个买入跳动的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定价格介于两个跳动之间,则 n=0 将找到最近的买入跳动。
Parameters:
参数:
value (double) – The reference value.
参考值。
num_ticks (int , default 0) – The number of ticks to move.
要移动的跳动数。
Return type: Price
Raises:
引发:
ValueError – If a tick scheme is not initialized.
如果未初始化跳动方案,则引发 ValueError。
"""
...
def notional_value(
self,
quantity: Quantity,
price: Price,
use_quote_for_inverse: bool = False
) -> Money:
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
对于标准工具,结果将以报价货币表示,对于反向工具,结果将以基础货币表示。
Parameters:
参数:
quantity (Quantity) – The total quantity.
总数量。
price (Price) – The price for the calculation.
用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
如果反向工具计算使用报价货币(而不是基础货币),则为 True。
Return type: Money
"""
...
@property
def price_increment(self) -> Price:
"""
The minimum price increment or tick size for the instrument.
工具的最小价格增量或跳动大小。
Returns: Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
工具的价格精度。
Returns: int
"""
...
@property
def quote_currency(self) -> Currency:
"""
The quote currency for the instrument.
工具的报价货币。
Returns: Currency
"""
...
@property
def raw_symbol(self) -> Symbol:
"""
The raw/local/native symbol for the instrument, assigned by the venue.
工具的原始/本地/原生代码,由场所分配。
Returns: Symbol
"""
...
@property
def size_increment(self) -> Quantity:
"""
The minimum size increment for the instrument.
工具的最小大小增量。
Returns: Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
工具的大小精度。
Returns: int
"""
...
@property
def symbol(self) -> Symbol:
"""
Return the instruments ticker symbol.
返回工具的股票代码。
Return type: Symbol
"""
...
@property
def taker_fee(self) -> Decimal:
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns: Decimal
"""
...
@property
def tick_scheme_name(self) -> str:
"""
The tick scheme name.
跳动方案名称。
Returns: str or None
"""
...
@staticmethod
def to_dict(obj: FuturesContract) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type: dict[str, object]
"""
...
@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
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the contract.
合约的标的资产。
Returns: str
"""
...
@property
def venue(self) -> Venue:
"""
Return the instruments trading venue.
返回工具的交易场所。
Return type: Venue
"""
...
class OptionsContract(Instrument):
"""
OptionsContract(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, Currency currency, int price_precision, Price price_increment, Quantity multiplier, Quantity lot_size, unicode underlying, OptionKind option_kind, Price strike_price, uint64_t activation_ns, uint64_t expiration_ns, uint64_t ts_event, uint64_t ts_init, unicode exchange=None, dict info=None)
Represents a generic options contract instrument.
表示一个通用的期权合约工具。
Parameters:
instrument_id (InstrumentId) – The instrument ID.
instrument_id (InstrumentId) - 金融工具ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The options contract asset class.
asset_class (AssetClass) - 期权合约的资产类别。
currency (Currency) – The options contract currency.
currency (Currency) - 期权合约货币。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
price_increment (Price) – The minimum price increment (tick size).
price_increment (Price) - 最小价格增量(tick 规模)。
multiplier (Quantity) – The option multiplier.
multiplier (Quantity) - 期权乘数。
lot_size (Quantity) – The rounded lot unit size (standard/board).
lot_size (Quantity) - 舍入后的 lot 单位规模(标准/板)。
underlying (str) – The underlying asset.
underlying (str) - 标的资产。
option_kind (OptionKind) – The kind of option (PUT | CALL).
option_kind (OptionKind) - 期权类型(PUT | CALL)。
strike_price (Price) – The option strike price.
strike_price (Price) - 期权行权价。
activation_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract activation.
activation_ns (uint64_t) - 合约激活的 UNIX 时间戳(纳秒)。
expiration_ns (uint64_t) – UNIX timestamp (nanoseconds) for contract expiration.
expiration_ns (uint64_t) - 合约到期的 UNIX 时间戳(纳秒)。
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 时间戳(纳秒)。
exchange (str , optional) – The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
exchange (str,可选) - 金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ],可选) - 附加的金融工具信息。
Raises:
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If tick_size is not positive (> 0).
ValueError - 如果 tick_size 不为正数 (> 0)。
ValueError – If lot_size is not positive (> 0).
ValueError - 如果 lot_size 不为正数 (> 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
currency: "Currency",
price_precision: int,
price_increment: "Price",
multiplier: "Quantity",
lot_size: "Quantity",
underlying: str,
option_kind: "OptionKind",
strike_price: "Price",
activation_ns: int,
expiration_ns: int,
ts_event: int,
ts_init: int,
exchange: str = None,
info: dict | None = None,
) -> None:
...
@property
def activation_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract activation.
合约激活的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def activation_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract activation timestamp (UTC).
返回合约激活时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
OptionsContract.activation_utc
"""
...
@property
def asset_class(self) -> "AssetClass":
"""
The asset class of the instrument.
金融工具的资产类别。
Returns:
AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> "Instrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Instrument
"""
...
@staticmethod
def base_to_dict(obj: "Instrument"):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: "Quantity", last_px: "Price") -> "Quantity":
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
quantity (Quantity) – The quantity to convert from.
quantity (Quantity) - 要转换的数量。
last_px (Price) – The last price for the instrument.
last_px (Price) - 金融工具的最新价格。
Return type:
Quantity
"""
...
@property
def exchange(self) -> str or None:
"""
The exchange ISO 10383 Market Identifier Code (MIC) where the instrument trades.
金融工具交易的交易所 ISO 10383 市场标识符代码(MIC)。
Returns:
str or None
"""
...
@property
def expiration_ns(self) -> int:
"""
UNIX timestamp (nanoseconds) for contract expiration.
合约到期的 UNIX 时间戳(纳秒)。
Returns:
unit64_t
"""
...
@property
def expiration_utc(self) -> "pd.Timestamp":
"""
pd.Timestamp
Return the contract expriation timestamp (UTC).
返回合约到期时间戳(UTC)。
Returns:
tz-aware UTC.
时区感知的 UTC。
Return type:
pd.Timestamp
Type:
OptionsContract.expiration_utc
"""
...
@staticmethod
def from_dict(values: dict) -> "OptionsContract":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
OptionsContract
"""
...
@staticmethod
def from_pyo3(pyo3_instrument) -> "OptionsContract":
"""
Return legacy Cython options contract instrument converted from the given pyo3 Rust object.
返回从给定的 pyo3 Rust 对象转换而来的旧版 Cython 期权合约工具。
Parameters:
pyo3_instrument (nautilus_pyo3.OptionsContract) – The pyo3 Rust options contract instrument to convert from.
pyo3_instrument (nautilus_pyo3.OptionsContract) - 要转换的 pyo3 Rust 期权合约工具。
Return type:
OptionsContract
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type:
str
"""
...
def get_base_currency(self) -> "Currency" or None:
"""
Return the instruments base currency (if applicable).
返回金融工具的基础货币(如果适用)。
Return type:
Currency or None
"""
...
def get_settlement_currency(self) -> "Currency":
"""
Return the currency used to settle a trade of the instrument.
返回用于结算金融工具交易的货币。
Standard linear instruments = quote_currency
标准线性金融工具 = quote_currency
Inverse instruments = base_currency
反向金融工具 = base_currency
Quanto instruments = settlement_currency
Quanto 金融工具 = settlement_currency
Return type:
Currency
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具ID。
Returns:
InstrumentId
"""
...
@property
def info(self) -> dict[str, object]:
"""
The raw info for the instrument.
金融工具的原始信息。
Returns:
dict[str, object]
"""
...
@property
def instrument_class(self) -> "InstrumentClass":
"""
The class of the instrument.
金融工具的类别。
Returns:
InstrumentClass
"""
...
@property
def is_inverse(self) -> "Currency":
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns:
Currency
"""
...
@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
"""
...
@property
def lot_size(self) -> "Quantity" or None:
"""
The rounded lot unit size (standard/board) for the instrument.
金融工具的舍入后的 lot 单位规模(标准/板)。
Returns:
Quantity or None
"""
...
def make_price(self, value) -> "Price":
"""
Return a new price from the given value using the instruments price precision.
使用金融工具的价格精度从给定值返回一个新的价格。
Parameters:
value (integer , float , str or Decimal) – The value of the price.
value (integer , float , str 或 Decimal) - 价格的值。
Return type:
Price
"""
...
def make_qty(self, value) -> "Quantity":
"""
Return a new quantity from the given value using the instruments size precision.
使用金融工具的规模精度从给定值返回一个新的数量。
Parameters:
value (integer , float , str or Decimal) – The value of the quantity.
value (integer , float , str 或 Decimal) - 数量的值。
Return type:
Quantity
Raises:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
ValueError - 如果由于金融工具的规模增量或规模精度,非零值被舍入为零。
"""
...
@property
def maker_fee(self) -> "Decimal":
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def margin_init(self) -> "Decimal":
"""
The initial (order) margin rate for the instrument.
金融工具的初始(订单)保证金率。
Returns:
Decimal
"""
...
@property
def margin_maint(self) -> "Decimal":
"""
The maintenance (position) margin rate for the instrument.
金融工具的维持(头寸)保证金率。
Returns:
Decimal
"""
...
@property
def max_notional(self) -> "Money" or None:
"""
The maximum notional order value for the instrument.
金融工具的最大名义订单价值。
Returns:
Money or None
"""
...
@property
def max_price(self) -> "Price" or None:
"""
The maximum printable price for the instrument.
金融工具的最大可打印价格。
Returns:
Price or None
"""
...
@property
def max_quantity(self) -> "Quantity" or None:
"""
The maximum order quantity for the instrument.
金融工具的最大订单数量。
Returns:
Quantity or None
"""
...
@property
def min_notional(self) -> "Money" or None:
"""
The minimum notional order value for the instrument.
金融工具的最小名义订单价值。
Returns:
Money or None
"""
...
@property
def min_price(self) -> "Price" or None:
"""
The minimum printable price for the instrument.
金融工具的最小可打印价格。
Returns:
Price or None
"""
...
@property
def min_quantity(self) -> "Quantity" or None:
"""
The minimum order quantity for the instrument.
金融工具的最小订单数量。
Returns:
Quantity or None
"""
...
@property
def multiplier(self) -> "Quantity":
"""
The contract multiplier for the instrument (determines tick value).
金融工具的合约乘数(决定 tick 值)。
Returns:
Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n ask ticks away from value.
返回距离 value n 个 ask ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 ask tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n bid ticks away from value.
返回距离 value n 个 bid ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 bid tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int,默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def notional_value(
self, quantity: "Quantity", price: "Price", use_quote_for_inverse: bool = False
) -> "Money":
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
结果将以标准工具的报价货币或反向工具的基础货币表示。
Parameters:
quantity (Quantity) – The total quantity.
quantity (Quantity) - 总数量。
price (Price) – The price for the calculation.
price (Price) - 用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
use_quote_for_inverse (bool) - 如果反向工具计算使用报价货币(而不是基础货币)。
Return type:
Money
"""
...
@property
def option_kind(self) -> "OptionKind":
"""
The option kind (PUT | CALL) for the contract.
合约的期权类型(PUT | CALL)。
Returns:
OptionKind
"""
...
@property
def price_increment(self) -> "Price":
"""
The minimum price increment or tick size for the instrument.
金融工具的最小价格增量或 tick 规模。
Returns:
Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
金融工具的价格精度。
Returns:
int
"""
...
@property
def quote_currency(self) -> "Currency":
"""
The quote currency for the instrument.
金融工具的报价货币。
Returns:
Currency
"""
...
@property
def raw_symbol(self) -> "Symbol":
"""
The raw/local/native symbol for the instrument, assigned by the venue.
金融工具的原始/本地/原生代码,由交易场所分配。
Returns:
Symbol
"""
...
@property
def size_increment(self) -> "Quantity":
"""
The minimum size increment for the instrument.
金融工具的最小规模增量。
Returns:
Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
金融工具的规模精度。
Returns:
int
"""
...
@property
def strike_price(self) -> "Price":
"""
The strike price for the contract.
合约的行权价。
Returns:
Price
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the instruments ticker symbol.
返回金融工具的代码。
Return type:
Symbol
"""
...
@property
def taker_fee(self) -> "Decimal":
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def tick_scheme_name(self) -> str or None:
"""
The tick scheme name.
tick 方案的名称。
Returns:
str or None
"""
...
@staticmethod
def to_dict(obj: "OptionsContract") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@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
"""
...
@property
def underlying(self) -> str:
"""
The underlying asset for the contract.
合约的标的资产。
Returns:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the instruments trading venue.
返回金融工具的交易场所。
Return type:
Venue
"""
...
class SyntheticInstrument(Data):
"""
SyntheticInstrument(Symbol symbol, uint8_t price_precision, list components, unicode formula, uint64_t ts_event, uint64_t ts_init)
Represents a synthetic instrument with prices derived from component instruments using a formula.
表示一个合成金融工具,其价格使用公式从成分金融工具中得出。
The id for the synthetic will become {symbol}.{SYNTH}.
合成工具的ID将变为{symbol}.{SYNTH}。
Parameters:
symbol (Symbol) – The symbol for the synethic instrument.
symbol (Symbol) - 合成金融工具的代码。
price_precision (uint8_t) – The price precision for the synthetic instrument.
price_precision (uint8_t) - 合成金融工具的价格精度。
components (list [InstrumentId ]) – The component instruments for the synthetic instrument.
components (list [InstrumentId ]) - 合成金融工具的成分金融工具。
formula (str) – The derivation formula for the synthetic instrument.
formula (str) - 合成金融工具的推导公式。
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 时间戳(纳秒)。
Raises:
ValueError – If price_precision is greater than 9.
ValueError - 如果 price_precision 大于 9。
OverflowError – If price_precision is negative (< 0).
OverflowError - 如果 price_precision 为负数 (< 0)。
ValueError – If the components list does not contain at least 2 instrument IDs.
ValueError - 如果 components 列表不包含至少 2 个金融工具 ID。
ValueError – If the formula is not a valid string.
ValueError - 如果 formula 不是有效的字符串。
ValueError – If the formula is not a valid expression.
ValueError - 如果 formula 不是有效的表达式。
WARNING
All component instruments should already be defined and exist in the cache prior to defining a new synthetic instrument.
在定义新的合成金融工具之前,所有成分金融工具都应该已经定义并存在于缓存中。
"""
def __init__(
self,
symbol: "Symbol",
price_precision: int,
components: list["InstrumentId"],
formula: str,
ts_event: int,
ts_init: int,
) -> None:
...
def calculate(self, inputs: list) -> "Price":
"""
Calculate the price of the synthetic instrument from the given inputs.
根据给定的输入计算合成金融工具的价格。
Parameters:
inputs (list *[*double ])
inputs (list *[*double ])
Return type:
Price
Raises:
ValueError – If inputs is empty, contains a NaN value, or length is different from components count.
ValueError - 如果 inputs 为空、包含 NaN 值或长度与成分数量不同。
RuntimeError – If an internal error occurs when calculating the price.
RuntimeError - 如果在计算价格时发生内部错误。
"""
...
def change_formula(self, formula: str) -> None:
"""
Change the internal derivation formula for the synthetic instrument.
更改合成金融工具的内部推导公式。
Parameters:
formula (str) – The derivation formula to change to.
formula (str) - 要更改为的推导公式。
Raises:
ValueError – If the formula is not a valid string.
ValueError - 如果 formula 不是有效的字符串。
ValueError – If the formula is not a valid expression.
ValueError - 如果 formula 不是有效的表达式。
"""
...
@property
def components(self) -> list["InstrumentId"]:
"""
list[InstrumentId]
Return the components of the synthetic instrument.
返回合成金融工具的成分。
Return type:
list[InstrumentId]
Type:
SyntheticInstrument.components
"""
...
@property
def formula(self) -> str:
"""
str
Return the synthetic instrument internal derivation formula.
返回合成金融工具的内部推导公式。
Return type:
str
Type:
SyntheticInstrument.formula
"""
...
@staticmethod
def from_dict(values: dict) -> "SyntheticInstrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 初始化金融工具所用的值。
Return type:
SyntheticInstrument
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type:
str
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具ID。
Returns:
InstrumentId
"""
...
@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, 可选) - 要检查的特定信号名称。如果没有提供 name 或传递空字符串,则该方法会检查类名是否指示通用信号类型。如果提供了 name,则该方法会检查类名是否对应于该特定信号。
Returns:
True if the class name matches the signal type or the specific signal name, otherwise False.
如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type:
bool
"""
...
@property
def price_increment(self) -> "Price":
"""
Price
Return the minimum price increment (tick size) for the synthetic instrument.
返回合成金融工具的最小价格增量(tick 规模)。
Return type:
Price
Type:
SyntheticInstrument.price_increment
"""
...
@property
def price_precision(self) -> int:
"""
int
Return the precision for the synthetic instrument.
返回合成金融工具的精度。
Return type:
int
Type:
SyntheticInstrument.price_precision
"""
...
@staticmethod
def to_dict(obj: "SyntheticInstrument") -> dict[str, object]:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def ts_event(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the data event occurred.
数据事件发生时的 UNIX 时间戳(纳秒)。
Return type:
int
Type:
SyntheticInstrument.ts_event
"""
...
@property
def ts_init(self) -> int:
"""
int
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Return type:
int
Type:
SyntheticInstrument.ts_init
"""
...
class Instrument(Data):
"""
Instrument(InstrumentId instrument_id, Symbol raw_symbol, AssetClass asset_class, InstrumentClass instrument_class, Currency quote_currency, bool is_inverse, int price_precision, int size_precision, Quantity size_increment, Quantity multiplier, margin_init: Decimal, margin_maint: Decimal, maker_fee: Decimal, taker_fee: Decimal, uint64_t ts_event, uint64_t ts_init, Price price_increment: Price | None = None, Quantity lot_size: Quantity | None = None, Quantity max_quantity: Quantity | None = None, Quantity min_quantity: Quantity | None = None, Money max_notional: Money | None = None, Money min_notional: Money | None = None, Price max_price: Price | None = None, Price min_price: Price | None = None, unicode tick_scheme_name=None, dict info=None)
The base class for all instruments.
所有金融工具的基类。
Represents a tradable instrument. This class can be used to define an instrument, or act as a parent class for more specific instruments.
表示一个可交易的金融工具。此类可用于定义金融工具,或作为更特定金融工具的父类。
Parameters:
instrument_id (InstrumentId) – The instrument ID for the instrument.
instrument_id (InstrumentId) - 金融工具的 ID。
raw_symbol (Symbol) – The raw/local/native symbol for the instrument, assigned by the venue.
raw_symbol (Symbol) - 金融工具的原始/本地/原生代码,由交易场所分配。
asset_class (AssetClass) – The instrument asset class.
asset_class (AssetClass) - 金融工具的资产类别。
instrument_class (InstrumentClass) – The instrument class.
instrument_class (InstrumentClass) - 金融工具的类别。
quote_currency (Currency) – The quote currency.
quote_currency (Currency) - 报价货币。
is_inverse (bool) – If the instrument costing is inverse (quantity expressed in quote currency units).
is_inverse (bool) - 如果金融工具的成本是反向的(数量以报价货币单位表示)。
price_precision (int) – The price decimal precision.
price_precision (int) - 价格的小数精度。
size_precision (int) – The trading size decimal precision.
size_precision (int) - 交易规模的小数精度。
size_increment (Price) – The minimum size increment.
size_increment (Price) - 最小规模增量。
multiplier (Decimal) – The contract value multiplier (determines tick value).
multiplier (Decimal) - 合约价值乘数(决定 tick 值)。
lot_size (Quantity , optional) – The rounded lot unit size (standard/board).
lot_size (Quantity, 可选) - 舍入后的 lot 单位规模(标准/板)。
margin_init (Decimal) – The initial (order) margin requirement in percentage of order value.
margin_init (Decimal) - 初始(订单)保证金要求,以订单价值的百分比表示。
margin_maint (Decimal) – The maintenance (position) margin in percentage of position value.
margin_maint (Decimal) - 维持(头寸)保证金,以头寸价值的百分比表示。
maker_fee (Decimal) – The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
maker_fee (Decimal) - 流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
taker_fee (Decimal) – The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
taker_fee (Decimal) - 流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
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 时间戳(纳秒)。
price_increment (Price , optional) – The minimum price increment (tick size).
price_increment (Price, 可选) - 最小价格增量(tick 规模)。
max_quantity (Quantity , optional) – The maximum allowable order quantity.
max_quantity (Quantity, 可选) - 最大允许订单数量。
min_quantity (Quantity , optional) – The minimum allowable order quantity.
min_quantity (Quantity, 可选) - 最小允许订单数量。
max_notional (Money , optional) – The maximum allowable order notional value.
max_notional (Money, 可选) - 最大允许订单名义价值。
min_notional (Money , optional) – The minimum allowable order notional value.
min_notional (Money, 可选) - 最小允许订单名义价值。
max_price (Price , optional) – The maximum allowable quoted price.
max_price (Price, 可选) - 最大允许报价。
min_price (Price , optional) – The minimum allowable quoted price.
min_price (Price, 可选) - 最小允许报价。
tick_scheme_name (str , optional) – The name of the tick scheme.
tick_scheme_name (str, 可选) - tick 方案的名称。
info (dict *[*str , object ] , optional) – The additional instrument information.
info (dict *[*str , object ], 可选) - 附加的金融工具信息。
Raises:
ValueError – If tick_scheme_name is not a valid string.
ValueError - 如果 tick_scheme_name 不是有效的字符串。
ValueError – If price_precision is negative (< 0).
ValueError - 如果 price_precision 为负数 (< 0)。
ValueError – If size_precision is negative (< 0).
ValueError - 如果 size_precision 为负数 (< 0)。
ValueError – If price_increment is not positive (> 0).
ValueError - 如果 price_increment 不为正数 (> 0)。
ValueError – If size_increment is not positive (> 0).
ValueError - 如果 size_increment 不为正数 (> 0)。
ValueError – If price_precision is not equal to price_increment.precision.
ValueError - 如果 price_precision 不等于 price_increment.precision。
ValueError – If size_increment is not equal to size_increment.precision.
ValueError - 如果 size_increment 不等于 size_increment.precision。
ValueError – If multiplier is not positive (> 0).
ValueError - 如果 multiplier 不为正数 (> 0)。
ValueError – If lot size is not positive (> 0).
ValueError - 如果 lot 规模不为正数 (> 0)。
ValueError – If max_quantity is not positive (> 0).
ValueError - 如果 max_quantity 不为正数 (> 0)。
ValueError – If min_quantity is negative (< 0).
ValueError - 如果 min_quantity 为负数 (< 0)。
ValueError – If max_notional is not positive (> 0).
ValueError - 如果 max_notional 不为正数 (> 0)。
ValueError – If min_notional is negative (< 0).
ValueError - 如果 min_notional 为负数 (< 0)。
ValueError – If max_price is not positive (> 0).
ValueError - 如果 max_price 不为正数 (> 0)。
ValueError – If min_price is negative (< 0).
ValueError - 如果 min_price 为负数 (< 0)。
"""
def __init__(
self,
instrument_id: "InstrumentId",
raw_symbol: "Symbol",
asset_class: "AssetClass",
instrument_class: "InstrumentClass",
quote_currency: "Currency",
is_inverse: bool,
price_precision: int,
size_precision: int,
size_increment: "Quantity",
multiplier: "Quantity",
margin_init: "Decimal",
margin_maint: "Decimal",
maker_fee: "Decimal",
taker_fee: "Decimal",
ts_event: int,
ts_init: int,
price_increment: "Price" | None = None,
lot_size: "Quantity" | None = None,
max_quantity: "Quantity" | None = None,
min_quantity: "Quantity" | None = None,
max_notional: "Money" | None = None,
min_notional: "Money" | None = None,
max_price: "Price" | None = None,
min_price: "Price" | None = None,
tick_scheme_name: str = None,
info: dict | None = None,
) -> None:
...
@property
def asset_class(self) -> "AssetClass":
"""
The asset class of the instrument.
金融工具的资产类别。
Returns:
AssetClass
"""
...
@staticmethod
def base_from_dict(values: dict) -> "Instrument":
"""
Return an instrument from the given initialization values.
从给定的初始化值返回一个金融工具。
Parameters:
values (dict *[*str , object ]) – The values to initialize the instrument with.
values (dict *[*str , object ]) - 用于初始化金融工具的值。
Return type:
Instrument
"""
...
@staticmethod
def base_to_dict(obj: "Instrument"):
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
def calculate_base_quantity(self, quantity: "Quantity", last_px: "Price") -> "Quantity":
"""
Calculate the base asset quantity from the given quote asset quantity and last price.
根据给定的报价资产数量和最新价格计算基础资产数量。
Parameters:
quantity (Quantity) – The quantity to convert from.
quantity (Quantity) - 要转换的数量。
last_px (Price) – The last price for the instrument.
last_px (Price) - 金融工具的最新价格。
Return type:
Quantity
"""
...
@classmethod
def fully_qualified_name(cls) -> str:
"""
Return the fully qualified name for the Data class.
返回数据类的完全限定名称。
Return type:
str
"""
...
def get_base_currency(self) -> "Currency" or None:
"""
Return the instruments base currency (if applicable).
返回金融工具的基础货币(如果适用)。
Return type:
Currency or None
"""
...
def get_settlement_currency(self) -> "Currency":
"""
Return the currency used to settle a trade of the instrument.
返回用于结算金融工具交易的货币。
Standard linear instruments = quote_currency
标准线性金融工具 = quote_currency
Inverse instruments = base_currency
反向金融工具 = base_currency
Quanto instruments = settlement_currency
Quanto 金融工具 = settlement_currency
Return type:
Currency
"""
...
@property
def id(self) -> "InstrumentId":
"""
The instrument ID.
金融工具ID。
Returns:
InstrumentId
"""
...
@property
def info(self) -> dict[str, object]:
"""
The raw info for the instrument.
金融工具的原始信息。
Returns:
dict[str, object]
"""
...
@property
def instrument_class(self) -> "InstrumentClass":
"""
The class of the instrument.
金融工具的类别。
Returns:
InstrumentClass
"""
...
@property
def is_inverse(self) -> "Currency":
"""
If the quantity is expressed in quote currency.
如果数量以报价货币表示。
Returns:
Currency
"""
...
@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, 可选) - 要检查的特定信号名称。如果没有提供 name 或传递空字符串,则该方法会检查类名是否指示通用信号类型。如果提供了 name,则该方法会检查类名是否对应于该特定信号。
Returns:
True if the class name matches the signal type or the specific signal name, otherwise False.
如果类名与信号类型或特定信号名称匹配,则返回 True,否则返回 False。
Return type:
bool
"""
...
@property
def lot_size(self) -> "Quantity" or None:
"""
The rounded lot unit size (standard/board) for the instrument.
金融工具的舍入后的 lot 单位规模(标准/板)。
Returns:
Quantity or None
"""
...
def make_price(self, value) -> "Price":
"""
Return a new price from the given value using the instruments price precision.
使用金融工具的价格精度从给定值返回一个新的价格。
Parameters:
value (integer , float , str or Decimal) – The value of the price.
value (integer, float, str 或 Decimal) - 价格的值。
Return type:
Price
"""
...
def make_qty(self, value) -> "Quantity":
"""
Return a new quantity from the given value using the instruments size precision.
使用金融工具的规模精度从给定值返回一个新的数量。
Parameters:
value (integer , float , str or Decimal) – The value of the quantity.
value (integer, float, str 或 Decimal) - 数量的值。
Return type:
Quantity
Raises:
ValueError – If a non zero value is rounded to zero due to the instruments size increment or size precision.
ValueError - 如果由于金融工具的规模增量或规模精度,非零值被舍入为零。
"""
...
@property
def maker_fee(self) -> "Decimal":
"""
The fee rate for liquidity makers as a percentage of order value (where 1.0 is 100%).
流动性提供者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def margin_init(self) -> "Decimal":
"""
The initial (order) margin rate for the instrument.
金融工具的初始(订单)保证金率。
Returns:
Decimal
"""
...
@property
def margin_maint(self) -> "Decimal":
"""
The maintenance (position) margin rate for the instrument.
金融工具的维持(头寸)保证金率。
Returns:
Decimal
"""
...
@property
def max_notional(self) -> "Money" or None:
"""
The maximum notional order value for the instrument.
金融工具的最大名义订单价值。
Returns:
Money or None
"""
...
@property
def max_price(self) -> "Price" or None:
"""
The maximum printable price for the instrument.
金融工具的最大可打印价格。
Returns:
Price or None
"""
...
@property
def max_quantity(self) -> "Quantity" or None:
"""
The maximum order quantity for the instrument.
金融工具的最大订单数量。
Returns:
Quantity or None
"""
...
@property
def min_notional(self) -> "Money" or None:
"""
The minimum notional order value for the instrument.
金融工具的最小名义订单价值。
Returns:
Money or None
"""
...
@property
def min_price(self) -> "Price" or None:
"""
The minimum printable price for the instrument.
金融工具的最小可打印价格。
Returns:
Price or None
"""
...
@property
def min_quantity(self) -> "Quantity" or None:
"""
The minimum order quantity for the instrument.
金融工具的最小订单数量。
Returns:
Quantity or None
"""
...
@property
def multiplier(self) -> "Quantity":
"""
The contract multiplier for the instrument (determines tick value).
金融工具的合约乘数(决定 tick 值)。
Returns:
Quantity
"""
...
def next_ask_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n ask ticks away from value.
返回距离 value n 个 ask ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest ask tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 ask tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int, 默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def next_bid_price(self, value: float, num_ticks: int = 0) -> "Price":
"""
Return the price n bid ticks away from value.
返回距离 value n 个 bid ticks 的价格。
If a given price is between two ticks, n=0 will find the nearest bid tick.
如果给定的价格位于两个 ticks 之间,则 n=0 将找到最近的 bid tick。
Parameters:
value (double) – The reference value.
value (double) - 参考值。
num_ticks (int , default 0) – The number of ticks to move.
num_ticks (int, 默认 0) - 要移动的 ticks 数量。
Return type:
Price
Raises:
ValueError – If a tick scheme is not initialized.
ValueError - 如果未初始化 tick 方案。
"""
...
def notional_value(
self, quantity: "Quantity", price: "Price", use_quote_for_inverse: bool = False
) -> "Money":
"""
Calculate the notional value.
计算名义价值。
Result will be in quote currency for standard instruments, or base currency for inverse instruments.
结果将以标准工具的报价货币或反向工具的基础货币表示。
Parameters:
quantity (Quantity) – The total quantity.
quantity (Quantity) - 总数量。
price (Price) – The price for the calculation.
price (Price) - 用于计算的价格。
use_quote_for_inverse (bool) – If inverse instrument calculations use quote currency (instead of base).
use_quote_for_inverse (bool) - 如果反向工具计算使用报价货币(而不是基础货币)。
Return type:
Money
"""
...
@property
def price_increment(self) -> "Price":
"""
The minimum price increment or tick size for the instrument.
金融工具的最小价格增量或 tick 规模。
Returns:
Price
"""
...
@property
def price_precision(self) -> int:
"""
The price precision of the instrument.
金融工具的价格精度。
Returns:
int
"""
...
@property
def quote_currency(self) -> "Currency":
"""
The quote currency for the instrument.
金融工具的报价货币。
Returns:
Currency
"""
...
@property
def raw_symbol(self) -> "Symbol":
"""
The raw/local/native symbol for the instrument, assigned by the venue.
金融工具的原始/本地/原生代码,由交易场所分配。
Returns:
Symbol
"""
...
@property
def size_increment(self) -> "Quantity":
"""
The minimum size increment for the instrument.
金融工具的最小规模增量。
Returns:
Quantity
"""
...
@property
def size_precision(self) -> int:
"""
The size precision of the instrument.
金融工具的规模精度。
Returns:
int
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the instruments ticker symbol.
返回金融工具的代码。
Return type:
Symbol
"""
...
@property
def taker_fee(self) -> "Decimal":
"""
The fee rate for liquidity takers as a percentage of order value (where 1.0 is 100%).
流动性接受者的费用率,以订单价值的百分比表示(其中 1.0 为 100%)。
Returns:
Decimal
"""
...
@property
def tick_scheme_name(self) -> str or None:
"""
The tick scheme name.
tick 方案的名称。
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
"""
...
@property
def venue(self) -> "Venue":
"""
Return the instruments trading venue.
返回金融工具的交易场所。
Return type:
Venue
"""
...
@staticmethod
def instruments_from_pyo3(pyo3_instruments: list) -> list:
...