pub struct DatabaseQueries;Implementations§
Source§impl DatabaseQueries
impl DatabaseQueries
Sourcepub async fn truncate(pool: &PgPool) -> Result<()>
pub async fn truncate(pool: &PgPool) -> Result<()>
Truncates all tables in the cache database via the provided Postgres pool.
§Errors
Returns an error if the TRUNCATE operation fails.
Sourcepub async fn add(pool: &PgPool, key: String, value: Vec<u8>) -> Result<()>
pub async fn add(pool: &PgPool, key: String, value: Vec<u8>) -> Result<()>
Inserts a raw key-value entry into the general table via the provided pool.
§Errors
Returns an error if the INSERT operation fails.
Sourcepub async fn load(pool: &PgPool) -> Result<HashMap<String, Vec<u8>>>
pub async fn load(pool: &PgPool) -> Result<HashMap<String, Vec<u8>>>
Loads all entries from the general table via the provided pool.
§Errors
Returns an error if the SELECT operation fails.
Sourcepub async fn add_currency(pool: &PgPool, currency: Currency) -> Result<()>
pub async fn add_currency(pool: &PgPool, currency: Currency) -> Result<()>
Inserts or ignores a Currency row via the provided pool.
§Errors
Returns an error if the INSERT operation fails.
Sourcepub async fn load_currencies(pool: &PgPool) -> Result<Vec<Currency>>
pub async fn load_currencies(pool: &PgPool) -> Result<Vec<Currency>>
Loads all Currency entries via the provided pool.
§Errors
Returns an error if the SELECT operation fails.
Sourcepub async fn load_currency(
pool: &PgPool,
code: &str,
) -> Result<Option<Currency>>
pub async fn load_currency( pool: &PgPool, code: &str, ) -> Result<Option<Currency>>
Loads a single Currency entry by code via the provided pool.
§Errors
Returns an error if the SELECT operation fails.
Sourcepub async fn add_instrument(
pool: &PgPool,
kind: &str,
instrument: Box<dyn Instrument>,
) -> Result<()>
pub async fn add_instrument( pool: &PgPool, kind: &str, instrument: Box<dyn Instrument>, ) -> Result<()>
Inserts or updates an InstrumentAny entry via the provided pool.
§Errors
Returns an error if the INSERT or UPDATE operation fails.
Sourcepub async fn load_instrument(
pool: &PgPool,
instrument_id: &InstrumentId,
) -> Result<Option<InstrumentAny>>
pub async fn load_instrument( pool: &PgPool, instrument_id: &InstrumentId, ) -> Result<Option<InstrumentAny>>
Loads a single InstrumentAny entry by instrument_id via the provided pool.
§Errors
Returns an error if the SELECT operation fails.
Sourcepub async fn load_instruments(pool: &PgPool) -> Result<Vec<InstrumentAny>>
pub async fn load_instruments(pool: &PgPool) -> Result<Vec<InstrumentAny>>
Loads all InstrumentAny entries via the provided pool.
§Errors
Returns an error if the SELECT operation fails.
Sourcepub async fn add_order(
pool: &PgPool,
_kind: &str,
updated: bool,
order: Box<dyn Order>,
client_id: Option<ClientId>,
) -> Result<()>
pub async fn add_order( pool: &PgPool, _kind: &str, updated: bool, order: Box<dyn Order>, client_id: Option<ClientId>, ) -> Result<()>
Sourcepub async fn add_order_snapshot(
pool: &PgPool,
snapshot: OrderSnapshot,
) -> Result<()>
pub async fn add_order_snapshot( pool: &PgPool, snapshot: OrderSnapshot, ) -> Result<()>
Sourcepub async fn load_order_snapshot(
pool: &PgPool,
client_order_id: &ClientOrderId,
) -> Result<Option<OrderSnapshot>>
pub async fn load_order_snapshot( pool: &PgPool, client_order_id: &ClientOrderId, ) -> Result<Option<OrderSnapshot>>
Loads an OrderSnapshot entry by client order ID via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn add_position_snapshot(
pool: &PgPool,
snapshot: PositionSnapshot,
) -> Result<()>
pub async fn add_position_snapshot( pool: &PgPool, snapshot: PositionSnapshot, ) -> Result<()>
Inserts or updates a PositionSnapshot entry via the provided pool.
§Errors
Returns an error if the SQL INSERT or UPDATE operation fails, or if beginning the transaction fails.
Sourcepub async fn load_position_snapshot(
pool: &PgPool,
position_id: &PositionId,
) -> Result<Option<PositionSnapshot>>
pub async fn load_position_snapshot( pool: &PgPool, position_id: &PositionId, ) -> Result<Option<PositionSnapshot>>
Loads a PositionSnapshot entry by position_id via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn check_if_order_initialized_exists(
pool: &PgPool,
client_order_id: ClientOrderId,
) -> Result<bool>
pub async fn check_if_order_initialized_exists( pool: &PgPool, client_order_id: ClientOrderId, ) -> Result<bool>
Checks if an OrderInitialized event exists for the given client_order_id via the provided pool.
§Errors
Returns an error if the SQL SELECT operation fails.
Sourcepub async fn check_if_account_event_exists(
pool: &PgPool,
account_id: AccountId,
) -> Result<bool>
pub async fn check_if_account_event_exists( pool: &PgPool, account_id: AccountId, ) -> Result<bool>
Checks if any account event exists for the given account_id via the provided pool.
§Errors
Returns an error if the SQL SELECT operation fails.
Sourcepub async fn add_order_event(
pool: &PgPool,
order_event: Box<dyn OrderEvent>,
client_id: Option<ClientId>,
) -> Result<()>
pub async fn add_order_event( pool: &PgPool, order_event: Box<dyn OrderEvent>, client_id: Option<ClientId>, ) -> Result<()>
Inserts or updates an order event entry via the provided pool.
§Errors
Returns an error if the SQL INSERT or UPDATE operation fails.
Sourcepub async fn load_order_events(
pool: &PgPool,
client_order_id: &ClientOrderId,
) -> Result<Vec<OrderEventAny>>
pub async fn load_order_events( pool: &PgPool, client_order_id: &ClientOrderId, ) -> Result<Vec<OrderEventAny>>
Loads all order events for a client_order_id via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn load_order(
pool: &PgPool,
client_order_id: &ClientOrderId,
) -> Result<Option<OrderAny>>
pub async fn load_order( pool: &PgPool, client_order_id: &ClientOrderId, ) -> Result<Option<OrderAny>>
Sourcepub async fn load_orders(pool: &PgPool) -> Result<Vec<OrderAny>>
pub async fn load_orders(pool: &PgPool) -> Result<Vec<OrderAny>>
Sourcepub async fn add_account(
pool: &PgPool,
kind: &str,
updated: bool,
account: Box<dyn Account>,
) -> Result<()>
pub async fn add_account( pool: &PgPool, kind: &str, updated: bool, account: Box<dyn Account>, ) -> Result<()>
Sourcepub async fn load_account_events(
pool: &PgPool,
account_id: &AccountId,
) -> Result<Vec<AccountState>>
pub async fn load_account_events( pool: &PgPool, account_id: &AccountId, ) -> Result<Vec<AccountState>>
Loads all account events for account_id via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn load_account(
pool: &PgPool,
account_id: &AccountId,
) -> Result<Option<AccountAny>>
pub async fn load_account( pool: &PgPool, account_id: &AccountId, ) -> Result<Option<AccountAny>>
Sourcepub async fn load_accounts(pool: &PgPool) -> Result<Vec<AccountAny>>
pub async fn load_accounts(pool: &PgPool) -> Result<Vec<AccountAny>>
Sourcepub async fn add_trade(pool: &PgPool, trade: &TradeTick) -> Result<()>
pub async fn add_trade(pool: &PgPool, trade: &TradeTick) -> Result<()>
Inserts a TradeTick entry via the provided pool.
§Errors
Returns an error if the SQL INSERT operation fails.
Sourcepub async fn load_trades(
pool: &PgPool,
instrument_id: &InstrumentId,
) -> Result<Vec<TradeTick>>
pub async fn load_trades( pool: &PgPool, instrument_id: &InstrumentId, ) -> Result<Vec<TradeTick>>
Loads all TradeTick entries for instrument_id via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn add_quote(pool: &PgPool, quote: &QuoteTick) -> Result<()>
pub async fn add_quote(pool: &PgPool, quote: &QuoteTick) -> Result<()>
Inserts a QuoteTick entry via the provided pool.
§Errors
Returns an error if the SQL INSERT operation fails.
Sourcepub async fn load_quotes(
pool: &PgPool,
instrument_id: &InstrumentId,
) -> Result<Vec<QuoteTick>>
pub async fn load_quotes( pool: &PgPool, instrument_id: &InstrumentId, ) -> Result<Vec<QuoteTick>>
Loads all QuoteTick entries for instrument_id via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn add_bar(pool: &PgPool, bar: &Bar) -> Result<()>
pub async fn add_bar(pool: &PgPool, bar: &Bar) -> Result<()>
Inserts a Bar entry via the provided pool.
§Errors
Returns an error if the SQL INSERT operation fails.
Sourcepub async fn load_bars(
pool: &PgPool,
instrument_id: &InstrumentId,
) -> Result<Vec<Bar>>
pub async fn load_bars( pool: &PgPool, instrument_id: &InstrumentId, ) -> Result<Vec<Bar>>
Loads all Bar entries for instrument_id via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn load_distinct_order_event_client_ids(
pool: &PgPool,
) -> Result<AHashMap<ClientOrderId, ClientId>>
pub async fn load_distinct_order_event_client_ids( pool: &PgPool, ) -> Result<AHashMap<ClientOrderId, ClientId>>
Loads all distinct client order IDs from order events via the provided pool.
§Errors
Returns an error if the SQL SELECT or iteration fails.
Sourcepub async fn add_signal(pool: &PgPool, signal: &Signal) -> Result<()>
pub async fn add_signal(pool: &PgPool, signal: &Signal) -> Result<()>
Inserts a Signal entry via the provided pool.
§Errors
Returns an error if the SQL INSERT operation fails.
Sourcepub async fn load_signals(pool: &PgPool, name: &str) -> Result<Vec<Signal>>
pub async fn load_signals(pool: &PgPool, name: &str) -> Result<Vec<Signal>>
Loads all Signal entries by name via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Sourcepub async fn add_custom_data(pool: &PgPool, data: &CustomData) -> Result<()>
pub async fn add_custom_data(pool: &PgPool, data: &CustomData) -> Result<()>
Inserts a CustomData entry via the provided pool.
§Errors
Returns an error if the SQL INSERT operation fails.
Sourcepub async fn load_custom_data(
pool: &PgPool,
data_type: &DataType,
) -> Result<Vec<CustomData>>
pub async fn load_custom_data( pool: &PgPool, data_type: &DataType, ) -> Result<Vec<CustomData>>
Loads all CustomData entries of data_type via the provided pool.
§Errors
Returns an error if the SQL SELECT or deserialization fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DatabaseQueries
impl RefUnwindSafe for DatabaseQueries
impl Send for DatabaseQueries
impl Sync for DatabaseQueries
impl Unpin for DatabaseQueries
impl UnwindSafe for DatabaseQueries
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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