Skip to main content

Module limits

Module limits 

Source
Expand description

Rate limits of the Finam connectors, loaded from the bundled limits.toml.

The only number Finam documents is 200 requests per minute for the whole API. The bundled buckets sit below it (global 200 per minute, orders 60, cancel 100, market data 120, reference 100, reports 20). Whether the quota is per user or per secret is not stated by the broker. The file reads it as PER USER, so create ONE BrokerLimiter per Finam user and give it to every connector. This reading is not verified against the live API.

A request over the limit is refused locally with Error::RateLimited and never sent.

§Examples

use brokapi_finam::limits::default_limits;
use brokapi_runtime::BrokerLimiter;

let limits = default_limits();
// Every proto method name has a route. Unknown names spend the "*" default route.
assert!(limits.route.contains_key("PlaceOrder"));
let limiter = BrokerLimiter::new(&limits);
// Hand `limiter.clone()` to every connector of this Finam user.
assert!(limiter.acquire("GetOrders", std::time::Instant::now()).is_ok());

Constants§

DEFAULT_LIMITS_TOML
Text of the bundled limits file. Written from the broker documentation, see the file header for sources.

Functions§

default_limits
The bundled limits, ready for BrokerLimiter::new.
parse_limits
Parses the [finam] section of a limits file through BrokerLimits::from_toml_section.