{
  "schemaVersion": 1,
  "slug": "car-trade-in-value-calculator",
  "category": "automotive",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "244ca2acec8e8f9d7fb0ecc0d900cf94abb65723b80bb430ee6dfa80aa7a4393",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/car-trade-in-value-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "P = V × c × m × a; T = P × (1 − d ÷ 100); m = clamp[1 − (mi − mi_expected) ÷ 100000, 0.85, 1.08]",
    "vars": [
      [
        "P",
        "Modeled private-party value"
      ],
      [
        "T",
        "Modeled trade-in value"
      ],
      [
        "V",
        "Comparable market-value baseline, USD"
      ],
      [
        "c",
        "Condition factor"
      ],
      [
        "m",
        "Capped mileage factor"
      ],
      [
        "a",
        "Accident-history factor"
      ],
      [
        "d",
        "Dealer-margin percentage"
      ]
    ],
    "note": "The same condition, mileage and accident factors apply to both estimates. These are scenario assumptions, not market data or dealer quotes."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const C = { excellent:0.95, good:0.88, fair:0.78, poor:0.65 }; const A = { none:1, minor:0.9, major:0.72 }; const raw = 1-(mileage-expectedMileage)/100000; const mileageFactor = Math.max(0.85, Math.min(1.08, raw)); const privateParty = marketValue*(C[condition] || 0.88)*mileageFactor*(A[accidents] || 1); const tradeInOffer = privateParty*(1-dealerMargin/100); return { privateParty, tradeInOffer, mileageFactor };",
    "inputs": [
      {
        "name": "marketValue",
        "type": "number",
        "default": 18000,
        "min": 0,
        "max": 3000000,
        "step": 100
      },
      {
        "name": "condition",
        "type": "select",
        "default": "good",
        "options": [
          {
            "value": "excellent"
          },
          {
            "value": "good"
          },
          {
            "value": "fair"
          },
          {
            "value": "poor"
          }
        ]
      },
      {
        "name": "mileage",
        "type": "number",
        "default": 60000,
        "min": 0,
        "max": 500000,
        "step": 1000
      },
      {
        "name": "expectedMileage",
        "type": "number",
        "default": 60000,
        "min": 0,
        "max": 500000,
        "step": 1000
      },
      {
        "name": "accidents",
        "type": "select",
        "default": "none",
        "options": [
          {
            "value": "none"
          },
          {
            "value": "minor"
          },
          {
            "value": "major"
          }
        ]
      },
      {
        "name": "dealerMargin",
        "type": "number",
        "default": 12,
        "min": 0,
        "max": 40,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "privateParty",
        "precision": 0,
        "unit": "USD"
      },
      {
        "name": "tradeInOffer",
        "precision": 0,
        "unit": "USD"
      },
      {
        "name": "mileageFactor",
        "precision": 3,
        "unit": "×"
      }
    ],
    "interpret": null
  }
}
