API overview
The entry points used in these docs. Root-level re-exports are the preferred API; item-level documentation is generated by rustdoc.
Note
The generated documentation for every public item is on
docs.rs, including the optional calendar module. For an
unreleased state, run cargo doc --open in a clone of the repository.
Overview
Indicators
catalogpub fn catalog() -> Vec<IndicatorCatalogEntry>Every registered indicator with name, description and default parameters.
output_unitpub fn output_unit(name: &str) -> IndicatorUnitWhat an indicator’s primary output is quoted in: Price, Ratio, Volume or Unitless.
Price means a price level and belongs on the price axis; everything else needs its own scale.
Unknown names return Unitless.
build_checkedpub fn build_checked(
name: &str,
params: &HashMap<String, f64>,
) -> Result<Box<dyn Indicator>, RegistryError>Parameters
name&str- A name from catalog(), e.g. "rsi".
params&HashMap<String, f64>- Parameter overrides. Missing keys take the defaults.
Indicatorpub trait Indicator: Send + Sync {
fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>;
fn on_checked_bar(&mut self, bar: &Bar) -> Result<Option<IndicatorOutput>, BarValidationError>;
fn alerts(&self) -> Vec<IndicatorAlert>;
fn warmup_period(&self) -> usize;
fn reset(&mut self);
}See Indicators for the output fields.
pair_catalogpub fn pair_catalog() -> Vec<IndicatorCatalogEntry>The indicators that read two bar series (relative_strength, correlation). None of them is in
catalog(); input_series(name) returns Some(2) for these names and Some(1) for the others.
build_pair_checkedpub fn build_pair_checked(
name: &str,
params: &HashMap<String, f64>,
) -> Result<Box<dyn PairIndicator>, RegistryError>Parameters
name&str- A name from pair_catalog(), e.g. "relative_strength".
params&HashMap<String, f64>- Parameter overrides. Missing keys take the defaults.
run_pair_batchpub fn run_pair_batch<P: PairIndicator + ?Sized>(
indicator: &mut P,
bars: &[Bar],
reference: &[Bar],
) -> Vec<TimestampedOutput>Pairs the bars of the two series by timestamp and returns one entry per bar of bars. See
Two series for the pairing rules.
Market regime
classify_regimepub fn classify_regime(bars: &[Bar], adx_val: f64, atr_val: f64) -> MarketRegimeParameters
bars&[Bar]- History up to the current bar; at least 21 bars.
adx_valf64- Current ADX value.
atr_valf64- Current ATR as a fraction of price (ATR / close).
Composite scoring
score_indicatorpub fn score_indicator(name: &str, output: &IndicatorOutput, alerts: &[IndicatorAlert]) -> SubScoreaggregate_subscorespub fn aggregate_subscores(
subscores: Vec<SubScore>,
weights: Option<&HashMap<String, f64>>,
regime: MarketRegime,
sr_zones: Vec<SupportResistanceZone>,
latest_bar: Option<&Bar>,
atr_val: f64,
) -> CompositeSignalSee Composite scoring for thresholds and grades.
Visualisation
kestrel-chartkit draws nothing for presentation; see Visualising results for chartlet and kestrel-loom.
viz::scene::Scenepub struct Scene { /* panes, axes and objects */ }The renderer-neutral scene model for overlays (markers, levels, zones) that kestrel-loom draws.
viz::render_chart_svg / viz::render_scene_svgpub fn render_chart_svg(data: &ChartRenderData, width: u32, height: u32) -> StringQuick-look SVG for tests and debugging, not a presentation layer.
Options at expiry
OptionExpiryPositionpub struct OptionExpiryPosition {
pub option_type: OptionType, // Call | Put
pub side: PositionSide, // Long = bought, Short = sold
pub strike: f64,
pub premium: f64, // per unit of the underlying, the positive amount
pub contract_size: f64, // 1.0 = every amount per unit
}One option position held to expiry. The result at expiry needs no pricing model.
option_expiry_resultpub fn option_expiry_result(
position: &OptionExpiryPosition,
underlying: f64,
) -> Result<f64, OptionError>(intrinsic - premium) * contract_size for the bought option and its negative for the sold
one, with intrinsic = max(S - K, 0) for a call and max(K - S, 0) for a put. Positive is a
profit of the position’s holder.
option_expiry_profilepub fn option_expiry_profile(
position: &OptionExpiryPosition,
) -> Result<OptionExpiryProfile, OptionError>break_even (K + P for a call, K - P for a put), max_profit and max_loss over every
price from 0 up. Both are a PayoffBound: Limited(amount) or Unlimited, so no infinite
number reaches an axis or a JSON document. max_loss is a positive amount.
option_expiry_seriespub fn option_expiry_series(
position: &OptionExpiryPosition,
from: f64,
to: f64,
points: usize,
) -> Result<Vec<OptionExpiryPoint>, OptionError>The result over points equally spaced prices from from to to, both included, for a payoff
diagram. The line through the points shows the bend at the strike exactly when the strike is
one of them.
Beyond these docs
The crate also exports trade statistics (stats, evaluation), option and bond valuation
(option, finance, valuation), portfolio risk and stress (portfolio, risk, stress),
bar transforms such as Heikin-Ashi (transform) and the optional exchange calendar (calendar).
The README gives an overview.