Function Signature
Description
Calculates the Purchasing Power Parity (PPP) adjusted fair price in USD for a given country. This function applies a country-specific price level ratio to adjust your pricing based on local purchasing power, with optional smoothing and rounding strategies.Parameters
The base price in USD (International Dollars). Must be a non-negative number.Validation: Throws an error if not a number or if negative.
The ISO country code (2-letter or 3-letter). Case-insensitive.Examples:
"US", "GB", "IND", "br" (automatically converted to uppercase)Validation: Throws an error if not a string.A value between 0 and 1 to normalize the price discount.
0= Raw PPP (Theoretical / Maximum Discount)0.2= Default (Balanced Discount)1= No adjustment (Original Price)
Rounding strategy for the final price. Must be one of:
'none'= Full precision (no rounding)'currency'= Standard currency rounding (2 decimal places)'pretty'= Marketing-friendly rounding:- < $10: Round to x.99 or x.49 (e.g., 4.31 → 4.49, 7.89 → 7.99)
- 100: Round to nearest whole number (e.g., 43.2 → 45, 48.7 → 49)
- > $100: Round to nearest 5 (e.g., 132 → 130, 138 → 140)
Return Value
The PPP-adjusted price in USD.Returns
null if:- The country code is not found in the database
- The country code is invalid (though validation errors are thrown first)
How It Works
The function applies the following formula:factor is the country’s Price Level Ratio from the World Bank data.
Examples
- Basic Usage
- Currency Rounding
- Pretty Rounding
- Smoothing Variations
- Error Handling
Type Definitions
Related
- ppp.factor() - Get the raw PPP factor for a country