Struct PostgresCacheDatabase

Source
pub struct PostgresCacheDatabase {
    pub pool: PgPool,
    /* private fields */
}

Fields§

§pool: PgPool

Implementations§

Source§

impl PostgresCacheDatabase

Source

pub async fn connect( host: Option<String>, port: Option<u16>, username: Option<String>, password: Option<String>, database: Option<String>, ) -> Result<Self, Error>

Connects to the Postgres cache database using the provided connection parameters.

§Errors

Returns an error if establishing the database connection fails.

§Panics

Panics if the internal Postgres pool connection attempt (connect_pg) unwraps on error.

Trait Implementations§

Source§

impl CacheDatabaseAdapter for PostgresCacheDatabase

Source§

fn close(&mut self) -> Result<()>

Closes the cache database connection. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes any pending changes to the database. Read more
Source§

fn load_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<CacheMap>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all cached data into memory. Read more
Source§

fn load(&self) -> Result<HashMap<String, Bytes>>

Loads raw key-value data from the database. Read more
Source§

fn load_currencies<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<Ustr, Currency>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all currencies from the cache. Read more
Source§

fn load_instruments<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<InstrumentId, InstrumentAny>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all instruments from the cache. Read more
Source§

fn load_synthetics<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<InstrumentId, SyntheticInstrument>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all synthetic instruments from the cache. Read more
Source§

fn load_accounts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<AccountId, AccountAny>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all accounts from the cache. Read more
Source§

fn load_orders<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<ClientOrderId, OrderAny>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all orders from the cache. Read more
Source§

fn load_positions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<PositionId, Position>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads all positions from the cache. Read more
Source§

fn load_index_order_position(&self) -> Result<HashMap<ClientOrderId, Position>>

Loads mapping from order IDs to position IDs. Read more
Source§

fn load_index_order_client(&self) -> Result<HashMap<ClientOrderId, ClientId>>

Loads mapping from order IDs to client IDs. Read more
Source§

fn load_currency<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 Ustr, ) -> Pin<Box<dyn Future<Output = Result<Option<Currency>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a single currency by code. Read more
Source§

fn load_instrument<'life0, 'life1, 'async_trait>( &'life0 self, instrument_id: &'life1 InstrumentId, ) -> Pin<Box<dyn Future<Output = Result<Option<InstrumentAny>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a single instrument by ID. Read more
Source§

fn load_synthetic<'life0, 'life1, 'async_trait>( &'life0 self, instrument_id: &'life1 InstrumentId, ) -> Pin<Box<dyn Future<Output = Result<Option<SyntheticInstrument>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a single synthetic instrument by ID. Read more
Source§

fn load_account<'life0, 'life1, 'async_trait>( &'life0 self, account_id: &'life1 AccountId, ) -> Pin<Box<dyn Future<Output = Result<Option<AccountAny>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a single account by ID. Read more
Source§

fn load_order<'life0, 'life1, 'async_trait>( &'life0 self, client_order_id: &'life1 ClientOrderId, ) -> Pin<Box<dyn Future<Output = Result<Option<OrderAny>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a single order by client order ID. Read more
Source§

fn load_position<'life0, 'life1, 'async_trait>( &'life0 self, position_id: &'life1 PositionId, ) -> Pin<Box<dyn Future<Output = Result<Option<Position>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a single position by position ID. Read more
Source§

fn load_actor( &self, component_id: &ComponentId, ) -> Result<HashMap<String, Bytes>>

Loads actor state by component ID. Read more
Source§

fn delete_actor(&self, component_id: &ComponentId) -> Result<()>

Errors Read more
Source§

fn load_strategy( &self, strategy_id: &StrategyId, ) -> Result<HashMap<String, Bytes>>

Loads strategy state by strategy ID. Read more
Source§

fn delete_strategy(&self, component_id: &StrategyId) -> Result<()>

Errors Read more
Source§

fn add(&self, key: String, value: Bytes) -> Result<()>

Errors Read more
Source§

fn add_currency(&self, currency: &Currency) -> Result<()>

Errors Read more
Source§

fn add_instrument(&self, instrument: &InstrumentAny) -> Result<()>

Errors Read more
Source§

fn add_synthetic(&self, synthetic: &SyntheticInstrument) -> Result<()>

Errors Read more
Source§

fn add_account(&self, account: &AccountAny) -> Result<()>

Errors Read more
Source§

fn add_order(&self, order: &OrderAny, client_id: Option<ClientId>) -> Result<()>

Errors Read more
Source§

fn add_order_snapshot(&self, snapshot: &OrderSnapshot) -> Result<()>

Errors Read more
Source§

fn add_position(&self, position: &Position) -> Result<()>

Errors Read more
Source§

fn add_position_snapshot(&self, snapshot: &PositionSnapshot) -> Result<()>

Errors Read more
Source§

fn add_order_book(&self, order_book: &OrderBook) -> Result<()>

Errors Read more
Source§

fn add_quote(&self, quote: &QuoteTick) -> Result<()>

Errors Read more
Source§

fn load_quotes(&self, instrument_id: &InstrumentId) -> Result<Vec<QuoteTick>>

Loads quote ticks by instrument ID. Read more
Source§

fn add_trade(&self, trade: &TradeTick) -> Result<()>

Errors Read more
Source§

fn load_trades(&self, instrument_id: &InstrumentId) -> Result<Vec<TradeTick>>

Loads trade ticks by instrument ID. Read more
Source§

fn add_bar(&self, bar: &Bar) -> Result<()>

Errors Read more
Source§

fn load_bars(&self, instrument_id: &InstrumentId) -> Result<Vec<Bar>>

Loads bars by instrument ID. Read more
Source§

fn add_signal(&self, signal: &Signal) -> Result<()>

Errors Read more
Source§

fn load_signals(&self, name: &str) -> Result<Vec<Signal>>

Loads signals by name. Read more
Source§

fn add_custom_data(&self, data: &CustomData) -> Result<()>

Errors Read more
Source§

fn load_custom_data(&self, data_type: &DataType) -> Result<Vec<CustomData>>

Loads custom data by data type. Read more
Source§

fn load_order_snapshot( &self, client_order_id: &ClientOrderId, ) -> Result<Option<OrderSnapshot>>

Loads an order snapshot by client order ID. Read more
Source§

fn load_position_snapshot( &self, position_id: &PositionId, ) -> Result<Option<PositionSnapshot>>

Loads a position snapshot by position ID. Read more
Source§

fn index_venue_order_id( &self, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, ) -> Result<()>

Errors Read more
Source§

fn index_order_position( &self, client_order_id: ClientOrderId, position_id: PositionId, ) -> Result<()>

Errors Read more
Source§

fn update_actor(&self) -> Result<()>

Errors Read more
Source§

fn update_strategy(&self) -> Result<()>

Errors Read more
Source§

fn update_account(&self, account: &AccountAny) -> Result<()>

Errors Read more
Source§

fn update_order(&self, event: &OrderEventAny) -> Result<()>

Errors Read more
Source§

fn update_position(&self, position: &Position) -> Result<()>

Errors Read more
Source§

fn snapshot_order_state(&self, order: &OrderAny) -> Result<()>

Errors Read more
Source§

fn snapshot_position_state(&self, position: &Position) -> Result<()>

Errors Read more
Source§

fn heartbeat(&self, timestamp: UnixNanos) -> Result<()>

Errors Read more
§

fn load_greeks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<InstrumentId, GreeksData>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Loads all [GreeksData] from the cache. Read more
§

fn load_yield_curves<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, YieldCurveData>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Loads all [YieldCurveData] from the cache. Read more
§

fn add_greeks(&self, greeks: &GreeksData) -> Result<(), Error>

Errors Read more
§

fn add_yield_curve(&self, yield_curve: &YieldCurveData) -> Result<(), Error>

Errors Read more
Source§

impl Debug for PostgresCacheDatabase

Source§

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

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

impl IntoPy<Py<PyAny>> for PostgresCacheDatabase

Source§

fn into_py(self, py: Python<'_>) -> PyObject

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23.0/migration) for more information.
Performs the conversion.
Source§

impl<'py> IntoPyObject<'py> for PostgresCacheDatabase

Source§

type Target = PostgresCacheDatabase

The Python output type
Source§

type Output = Bound<'py, <PostgresCacheDatabase 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 PostgresCacheDatabase

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for PostgresCacheDatabase

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§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<PostgresCacheDatabase>

This handles following two situations: Read more
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 doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

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

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a PostgresCacheDatabase

Source§

type Holder = Option<PyRef<'py, PostgresCacheDatabase>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut PostgresCacheDatabase

Source§

type Holder = Option<PyRefMut<'py, PostgresCacheDatabase>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<PostgresCacheDatabase> for PyClassImplCollector<PostgresCacheDatabase>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for PostgresCacheDatabase

Source§

const NAME: &'static str = "PostgresCacheDatabase"

Class name.
Source§

const MODULE: Option<&'static str>

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 type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

👎Deprecated since 0.23.0: renamed to PyTypeInfo::type_object
Deprecated name for [PyTypeInfo::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_type_of_bound(object: &Bound<'_, PyAny>) -> bool

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_type_of
Deprecated name for [PyTypeInfo::is_type_of].
§

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

Checks if object is an instance of this type.
§

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

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_exact_type_of
Deprecated name for [PyTypeInfo::is_exact_type_of].
Source§

impl DerefToPyAny for PostgresCacheDatabase

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
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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> IntoPyObjectPoseiExt<'py> for T
where T: IntoPyObjectExt<'py>,

§

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

§

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,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

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

Checks if object is an instance of Self, which may include a subtype. Read more
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 = Infallible

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
§

impl<T> ErasedDestructor for T
where T: 'static,

§

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