Skip to main content

kestrel_chartkit/
lib.rs

1//! Streaming technical-analysis primitives, regime classification, composite scoring, and SVG
2//! chart exports.
3//!
4//! Most consumers should start with the root re-exports. Concrete indicator and engine modules
5//! remain public for advanced composition; the crate is pre-1.0 and does not yet promise API
6//! stability for those lower-level modules.
7
8/// Provider-neutral data-feed and notification integration contracts (traits), plus
9/// dependency-free reference implementations.
10pub mod adapters;
11/// Shared, typed result/artifact models (pivots, zones, profiles, scenarios).
12pub mod artifact;
13/// IANA-timezone, DST-aware exchange calendars. Requires the `calendar` feature.
14#[cfg(feature = "calendar")]
15pub mod calendar;
16/// Versioned state snapshots for long-running engines.
17pub mod checkpoint;
18/// Deterministic clustering and robust adaptive-threshold primitives.
19pub mod clustering;
20/// Market-context and execution-support calculations.
21pub mod engine;
22/// Evaluation records and aggregate trade statistics.
23pub mod evaluation;
24/// Event/alert enrichment: timestamps, instrument/timeframe context, stable IDs, deduplication.
25pub mod event;
26/// Provider-neutral order/fill simulator: orders, partial fills, pyramiding, costs, position state.
27pub mod execution;
28/// Generic composition graph: typed indicator dependencies, shared intermediate outputs, and
29/// centralized warmup/execution ordering.
30pub mod graph;
31/// Streaming indicators and the validated indicator registry.
32pub mod indicator;
33/// Lower-timeframe (intrabar) child-bar grouping under a higher-timeframe parent bucket.
34pub mod intrabar;
35/// Bar lifecycle events and rollback-safe, idempotent recomputation.
36pub mod lifecycle;
37/// Shared OHLCV and market-domain types.
38pub mod model;
39/// Pine-parity fixture harness: standardized reference-value comparison with timestamp
40/// alignment, warmup handling, tolerances, MTF boundaries, and explicit missing values.
41pub mod parity;
42/// Market-regime classification.
43pub mod regime;
44/// Advanced regime-model building blocks: Markov transitions, persistence, predictability,
45/// hysteretic transitions, and adaptive cycle-length tracking.
46pub mod regime_advanced;
47/// Provider-neutral risk and position-sizing: account risk, leverage/notional limits,
48/// scale-in/out plans, break-even/time-stop rules.
49pub mod risk;
50/// Batch and replay execution over a full bar history.
51pub mod runner;
52/// Generic composite scenario state machine: multi-stage progressions with per-stage expiry and
53/// explicit invalidation.
54pub mod scenario;
55/// Indicator scoring and composite aggregation.
56pub mod scoring;
57/// Historical series sliding lookback and event helpers.
58pub mod series;
59/// Trading session and Opening Range Breakout (ORB) tracking.
60pub mod session;
61/// Composite signal data types.
62pub mod signal;
63/// Rolling statistical primitives and linear regression.
64pub mod stats;
65/// Support and resistance discovery and zone lifecycle.
66pub mod structure;
67/// Custom timeframe types and OHLCV bar resampling.
68pub mod timeframe;
69/// Chart DTOs and static SVG rendering.
70pub mod viz;
71
72pub use adapters::{
73    DataFeedAdapter, InMemoryDataFeed, LoggingNotificationSink, NotificationEvent,
74    NotificationSeverity, NotificationSink, WebhookNotificationSink,
75};
76pub use artifact::{
77    Artifact, PivotArtifact, ProfileArtifact, ProfileBin, ScenarioArtifact, ZoneArtifact,
78};
79#[cfg(feature = "calendar")]
80pub use calendar::{ExchangeCalendar, SessionSegment};
81pub use checkpoint::{Checkpoint, CheckpointStore};
82pub use clustering::{kmeans_1d, KMeansResult, RobustBand, RollingRobustThreshold};
83pub use event::{AlertDeduplicator, AlertEvent, EventPhase};
84pub use execution::{
85    submit_bracket, ExecutionCosts, Fill, FillSimulator, FillSimulatorConfig, Order, OrderKind,
86    OrderSide, OrderStatus, Position,
87};
88pub use graph::{ComposedNode, CompositionGraph, GraphError, GraphIndicator, Leaf};
89pub use indicator::registry::{
90    build, build_checked, build_typed, catalog, ParamValue, RegistryError, TypedParams,
91};
92pub use indicator::{Indicator, IndicatorAlert, IndicatorOutput};
93pub use intrabar::{IntrabarGroup, IntrabarGrouper};
94pub use lifecycle::{BarLifecycle, LifecycleRunner};
95pub use model::{
96    Bar, BarQuality, BarValidationError, InstrumentMeta, InstrumentMetaError, MarketRegime,
97    QualifiedBar, Resolution, RiskPlan, Source, SupportResistanceZone, ZoneKind,
98};
99pub use parity::{
100    ParityFixture, ParityFixtureError, ParityFixtureRow, ParityOutcome, ParityReport,
101};
102pub use regime::classify_regime;
103pub use regime_advanced::{
104    AdaptiveCycleOutput, AdaptiveCycleTracker, HysteresisBand, HysteresisLevel,
105    PredictabilityTracker, RegimeMarkovModel, RegimePersistenceOutput, RegimePersistenceTracker,
106};
107pub use risk::{
108    position_size, AccountRisk, PositionSizeResult, ScaleInStep, ScaleOutStep, ScalePlan,
109    StopDecision, StopManager,
110};
111pub use runner::{run_batch, run_batch_checked, TimestampedOutput};
112pub use scenario::{ScenarioStateMachine, ScenarioStatus, StageConfig};
113pub use scoring::{
114    aggregate_subscores, aggregate_subscores_with_instrument, score_indicator, WeightPreset,
115};
116pub use series::{CumulativeSum, Series, SeriesEvents};
117pub use session::{SessionConfig, SessionConfigError, SessionTracker};
118pub use signal::{CompositeSignal, PermissionGrade, SignalDirection, SubScore};
119pub use stats::{correlation, linear_regression};
120pub use structure::{find_sr_zones, ManagedZone, ZoneRegistry, ZoneState};
121pub use timeframe::{BarResampler, ConfirmedResampler, Timeframe, TimeframeError};