Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Currency Conversion #3566

Open
bretg opened this issue Mar 12, 2024 · 1 comment
Open

Enhanced Currency Conversion #3566

bretg opened this issue Mar 12, 2024 · 1 comment
Labels
good first issue Issues which are good for new contributors looking to get involved in the project med priority PBS-Go

Comments

@bretg
Copy link
Contributor

bretg commented Mar 12, 2024

The Prebid.js currency module is able to convert any of the currencies in the file to any other currency using USD (or GBP) as an intermediate.

Apparently this feature was not implemented in PBS, at least PBS-Java. We're seeing this error:

Unable to convert from currency NOK to desired ad server currency SEK

Here's an example currency rates definition:

  "rates": {
    "USD": {
      "USD": 1,
      "JPY": 146.83324180853012,
      "BGN": 1.7900421014094818,
      "CZK": 23.175910671792053,
      "DKK": 6.8233571297821705,
      "GBP": 0.7798645432912319,
      "HUF": 362.02635914332785,
      "PLN": 3.917719201903716,
      "RON": 4.543657331136738,
      "SEK": 10.238422112392458,
      "CHF": 0.8780889621087314,
      "ISK": 136.28043199707122,
      "NOK": 10.470895112575509,
      "TRY": 32.001647446457994,
      "AUD": 1.5143693941058027,
      "BRL": 4.992586490939044,
      "CAD": 1.3502654219293428,
      "CNY": 7.182042833607908,
      "HKD": 7.8198791872597475,
      "IDR": 15486.847885777046,
      "ILS": 3.6087314662273475,
      "INR": 82.7471169686985,
      "KRW": 1311.056196229178,
      "MXN": 16.802947098663736,
      "MYR": 4.683964854475563,
      "NZD": 1.6204466410397218,
      "PHP": 55.36976020501556,
      "SGD": 1.3303130148270181,
      "THB": 35.410031118433096,
      "ZAR": 18.69641222771371,
      "EUR": 0.9152480322167307
    },

If desired destination currency is not present, PBS should:

  1. loop through the rate conversions available
  2. If source and destination currencies are present in a single object under an intermediate currency, use the first one available:
    1. destCurBidPrice=sourceCurBidPrice * (destCurRate/sourceCurRate)
    2. apply bid CPM adjustments as needed

e.g. a bid of 5 NOK would be 5 * (10.238422112392458 / 10.470895112575509) = 4.89 SEK

@bretg
Copy link
Contributor Author

bretg commented Apr 4, 2024

Done with PBS-Java 2.15

@bretg bretg added the PBS-Go label Apr 4, 2024
@bsardo bsardo added the good first issue Issues which are good for new contributors looking to get involved in the project label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues which are good for new contributors looking to get involved in the project med priority PBS-Go
Projects
Status: Ready for Dev
Development

No branches or pull requests

2 participants