MCPcopy Create free account
hub / github.com/Open-Quant/openquant / num_concurrent_events

Function num_concurrent_events

crates/openquant/src/sample_weights.rs:6–17  ·  view source on GitHub ↗

Compute number of concurrent events for each timestamp.

(
    close_index: &[NaiveDateTime],
    label_endtime: &[(NaiveDateTime, NaiveDateTime)],
)

Source from the content-addressed store, hash-verified

4
5/// Compute number of concurrent events for each timestamp.
6fn num_concurrent_events(
7 close_index: &[NaiveDateTime],
8 label_endtime: &[(NaiveDateTime, NaiveDateTime)],
9) -> BTreeMap<NaiveDateTime, usize> {
10 let mut counts: BTreeMap<NaiveDateTime, usize> = BTreeMap::new();
11 for (start, end) in label_endtime {
12 for ts in close_index.iter().filter(|ts| **ts >= *start && **ts <= *end) {
13 *counts.entry(*ts).or_insert(0) += 1;
14 }
15 }
16 counts
17}
18
19/// Average uniqueness from triple barrier events.
20#[allow(dead_code)]

Callers 2

get_weights_by_returnFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected