probability function

double probability(
  1. PricerInputs inputs,
  2. double strike,
  3. String side
)

Binary probability at strike for the given side ('up' = P(>strike), 'down' = 1 − up).

Implementation

double probability(PricerInputs inputs, double strike, String side) {
  // Anything not exactly 'up'/'down' must throw rather than silently price
  // the DOWN side: `side` arrives from UI state, JSON, or a DB column at
  // runtime, where a type alone does not protect (same guard as
  // `binaryRangeTicks`).
  if (side != 'up' && side != 'down') {
    throw PredictInputError("side must be 'up' or 'down', got '$side'");
  }
  final up = upProbability(inputs, strike);
  return side == 'up' ? up : 1 - up;
}