Files
Aura/crates/aura-std/src/lib.rs
T
Brummel f5e00a9c72 feat(0085): per-cycle-held accrual — CarryCost + ChargeMode (approach B)
Cycle 5 of milestone #148 (cost-model graph in R): the per-cycle-held accrual
mechanism — C10's "per-cycle-held factors accrue over the hold". A carry/funding cost
is charged for every cycle a position is held, so the net_r_equity equity curve bleeds
continuously over the hold (approach B, "ja, mach B") rather than stepping at close.

Mechanism (logged on #148): ChargeMode { AtClose, PerHeldCycle } is a property of the
cost factor, read by the one shared CostRunner (no second runner type). The AtClose arm
is the pre-cycle-5 eval tokens VERBATIM (IEEE-754 byte-identity). The PerHeldCycle arm
accrues `per` into `acc` each held cycle, dumps the accrued total into `cum` at close
(resetting acc), and marks the open position via a growing open_cost_in_r. The bleed
lives in open_cost_in_r, which the net_r_equity tap already subtracts — so summarize_r
and the CLI net_eq wiring are UNCHANGED, and the cycle-0083/0084 net_expectancy_r
goldens (-614.3134020253314 flat, -615.0304388396047 composed) + the C18 no-cost golden
stay byte-identical.

CarryCost is a ConstantCost twin differing only in charge_mode() -> PerHeldCycle (a
labelled stress parameter, the flat base of the accrual family). Wired through the
existing cost_graph/CostSum aggregation; a per-trade ConstantCost and a per-held-cycle
CarryCost compose in one run (the costs sum per-field — the composed golden is exactly
the sum of the two single-cost charges). New run-path --carry-per-cycle flag
(sweep/walkforward/mc pass None, as the existing cost flags do).

Tests: 2 RED-first unit B-proofs (open_cost grows over the hold, dumps the total at
close, acc resets between trades — the discriminator a scalar net_expectancy_r cannot
see); the CarryCost twin's 5 unit tests; 2 captured net_expectancy_r goldens
(-768.2095026600887 carry, -1383.7939051991182 composed); a net_r_equity-bleeds-over-
the-hold integration test (the terminal open hold's r_equity-net_r_equity gap strictly
grows); plus negative-rate-refused-exit-2, monotone-in-rate, and zero-rate-exactly-free
guards.

Verified: cargo test --workspace (0 failures), cargo build --workspace, cargo clippy
--workspace --all-targets -- -D warnings clean. summarize_r / aura-analysis untouched.
Deferred to later #148 cycles (logged there): notional-based carry, the calendar-aware
overnight swap, sweep-path cost.

refs #148
2026-06-29 01:00:51 +02:00

86 lines
2.4 KiB
Rust

//! `aura-std` — the standard node library shipped with the engine.
//!
//! The universal, batteries-included building blocks every project gets for
//! free: common indicators (SMA, ATR, RSI, …), resamplers, the `SessionNode`,
//! standard combinators, the legacy `SimBroker` pip yardstick, and cost-model
//! nodes authored against the [`CostNode`] trait + [`CostRunner`] adapter
//! (`ConstantCost`, `VolSlippageCost`, …, in R — C10). Depends only on `aura-core`
//! (the shared contract).
//!
//! This is the top tier of the three-tier node-reuse model (contract C16):
//!
//! - `aura-std` — universal blocks, here, ship with the engine;
//! - shared node crates — cross-project-reusable blocks, in their own repos,
//! pulled in as cargo git dependencies;
//! - project-local `nodes/` — experimental, project-specific blocks.
//!
//! The first block lands with the walking skeleton: [`Sma`], the simple moving
//! average — a worked producer node proving the `aura-core` `Node` contract.
mod add;
mod and;
mod bias;
mod carry_cost;
mod constant_cost;
mod cost;
mod cost_sum;
mod delay;
mod ema;
mod eqconst;
mod gated_recorder;
mod gt;
mod latch;
mod lincomb;
mod longonly;
mod mul;
mod position_management;
mod recorder;
mod resample;
mod rolling_max;
mod rolling_min;
mod series_reducer;
mod session;
mod sim_broker;
mod sizer;
mod sma;
mod sqrt;
mod stop_rule;
mod sub;
mod vol_slippage_cost;
pub use add::Add;
pub use and::And;
pub use bias::Bias;
pub use carry_cost::CarryCost;
pub use constant_cost::ConstantCost;
pub use cost::{
cost_node_builder, ChargeMode, CostNode, CostRunner, COST_FIELD_NAMES, COST_WIDTH,
GEOMETRY_WIDTH,
};
pub use cost_sum::CostSum;
pub use delay::Delay;
pub use ema::Ema;
pub use eqconst::EqConst;
pub use gated_recorder::GatedRecorder;
pub use gt::Gt;
pub use latch::Latch;
pub use lincomb::LinComb;
pub use longonly::LongOnly;
pub use mul::Mul;
pub use position_management::{
ExitReason, FIELD_NAMES as PM_FIELD_NAMES, PositionManagement, RECORD_KINDS as PM_RECORD_KINDS,
WIDTH as PM_WIDTH,
};
pub use recorder::Recorder;
pub use resample::Resample;
pub use rolling_max::RollingMax;
pub use rolling_min::RollingMin;
pub use series_reducer::SeriesReducer;
pub use session::Session;
pub use sim_broker::SimBroker;
pub use sizer::Sizer;
pub use sma::Sma;
pub use sqrt::Sqrt;
pub use stop_rule::FixedStop;
pub use sub::Sub;
pub use vol_slippage_cost::VolSlippageCost;