Quote One Request
Learn this problemProblem statement
Quote one client request around a reference price. First add a size penalty to the supplied half spread:
adjustedHalfSpread = halfSpread + penaltyPerUnit * quantity
For a BUY request, form the ask price reference + adjustedHalfSpread and round it upward to the next multiple of tickSize. For a SELL request, form the bid price reference - adjustedHalfSpread and round it downward to the next multiple of tickSize. A price already on a tick remains unchanged.
Every decimal input is exact and has at most seven digits after the decimal point. Return the tick-rounded quote rounded half upward to six decimal places.
Function
quoteOneRequest(reference: double, halfSpread: double, penaltyPerUnit: double, quantity: int, side: String, tickSize: double) → doubleExamples
Example 1
reference = 100.0halfSpread = 0.05penaltyPerUnit = 0.0002quantity = 100side = "BUY"tickSize = 0.01return = 100.07The adjusted half spread is 0.05 + 0.0002 * 100 = 0.07. The raw ask 100.07 is already on a 0.01 tick.
Example 2
reference = 100.0halfSpread = 0.05penaltyPerUnit = 0.0002quantity = 125side = "SELL"tickSize = 0.01return = 99.92The adjusted half spread is 0.075, so the raw bid is 99.925. Rounding downward to a 0.01 tick gives 99.92.
Constraints
0 < reference <= 2 * 10^80 <= halfSpread <= 10^60 <= penaltyPerUnit <= 10^31 <= quantity <= 10^6sideis eitherBUYorSELL.10^-6 <= tickSize <= 10^3.- Each decimal input has at most seven digits after the decimal point.
- The raw quote and the rounded quote are positive and at most
2 * 10^8.