← Akuna Capital Interview Insights
The moving average part was fine, sliding window, nothing crazy.
Start by clarifying requirements: fixed window size N, threshold T, and definition of a 'cross' (e.g., moving average crossing above or below T). Then propose an efficient data structure (e.g., circular buffer with running sum) to compute the moving average in O(1) per update, and describe how to detect crossings by comparing the current and previous moving averages relative to T. Finally, discuss trade-offs like handling missing data, latency, and backpressure.
Pro tip: Emphasize the importance of defining the signal semantics precisely—e.g., whether a crossing means the moving average transitions from below to above T (golden cross) or vice versa—and mention that you would confirm this with stakeholders to avoid ambiguity in production.
Confirm the window size N, threshold T, and what constitutes a 'cross' (e.g., moving average crossing above or below T). Also clarify input rate, data format, and whether the signal should be emitted once per crossing or continuously while above/below.
Propose using a circular buffer of size N to store the last N prices and maintain a running sum. This allows O(1) update and O(1) moving average retrieval by adding the new price and subtracting the oldest.
Keep track of the previous moving average value. After each update, compare the current moving average to the threshold and the previous moving average to the threshold. If the relationship changes (e.g., previous < T and current >= T), emit a signal.
Address handling of initial warm-up period (when fewer than N prices are available), missing data, out-of-order events, and potential floating-point precision issues. Discuss whether to use a simple moving average or exponential moving average and why.
Mention how the design would scale to multiple symbols or high-frequency streams (e.g., sharding by symbol, using a streaming framework). Discuss latency, backpressure, and fault tolerance.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.