FastPrepDaily Settlement for Long and Short Positions
Problems/Daily Settlement for Long and Short Positions

Daily Settlement for Long and Short Positions

Belvedere Trading logoBelvedere Trading● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Belvedere Trading full-time online assessment. The rules for signed positions, the order of settlement, and the worked example are about 95% the same as the report. The report does not show numeric limits or the limits on the arithmetic in the middle. We added those.

A futures desk starts before day 1 with position startPosition and the previous day's settlement price startSettle. A positive position is long and a negative position is short.

For each day i:

  1. The desk holds its current position through that day's settlement. Its cash change is position * (settle[i] - previousSettle).
  2. The signed trade trade[i] takes effect at that close, after the day's cash change is calculated. A positive trade buys futures and a negative trade sells futures.
  3. The current settlement price becomes settle[i].

Return the running total settlement cash after every day.

Function

variationMargin(startPosition: int, startSettle: int, trade: int[], settle: int[]) → long[]

Examples

Example 1

startPosition = -2startSettle = 100trade = [0,5,0]settle = [110,104,95]return = [-20,-8,-35]

The initial short position earns -2 * 10 = -20 on day 1. It earns -2 * -6 = 12 on day 2 before the buy changes the position to 3, so the running total becomes -8. Day 3 contributes 3 * -9 = -27, producing -35.

Example 2

startPosition = 3startSettle = 50trade = [-1,0]settle = [55,53]return = [15,11]

Day 1 contributes 3 * 5 = 15, then the sell changes the position to 2. Day 2 contributes 2 * -2 = -4, leaving a running total of 11.

Constraints

  • 1 <= trade.length <= 10^5.
  • trade.length = settle.length.
  • -10^9 <= startPosition, trade[i] <= 10^9.
  • 1 <= startSettle, settle[i] <= 10^9.
  • Every position and returned running total fits in a signed 64-bit integer.
  • Every daily settlement cash change and every intermediate running cash total fits in a signed 64-bit integer.

More Belvedere Trading Online Assessment questions

  • Distances to CyclesOA · Seen Oct 2026
  • Minimum AmountOA · Seen Oct 2026
  • Realized PnL with Oldest Inventory FirstOA · Seen Oct 2026

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Prime Factor VisitationMaven Securities · OAMaven Securities interview questions
  • Proportional Momentum Investment StatisticsOptiver · OAOptiver interview questions
  • Sort an Array with Rotate and FlipAmazon · OA
  • Total Waiting Time for Handmade ItemsMicrosoft · OAMicrosoft interview questions
  • Prefix Scores With the Running MaximumC3.ai · OAC3.ai interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
See Belvedere Trading hiring insights
Saved
class Solution {
    public long[] variationMargin(int startPosition, int startSettle, int[] trade, int[] settle) {
      // write your code here
    }
}
Checking account…