mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-11-02 07:26:12 +00:00
Series arithmetic (lib/numerics): - Add, Sub, Mul, Div, Lag, reusing BiInputIndicatorBase at period=1 - Div publishes 0.0 (not NaN) on a zero denominator, since a non-finite ComputeError result permanently poisons the base's running sum - BiInputIndicatorBase gains Subscribe(a, b) implementing the strategy-primitives spec's time-join rule for event-chained two-input nodes Phase 0 contracts (lib/core): - TTradeContext, BracketFlags, ExitReason, TrendState, VolState - SignalConstants (DefaultEpsilon, TruthThreshold), OutOfRangePolicy - ConfirmOnClose: bar-confirmation wrapper (Section 8.6) Signal predicates (lib/signals/predicates), Phase 1: - Above, Below, Equal (ComparePredicateBase<TOp> generic comparison core) - InsideChannel, OutsideChannel, ChannelPosition (new MultiInputBase, 3-input time-join) - IsRising, IsFalling (exclude current bar, confirm-then-push window) - AtHighest, AtLowest (include current bar, rebuild-on-correction, mirrors channels/Dc) - Hysteresis, PercentDistance All new nodes ship with .cs, tests, and .md docs; indices and the StrategyPrimitives.Spec.md are updated with placement decisions and design notes. Full suite: 16730 tests, 0 failures, 0 warnings.
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
// BELOW: Less-Than Predicate
|
|
// Crisp predicate: publishes 1.0 when a < b, 0.0 otherwise, NaN while cold.
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace QuanTAlib;
|
|
|
|
/// <summary>
|
|
/// BELOW: Less-Than Predicate
|
|
/// Tests whether the left value is strictly less than the right value or a fixed scalar.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Key properties:
|
|
/// - Crisp output: exactly 1.0 (true) or 0.0 (false) while hot, NaN while cold
|
|
/// - Built on <see cref="ComparePredicateBase{TOp}"/> (a thin sealed class over
|
|
/// <see cref="BiInputIndicatorBase"/> at period = 1): rollback and NaN-substitution for the
|
|
/// two inputs come from the shared base with no extra state
|
|
/// - The scalar overload never constructs a constant child publisher
|
|
/// - Feeds triggers such as <c>CrossUnder</c> and combinators such as <c>AllOf</c>
|
|
/// </remarks>
|
|
/// <seealso href="Below.md">Detailed documentation</seealso>
|
|
[SkipLocalsInit]
|
|
public sealed class Below : ComparePredicateBase<BelowOp>
|
|
{
|
|
/// <summary>
|
|
/// Creates a Below predicate for direct pull-style updates.
|
|
/// </summary>
|
|
public Below() : base("Below", SignalConstants.DefaultEpsilon)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a Below predicate chained to two upstream publishers using the time-join rule.
|
|
/// </summary>
|
|
public Below(ITValuePublisher a, ITValuePublisher b) : this()
|
|
{
|
|
SubscribeTwo(a, b);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a Below predicate testing a stream against a fixed scalar threshold.
|
|
/// </summary>
|
|
public Below(ITValuePublisher a, double threshold) : this()
|
|
{
|
|
SubscribeScalar(a, threshold);
|
|
}
|
|
}
|