Skip to main content

UserDataConfig

Struct UserDataConfig 

Source
pub struct UserDataConfig {
    pub tbank: TbankConfig,
    pub source: Arc<str>,
    pub order_state_buffer: usize,
    pub ping_interval: Duration,
    pub price_grid: PriceGrid,
}
Expand description

User data connector config. One connector = one account: tbank.account_id. With None the connector uses the token’s only open account and refuses to start when there are several.

Several accounts of one token need several connectors, each with its own config that differs in tbank.account_id and in source. Share one rate limiter between them.

§Examples

use brokapi_tbank::UserDataConfig;
use brokapi_tbank_protocol::TbankConfig;

let cfg = UserDataConfig::new(TbankConfig::sandbox("t.my-token").with_account("acc-main"), "tbank-ud-main");
assert_eq!(cfg.tbank.account_id.as_deref(), Some("acc-main"));
assert_eq!(cfg.order_state_buffer, 1024);

Fields§

§tbank: TbankConfig

Endpoint, token, account and timeouts of the API. Set account_id with [TbankConfig::with_account] when the token sees more than one account.

§source: Arc<str>

Envelope source label, e.g. "tbank-ud-main". Give every account its own.

§order_state_buffer: usize

Lossless buffer capacity for the order state and executions subscriptions.

Own order states and trades are never dropped. If the consumer is so slow that the buffer fills up, an overflow event is sent and the trading gate closes until the next successful reconcile. Default 1024.

§ping_interval: Duration

Server ping period on the user data streams. A value outside 5 s to 120 s is brought into that range, both for the request and for the silence limit. A stream silent for three periods is treated as dead and reconnected. Default 30 s.

§price_grid: PriceGrid

Price steps the connector checks order prices against (default: empty, nothing is checked). Fill it with [PriceGrid::learn] from the trading parameters of the instruments you trade. A price off the step is then refused with Rejected (price_off_step) before anything is sent.

Implementations§

Source§

impl UserDataConfig

Source

pub fn new(tbank: TbankConfig, source: impl Into<Arc<str>>) -> Self

A config with the default buffer (1024 events) and ping period (30 s).

source labels every Envelope of this connector. Give each account its own label.

§Examples
use brokapi_tbank::UserDataConfig;
use brokapi_tbank_protocol::TbankConfig;

let cfg = UserDataConfig::new(TbankConfig::sandbox("t.my-token"), "tbank-ud");
assert_eq!(&*cfg.source, "tbank-ud");

Trait Implementations§

Source§

impl Clone for UserDataConfig

Source§

fn clone(&self) -> UserDataConfig

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 UserDataConfig

Source§

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

Formats the value using the given formatter. Read more

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

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

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
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, 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<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