Data
class Bar
Bases: Data
Bar(BarType bar_type, Price open, Price high, Price low, Price close, Quantity volume, uint64_t ts_event, uint64_t ts_init, bool is_revision=False) -> None Represents an aggregated bar.
- Parameters:
- bar_type (BarType) – The bar type for this bar.
- open (Price) – The bars open price.
- high (Price) – The bars high price.
- low (Price) – The bars low price.
- close (Price) – The bars close price.
- volume (Quantity) – The bars volume.
- ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the data event occurred.
- ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized.
- is_revision (bool , default False) – If this bar is a revision of a previous bar with the same ts_event.
- Raises:
- ValueError – If high is not >= low.
- ValueError – If high is not >= close.
- ValueError – If low is not <= close.
bar_type
BarType Return the bar type of bar.
- Return type: BarType
- Type: Bar.bar_type
close
Price Return the close price of the bar.
- Return type: Price
- Type: Bar.close
static from_dict(dict values) → Bar
Return a bar parsed from the given values.
- Parameters: values (dict *[*str , object ]) – The values for initialization.
- Return type: Bar
static from_pyo3(pyo3_bar) → Bar
Return a legacy Cython bar converted from the given pyo3 Rust object.
- Parameters: pyo3_bar (nautilus_pyo3.Bar) – The pyo3 Rust bar to convert from.
- Return type: Bar
static from_pyo3_list(list pyo3_bars) → list[Bar]
Return legacy Cython bars converted from the given pyo3 Rust objects.
- Parameters: pyo3_bars (list *[*nautilus_pyo3.Bar ]) – The pyo3 Rust bars to convert from.
- Return type: list[Bar]
static from_raw(BarType bar_type, PriceRaw open, PriceRaw high, PriceRaw low, PriceRaw close, uint8_t price_prec, QuantityRaw volume, uint8_t size_prec, uint64_t ts_event, uint64_t ts_init) → Bar
static from_raw_arrays_to_list(BarType bar_type, uint8_t price_prec, uint8_t size_prec, double[:] opens, double[:] highs, double[:] lows, double[:] closes, double[:] volumes, uint64_t[:] ts_events, uint64_t[:] ts_inits) → list[Bar]
classmethod fully_qualified_name(cls) → str
Return the fully qualified name for the Data class.
- Return type: str
high
Price Return the high price of the bar.
- Return type: Price
- Type: Bar.high
is_revision
If this bar is a revision for a previous bar with the same ts_event.
- Returns: bool
classmethod is_signal(cls, str name='') → 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.
- Return type: bool
is_single_price(self) → bool
If the OHLC are all equal to a single price.
- Return type: bool
low
Price Return the low price of the bar.
- Return type: Price
- Type: Bar.low
open
Price Return the open price of the bar.
- Return type: Price
- Type: Bar.open
static to_dict(Bar obj)
Return a dictionary representation of this object.
- Return type: dict[str, object]
to_pyo3(self) → nautilus_pyo3.Bar
Return a pyo3 object from this legacy Cython instance.
- Return type: nautilus_pyo3.Bar
static to_pyo3_list(list bars) → list[nautilus_pyo3.Bar]
Return pyo3 Rust bars converted from the given legacy Cython objects.
- Parameters: bars (list [Bar ]) – The legacy Cython bars to convert from.
- Return type: list[nautilus_pyo3.Bar]
ts_event
int UNIX timestamp (nanoseconds) when the data event occurred.
- Return type: int
- Type: Bar.ts_event
ts_init
int UNIX timestamp (nanoseconds) when the object was initialized.
- Return type: int
- Type: Bar.ts_init
volume
Quantity Return the volume of the bar.
- Return type: Quantity
- Type: Bar.volume
class BarAggregation
Bases: IntFlag
conjugate()
Returns self, the complex conjugate of any int.
bit_length()
Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', , signed=False)
Return an array of bytes representing an integer.
length : Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
byteorder
: The byte order used to represent the integer. If byteorder is ‘big’,
the most significant byte is at the beginning of the byte array. If
byteorder is ‘little’, the most significant byte is at the end of the
byte array. To request the native byte order of the host system, use
`
sys.byteorder’ as the byte order value. Default is to use ‘big’.
signed : Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
classmethod from_bytes(bytes, byteorder='big', , signed=False)
Return the integer represented by the given array of bytes.
bytes : Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
byteorder
: The byte order used to represent the integer. If byteorder is ‘big’,
the most significant byte is at the beginning of the byte array. If
byteorder is ‘little’, the most significant byte is at the end of the
byte array. To request the native byte order of the host system, use
`
sys.byteorder’ as the byte order value. Default is to use ‘big’.
signed : Indicates whether two’s complement is used to represent the integer.
as_integer_ratio()
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
is_integer()
Returns True. Exists for duck type compatibility with float.is_integer.
real
the real part of a complex number
imag
the imaginary part of a complex number
numerator
the numerator of a rational number in lowest terms
denominator
the denominator of a rational number in lowest terms
TICK = 1
TICK_IMBALANCE = 2
TICK_RUNS = 3
VOLUME = 4
VOLUME_IMBALANCE = 5
VOLUME_RUNS = 6
VALUE = 7
VALUE_IMBALANCE = 8
VALUE_RUNS = 9
MILLISECOND = 10
SECOND = 11
MINUTE = 12
HOUR = 13
DAY = 14
WEEK = 15
MONTH = 16
class BarSpecification
Bases: object
BarSpecification(int step, BarAggregation aggregation, PriceType price_type) -> None Represents a bar aggregation specification including a step, aggregation method/rule and price type.
- Parameters:
- step (int) – The step for binning samples for bar aggregation (> 0).
- aggregation (BarAggregation) – The type of bar aggregation.
- price_type (PriceType) – The price type to use for aggregation.
- Raises: ValueError – If step is not positive (> 0).
aggregation
BarAggregation Return the aggregation for the specification.
- Return type: BarAggregation
- Type: BarSpecification.aggregation
static check_information_aggregated(BarAggregation aggregation)
Check the given aggregation is a type of information aggregation.
- Parameters: aggregation (BarAggregation) – The aggregation type to check.
- Returns: True if information aggregated, else False.
- Return type: bool
static check_threshold_aggregated(BarAggregation aggregation)
Check the given aggregation is a type of threshold aggregation.
- Parameters: aggregation (BarAggregation) – The aggregation type to check.
- Returns: True if threshold aggregated, else False.
- Return type: bool
static check_time_aggregated(BarAggregation aggregation)
Check the given aggregation is a type of time aggregation.
- Parameters: aggregation (BarAggregation) – The aggregation type to check.
- Returns: True if time aggregated, else False.
- Return type: bool
static from_str(str value) → BarSpecification
Return a bar specification parsed from the given string.
-
Parameters: value (str) – The bar specification string to parse.
-
Return type: BarSpecification
-
Raises: ValueError – If value is not a valid string.
static from_timedelta(timedelta duration, PriceType price_type) → BarSpecification
Return a bar specification parsed from the given timedelta and price_type.
-
Parameters:
- duration (timedelta) – The bar specification timedelta to parse.
- price_type (PriceType) – The bar specification price_type.
-
Return type: BarSpecification
-
Raises: ValueError – If duration is not rounded step of aggregation.
is_information_aggregated(self) → bool
Return a value indicating whether the aggregation method is information-driven.
TICK_RUNS
VOLUME_RUNS
VALUE_RUNS
- Return type: bool
is_threshold_aggregated(self) → bool
Return a value indicating whether the bar aggregation method is threshold-driven.
TICK
TICK_IMBALANCE
VOLUME
VOLUME_IMBALANCE
VALUE
VALUE_IMBALANCE
- Return type: bool
is_time_aggregated(self) → bool
Return a value indicating whether the aggregation method is time-driven.
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
- Return type: bool
price_type
PriceType Return the price type for the specification.
- Return type: PriceType
- Type: BarSpecification.price_type
step
int Return the step size for the specification.
- Return type: int
- Type: BarSpecification.step
timedelta
timedelta Return the timedelta for the specification.
- Return type: timedelta
- Raises: ValueError – If aggregation is not a time aggregation, or is``MONTH`` (which is ambiguous).
- Type: BarSpecification.timedelta
class BarType
Bases: object
BarType(InstrumentId instrument_id, BarSpecification bar_spec, AggregationSource aggregation_source=AggregationSource.EXTERNAL) -> None Represents a bar type including the instrument ID, bar specification and aggregation source.
- Parameters:
- instrument_id (InstrumentId) – The bar type’s instrument ID.
- bar_spec (BarSpecification) – The bar type’s specification.
- aggregation_source (AggregationSource , default EXTERNAL) – The bar type aggregation source. If
INTERNAL
the DataEngine will subscribe to the necessary ticks and aggregate bars accordingly. Else ifEXTERNAL
then bars will be subscribed to directly from the venue / data provider.
aggregation_source
AggregationSource Return the aggregation source for the bar type.
- Return type: AggregationSource
- Type: BarType.aggregation_source
composite(self) → BarType
static from_str(str value) → BarType
Return a bar type parsed from the given string.
- Parameters: value (str) – The bar type string to parse.
- Return type: BarType
- Raises: ValueError – If value is not a valid string.
instrument_id
InstrumentId Return the instrument ID for the bar type.
- Return type: InstrumentId
- Type: BarType.instrument_id
is_composite(self) → bool
Return a value indicating whether the bar type corresponds to BarType::Composite in Rust.
- Return type: bool
is_externally_aggregated(self) → bool
Return a value indicating whether the bar aggregation source is EXTERNAL
.
- Return type: bool
is_internally_aggregated(self) → bool
Return a value indicating whether the bar aggregation source is INTERNAL
.
- Return type: bool
is_standard(self) → bool
Return a value indicating whether the bar type corresponds to BarType::Standard in Rust.
- Return type: bool
static new_composite(InstrumentId instrument_id, BarSpecification bar_spec, AggregationSource aggregation_source, int composite_step, BarAggregation composite_aggregation, AggregationSource composite_aggregation_source) → BarType
spec
BarSpecification Return the specification for the bar type.
- Return type: BarSpecification
- Type: BarType.spec
standard(self) → BarType
class BookOrder
Bases: object
BookOrder(OrderSide side, Price price, Quantity size, uint64_t order_id) -> None Represents an order in a book.
- Parameters:
exposure(self) → double
Return the total exposure for this order (price * size).
- Return type: double