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 82)
67fn load_actual_index_dumps(moex_client: &Client) -> Result<Vec<IndexDump>, ExampleError> {
68    let indexes = with_retry(retry_policy(), || moex_client.indexes())?.into_actual_by_till();
69    let page_limit = NonZeroU32::new(INDEX_ANALYTICS_PAGE_LIMIT)
70        .expect("INDEX_ANALYTICS_PAGE_LIMIT constant must be greater than zero");
71
72    indexes
73        .into_iter()
74        .map(|index| {
75            let components = with_retry(retry_policy(), || {
76                moex_client
77                    .index(index.id().clone())
78                    .expect("index id from payload must be valid")
79                    .analytics_pages(page_limit)
80                    .all()
81            })?
82            .into_actual_by_session()
83            .into_sorted_by_weight_desc();
84            Ok(IndexDump {
85                index_id: index.id().as_str().to_owned().into_boxed_str(),
86                short_name: index.short_name().to_owned().into_boxed_str(),
87                components,
88            })
89        })
90        .collect()
91}
Source

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

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

Examples found in repository?
examples/actual_indexes_dump.rs (line 83)
67fn load_actual_index_dumps(moex_client: &Client) -> Result<Vec<IndexDump>, ExampleError> {
68    let indexes = with_retry(retry_policy(), || moex_client.indexes())?.into_actual_by_till();
69    let page_limit = NonZeroU32::new(INDEX_ANALYTICS_PAGE_LIMIT)
70        .expect("INDEX_ANALYTICS_PAGE_LIMIT constant must be greater than zero");
71
72    indexes
73        .into_iter()
74        .map(|index| {
75            let components = with_retry(retry_policy(), || {
76                moex_client
77                    .index(index.id().clone())
78                    .expect("index id from payload must be valid")
79                    .analytics_pages(page_limit)
80                    .all()
81            })?
82            .into_actual_by_session()
83            .into_sorted_by_weight_desc();
84            Ok(IndexDump {
85                index_id: index.id().as_str().to_owned().into_boxed_str(),
86                short_name: index.short_name().to_owned().into_boxed_str(),
87                components,
88            })
89        })
90        .collect()
91}

Implementations on Foreign Types§

Source§

impl IndexAnalyticsExt for Vec<IndexAnalytics>

Implementors§