Skip to main content

PyStrategy

Struct PyStrategy 

Source
pub struct PyStrategy { /* private fields */ }
Expand description

Python-facing wrapper for Strategy.

Implementations§

Source§

impl PyStrategy

Source

pub fn new_checked(config: Option<StrategyConfig>) -> CorrectnessResult<Self>

Creates a new PyStrategy instance with correctness checking.

§Errors

Returns an error if the configured order ID tag contains the ‘-’ strategy ID separator, or if composing it into the strategy ID does not produce a valid StrategyId.

Source

pub fn new(config: Option<StrategyConfig>) -> Self

Creates a new PyStrategy instance.

§Panics

Panics if the configured order ID tag contains the ‘-’ strategy ID separator, or if composing it into the strategy ID does not produce a valid StrategyId.

Source

pub fn set_python_instance(&mut self, py_obj: &Bound<'_, PyAny>) -> PyResult<()>

Sets the Python instance reference for method dispatch.

Only a weak reference is stored, so the caller keeps ownership of py_obj. The trader owns registered wrappers; an unregistered strategy stays collectable.

§Errors

Returns an error if py_obj cannot be weakly referenced.

Source

pub fn set_config(&mut self, config: Option<Py<PyAny>>)

Stores the original Python config object passed at construction.

Retained so the constructed instance exposes .config and instance-based registration can source strategy ID, order ID tag, and logging flags from the same single config object.

Source

pub fn set_external_order_claims( &mut self, external_order_claims: Option<Vec<InstrumentId>>, )

Updates configured external order claim instrument IDs before registration.

Source

pub fn external_order_claims(&self) -> Option<Vec<InstrumentId>>

Returns the configured external order claim instrument IDs.

Source

pub fn set_actor_id(&mut self, actor_id: ActorId)

Updates the runtime component identity used until a strategy ID is assigned.

Must only be called before registration. See PyDataActor::set_actor_id.

Source

pub fn set_strategy_id(&mut self, strategy_id: StrategyId) -> Result<()>

Updates the runtime strategy ID.

Must only be called before registration. See PyDataActor::set_actor_id.

§Errors

Returns an error if composing the current order ID tag into strategy_id does not produce a valid StrategyId.

Source

pub fn set_order_id_tag(&mut self, order_id_tag: &str) -> Result<()>

Updates the runtime order ID tag.

§Errors

Returns an error if order_id_tag contains the ‘-’ strategy ID separator, or if composing it into the current strategy ID does not produce a valid StrategyId.

Source

pub fn set_log_events(&mut self, log_events: bool)

Updates the runtime log_events setting.

Source

pub fn set_log_commands(&mut self, log_commands: bool)

Updates the runtime log_commands setting.

Source

pub fn strategy_id(&self) -> StrategyId

Returns the strategy ID.

Until registration assigns an order ID tag, an unconfigured strategy reports the class-derived ID with the unassigned tag, such as MyStrategy-None.

Source

pub fn configured_strategy_id(&self) -> Option<StrategyId>

Returns the strategy ID once configured or assigned, otherwise None.

Source

pub fn order_id_tag(&self) -> Option<String>

Returns the runtime order ID tag.

Source

pub fn is_registered(&self) -> bool

Returns a value indicating whether the strategy has been registered with a trader.

Source

pub fn register( &mut self, trader_id: TraderId, clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>, portfolio: Rc<RefCell<Portfolio>>, ) -> Result<()>

Register the strategy with a trader.

§Errors

Returns an error if registration fails.

Source

pub fn register_in_global_registries(&self) -> PyResult<()>

Registers this strategy in the global component, actor, and wrapper registries.

The Python wrapper is retained as part of the same act, so a registered strategy always has an owner for the wrapper its inner only weakly references.

§Errors

Returns an error if no Python wrapper is attached, or if the attached wrapper has already been collected. Nothing is registered in that case.

Trait Implementations§

Source§

impl Debug for PyStrategy

Source§

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

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

impl DerefToPyAny for PyStrategy

Source§

impl ExtractPyClassWithClone for PyStrategy

Source§

impl<'py> IntoPyObject<'py> for PyStrategy

Source§

type Target = PyStrategy

The Python output type
Source§

type Output = Bound<'py, <PyStrategy 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 PyClass for PyStrategy

Source§

const NAME: &str = "Strategy"

Name of the class. Read more
Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassBaseType for PyStrategy

Source§

type LayoutAsBase = <PyStrategy as PyClassImpl>::Layout

Source§

type BaseNativeType = <PyStrategy as PyClassImpl>::BaseNativeType

Source§

type Initializer = PyClassInitializer<PyStrategy>

Source§

type PyClassMutability = <PyStrategy as PyClassImpl>::PyClassMutability

Source§

type Layout<T: PyClassImpl> = <<PyStrategy as PyClassBaseType>::BaseNativeType as PyClassBaseType>::Layout<T>

The type of object layout to use for ancestors or descendants of this type.
Source§

impl PyClassImpl for PyStrategy

Source§

const MODULE: Option<&str>

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

const IS_BASETYPE: bool = true

#[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 = /// Python-facing wrapper for Strategy.

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 = <<PyStrategy as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<PyStrategy>

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

type BaseType = PyAny

Base class
Source§

type ThreadChecker = ThreadCheckerImpl

This handles following two situations: Read more
Source§

type Inventory = Pyo3MethodsInventoryForPyStrategy

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 = PyClassWeakRefSlot

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 weaklist_offset() -> Option<PyObjectOffset>

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

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

§

fn dict_offset() -> Option<PyObjectOffset>

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

impl PyClassNewTextSignature for PyStrategy

Source§

const TEXT_SIGNATURE: &'static str = "(config=None)"

Source§

impl PyStubType for PyStrategy

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 PyStrategy

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.

Auto Trait Implementations§

Blanket Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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, 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> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more