From 2473cc04bb0786ca72a0d6f847983a97eb785d4c Mon Sep 17 00:00:00 2001 From: boris Date: Thu, 10 Sep 2026 16:32:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=8E=9F=E7=94=9F=E5=9B=A0=E5=AD=90?= =?UTF-8?q?=E7=A0=94=E7=A9=B6=E5=86=BB=E7=BB=93=E8=AE=A1=E7=AE=97=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/fidc-core/examples/factor-event-kernel.rs | 7 +++++++ crates/fidc-core/src/factor_events.rs | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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,