Calculate the Half Spread
Updated
Problem statement
A market-making model starts with a base half spread, then adjusts it for volatility and liquidity. Higher volatility must make the quote wider, while higher liquidity must make it narrower.
Implement calculateHalfSpread and compute:
modeledHalfSpread = baseHalfSpread * (1 + volatility) / liquidityScore
Each input is a decimal value with at most seven digits after the decimal point; interpret those decimal values exactly. Return the larger of modeledHalfSpread and minimumHalfSpread. Round the result to six decimal places; an exact halfway case rounds upward.
Function
calculateHalfSpread(baseHalfSpread: double, volatility: double, liquidityScore: double, minimumHalfSpread: double) → doubleExamples
Example 1
baseHalfSpread = 0.02volatility = 0.5liquidityScore = 0.75minimumHalfSpread = 0.03return = 0.04The modeled value is 0.02 * 1.5 / 0.75 = 0.04. It is larger than the minimum 0.03.
Example 2
baseHalfSpread = 0.01volatility = 0.1liquidityScore = 1.0minimumHalfSpread = 0.02return = 0.02The modeled value is 0.011, so the minimum half spread 0.02 becomes the result.
Constraints
0 < baseHalfSpread <= 1000 <= volatility <= 1010^-6 <= liquidityScore <= 10 <= minimumHalfSpread <= 100- Every input has at most seven digits after the decimal point.
- The unrounded modeled value is at most
10^9.
More Millennium Online Assessment questions
- Debug the Impact ModelOA · Seen Sep 2026
- Debug the Risk-Limit QuoterOA · 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
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Costliest ChocolateRippling · OARippling interview questions
- Distinct Chapters Missed During a Cyclic AbsenceVisa · OAVisa interview questions
- Count Palindromic Base RepresentationsSEDEMAC · OA
- Reduce a Number to One DigitAccenture · OAAccenture interview questions
- Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
- Plus Mult ArrayIBM · OAIBM interview questions
- Product Minus Sum of DigitsTikTok · OATikTok interview questions
- Progressive Tax CalculatorInteractive Brokers · OA