Problem · Math

Quote One Request

Learn this problem
EasyMillennium logoMillenniumNEW GRADINTERNOA

Problem 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) → double

Examples

Example 1

reference = 100.0halfSpread = 0.05penaltyPerUnit = 0.0002quantity = 100side = "BUY"tickSize = 0.01return = 100.07

The 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.92

The 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^8
  • 0 <= halfSpread <= 10^6
  • 0 <= penaltyPerUnit <= 10^3
  • 1 <= quantity <= 10^6
  • side is either BUY or SELL.
  • 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.

More Millennium problems

drafts saved locally
public double quoteOneRequest(double reference, double halfSpread, double penaltyPerUnit, int quantity, String side, double tickSize) {
    // write your code here
}
reference100.0
halfSpread0.05
penaltyPerUnit0.0002
quantity100
side"BUY"
tickSize0.01
expected100.07
checking account