Skip to main content

Module config

Module config 

Expand description

Connector configuration

MarketDataConfig and UserDataConfig wrap a [TbankConfig] (endpoint, token, account) and add what the connector itself needs: the label of its events and the ping period of its streams.

§Examples

use std::time::Duration;
use brokapi_tbank::{MarketDataConfig, UserDataConfig};
use brokapi_tbank_protocol::TbankConfig;

let token = TbankConfig::sandbox("t.my-token");

// Market data does not depend on the account.
let md = MarketDataConfig::new(token.clone(), "tbank-md");
assert_eq!(md.ping_interval, Duration::from_secs(30));

// Two accounts of one token: two configs, each with its own account and its own source label.
let main = UserDataConfig::new(token.clone().with_account("acc-main"), "tbank-ud-main");
let second = UserDataConfig::new(token.with_account("acc-second"), "tbank-ud-second");
assert_ne!(main.source, second.source);

Structs§

MarketDataConfig
Market data connector config. Not tied to an account: one per broker (token) is enough.
UserDataConfig
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.