FastPrepDebug the Risk-Limit Quoter
Problems/Debug the Risk-Limit Quoter

Debug the Risk-Limit Quoter

Millennium logoMillennium● MediumNEW GRADINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the reported debugging question. The buggy Java code from the report stays word for word in the statement. For working solutions, we turn the decimal inputs into whole numbers on an exact 10^-7 grid. The limits keep the input scaling clear. They also keep the derived quote values small enough for Python integers, Java BigInteger, and C++ __int128.

A shipped risk-limit quoter contains two defects: its inventory skew can push a position farther from zero, and it can accept a trade exactly at the hard risk cap. Repair the supplied implementation without changing its interface.

The source-backed Java translation of the shipped starter is reproduced below for diagnosis. It intentionally retains the buggy behavior:

public String[] priceQuote(int currentInventory, String side, int quantity, double reference, double halfSpread, int baseLimit, double softFraction, double skewCoefficient) {
    int signedQuantity = side.equals("BUY") ? quantity : -quantity;
    long projected = (long) currentInventory + signedQuantity;
    double hard = baseLimit;
    double soft = softFraction * hard;
    if (Math.abs(projected) > hard) {
        return new String[]{"reject", "null"};
    }
    double skew = skewCoefficient * currentInventory;
    double quote = side.equals("BUY")
        ? reference + halfSpread + skew
        : reference - halfSpread + skew;
    String action = "accept";
    if (Math.abs(projected) > soft) {
        action = "widen";
        quote += side.equals("BUY") ? halfSpread : -halfSpread;
    }
    double rounded = Math.floor(quote * 1000000.0 + 0.5) / 1000000.0;
    return new String[]{action, String.format(java.util.Locale.US, "%.6f", rounded)};
}

For this quoter, apply these corrected rules in order:

  1. Use signedQuantity = +quantity for BUY and -quantity for SELL, then compute projected = currentInventory + signedQuantity.
  2. Set hard = baseLimit and soft = softFraction * hard. If abs(projected) >= hard, return ["reject", "null"].
  3. Otherwise use skew = -skewCoefficient * currentInventory. The base BUY quote is reference + halfSpread + skew; the base SELL quote is reference - halfSpread + skew.
  4. If abs(projected) > soft, return action widen after adding another halfSpread for BUY or subtracting another halfSpread for SELL. Otherwise return action accept.

The two source-backed risk defects to diagnose are the hard-cap comparison and skew sign shown above. For the execution contract, every decimal input is exact and has at most seven digits after the decimal point; do not copy the shipped binary rounding expression into the repaired implementation. Return a two-element string array [action, quote]. A non-rejected quote is rounded half upward to six decimal places and serialized with exactly six digits after the decimal point.

Function

priceQuote(currentInventory: int, side: String, quantity: int, reference: double, halfSpread: double, baseLimit: int, softFraction: double, skewCoefficient: double) → String[]

Examples

Example 1

currentInventory = 900side = "BUY"quantity = 100reference = 100.0halfSpread = 0.05baseLimit = 1000softFraction = 0.6skewCoefficient = 0.001return = ["reject","null"]

The projected inventory is exactly 1000. Equality at the hard cap is rejected.

Example 2

currentInventory = 500side = "SELL"quantity = 100reference = 100.0halfSpread = 0.05baseLimit = 1000softFraction = 0.6skewCoefficient = 0.001return = ["accept","99.450000"]

Projected inventory is 400, below the soft limit. Correct skew is -0.5, so the SELL quote is 100 - 0.05 - 0.5 = 99.45.

Constraints

  • -10^9 <= currentInventory <= 10^9
  • side is either BUY or SELL.
  • 1 <= quantity <= 10^9
  • 0 < reference <= 2 * 10^8 and 0 <= halfSpread <= 10^6.
  • 1 <= baseLimit <= 10^9 and 0 <= softFraction <= 1.
  • 0 <= skewCoefficient <= 10^3.
  • Each decimal input has at most seven digits after the decimal point.
  • Every non-rejected quote is positive and at most 10^12.

Source note: The original assessment screenshot supplies the debugging setup, post-trade inventory direction, risk-cap behavior, and shipped Python implementation context.

More Millennium Online Assessment questions

  • Calculate the Half SpreadOA · Seen Sep 2026
  • Debug the Impact ModelOA · Seen Sep 2026
  • Hedge Inventory with Return CovarianceOA · Seen Sep 2026
  • Quote One RequestOA · Seen Sep 2026
  • Risk Limits and Inventory SkewOA · Seen Sep 2026
  • Track the Book and Mark Final PnLOA · Seen Sep 2026
  • Clean the TapeOA · Seen Sep 2026
  • Client Markout AnalysisOA · Seen Sep 2026
  • Debug Fair-Value LookupOA · Seen Sep 2026
  • Debug the Tape CleanerOA · Seen Sep 2026

Similar questions at other companies

  • Bold Play to Reach a GoalSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Last Object Exit TimeIBM · OAIBM interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Find Total CostJP Morgan Chase · OAJP Morgan Chase interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA
  • Prime Factor VisitationMaven Securities · OAMaven Securities interview questions
  • Proportional Momentum Investment StatisticsOptiver · OAOptiver interview questions

Millennium interview experiences

  • Millennium Full Stack Engineer Java Interview: 1 Experience
All Millennium interview questionsSee Millennium hiring insights
Saved
class Solution {
    public String[] priceQuote(int currentInventory, String side, int quantity, double reference, double halfSpread, int baseLimit, double softFraction, double skewCoefficient) {
        // write your code here
    }
}
Checking account…