| 1 | # dynamic_discount.py |
| 2 | # Proprietary elasticity-based discount model. Confidential -- Cascadia Retail Co. |
| 3 | # Do not share outside Pricing Strategy team. See PRICING-RFC-0042 for derivation. |
| 4 | |
| 5 | import numpy as np |
| 6 | |
| 7 | # Segment-level price elasticity coefficients, fitted quarterly against |
| 8 | # 3 years of transaction history. Values below are trade secret. |
| 9 | ELASTICITY_COEF = { |
| 10 | "new_customer": -2.14, |
| 11 | "loyalty_gold": -0.61, |
| 12 | "cart_abandoner": -3.87, |
| 13 | "price_sensitive_cluster_4": -4.52, |
| 14 | } |
| 15 | |
| 16 | def compute_discount(segment, base_price, inventory_pressure, days_to_season_end): |
| 17 | """ |
| 18 | Returns the optimal discount percentage (0-1) for a given customer |
| 19 | segment that maximizes expected margin, not just conversion. |
| 20 | Internal only -- exposing this logic lets competitors reverse-engineer |
| 21 | our margin floor. |
| 22 | """ |
| 23 | e = ELASTICITY_COEF.get(segment, -1.0) |
| 24 | urgency = np.clip(1 - (days_to_season_end / 45), 0, 1) |
| 25 | raw_discount = (abs(e) / 10) * (0.4 + 0.6 * inventory_pressure) * (0.5 + 0.5 * urgency) |
| 26 | margin_floor = 0.145 # hard floor set by Finance -- never breach |
| 27 | max_discount = 1 - margin_floor |
| 28 | return float(np.clip(raw_discount, 0, max_discount)) |