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

Added float precision check in floor price comparision #3042

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

pm-jaydeep-mohite
Copy link
Contributor

bidadjustment factor: 0.9

original bidfloor: 4 USD

bidfloor in partner request 4/0.9 = 4.444444444444445

bid returned by partner : 4.44 USD

final bid price : 4.44-10% = 3.996 USD

in above scenario bid was getting rejected since bid price 3.99 is less than bidfloor 4 even when bidder returned bid which is equal to the bidfloor in request.

name string
bidFloor float64
bidPrice float64
precision float64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The precision field does not seem to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused variable

@@ -154,6 +155,14 @@ func enforceFloorToBids(bidRequestWrapper *openrtb_ext.RequestWrapper, seatBids
return seatBids, errs, rejectedBids
}

// isBidPriceLowerThanBidfloor checks for bid price with bid floor with given precision
func isBidPriceLowerThanBidfloor(bidFloor float64, bidPrice float64) bool {
if bidPrice < bidFloor && math.Abs(bidFloor-bidPrice) > floorPrecision {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this not be the same as (bidPrice + floorPrecision) < bidFloor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected

@hhhjort
Copy link
Collaborator

hhhjort commented Aug 22, 2023

In your example, the bid floor is 4.444444444444445. If you round to the nearest cent, you round down, so 4.44 is technically less than 4.444444444444445. The bidder would have to bid 4.45 in order to win in the old code, which is the lowest whole cent value that is at or above the given bid floor.

In practice, I don't see this mattering unless the bidder knows both the exact bid floor and the bid adjustment value applied to them. Knowing the bid floor is common, but I thought publishers typically wish to keep the bid adjustment values private from the bidders. Is it common for bidders to know the bid adjustment value that is getting applied to them?

@hhhjort hhhjort self-assigned this Aug 22, 2023
@pm-jaydeep-mohite
Copy link
Contributor Author

In your example, the bid floor is 4.444444444444445. If you round to the nearest cent, you round down, so 4.44 is technically less than 4.444444444444445. The bidder would have to bid 4.45 in order to win in the old code, which is the lowest whole cent value that is at or above the given bid floor.

In practice, I don't see this mattering unless the bidder knows both the exact bid floor and the bid adjustment value applied to them. Knowing the bid floor is common, but I thought publishers typically wish to keep the bid adjustment values private from the bidders. Is it common for bidders to know the bid adjustment value that is getting applied to them?

Precision margin is required when precision loss occurred due to bidAdjustment for any bidder is present, otherwise no need of precision margin.

Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hhhjort hhhjort merged commit 4c10fac into prebid:master Sep 5, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants