Skip to main content

IndexAnalyticsExt

Trait IndexAnalyticsExt 

Source
pub trait IndexAnalyticsExt {
    // Required methods
    fn retain_actual_by_session(&mut self);
    fn sort_by_weight_desc(&mut self);

    // Provided methods
    fn into_actual_by_session(self) -> Self
       where Self: Sized { ... }
    fn into_sorted_by_weight_desc(self) -> Self
       where Self: Sized { ... }
}
Expand description

Методы fluent-интерфейса для коллекции состава индекса.

Required Methods§

Source

fn retain_actual_by_session(&mut self)

Оставить только актуальную торговую сессию: максимальные trade_session_date и tradingsession.

Source

fn sort_by_weight_desc(&mut self)

Отсортировать по убыванию weight и затем по secid.

Provided Methods§

Source

fn into_actual_by_session(self) -> Self
where Self: Sized,

Вернуть только актуальную торговую сессию.

Examples found in repository?
examples/actual_indexes_dump.rs (line 98)
83fn load_actual_index_dumps(moex_client: &Client) -> Result<Vec<IndexDump>, ExampleError> {
84    let indexes = with_retry(retry_policy(), || moex_client.indexes())?.into_actual_by_till();
85    let page_limit = NonZeroU32::new(INDEX_ANALYTICS_PAGE_LIMIT)
86        .expect("INDEX_ANALYTICS_PAGE_LIMIT constant must be greater than zero");
87
88    indexes
89        .into_iter()
90        .map(|index| {
91            let components = with_retry(retry_policy(), || {
92                moex_client
93                    .index(index.id().clone())
94                    .expect("index id from payload must be valid")
95                    .analytics_pages(page_limit)
96                    .all()
97            })?
98            .into_actual_by_session()
99            .into_sorted_by_weight_desc();
100            Ok(IndexDump {
101                index_id: index.id().as_str().to_owned().into_boxed_str(),
102                short_name: index.short_name().to_owned().into_boxed_str(),
103                components,
104            })
105        })
106        .collect()
107}
Source

fn into_sorted_by_weight_desc(self) -> Self
where Self: Sized,

Вернуть отсортированную по убыванию weight коллекцию.

Examples found in repository?
examples/actual_indexes_dump.rs (line 99)
83fn load_actual_index_dumps(moex_client: &Client) -> Result<Vec<IndexDump>, ExampleError> {
84    let indexes = with_retry(retry_policy(), || moex_client.indexes())?.into_actual_by_till();
85    let page_limit = NonZeroU32::new(INDEX_ANALYTICS_PAGE_LIMIT)
86        .expect("INDEX_ANALYTICS_PAGE_LIMIT constant must be greater than zero");
87
88    indexes
89        .into_iter()
90        .map(|index| {
91            let components = with_retry(retry_policy(), || {
92                moex_client
93                    .index(index.id().clone())
94                    .expect("index id from payload must be valid")
95                    .analytics_pages(page_limit)
96                    .all()
97            })?
98            .into_actual_by_session()
99            .into_sorted_by_weight_desc();
100            Ok(IndexDump {
101                index_id: index.id().as_str().to_owned().into_boxed_str(),
102                short_name: index.short_name().to_owned().into_boxed_str(),
103                components,
104            })
105        })
106        .collect()
107}

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IndexAnalyticsExt for Vec<IndexAnalytics>

Implementors§