{
  "schema_version": "1.0.0",
  "topic_id": "D06-F01-A01",
  "tolerance": 1e-12,
  "valid_cases": [
    {
      "name": "canonical_bullish",
      "direction_epsilon": 0,
      "input": {
        "timestamp": "2026-01-05T10:00:00Z",
        "instrument_id": "SYNTH:ABC",
        "interval": "5m",
        "open": 100,
        "high": 108,
        "low": 97,
        "close": 105,
        "is_closed": true,
        "volume": 1200,
        "price_basis": "raw-trades",
        "session": "synthetic-utc"
      },
      "expected": {
        "body_high": 105,
        "body_low": 100,
        "body": 5,
        "upper_shadow": 3,
        "lower_shadow": 3,
        "range": 11,
        "direction": "bullish",
        "body_to_range": 0.45454545454545453,
        "upper_shadow_to_range": 0.2727272727272727,
        "lower_shadow_to_range": 0.2727272727272727,
        "open_position": 0.2727272727272727,
        "close_position": 0.7272727272727273
      }
    },
    {
      "name": "bearish",
      "direction_epsilon": 0,
      "input": {
        "timestamp": "2026-01-05T10:05:00Z",
        "instrument_id": "SYNTH:ABC",
        "interval": "5m",
        "open": 105,
        "high": 109,
        "low": 98,
        "close": 101,
        "is_closed": true
      },
      "expected": {
        "body_high": 105,
        "body_low": 101,
        "body": 4,
        "upper_shadow": 4,
        "lower_shadow": 3,
        "range": 11,
        "direction": "bearish",
        "body_to_range": 0.36363636363636365,
        "upper_shadow_to_range": 0.36363636363636365,
        "lower_shadow_to_range": 0.2727272727272727,
        "open_position": 0.6363636363636364,
        "close_position": 0.2727272727272727
      }
    },
    {
      "name": "exact_neutral",
      "direction_epsilon": 0,
      "input": {
        "timestamp": "2026-01-05T10:10:00Z",
        "instrument_id": "SYNTH:ABC",
        "interval": "5m",
        "open": 100,
        "high": 102,
        "low": 98,
        "close": 100,
        "is_closed": true
      },
      "expected": {
        "body_high": 100,
        "body_low": 100,
        "body": 0,
        "upper_shadow": 2,
        "lower_shadow": 2,
        "range": 4,
        "direction": "neutral",
        "body_to_range": 0,
        "upper_shadow_to_range": 0.5,
        "lower_shadow_to_range": 0.5,
        "open_position": 0.5,
        "close_position": 0.5
      }
    },
    {
      "name": "flat_zero_range",
      "direction_epsilon": 0,
      "input": {
        "timestamp": "2026-01-05T10:15:00Z",
        "instrument_id": "SYNTH:ABC",
        "interval": "5m",
        "open": 100,
        "high": 100,
        "low": 100,
        "close": 100,
        "is_closed": true
      },
      "expected": {
        "body_high": 100,
        "body_low": 100,
        "body": 0,
        "upper_shadow": 0,
        "lower_shadow": 0,
        "range": 0,
        "direction": "neutral",
        "body_to_range": null,
        "upper_shadow_to_range": null,
        "lower_shadow_to_range": null,
        "open_position": null,
        "close_position": null
      }
    },
    {
      "name": "negative_prices",
      "direction_epsilon": 0,
      "input": {
        "timestamp": "2026-01-05T10:20:00Z",
        "instrument_id": "SYNTH:NEG",
        "interval": "5m",
        "open": -10,
        "high": -5,
        "low": -20,
        "close": -15,
        "is_closed": true
      },
      "expected": {
        "body_high": -10,
        "body_low": -15,
        "body": 5,
        "upper_shadow": 5,
        "lower_shadow": 5,
        "range": 15,
        "direction": "bearish",
        "body_to_range": 0.3333333333333333,
        "upper_shadow_to_range": 0.3333333333333333,
        "lower_shadow_to_range": 0.3333333333333333,
        "open_position": 0.6666666666666666,
        "close_position": 0.3333333333333333
      }
    },
    {
      "name": "epsilon_neutral",
      "direction_epsilon": 0.01,
      "input": {
        "timestamp": "2026-01-05T10:25:00Z",
        "instrument_id": "SYNTH:ABC",
        "interval": "5m",
        "open": 100,
        "high": 101,
        "low": 99,
        "close": 100.005,
        "is_closed": false
      },
      "expected": {
        "body_high": 100.005,
        "body_low": 100,
        "body": 0.0049999999999954525,
        "upper_shadow": 0.9950000000000045,
        "lower_shadow": 1,
        "range": 2,
        "direction": "neutral",
        "body_to_range": 0.0024999999999977263,
        "upper_shadow_to_range": 0.4975000000000023,
        "lower_shadow_to_range": 0.5,
        "open_position": 0.5,
        "close_position": 0.5024999999999977
      }
    }
  ],
  "invalid_cases": [
    {
      "name": "high_below_close",
      "input": {"open": 100, "high": 104, "low": 99, "close": 105},
      "direction_epsilon": 0
    },
    {
      "name": "low_above_open",
      "input": {"open": 100, "high": 105, "low": 101, "close": 104},
      "direction_epsilon": 0
    },
    {
      "name": "missing_close",
      "input": {"open": 100, "high": 105, "low": 99},
      "direction_epsilon": 0
    },
    {
      "name": "boolean_price",
      "input": {"open": true, "high": 105, "low": 99, "close": 104},
      "direction_epsilon": 0
    },
    {
      "name": "non_finite_string",
      "input": {"open": 100, "high": "Infinity", "low": 99, "close": 104},
      "direction_epsilon": 0
    },
    {
      "name": "negative_epsilon",
      "input": {"open": 100, "high": 105, "low": 99, "close": 104},
      "direction_epsilon": -0.01
    },
    {
      "name": "non_object_candle",
      "input": null,
      "direction_epsilon": 0
    },
    {
      "name": "invalid_closed_state",
      "input": {"open": 100, "high": 105, "low": 99, "close": 104, "is_closed": "yes"},
      "direction_epsilon": 0
    },
    {
      "name": "invalid_timestamp",
      "input": {"open": 100, "high": 105, "low": 99, "close": 104, "timestamp": 123},
      "direction_epsilon": 0
    },
    {
      "name": "invalid_volume",
      "input": {"open": 100, "high": 105, "low": 99, "close": 104, "volume": "1200"},
      "direction_epsilon": 0
    }
  ]
}
