diff --git a/crates/fidc-core/examples/factor-event-kernel.rs b/crates/fidc-core/examples/factor-event-kernel.rs index ad82788..39beb11 100644 --- a/crates/fidc-core/examples/factor-event-kernel.rs +++ b/crates/fidc-core/examples/factor-event-kernel.rs @@ -15,6 +15,13 @@ fn main() -> Result<(), Box> { io::stdin().read_to_string(&mut input)?; let output = if input.trim().is_empty() { factor_events::catalog() + } else if serde_json::from_str::(&input)?.get("rank_history").is_some() { + #[derive(Deserialize)] + #[serde(deny_unknown_fields)] + struct Rank { dates:Vec, universe:Vec, values:std::collections::BTreeMap>> } + let value:Value=serde_json::from_str(&input)?; + let request:Rank=serde_json::from_value(value["rank_history"].clone())?; + json!({"result":fidc_core::factor_cross_section::rank_history(&request.dates,&request.universe,&request.values)?}) } else { let request: Request = serde_json::from_str(&input)?; let results = request diff --git a/crates/fidc-core/src/factor_events.rs b/crates/fidc-core/src/factor_events.rs index 3539649..5844c0a 100644 --- a/crates/fidc-core/src/factor_events.rs +++ b/crates/fidc-core/src/factor_events.rs @@ -169,6 +169,12 @@ const OPERATORS: &[&str] = &[ ]; pub fn catalog() -> Value { + use sha2::{Digest, Sha256}; + let mut implementation = Sha256::new(); + for file in [include_bytes!("factor_events.rs").as_slice(), include_bytes!("factor_cross_section.rs").as_slice(), + include_bytes!("daily_patterns.rs").as_slice(),include_bytes!("market_event_context.rs").as_slice(), + include_bytes!("session_events.rs").as_slice(),include_bytes!("pattern_context.rs").as_slice(),TA_REV.as_bytes()] {implementation.update(file);} + let implementation_sha256=format!("{:x}",implementation.finalize()); let indicators: Vec = abstract_api::funcs().map(|f| json!({ "name":f.name, "group":format!("{:?}",f.group), "description":f.hint, "inputs":f.inputs.iter().map(|p|json!({"name":p.param_name,"kind":format!("{:?}",p.kind),"flags":p.flags.0})).collect::>(), @@ -176,7 +182,7 @@ pub fn catalog() -> Value { "outputs":f.outputs.iter().enumerate().map(|(i,p)|json!({"index":i,"name":p.param_name,"kind":format!("{:?}",p.kind)})).collect::>(), "unstable_period":format!("{:?}",f.unst_id), "production_eligible":false, })).collect(); - json!({"contract":CONTRACT,"library":{"name":"TA-Lib native Rust","revision":TA_REV,"license":"BSD-3-Clause"}, + json!({"contract":CONTRACT,"expression_kernel_sha256":implementation_sha256,"library":{"name":"TA-Lib native Rust","revision":TA_REV,"license":"BSD-3-Clause"}, "execution_context_contract":crate::pattern_context::CONTRACT, "execution_context_fields":crate::pattern_context::CONTEXT_FIELDS, "market_event_context_contract":crate::market_event_context::CONTRACT,