-
Notifications
You must be signed in to change notification settings - Fork 744
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
Conversation
floors/enforce_test.go
Outdated
name string | ||
bidFloor float64 | ||
bidPrice float64 | ||
precision float64 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unused variable
floors/enforce.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.