Skip to main content

PortfolioSnapshot

Struct PortfolioSnapshot 

Source
#[repr(C)]
pub struct PortfolioSnapshot {
Show 16 fields pub account_id: AccountId, pub account_type: AccountType, pub base_currency: Option<Currency>, pub balances: Vec<AccountBalance>, pub margins: Vec<MarginBalance>, pub unrealized_pnls: Vec<Money>, pub realized_pnls: Vec<Money>, pub total_equity: Vec<Money>, pub base_currency_equity: Option<Money>, pub is_stale: bool, pub stale_instruments: Vec<InstrumentId>, pub stale_currencies: Vec<Currency>, pub unpriced_instruments: Vec<InstrumentId>, pub event_id: UUID4, pub ts_event: UnixNanos, pub ts_init: UnixNanos,
}
Expand description

Represents a point-in-time snapshot of portfolio state for a single account.

Unlike AccountState, which fires only on balance or margin changes, PortfolioSnapshot carries a continuous mark-to-market view by folding open-position valuations into the totals. The default equity curve records one snapshot at account registration, at every UTC midnight, and at shutdown, including while the account is flat. An optional fine-grained stream records additional snapshots while positions are open. Totals span every venue the account holds positions on, so multi-venue accounts (e.g., a prime broker routing across exchanges) produce a single account-wide snapshot rather than per-venue slices.

Fields§

§account_id: AccountId

The account ID this snapshot belongs to.

§account_type: AccountType

The type of the account (e.g., cash, margin).

§base_currency: Option<Currency>

The base currency for the account, if applicable.

§balances: Vec<AccountBalance>

The per-currency account balances at snapshot time.

§margins: Vec<MarginBalance>

The per-instrument margin balances at snapshot time (margin accounts only).

§unrealized_pnls: Vec<Money>

The per-currency unrealized PnL across all open positions at snapshot time.

§realized_pnls: Vec<Money>

The per-currency realized PnL accumulated for positions opened in this session.

§total_equity: Vec<Money>

The per-currency total equity (mark-to-market).

For cash accounts: balance.total + Σ mark_value(open positions) in the same currency. For margin accounts: balance.total + Σ unrealized_pnl(open positions) in the same currency.

§base_currency_equity: Option<Money>

The resolved total equity in the account base currency, when conversion is enabled.

§is_stale: bool

Whether this sample contains carried or unavailable valuation inputs.

§stale_instruments: Vec<InstrumentId>

Instruments valued with a carried price.

§stale_currencies: Vec<Currency>

Source currencies converted with a carried exchange rate.

§unpriced_instruments: Vec<InstrumentId>

Open-position instruments excluded because no complete valid valuation was ever available.

§event_id: UUID4

The unique identifier for the event.

§ts_event: UnixNanos

UNIX timestamp (nanoseconds) when the event occurred.

§ts_init: UnixNanos

UNIX timestamp (nanoseconds) when the event was initialized.

Implementations§

Source§

impl PortfolioSnapshot

Source

pub fn new( account_id: AccountId, account_type: AccountType, base_currency: Option<Currency>, balances: Vec<AccountBalance>, margins: Vec<MarginBalance>, unrealized_pnls: Vec<Money>, realized_pnls: Vec<Money>, total_equity: Vec<Money>, base_currency_equity: Option<Money>, is_stale: bool, stale_instruments: Vec<InstrumentId>, stale_currencies: Vec<Currency>, unpriced_instruments: Vec<InstrumentId>, event_id: UUID4, ts_event: UnixNanos, ts_init: UnixNanos, ) -> Self

Creates a new PortfolioSnapshot instance.

Trait Implementations§

Source§

impl CatalogPathPrefix for PortfolioSnapshot

Source§

fn path_prefix() -> &'static str

Returns the path prefix (directory name) for this data type.
Source§

impl Clone for PortfolioSnapshot

Source§

fn clone(&self) -> PortfolioSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PortfolioSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DerefToPyAny for PortfolioSnapshot

Source§

impl<'de> Deserialize<'de> for PortfolioSnapshot

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PortfolioSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, 'py> FromPyObject<'a, 'py> for PortfolioSnapshot
where Self: Clone,

Source§

type Error = PyClassGuardError<'a, 'py>

The type returned in the event of a conversion error. Read more
Source§

fn extract( obj: Borrowed<'a, 'py, PyAny>, ) -> Result<Self, <Self as FromPyObject<'a, 'py>>::Error>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl HasTsInit for PortfolioSnapshot

Source§

fn ts_init(&self) -> UnixNanos

Returns the UNIX timestamp (nanoseconds) when the instance was created.
Source§

impl<'py> IntoPyObject<'py> for PortfolioSnapshot

Source§

type Target = PortfolioSnapshot

The Python output type
Source§

type Output = Bound<'py, <PortfolioSnapshot as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PartialEq for PortfolioSnapshot

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PyClass for PortfolioSnapshot

Source§

const NAME: &str = "PortfolioSnapshot"

Name of the class. Read more
Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for PortfolioSnapshot

Source§

const MODULE: Option<&str>

Module which the class will be associated with. Read more
Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

const RAW_DOC: &'static CStr = /// Represents a point-in-time snapshot of portfolio state for a single account. /// /// Unlike [`AccountState`](crate::events::AccountState), which fires only on /// balance or margin changes, `PortfolioSnapshot` carries a continuous /// mark-to-market view by folding open-position valuations into the totals. /// The default equity curve records one snapshot at account registration, at every /// UTC midnight, and at shutdown, including while the account is flat. An optional /// fine-grained stream records additional snapshots while positions are open. /// Totals span every venue the account holds positions on, so multi-venue /// accounts (e.g., a prime broker routing across exchanges) produce a single /// account-wide snapshot rather than per-venue slices.

Docstring for the class provided on the struct or enum. Read more
Source§

const DOC: &'static CStr

Fully rendered class doc, including the text_signature if a constructor is defined. Read more
Source§

type Layout = <<PortfolioSnapshot as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<PortfolioSnapshot>

Description of how this class is laid out in memory
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = NoopThreadChecker

This handles following two situations: Read more
Source§

type Inventory = Pyo3MethodsInventoryForPortfolioSnapshot

Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<PyObjectOffset>

Used to provide the dictoffset slot (equivalent to tp_dictoffset)
§

fn weaklist_offset() -> Option<PyObjectOffset>

Used to provide the weaklistoffset slot (equivalent to tp_weaklistoffset
Source§

impl PyClassNewTextSignature for PortfolioSnapshot

Source§

const TEXT_SIGNATURE: &'static str = "(account_id, account_type, balances, margins, unrealized_pnls, realized_pnls, total_equity, event_id, ts_event, ts_init, base_currency=None, base_currency_equity=None, is_stale=False, stale_instruments=None, stale_currencies=None, unpriced_instruments=None)"

Source§

impl PyStubType for PortfolioSnapshot

Source§

fn type_output() -> TypeInfo

The type to be used in the output signature, i.e. return type of the Python function or methods.
§

fn type_input() -> TypeInfo

The type to be used in the input signature, i.e. the arguments of the Python function or methods. Read more
Source§

impl PyTypeInfo for PortfolioSnapshot

Source§

const NAME: &str = <Self as ::pyo3::PyClass>::NAME

👎Deprecated since 0.28.0:

prefer using ::type_object(py).name() to get the correct runtime value

Class name.
Source§

const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE

👎Deprecated since 0.28.0:

prefer using ::type_object(py).module() to get the correct runtime value

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl Serialize for PortfolioSnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<'py, T> FromPyObjectOwned<'py> for T
where T: for<'a> FromPyObject<'a, 'py>,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
§

impl<'py, T> IntoPyObjectNautilusExt<'py> for T
where T: IntoPyObjectExt<'py>,

§

fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
where Self: IntoPyObject<'py, Error = !>,

Converts self into a [Py<PyAny>] when the underlying conversion is infallible.
§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
§

fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>

Returns the expected type as a possible argument for the isinstance and issubclass function. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,