E
edgecase
quant prep

Quant Research

The research workflow, end to end. Reason it out loud before you reveal.

1044 items
0 of 1044 mastered1044 unseen
warmupFeature Construction

diff() vs pct_change(): which transform actually makes a feature stationary

Question

You're building a feature off a price level that's clearly non-stationary -- its mean and variance drift over years. A teammate says "just call .diff() on it to make it stationary." Is diff() always the right transform, and when would pct_change() be the better choice instead?

Think first, then tap
warmupPortfolio Construction

Gross exposure vs margin: how much leverage can you actually run

Question

Your long-short book has 100% long and 100% short positions against 100% of NAV -- gross exposure of 200%, net exposure of 0%. A junior researcher says "we're market-neutral, so we could run this at 5x gross with no problem." What is wrong with that reasoning?

Think first, then tap
warmupPerformance Analytics

Sortino ratio vs Sharpe: why penalizing only downside volatility matters for an options-selling strategy

Question

A short-volatility options-selling strategy has a Sharpe ratio of 1.2, but its return distribution is heavily asymmetric: frequent small gains from collected premium, with rare large losses when the underlying gaps. A colleague argues Sharpe understates how risky this strategy really is, and prefers the Sortino ratio. What does Sortino actually change about the risk measure, and does it support or undercut the colleague's worry?

Think first, then tap
coreData Assembly

Cross join: building every ticker pair without a nested loop

Question

You have a list of 500 tickers and need every possible pair for a pairs-trading universe scan (500 choose 2 is about 124,750 pairs). How do you build that pair table in pandas without writing a nested Python loop, and what's the actual vectorized tool for it?

Think first, then tap
hardFeature Construction

Pruning redundant features by correlation before they double-count in a model

Question

You've built 40 candidate features for a cross-sectional model, several of which are near-duplicates of each other (e.g., 20-day and 21-day momentum). Left as-is, what actually goes wrong downstream, and how would you prune before fitting rather than after?

Think first, then tap
coreData Assembly

pivot_table's dropna=True default silently drops an all-NaN row or column

Question

You build a sector x date average-return pivot with df.pivot_table(index="date", columns="sector", values="ret"). One sector was newly added to your universe and has no trading data for the first week. A teammate notices that sector's column is just missing from the output entirely, not full of NaN. What setting caused that, and why does it matter?

Think first, then tap
warmupData Assembly

Named aggregation (pd.NamedAgg) for multiple stats per group in one pass

Question

You need, per ticker per day, the mean, max, and count of trade sizes from a tick-level DataFrame, with clean output column names like avg_size, max_size, and n_trades instead of pandas' default multi-level column names. A teammate runs three separate groupby calls and joins the results together. What's the one-pass alternative, and why does it matter beyond just being shorter?

Think first, then tap
coreCleaning & Corp Actions

Parsing a vendor's epoch timestamps with the wrong unit (milliseconds read as seconds, or vice versa) silently produces dates in 1970 or in the year 50000+

Question

A new tick-data vendor sends timestamps as a raw integer column, e.g. 1769558400000. You parse it with pd.to_datetime(col, unit="s") and every row comes back dated sometime in the year 58045. What went wrong, and how would you have caught it before it reached a backtest?

Think first, then tap
coreCalendars & Alignment

A daylight-saving transition inside a daily resample window silently makes one bar 23 or 25 hours long, distorting a volume-per-hour feature

Question

You resample a tz-aware intraday feed to daily bars with df.tz_convert("America/New_York").resample("1D").agg(...) and compute a volume-per-hour feature by dividing each day's total volume by 24. On the Sunday nights DST changes in March and November, that feature jumps noticeably even though nothing unusual happened in the market. Why, and how do you fix it?

Think first, then tap
hardStatistics

Backtesting 200 candidate factors and picking the best Sharpe: Bonferroni is far more conservative than you want, and Benjamini-Hochberg FDR control is the practical middle ground

Question

You backtest 200 candidate factors and get a p-value for each one's Sharpe ratio being nonzero. Using the usual alpha=0.05 cutoff on each p-value separately would call about 10 of them "significant" by chance alone. A teammate suggests Bonferroni correction: divide alpha by 200, so only p < 0.00025 counts. What's wrong with reaching for Bonferroni by default here, and what would you use instead?

Think first, then tap
coreStatistics

Leave-one-out stability check: is your IC driven by the whole cross-section, or by one or two extreme names?

Question

Your signal posts a monthly cross-sectional IC of 0.08 across 50 names, which looks solid. Before you believe it, what's a quick diagnostic to check whether that number is genuinely broad-based, and what would make you distrust it?

Think first, then tap
coreCleaning & Corp Actions

Total-return series

Question

Your split-adjusted prices still ignore dividends, and a colleague's "performance" of a utilities portfolio looks weirdly poor over 20 years. Build a total-return series and explain what it fixes.

Think first, then tap
warmupData Assembly

Stable sort for price-time priority

Question

You're reconstructing a limit order book from a raw trade log that isn't in price order. You need to sort resting orders by price for matching, but orders at the same price must stay in original arrival order (price-time priority). Does sort_values give you that for free, or do you need to do something else?

Think first, then tap
coreFeature Construction

Vol-scaling a signal before it goes into the book

Question

Two momentum signals have identical rank-IC, but one is computed on high-volatility small caps and the other on low-volatility large caps. A teammate suggests dividing each stock's raw return-based feature by that stock's own trailing realized volatility before ranking, calling it "vol-scaling". What problem does that fix, and what does it NOT fix?

Think first, then tap
warmupCalendars & Alignment

Roll conventions: modified following vs preceding for a holiday rebalance date

Question

Your strategy rebalances on the last calendar day of each month, but this year that date -- say June 30 -- falls on a Sunday, and June 29 is a Saturday. Your code just picks the nearest earlier trading day. A colleague asks whether you're using following, preceding, or modified following -- what's the difference, and why would picking the wrong one shift returns systematically?

Think first, then tap
warmupData Assembly

Chunked CSV reads for a file that doesn't fit in memory

Question

You're handed a 40GB CSV of tick-level trades that won't fit in memory, and you just need total daily volume per ticker. How do you compute that without loading the whole file at once?

Think first, then tap
warmupStatistics

How many years to trust a Sharpe?

Question

A strategy shows a Sharpe ratio of 0.5 over three years of daily data. Roughly how uncertain is that estimate, and how many years would you need before it is statistically distinguishable from zero?

Think first, then tap
corePerformance Analytics

Projecting how Sharpe degrades as you scale a strategy's AUM

Question

A strategy backtests at a Sharpe of 2.5 running $50M of gross exposure. Your PM wants to know what Sharpe to expect running it at $500M instead, before committing capital. You already have a square-root market-impact model calibrated for this universe. How do you turn that into a capacity-adjusted Sharpe projection, and why doesn't the answer scale linearly with the fee-free backtest?

Think first, then tap
warmupStatistics

Information coefficient and hit rate measure different things, and a factor can look great on one and mediocre on the other

Question

Your factor has a monthly information coefficient (IC), the Spearman rank correlation between the factor and next-month returns, of 0.05 -- a solid number for a single cross-sectional factor. But when you check the SIMPLE hit rate (fraction of stocks where the factor correctly predicted the sign of next month's return), it's only 51%, barely better than a coin flip. Is the IC number misleading, is the hit rate number misleading, or are they just answering different questions?

Think first, then tap
hardCalendars & Alignment

Historical DST rule changes: why a hardcoded offset breaks on old dates

Question

You're building a 20-year history of intraday bars for US equities. A junior engineer converts every local timestamp to UTC using a single hardcoded rule for when daylight saving applies (say, "DST from April through October"). The 2007 Energy Policy Act extended US daylight saving time by about four weeks starting that year. What breaks in this backtest, and how should timezone handling actually work across a rule change like this?

Think first, then tap
warmupPerformance Analytics

CVaR vs VaR: why Expected Shortfall is coherent (subadditive) and VaR isn't

Question

Your risk report shows 95% 1-day VaR for two uncorrelated sleeves, A and B, each $1M. A PM assumes the combined book's VaR is at most $2M, "since diversification can only help." You check the actual numbers and the combined VaR comes out to $2.3M -- more than the simple sum. Is that a bug, or does this reveal something fundamental about VaR?

Think first, then tap
hardBacktest Mechanics

Pyramiding: letting repeated signals silently stack exposure past any intended cap

Question

Your backtest generates a daily buy/sell signal per name, and the position-update rule is simply "if signal is buy, increase position by a fixed increment; if sell, decrease by the same increment," with no check against a maximum. On a strong trending stock the signal stays "buy" for 40 straight days. What happens to that position, and why might the backtest's reported Sharpe be misleadingly good?

Think first, then tap
coreCleaning & Corp Actions

A live tender offer compresses price and spikes volume -- real data, not an outlier

Question

A tender offer (a company announcing it'll buy back shares directly from holders at a fixed premium price) is live for one of your names over a two-week window. During that window trading volume roughly triples and the stock's price compresses tightly around the tender price instead of moving with the sector. Your standard outlier filter flags several of these days as suspect stale-price candidates, and your return-based signals go haywire. What's actually happening, and how do you handle it?

Think first, then tap
coreCleaning & Corp Actions

Halted trading masquerading as a zero return

Question

A stock gets halted for a pending news announcement at 11am and doesn't resume until the next session. In your daily returns panel, that day shows close equal to previous close, return exactly 0.0, and volume near zero. If you don't special-case this, what goes wrong downstream, and how do you detect it?

Think first, then tap
warmupFeature Construction

Cross-sectional rank vs time-series percentile: two different things called 'rank'

Question

Two teammates both say they're "ranking" the same momentum feature, but their numbers disagree every single day. One computes df.groupby("date")["mom"].rank(pct=True); the other computes df.groupby("ticker")["mom"].rolling(252).apply(lambda x: x.rank(pct=True).iloc[-1]). What is each one actually measuring?

Think first, then tap
hardBacktest Mechanics

Pairs-trade backtests assume simultaneous fills -- leg risk when one side doesn't

Question

A vectorized pairs-trading backtest opens both legs of a spread trade at the same timestamp and the same modeled price every time. In live trading, the two legs are separate orders hitting separate order books with separate latency and liquidity. What risk does the backtest completely miss by assuming simultaneous fills, and how would you stress-test for it?

Think first, then tap
hardPerformance Analytics

Crash beta: market exposure conditional on large down-days

Question

Your strategy's unconditional beta to the market, estimated over the full backtest, comes out near zero -- it looks market-neutral. But in the worst 5% of market down-days, your strategy's losses track the market almost one-for-one. How can both of these be true, and which one actually matters for risk management?

Think first, then tap
hardFeature Construction

Residualizing a feature against multiple risk factors in one multivariate regression instead of sequential orthogonalization

Question

Your value signal is correlated with both sector and size, so you want it clean of both before it goes into the model. A teammate suggests orthogonalizing against sector first, then taking that residual and orthogonalizing against size in a second pass. Why can this two-step sequential approach give a different, and generally worse, answer than a single multivariate regression against both controls at once?

Think first, then tap
coreData Assembly

combine_first vs fillna for patching gaps from a secondary source

Question

You have a primary vendor's price series with occasional missing days, and a secondary vendor's series that covers most of the same gaps but isn't a strict superset. A teammate writes primary.fillna(secondary) to patch the gaps. Does that work, and how is combine_first different?

Think first, then tap
warmupPortfolio Construction

From signal to weights

Question

You have a cross-sectional alpha signal for 500 stocks - one number per stock per day, higher means more attractive. Walk me through the simplest defensible way to turn that into portfolio weights.

Think first, then tap
hardCalendars & Alignment

numpy busday_offset vs pandas CustomBusinessDay: two holiday calendars that can quietly disagree

Question

You need to shift every trade date forward by one business day, skipping weekends and a list of exchange holidays. One teammate uses numpy.busday_offset with a holidays array; another uses a pandas Timestamp plus pd.offsets.CustomBusinessDay(holidays=...). Both seem to "work." Where could they silently diverge?

Think first, then tap
coreCleaning & Corp Actions

A mislabeled split ratio (3-for-2 vs 2-for-3) silently inverts your price adjustment

Question

Your corporate-actions feed reports a split as ratio "3-for-2" for a stock, and your adjustment code multiplies historical prices by (from_shares / to_shares) parsed directly from the ratio string. A vendor data-entry error flips the ratio to "2-for-3" for one event. What does the adjusted price series look like after that flip, and how would you catch it?

Think first, then tap
hardCleaning & Corp Actions

Currency redenomination: adjusting a price series when old units become new units

Question

A frontier-market stock in your history was quoted in an old currency that then redenominated -- the government dropped some zeros and issued a new currency unit (say, 1000 old units become 1 new unit) on a specific date. Your raw price feed just switches units on that date with no flag. What does this do to a naive returns calculation, and how do you detect and fix it?

Think first, then tap
coreBacktest Mechanics

Standardizing a feature using the FULL-SAMPLE mean and std leaks the whole backtest's future into every single day

Question

A teammate z-scores a feature once, using feature.mean() and feature.std() computed over the ENTIRE backtest history, then runs the backtest. The backtest looks great. What's wrong with how that feature was built, and why does it specifically inflate performance rather than just being "slightly off"?

Think first, then tap
warmupBacktest Mechanics

Linear cost vs square-root market impact

Question

Your backtest currently charges a flat 5 basis points per unit traded, regardless of trade size. A teammate says that is fine for a 50-million-dollar book but will badly understate costs if the strategy scales to 2 billion. What is missing from a flat linear cost, and what is the standard fix?

Think first, then tap
hardPerformance Analytics

A strategy's CAPM alpha and its Fama-French-style multi-factor alpha can disagree in sign, not just magnitude

Question

A strategy shows a solidly positive CAPM alpha (regressing its returns on just the market factor) but a slightly negative alpha once you add size, value, and momentum factors to the regression. Which number is "right," and what does the disagreement actually tell you?

Think first, then tap
coreCalendars & Alignment

Feb 29 quietly breaks a hardcoded one-year-ago DateOffset lookback

Question

A feature computes a trailing one-year return using date - pd.DateOffset(years=1) as the lookback date. On February 29, 2024, this resolves to February 28, 2023 without error. Six months later, someone reuses the same helper going the other direction on a Feb 28-anchored date and gets a different kind of surprise. What's DateOffset actually doing at a leap-day boundary, and where can it bite?

Think first, then tap
hardBacktest Mechanics

Rebalance gap risk: sizing off yesterday's close, executing at a gapped-open price

Question

Your daily rebalance computes target weights using yesterday's close, and your vectorized backtest fills the resulting trades at today's open. On a day with significant overnight news, a name gaps 8% at the open before you trade it. What's actually wrong with crediting the fill at that day's open price, and how would you model the gap risk a vectorized backtest usually hides?

Think first, then tap
warmupCleaning & Corp Actions

Detecting stale/frozen prices in an illiquid feed

Question

A small-cap ticker's daily close repeats the identical value (to the cent) for 11 straight trading days, then jumps 4%. Reported volume is nonzero every day. Is this a real flat period, a data feed bug, or something else -- and what quick check separates the possibilities?

Think first, then tap
hardCleaning & Corp Actions

Rights issues: a corporate action your split/dividend handlers miss

Question

A company announces a rights issue: existing holders may buy 1 new share for every 4 held at a 20% discount to the pre-announcement price. On the ex-rights date the stock price drops more than a normal dividend would explain. Your pipeline only has handlers for splits (ratio factor) and cash dividends (add back the cash). What is a rights issue economically, and how do you adjust for it?

Think first, then tap
coreBacktest Mechanics

Modeling short-sale constraints: borrow and locate

Question

Your long-short backtest assumes every short position can be entered at any size, any time, for free. In production, shorting requires borrowing shares from a lender, paying a borrow fee, and the borrow can be recalled or simply unavailable for hard-to-borrow names. What does ignoring this do to a backtest, and how do you model it?

Think first, then tap
hardStatistics

The jackknife as a cheaper alternative to the bootstrap for a Sharpe ratio's standard error

Question

A teammate bootstraps 10,000 resamples to get a confidence interval on a strategy's Sharpe ratio. You only have time to run a much cheaper check before a meeting. What does the jackknife give you instead, and when is it an acceptable substitute for the bootstrap here?

Think first, then tap
hardCleaning & Corp Actions

Back-adjusting a continuous futures series can push historical prices negative

Question

You build a continuous crude oil futures series by back-adjusting: at each roll date, you add the (new contract price minus old contract price) spread to every price before that date, so the series has no artificial jump at the roll. After 15 years and dozens of rolls, some early-history prices in your continuous series are negative, even though no contract ever traded negative until 2020. Is this a bug?

Think first, then tap
warmupFeature Construction

pct_change and the fill_method trap

Question

You compute daily returns with prices.pct_change() on a wide price matrix that has some NaN gaps from tickers that hadn't listed yet. On an older pandas version this ran silently; on pandas 2.x it raises a FutureWarning about fill_method, and a teammate suggests just passing fill_method=None to make the warning go away. Is that the right fix, and what was pct_change actually doing before?

Think first, then tap
hardStatistics

Robust standard errors for cross-sectional regressions

Question

You regress next-month return on a valuation signal, cross-sectionally, one regression per month. Large-cap names have much tighter residual variance than small-caps in every cross-section. Does that bias your coefficient estimate? Does it bias your standard errors, and what do you do about it?

Think first, then tap
warmupPoint-in-Time

A panel-wide .shift(1) leaks another ticker's value as 'yesterday' at every ticker boundary if the frame isn't grouped first

Question

You have a long panel with columns (date, ticker, close), sorted by date then ticker, and you write df["prev_close"] = df["close"].shift(1) to build a lagged feature. For most rows this is fine. At specific rows it's not just wrong, it's a point-in-time violation. Which rows, and why is this a PIT bug and not just an off-by-one?

Think first, then tap
hardCleaning & Corp Actions

Ratio vs subtraction adjustment

Question

Dividends can be folded into history multiplicatively (scale prices before the ex-date by 1 minus dividend over price) or by subtraction (subtract future dividends from earlier prices). Contrast the two -- what does each preserve, and where does each break?

Think first, then tap
warmupCalendars & Alignment

The fixed 252 annualization constant

Question

You annualize a Sharpe ratio by multiplying the daily Sharpe by sqrt(252) in every script you write, and a colleague points out that 2024 actually had 252 trading days but 2023 had 250, and crypto data has 365. Does the constant matter, and how do you handle it correctly?

Think first, then tap
hardStatistics

Standard error of the Sharpe ratio: building a confidence interval, not just a point estimate

Question

A strategy shows a backtested Sharpe ratio of 1.2 over 3 years of daily returns. Your PM asks: what's the confidence interval on that 1.2? How do you actually compute a standard error for a Sharpe ratio rather than just reporting the point estimate?

Think first, then tap
corePortfolio Construction

Multi-asset Kelly sizing: why correlated bets need the covariance matrix, not just each strategy's own Sharpe

Question

You've sized a single strategy using fractional Kelly based on its own mean and variance. Now you're running three correlated strategies at once and want Kelly-optimal sizing for the BOOK, not each one in isolation. Can you just apply each strategy's own single-asset Kelly fraction independently and run them side by side?

Think first, then tap
corePortfolio Construction

L1 vs L2 turnover penalty in the optimizer objective

Question

Your optimizer's objective currently penalizes turnover with lambda * sum((w - w_prev)^2), an L2 penalty. A colleague suggests switching to lambda * sum(|w - w_prev|), an L1 penalty, arguing it will produce a "cleaner" set of trades. What actually changes about the resulting trade list, and which cost model does each penalty implicitly assume?

Think first, then tap
coreData Assembly

wide_to_long for multiple prefixed value columns

Question

You receive a quarterly fundamentals file where each ticker has columns revenue_q1, revenue_q2, revenue_q3, revenue_q4, eps_q1, eps_q2, eps_q3, eps_q4 -- one row per ticker, four quarters of two different fields jammed into the column names. You need one row per (ticker, quarter) with separate revenue and eps columns. melt alone turns every one of those 8 columns into its own row, mixing revenue and eps together in one value column. What's the right tool, and how do you set it up?

Think first, then tap
warmupBacktest Mechanics

Loop-free daily P&L

Question

Write the complete daily P&L for a long-short equity backtest - weights DataFrame, returns DataFrame, 5 bps per dollar traded - with no loops. Where do people usually get the cost line wrong?

Think first, then tap
hardPoint-in-Time

merge_asof without a tolerance: matching a feature to data that's stale by months

Question

You use pd.merge_asof(prices, fundamentals, on="date", by="ticker", direction="backward") to attach the most recent known fundamentals to each daily price row. It runs without error and every row gets a value -- no NaNs at all. Is that a good sign, and what should you check before trusting it?

Think first, then tap
hardPerformance Analytics

A strategy's own max drawdown and an investor's experienced drawdown can differ even with identical returns

Question

A fund's tearsheet reports a strategy max drawdown of -18%. An investor who redeemed a large chunk of their capital near the bottom of that exact drawdown, before the recovery, claims they personally experienced a much worse loss. Both numbers can be correct at the same time -- how?

Think first, then tap
corePortfolio Construction

Ledoit-Wolf shrinkage target: identity vs constant-correlation vs single-factor

Question

You're applying Ledoit-Wolf shrinkage to a 300-asset sample covariance matrix. The shrinkage intensity is only half the recipe -- you also need a shrinkage target, the structured matrix you're shrinking toward. What are the common choices and how do you pick one?

Think first, then tap
hardPortfolio Construction

The constrained optimizer wins

Question

In-sample, your unconstrained mean-variance backtest clearly beats the long-only, position-capped version. Which one goes to production, and what is the statistical argument - not just the risk-management one?

Think first, then tap
warmupCleaning & Corp Actions

Trailing whitespace in a vendor's ticker column silently breaks every join that looks like it should match

Question

You're merging a prices table and a fundamentals table on ticker. Both clearly contain "AAPL" when you print them, but the merge comes back with almost no matches. What's a common, easy-to-miss cause, and how do you check for it?

Think first, then tap
coreData Assembly

merge()'s validate= parameter: catching an unexpected one-to-many join before it silently duplicates rows

Question

You join a trades DataFrame to a reference table of security master data on symbol, expecting each trade to match exactly one security row. The merge succeeds and returns a DataFrame -- but it has more rows than the original trades table. What happened, and how would you have caught it before trusting the output?

Think first, then tap
warmupFeature Construction

Winsorizing before z-scoring, not after

Question

You're building a cross-sectional feature: rank each stock's earnings yield, then z-score it within the day's universe. One stock has a data error making its earnings yield 50x everyone else's. Where in the pipeline should you handle that, and what goes wrong if you z-score first and clip second?

Think first, then tap
warmupData Assembly

pd.cut with fixed edges vs pd.qcut: absolute thresholds vs relative population buckets

Question

You're bucketing dividend yield into "low/mid/high" tiers for a screening rule using pd.qcut(df['div_yield'], 3, labels=['low','mid','high']), and the boundaries shift every single day even though your investment committee wants a stable, interpretable rule like "high yield means above 4%." What's the mismatch, and how do you fix it?

Think first, then tap
hardBacktest Mechanics

Weight drift between rebalances: your Monday target isn't Friday's actual weight

Question

Your strategy rebalances to target weights every Monday, but you compute daily P&L all week using those Monday target weights held constant. Prices move every day. What's wrong with that P&L calculation, and how do you fix it?

Think first, then tap
coreBacktest Mechanics

Modeling financing cost (repo/margin interest) on a levered long-short backtest

Question

Your long-short backtest runs at 150% gross exposure funded with leverage, and it reports Sharpe 2.5 counting only trading costs. What's missing, and how would you add it?

Think first, then tap
warmupStatistics

One-sided vs two-sided t-test when you have a genuine directional prior

Question

You backtested a new momentum signal and want to test whether its IC is significantly positive. A teammate uses scipy's default two-sided t-test and gets a p-value of 0.08 -- "not significant at 5%." You had a strong directional prior going in that momentum should be positive, not negative, before you ever ran the test. Does that change which test you should have used, and does it change the conclusion?

Think first, then tap
warmupStatistics

The law of small numbers: why 20 good trades don't prove a strategy works

Question

A researcher shows you a strategy that won 14 of its last 20 trades and asks if that's statistically meaningful. How do you reason about it on the spot, and what's the underlying mistake in trusting a small sample this way?

Think first, then tap
hardPoint-in-Time

Using an announced buyback's size to reduce shares outstanding immediately, instead of waiting for shares to actually be retired, overstates EPS and understates market cap before the repurchase has happened

Question

A company announces a $2B buyback authorization. Your fundamentals pipeline updates its shares-outstanding field on the announcement date, reducing it by the authorization size divided by the current price, so that EPS and market-cap features reflect the "expected" post-buyback share count right away. What's wrong with that from a point-in-time standpoint, and what should the feature actually use?

Think first, then tap
hardFeature Construction

Fractional differencing: stationarity without throwing away as much memory as diff()

Question

Your momentum feature needs a stationary input, so you've been using the log-price first difference (i.e. returns) as the base series. A colleague argues a full first difference removes more memory (predictive structure from the level) than is strictly needed to achieve stationarity, and proposes fractional differencing instead. What's the idea, and why might it produce a better feature?

Think first, then tap
hardCleaning & Corp Actions

A feed reports cumulative day-to-date volume at each print, not per-trade size -- summing it directly wildly overstates daily volume

Question

Your tick feed's "volume" field at each print is the exchange's running cumulative total for the session so far, not that individual trade's own size. A teammate computes daily volume with df.groupby("date")["volume"].sum() and gets numbers roughly ten times too high. What's going on, and how do you fix it?

Think first, then tap
warmupPerformance Analytics

Sortino ratio: downside deviation instead of full-sample volatility

Question

A strategy has decent Sharpe but a teammate wants to also report its Sortino ratio, arguing Sharpe unfairly penalizes it. What does Sortino actually change relative to Sharpe, and when does that change the story?

Think first, then tap
hardBacktest Mechanics

Execution timing sensitivity

Question

Delaying your backtest's execution by one extra day drops Sharpe from 1.8 to 0.4. What exactly does that experiment measure, and does it kill the strategy?

Think first, then tap
corePoint-in-Time

Timezone mismatch: an ET-timestamped earnings feed joined against a UTC backtest clock misdates the event by a day

Question

Your earnings-announcement feed timestamps releases in US Eastern time, but your backtest engine's master clock and all your price data run in UTC. A company reports after the close at 4:05pm ET on a Tuesday. Your pipeline naively treats the feed's date string as if it were already a UTC calendar date. What goes wrong, and on which days does it actually bite?

Think first, then tap
coreCleaning & Corp Actions

MAD-based outlier detection for fat-tailed return data

Question

You want to flag outlier daily returns in a cleaning pipeline before they feed a covariance estimate. A teammate proposes flagging anything more than 3 standard deviations from the mean. Why might that underperform on real return data, and what would you use instead?

Think first, then tap
coreCleaning & Corp Actions

SIP trade condition codes: excluding non-regular prints before computing a 'last sale' close

Question

You compute "close" as the last trade price of the day from a raw tick feed, but your number keeps disagreeing with the exchange's official closing price by a few cents on names with thin end-of-day activity. The feed includes a trade condition code on every row. What's probably happening, and how do you fix the close calculation?

Think first, then tap
warmupCalendars & Alignment

pd.infer_freq() returning None on a real trading calendar

Question

You load a year of daily close prices for one ticker into a DatetimeIndex and call pd.infer_freq(idx) to confirm it's a clean daily series before resampling. It returns None instead of "D" or "B", even though the data looks like an ordinary daily series with no obvious problems. What's actually going on, and what do you check first?

Think first, then tap
hardStatistics

Tied ranks from a coarse/discretized signal bias a naive Spearman rank-IC unless you use the tie-corrected formula

Question

Your signal is a discrete analyst-rating score (five buckets: Strong Buy, Buy, Hold, Sell, Strong Sell) rather than a continuous number, so on any given day hundreds of names tie at the same rating. You compute the rank-IC between this score and forward returns using the simplified textbook Spearman formula, which assumes no ties. Does that formula still give you the right answer, and what's the mechanism if not?

Think first, then tap
warmupData Assembly

xs() for slicing a MultiIndex without flattening it

Question

You have a panel indexed by (date, ticker) with columns close, volume. You want just the rows for ticker AAPL, still indexed by date only. df.loc[(slice(None), "AAPL"), :] works but is clunky and returns a frame that still carries the (date, ticker) MultiIndex. What is the cleaner tool, and what does it do differently?

Think first, then tap
coreBacktest Mechanics

Maker rebates vs taker fees: why one flat cost misprices a market-making backtest

Question

You're backtesting a market-making strategy that posts limit orders (maker) but sometimes crosses the spread to flatten inventory (taker). Your current backtest applies one flat bps cost to every fill. What's wrong with that for this strategy specifically?

Think first, then tap
warmupCalendars & Alignment

Easter-relative holidays (Good Friday) breaking a hardcoded fixed-date calendar

Question

Your US equities holiday list is a hand-maintained set of fixed month/day pairs -- "12-25", "01-01", and so on. NYSE is also closed every year on Good Friday. Why does that one holiday break your hardcoded approach specifically, and what's the fix?

Think first, then tap
coreData Assembly

assert_frame_equal's check_like and check_exact: comparing two pipeline runs that should match

Question

You rewrote a data pipeline to be faster and want to confirm it produces the exact same output as the old pipeline on a year of historical data. You call pandas.testing.assert_frame_equal(old_df, new_df) and it raises, even though a manual eyeball of both DataFrames looks identical. What are the two most common reasons assert_frame_equal fails on "equal-looking" DataFrames, and how do you fix the comparison instead of the data?

Think first, then tap
hardFeature Construction

A rolling z-score ties the mean-estimation window to the vol-scaling window -- why decoupling them (long window for the mean, short for the vol) often works better

Question

You're building a rolling cross-sectional z-score: (feature - rolling_mean) / rolling_std, both computed over the same 60-day window. In a sudden vol spike, the z-scores blow out and stay elevated for weeks even after the spike passes. A teammate suggests just shortening the window to react faster. What actually goes wrong with that fix, and what's the better structural change?

Think first, then tap
coreData Assembly

Copy-on-Write: chained assignment now fails silently, not loudly

Question

You upgrade a research pipeline to a pandas version with Copy-on-Write enabled by default, and a line that used to at least raise a SettingWithCopyWarning now runs with no warning at all and simply does not update the DataFrame. What changed under Copy-on-Write, and what discipline does it demand?

Think first, then tap
coreData Assembly

DataFrame.align() and the silent reindex when combining frames with different indexes

Question

You have a daily-close Series for 400 tickers and a separate daily-signal Series computed on a slightly different set of names (a few tickers delisted on one side, a couple of extra holidays on the other). You write signal * close directly. What does pandas actually do here, and how do you make sure you know what happened?

Think first, then tap
hardStatistics

Quantile regression: does a factor matter more for the WORST days than the average day?

Question

You've run an OLS regression of next-day portfolio return on a stress indicator and found a small, barely significant average effect. The desk suspects the indicator matters a lot more on the worst days specifically, not on average. How would you actually test that?

Think first, then tap
hardCalendars & Alignment

NYSE/LSE overlap window: why US and UK DST transitions don't move together

Question

You want to compute, for each trading day, how many minutes NYSE (9:30-16:00 America/New_York) and LSE (08:00-16:30 Europe/London) are simultaneously open -- the window where a cross-listed arbitrage trade is executable on both legs at once. A teammate hardcodes it as "9:30am-11:30am Eastern, every day" and moves on. What's wrong with that, and how do you compute it correctly?

Think first, then tap
corePerformance Analytics

P&L attribution by sector

Question

The PM asks: of last quarter's 4 percent return, how much came from each sector? Show me the computation and one thing that must be true for the pieces to be trusted.

Think first, then tap
hardStatistics

Bootstrapping a Sharpe ratio confidence interval: why i.i.d. resampling understates uncertainty for autocorrelated returns

Question

You bootstrap a 95% confidence interval for a strategy's Sharpe ratio by resampling daily returns independently with replacement, 10,000 times, and recomputing Sharpe each time. The strategy's daily returns have meaningful positive autocorrelation (today's return predicts a chunk of tomorrow's, from slow-moving signal decay). Why does ordinary i.i.d. resampling give you a confidence interval that's too narrow, and what should you do instead?

Think first, then tap
coreCleaning & Corp Actions

A pending corporate action gets cancelled after you've already applied its adjustment factor

Question

Your corporate-actions feed flags a 2-for-1 split for ticker XYZ with an effective date next Monday, and your pipeline pre-applies the 0.5x adjustment factor to historical prices ahead of time so the adjusted series is ready before the open. On Friday, the company abruptly cancels the split. What's the actual failure mode in your stored data, and what's the fix?

Think first, then tap
hardCalendars & Alignment

Options and futures expiration dates landing on a holiday: roll conventions are product-specific, not a universal 'shift one day'

Question

A monthly equity option's listed expiration is the third Friday of the month, but this cycle that Friday turns out to be an exchange holiday. Your code just subtracts one calendar day to get the real expiration. Is that safe in general, and would a futures contract on the same underlying necessarily roll the same way?

Think first, then tap
hardStatistics

Bonferroni's blind spot: correcting for correlated, not independent, trials

Question

You backtested 200 candidate signals built from overlapping raw features (many are just different lookback windows of the same underlying momentum idea) and found 6 with IC t-stats above 3. A naive Bonferroni correction with 200 tests would wipe out most of them. Is that the right correction to apply?

Think first, then tap
warmupData Assembly

pd.concat along axis=1 doesn't check for duplicate column names, and selecting that column later no longer returns a Series

Question

You pd.concat two DataFrames along axis=1 that happen to both have a column called "price" -- pandas doesn't raise an error. What actually happens to the result, and why is that dangerous?

Think first, then tap
hardPoint-in-Time

Point-in-time shares outstanding for market-cap weights

Question

A company announces a large buyback on March 1st and completes it by April 15th, retiring 8% of its shares. Your security master table has one row per ticker with a "shares_outstanding" field that gets overwritten every time the vendor refreshes it. You use that field to compute market-cap weights for a backtest running from 2015 to today. What is wrong, and how should the table be structured instead?

Think first, then tap
hardFeature Construction

Winsorizing at inference time with training-set percentiles, not the live batch's own

Question

Your feature pipeline winsorizes a raw signal at its 1st and 99th percentile before feeding it to the model. In production you compute those percentiles fresh, on each day's live cross-section, exactly like you did in training. Why is that subtly wrong, and what should change?

Think first, then tap
warmupData Assembly

A 'many-to-one' merge becomes many-to-many when the key isn't actually unique on one side, silently multiplying rows

Question

You merge a 2M-row trades DataFrame against a 3,000-row reference table of (ticker, sector, country) on "ticker", expecting the row count to stay at 2M since you're just attaching static reference columns. Instead the merged DataFrame has 2.1M rows. What's the most likely cause, and how do you catch it before it happens again?

Think first, then tap
warmupData Assembly

merge()'s indicator=True: auditing join coverage instead of eyeballing NaNs

Question

You're left-merging your daily price panel with a fundamentals table on (ticker, date), and you want to verify that every price row actually found a fundamentals match before trusting the merged frame. What single argument turns that check into something you can groupby, instead of eyeballing NaNs after the fact?

Think first, then tap
hardPoint-in-Time

13F filing lag: institutional holdings disclosed 45 days after quarter end

Question

You want a feature tracking hedge fund crowding -- how many 13F-reporting institutions hold a stock, and how concentrated their positions are, as of each quarter end. The SEC's 13F filings report holdings as of quarter-end, but institutions have up to 45 calendar days after quarter end to actually file. How do you build this feature without lookahead?

Think first, then tap
coreCalendars & Alignment

Combining NYSE's equity holiday calendar with CME's index-futures calendar for a strategy trading both legs

Question

You're backtesting a strategy that trades SPY on NYSE alongside ES futures on CME. NYSE closes fully for Good Friday; CME's ES contract trades a shortened electronic session that same day instead of closing outright. If you build your master trading-day calendar from NYSE holidays alone and use it to decide which days to include for BOTH instruments, what breaks, and should the combined calendar be the union or the intersection of each venue's open days?

Think first, then tap
warmupBacktest Mechanics

Running pct_change() on raw (non-total-return) closing prices makes the ex-dividend date look like a loss a shareholder never actually experienced

Question

Your vectorized backtest computes daily returns as prices.pct_change() on the raw close column. For a high-dividend-yield stock, the backtest shows a return of roughly negative 3% on a day nothing bad happened. What's going on?

Think first, then tap
warmupPoint-in-Time

merge_asof direction

Question

pd.merge_asof has direction equal to backward, forward, or nearest. Explain what each does and which one is the only PIT-safe choice for joining data onto a trading timeline.

Think first, then tap
warmupCleaning & Corp Actions

Duplicate rows from overlapping vendor backfill date ranges

Question

Every night your pipeline pulls the vendor's "last 10 trading days" price file to catch any late corrections to recent prints, then appends it to your historical price table. After a few weeks you notice duplicate (ticker, date) rows in the table, and worse, sometimes the duplicate has a different close price than the earlier one for the same day. What's going on and how do you handle it?

Think first, then tap
warmupCalendars & Alignment

date_range(periods=..., freq=...) anchors to the frequency's own grid, not the day-of-month your start happens to be

Question

You call pd.date_range(start="2026-01-01", periods=12, freq="M") expecting it to land exactly on "2026-12-01", but the last date isn't what you expected, and a teammate's pd.date_range(start="2026-01-01", end="2026-12-01", freq="M") produces a DIFFERENT number of dates than yours. What's going on, and which call should you trust for an exact calendar grid?

Think first, then tap
coreBacktest Mechanics

Backtesting an intraday-frequency signal against daily OHLC bars forces a biased fill assumption

Question

Your signal fires and can trigger a trade at any point during the trading day -- sometimes several times -- but your backtest only has daily OHLC bars to work with. You pick a fill convention (say, the day's proxy (O+H+L+C)/4) for every trade that day. What bias does this introduce, and what can and can't you actually validate with only daily bars?

Think first, then tap
hardPoint-in-Time

Vendor weekend batch jobs: Friday's fundamentals not visible until Monday

Question

Your fundamentals vendor runs its ingestion batch job only on weekday mornings. A company reports earnings after Friday's close. The vendor's row has knowledge_date = Friday (the date the filing became public), but the row doesn't actually land in your database until Monday morning's batch run -- Saturday and Sunday, nothing updates. Your PIT join uses merge_asof on knowledge_date. What's wrong with that, and how do you fix it?

Think first, then tap
corePortfolio Construction

Inverse-volatility weighting as a risk-parity shortcut -- and where it quietly breaks

Question

Someone proposes a quick risk parity portfolio: weight each asset by 1 divided by its own volatility, normalized to sum to one, with no covariance matrix needed. When does this actually achieve risk parity -- equal risk contribution from each asset -- and when does it miss?

Think first, then tap
coreData Assembly

set_index's verify_integrity=True: catching a silent duplicate key before it corrupts a downstream join

Question

You set_index(["ticker", "date"]) on a panel to prepare it for a merge against another panel. If there happen to be two rows with the same (ticker, date) -- say a vendor sent the same print twice -- what happens by default, and how do you make pandas tell you immediately instead of finding out three merges later?

Think first, then tap
hardPoint-in-Time

A single restated quarter propagates through a trailing-twelve-month feature

Question

You compute trailing-twelve-month (TTM) revenue as the sum of the last four reported quarters. Three quarters later, the company restates one of those four quarters' revenue. Should your point-in-time TTM series for all the historical dates that included the original quarter now be revised to reflect the restated value?

Think first, then tap
warmupData Assembly

Arrow-backed strings: string[pyarrow] vs object vs categorical

Question

You are loading a table with a free-text trade-note column -- almost every value is unique (broker references, manual override tickets), so it never repeats the way a ticker column does. Profiling shows this object-dtype column dominates memory and string-method runtime. A teammate suggests dtype="string[pyarrow]" rather than converting it to categorical. What does the pyarrow-backed string dtype change under the hood, and why is categorical the wrong tool here specifically?

Think first, then tap
hardPortfolio Construction

Running a market-neutral overlay alongside a core long-only book under one shared exposure cap

Question

The fund runs a core long-only equity book (always net long, no shorting) and wants to add a market-neutral long-short overlay on top, funded by the same capital base, under one firm-wide gross exposure cap. What's the right way to think about combining these two books so the cap actually constrains total risk, rather than each book just assuming it owns the whole limit?

Think first, then tap
coreFeature Construction

Correlating a feature with the forward return without leaking the future into the feature

Question

You want a quick sanity check of a new feature's predictive power before running a full backtest: correlate today's feature value with tomorrow's return, per date, across the cross-section. Where exactly does lookahead most commonly sneak into this seemingly simple check?

Think first, then tap
hardStatistics

A backtest that fails to reach significance isn't necessarily evidence the signal has no edge -- it might just be underpowered for the true IC size and sample length you have

Question

Your signal's daily IC over a 2-year backtest averages 0.015 with a Newey-West t-stat of 1.3 -- not significant at the usual 2.0 bar. Your manager asks whether this signal is dead, or whether the test just didn't have enough data to tell. How do you answer that with a number, not a gut feel?

Think first, then tap
coreCalendars & Alignment

to_period('M') for a monthly join key, and why it beats truncating a timestamp by hand

Question

You have a daily price panel and a monthly-rebalanced signal keyed by month. You need to join the signal onto every daily row in its month. What's the clean way to build the join key, and what goes wrong if you build it with string slicing instead?

Think first, then tap
warmupPoint-in-Time

datetime.now() inside a backtest's feature pipeline

Question

A teammate's feature function computes "days until next FOMC meeting" by calling datetime.now() to get "today" and comparing it against a hardcoded meeting calendar. It works fine in a notebook. When you plug it into a historical backtest looping over 2020-2024, every single day gets the SAME feature value. What's wrong, and why is this a point-in-time bug specifically, not just an ordinary logic bug?

Think first, then tap
hardStatistics

How much data to detect an IC of 0.02

Question

Before running a six-month pilot on a new signal, your PM asks: if the signal's TRUE mean IC is 0.02 and daily IC volatility is around 0.10 -- typical numbers -- how many days of data do we actually need to have a reasonable chance of detecting it as statistically significant? Do the calculation, not just the vibe.

Think first, then tap
warmupPerformance Analytics

Annualizing a Sharpe ratio when the return series has gaps

Question

You compute a strategy's daily Sharpe ratio as mean(daily_returns) / std(daily_returns) and annualize it by multiplying by sqrt(252), the standard convention. Your return series spans exactly one calendar year but is missing returns for 15 scattered days (some data vendor outages, a few days the strategy was flat and got dropped instead of recorded as zero). Is sqrt(252) still the right annualization factor?

Think first, then tap
coreCleaning & Corp Actions

IPO seasoning: excluding the first weeks of noisy post-listing price discovery

Question

A stock IPO'd three weeks ago and already shows up in your universe with wild daily swings -- +18%, -12%, +9% in its first five sessions -- before settling into normal volatility. Your vol-scaling feature is getting badly distorted by these names. What's happening, and how do you handle newly listed stocks in your pipeline?

Think first, then tap
warmupData Assembly

pd.qcut for decile portfolios: what happens when the signal has mass ties at one value

Question

You use pd.qcut(df['signal'], 10, labels=False) to bucket stocks into decile portfolios each day. On some dates it raises "Bin edges must be unique" or silently produces buckets with wildly uneven counts. Your signal is a share-buyback yield that's exactly 0.0 for about 40% of the universe on any given day. What's happening, and how do you fix the bucketing?

Think first, then tap
coreCleaning & Corp Actions

Crossed and locked quotes: bid >= ask in raw NBBO data

Question

You're building features off the raw NBBO (National Best Bid and Offer) quote feed and notice some rows where the bid price is greater than or equal to the ask price. Is that a data error you should drop, and what could actually cause it?

Think first, then tap
warmupFeature Construction

Calling .rolling() directly on a multi-ticker panel sorted by (ticker, date) without groupby() blends the tail of one ticker's window into the next ticker's feature

Question

You have a long-format panel sorted by ticker then date, and you build a 5-day rolling mean with df["close"].rolling(5).mean() directly on the whole column, no groupby. The first few rows of every ticker after the first one look suspiciously smooth. What's wrong, and what's the one-line fix?

Think first, then tap
warmupData Assembly

Index.difference and symmetric_difference for diagnosing universe membership changes

Question

Between last Friday's rebalance and today's, your signal universe is supposed to stay the same unless a name is added or dropped by committee. Before running today's job, you want a quick check: which tickers, if any, appeared or disappeared from the universe list since last Friday?

Think first, then tap
warmupPerformance Analytics

Cornish-Fisher VaR: adjusting for skew and kurtosis instead of assuming normality

Question

Your parametric VaR calculation assumes returns are normally distributed, but your strategy's returns are visibly left-skewed with fat tails. What's a quick fix that doesn't require switching to full historical simulation?

Think first, then tap
corePerformance Analytics

Decomposing total return into price return and dividend/carry return for a tearsheet, not lumping everything into one P&L number

Question

Your long-only equity strategy's tearsheet shows a single total return number per period. A reviewer asks: how much of that came from price appreciation versus dividends? Why does that split matter, and how do you actually compute it?

Think first, then tap
hardPortfolio Construction

The KKT multiplier on a binding long-only constraint IS the marginal answer to 'how much would relaxing this help' -- no re-solve needed

Question

Your long-only mean-variance optimizer returns a solution where several names are pinned at exactly zero weight -- the long-only constraint is binding for them. Your PM asks: "if I let you go slightly short in one of these, how much better does the portfolio get?" How do you answer that without re-running the optimization with the constraint relaxed?

Think first, then tap
corePortfolio Construction

Computing a hedge ratio for a pairs trade

Question

You want to trade a mean-reverting spread between two cointegrated stocks, A and B. How do you compute the hedge ratio, and why is regressing A on B different from regressing B on A -- does it matter which one you pick?

Think first, then tap
coreCleaning & Corp Actions

ADR ratio adjustment for a foreign-listed stock

Question

You're building a global panel and pull in Toyota via its NYSE-listed ADR (American Depositary Receipt) ticker TM, planning to treat its price and volume like any US stock. A colleague warns the raw ADR price and volume aren't directly comparable to the Tokyo-listed ordinary shares. What's the issue, and how do you adjust for it?

Think first, then tap
coreBacktest Mechanics

Random k-fold cross-validation leaks the future into training on time-series data -- walk-forward validation is the only valid scheme

Question

A colleague wants to tune a model's hyperparameters using standard 5-fold cross-validation on five years of daily data, shuffling rows randomly into folds the normal scikit-learn way. Why is that invalid for a trading signal, and what should they use instead?

Think first, then tap
corePortfolio Construction

Delta-adjusted exposure: why raw notional misstates risk once the book holds options

Question

Your book holds 10,000 shares of AAPL (long) and separately is short 100 AAPL call option contracts (100 shares per contract) with a delta of 0.4. A risk report that sums raw notional says you're long roughly 10,000 shares worth of AAPL plus short 10,000 contract-equivalents, and calls the position "roughly flat." Is that a reasonable read of your actual directional exposure?

Think first, then tap
hardStatistics

Testing for ARCH effects before trusting a constant-volatility model

Question

Your risk model assumes daily portfolio return volatility is constant and estimates it as a simple trailing sample standard deviation. Before defending that assumption to a risk committee, how would you actually TEST whether volatility clustering (ARCH effects) is present, rather than just eyeballing a chart?

Think first, then tap
coreBacktest Mechanics

A backtest that fills a limit order whenever the bar's range touches the limit price overstates fill rates -- touching a price isn't the same as trading through it with enough volume

Question

Your backtest places a limit buy order at a price inside a bar's high-low range and assumes it fills in full the moment the bar's low touches or crosses that price. Live execution on the same strategy fills noticeably less often, and the fills it does get come later than the backtest assumes. What's the gap between "the bar's range touched my limit price" and an actual fill, and how do you model it more realistically?

Think first, then tap
warmupCleaning & Corp Actions

Dual share classes: GOOG vs GOOGL as distinct instruments, not duplicate rows

Question

Your universe includes both GOOG and GOOGL -- Alphabet's two publicly traded share classes. A junior teammate flags them as "probably a data error, duplicate company." Are they duplicates you should drop, and how should you actually treat them in a cross-sectional universe?

Think first, then tap
hardCalendars & Alignment

tz_localize's nonexistent= parameter: the spring-forward hour that doesn't exist at all

Question

You tz_localize a batch of naive timestamps to "America/New_York" and one row raises a NonExistentTimeError for 2026-03-08 02:30:00. The data isn't corrupted -- what's actually going on with that specific timestamp, and how do you decide what to do with it?

Think first, then tap
corePortfolio Construction

A 'fixed 2x gross leverage' target measured against NAV silently drifts between rebalances as unrealized P&L moves the NAV itself

Question

Your book targets exactly 2.0x gross exposure relative to NAV, enforced at each weekly rebalance. Three days after a rebalance, a sharp move leaves the book's positions worth notably more (or less) than at rebalance time, with no new trades. Is the book still at 2.0x gross, and what does that imply about how often leverage actually needs checking, not just rebalancing?

Think first, then tap
corePortfolio Construction

Converting optimal target weights into a trade list under a hard turnover budget

Question

Your optimizer outputs a new target weight vector each rebalance. Today's turnover from current weights to the new targets would be 40% of NAV, but the desk has a hard cap of 15% turnover per rebalance (transaction cost budget). A junior quant proposes just scaling every trade by 15/40 proportionally. What's wrong with that shortcut, and what would you do instead?

Think first, then tap
corePortfolio Construction

Choosing rebalance frequency: alpha decay vs transaction costs

Question

Your signal's information coefficient decays with roughly a 10-day half-life -- it's still somewhat predictive a week out but mostly stale after three weeks. Someone suggests rebalancing daily to capture the freshest signal at all times. What's the actual trade-off in choosing a rebalance frequency here, and would you actually rebalance daily?

Think first, then tap
coreCalendars & Alignment

Rebalancing on 'the 15th' when it is not a trading day

Question

Your mandate says "rebalance on the 15th of each month." Some months the 15th is a Saturday; some months it's a market holiday. A junior researcher writes code that looks up rows where date.day == 15 and silently gets zero rows in those months, so the backtest just skips the rebalance entirely that month. What is the right way to define "the 15th" as a trading-calendar concept, and what convention do you pick?

Think first, then tap
coreCalendars & Alignment

US and UK shift clocks on different calendar dates, breaking a hardcoded 5-hour NYSE/LSE offset

Question

You align NYSE close (16:00 America/New_York) with LSE close (16:30 Europe/London) by hardcoding a 5-hour offset between Eastern and GMT/BST. For one week each spring and each fall, your aligned timestamps are off by an hour. Why, and how do you fix it properly?

Think first, then tap
coreStatistics

Correcting for the search

Question

Concretely, how do you adjust significance when you have tested N signals? Walk me through Bonferroni and the idea behind the deflated Sharpe ratio.

Think first, then tap
coreCleaning & Corp Actions

Tick-size heterogeneity across venues creates phantom outliers when consolidating a multi-exchange feed

Question

You're consolidating trade prints for the same stock across three venues into one tape, then flagging outliers with a simple rolling z-score on price changes. One venue quotes in a coarser tick size (say 5 cents) than the other two (1 cent). The z-score filter keeps flagging prints from the coarse-tick venue as outliers even on quiet days. What's actually going on?

Think first, then tap
hardBacktest Mechanics

Standard k-fold cross-validation leaks future information into a time-series strategy backtest

Question

You're tuning a strategy's hyperparameters (say, a lookback window length) using standard scikit-learn k-fold cross-validation on daily data: shuffle, split into 5 folds, train on 4, validate on the 5th, rotate. The strategy looks great in cross-validation but underperforms badly out-of-sample live. What's wrong with applying standard k-fold to time-series data, and what should you use instead?

Think first, then tap
warmupPortfolio Construction

Active weights vs total weights: what actually counts as a bet in a benchmark-relative book

Question

Your long-only portfolio holds 3% of NAV in a stock, and someone asks "what's your bet on this name?" The benchmark also holds 2.5% in that same stock. Is 3% the right number to report as your bet size, and if not, why does it matter for how you think about risk?

Think first, then tap
warmupStatistics

Testing whether daily strategy returns are normal before trusting a t-test

Question

Before reporting a Sharpe ratio's confidence interval using a standard t-test, your interviewer asks: how would you check whether that's even a reasonable thing to do, given daily strategy returns are famously fat-tailed and skewed?

Think first, then tap
hardCleaning & Corp Actions

Return of capital: a cash distribution that is not a dividend

Question

A REIT distributes $0.50/share, labeled on its 1099 as partly "ordinary income" and partly "return of capital." Your pipeline treats every cash distribution as an ordinary dividend for total-return adjustment. Does the return-of-capital portion need different handling in the price/total-return math?

Think first, then tap
warmupCleaning & Corp Actions

GBX vs GBP: a hidden 100x unit error

Question

You merge UK equity prices from two vendors and one name's price shows a sudden 100x jump on a specific date, with no corporate action anywhere in the news or the corp-action file. What is the likely cause, and how do you guard against it?

Think first, then tap
hardFeature Construction

EWM correlation between two features for a time-varying interaction

Question

You've built two independent alpha signals -- a fast reversal signal and a slow value signal -- and want an interaction feature that captures "value works especially well when reversal is also positive." You compute interaction = reversal_z * value_z, but backtests show the interaction feature's own volatility swings wildly across regimes even though both inputs are already cross-sectionally z-scored each day. What's causing that and how do you fix it?

Think first, then tap
hardPoint-in-Time

Point-in-time model versioning: making sure a periodically retrained model only ever used data available at that time

Question

Your team retrains a signal-generating ML model every month on a trailing window of data. When you backtest the resulting strategy, do you need to worry about lookahead beyond just lagging the input features correctly?

Think first, then tap
warmupPerformance Analytics

Why two strategies' Sharpe ratios don't average (or add) to give the combined book's Sharpe

Question

Strategy A runs at a Sharpe of 1.5, Strategy B at a Sharpe of 1.0, each at equal capital. A PM asks what Sharpe to expect running both together. Is it just the average of 1.5 and 1.0, or somewhere close to it?

Think first, then tap
hardStatistics

Optional stopping: peeking at a live Sharpe ratio and stopping the first time it looks significant

Question

You've paper-traded a new signal for 40 days and check its cumulative t-stat on the Sharpe ratio every single day. On day 23 it crosses 2.0 for the first time, so you stop the trial and declare it significant. What's wrong with this, even though the day-23 t-stat genuinely was above 2.0?

Think first, then tap
coreCleaning & Corp Actions

Ex-date vs pay-date for dividends

Question

Your total-return series applies each dividend on its PAY date, which lands two to four weeks after the ex-dividend date. A daily backtest shows a small return trough after every ex-date, followed by a jump on pay date, that no live trader would actually experience. What is wrong, and which date should the dividend be booked on?

Think first, then tap
coreBacktest Mechanics

Using (high+low)/2 instead of close for a daily-bar backtest's mark price

Question

A teammate's backtest marks open positions each day using (high + low) / 2 instead of the close, arguing it's "a more representative price for the day." What breaks when you compute both P&L and realized volatility off that mark instead of the close?

Think first, then tap
hardStatistics

Deflated Sharpe Ratio: discounting a backtested Sharpe for how many strategies you tried

Question

You tested 200 signal variants over the same historical data and kept the one with the best backtested Sharpe ratio, 2.1. A colleague says the "real" Sharpe you should trust is much lower than 2.1, even though the backtest math is correct. Why, and how would you quantify the discount?

Think first, then tap
warmupCalendars & Alignment

Fiscal-year-anchored offsets: QS-JAN vs QS-APR for non-calendar fiscal years

Question

A company's fiscal year starts in April, not January (common for retailers and some Asian issuers). You need a series of that company's fiscal-quarter-start dates to align quarterly fundamentals data. What's wrong with just using pd.date_range(freq="QS"), and how do you fix it?

Think first, then tap
hardCleaning & Corp Actions

Pre-decimalization prices: when a close of 45.0625 really means 45 1/16

Question

You're backfilling US equities price history into the late 1990s. Before April 2001, US stocks traded in fractions of a dollar (eighths, then sixteenths), not decimal cents. A vendor's historical file shows closes like 45.0625 and 32.1875 for that era. What's actually going on, and what breaks if you treat this data exactly like modern decimal prices?

Think first, then tap
warmupFeature Construction

pd.get_dummies at inference time silently produces a different column set than training when the live batch is missing a category that appeared during training

Question

You one-hot-encode a "sector" feature with pd.get_dummies(df["sector"]) at training time across 11 GICS sectors, and train a model on those 11 columns. In production today, only 9 sectors trade anything, so get_dummies on the live batch produces 9 columns. What breaks, and why doesn't it error?

Think first, then tap
corePortfolio Construction

Why a mean-variance optimizer takes a large position in an asset with zero expected alpha

Question

You run a mean-variance optimizer over a small universe and notice it assigns a sizeable short position to an asset whose expected return input you set to exactly zero. Is that a bug, and what is the optimizer actually doing with that asset?

Think first, then tap
hardBacktest Mechanics

Instant-settlement cash tracking hiding a phantom leverage breach

Question

Your vectorized backtest tracks a single cash balance that updates instantly: sell a position, cash goes up that instant; buy a position, cash goes down that instant, all on the same bar. In a bad month it briefly shows negative cash even though the strategy is supposedly long-only and never uses leverage. What's unrealistic about the cash mechanics, and does it actually change the strategy's reported P&L?

Think first, then tap
hardPortfolio Construction

Converting a target gross exposure into buying power under Reg-T margin

Question

Your optimizer outputs a target of 150% gross exposure (long 100%, short 50%) on a $10M long-short book. Before you can actually size the trades, your PM asks whether that's even achievable under Reg-T margin rules, and what the margin cushion looks like. Walk through the mechanics.

Think first, then tap
coreBacktest Mechanics

Point-in-time shares outstanding for cap-weighted backtests

Question

You build a cap-weighted universe by multiplying each day's price by a shares-outstanding figure pulled from a "current" reference table, refreshed nightly with the LATEST known share count for every ticker. A stock did a large secondary offering in March, roughly doubling its share count. What does that do to your backtest's weights for January and February of the same year, and how do you fix the data?

Think first, then tap
hardBacktest Mechanics

A vectorized backtest that doesn't sequence same-day buys and sells can show a phantom margin breach that would never happen live

Question

Your backtest generates target weights each day and computes trades as the difference from yesterday's weights, applying all of them simultaneously via vectorized P&L. On days with both buys and sells, your logged "intraday peak gross exposure" sometimes exceeds your stated margin limit, even though the END-of-day weights are well within limits. Is that a real risk your live execution would also hit, or an artifact?

Think first, then tap
coreData Assembly

float32 vs float64

Question

To halve memory, a teammate proposes storing your entire research price and returns store in float32 instead of float64. Where is that safe, where is it dangerous, and what would you propose instead?

Think first, then tap
hardCalendars & Alignment

As-of joins across feeds

Question

You need each stock's 4pm New York close converted to euros using the FX rate prevailing at that moment. FX ticks arrive on their own irregular timestamps. An exact-timestamp join returns almost nothing. What is the right tool and what are its sharp edges?

Think first, then tap
coreFeature Construction

Rank vs z-score

Question

You are building a value factor from earnings yield. Why might you use the cross-sectional percentile rank instead of the z-score of the raw ratio?

Think first, then tap
hardPerformance Analytics

Information ratio vs Sharpe ratio

Question

Your long-only equity strategy reports a Sharpe ratio of 0.9 and, in the same tearsheet, an information ratio of 1.6 relative to its benchmark. Both measure "return per unit of risk" -- what is actually different about what each one is dividing, and why can they diverge this much?

Think first, then tap
warmupData Assembly

Reading a partitioned parquet dataset: column and filter pushdown vs load-then-filter

Question

You have five years of daily per-ticker pricing data saved as parquet files partitioned by year and month (e.g. data/year=2024/month=03/part.parquet). You need March 2024's close prices for 20 tickers out of a universe of 3000. A teammate writes pd.read_parquet("data/") and then filters with boolean masks. What's wasteful about that, and how do you fix it?

Think first, then tap
hardStatistics

The Probabilistic Sharpe Ratio: testing whether an observed Sharpe is statistically meaningful without assuming normal returns

Question

A strategy backtests at a Sharpe ratio of 1.3 over 3 years of daily data. A naive t-stat on the Sharpe, assuming normality, says it's highly significant. But the return distribution has visible negative skew and fat tails -- occasional sharp drawdowns, frequent small gains -- exactly the shape that makes a normal-theory standard error for a Sharpe ratio unreliable. What does the Probabilistic Sharpe Ratio (PSR) framework do differently, and how does it change the conclusion?

Think first, then tap
warmupCleaning & Corp Actions

The -50% that never happened

Question

Your raw price file shows a stock closing at 500 on Tuesday and 250 on Wednesday, and your return series prints -50% -- but the news shows nothing happened to the company. What is going on, and what is the fix?

Think first, then tap
coreData Assembly

A row-level boolean Series silently nulls every column, not just the one you meant, in a bare df[mask] = value assignment

Question

You want to null out the price column where it's negative: df[df["price"] < 0] = np.nan. Running this on a DataFrame with columns price, volume, and ticker, you discover volume and ticker got nulled on those same rows too -- including ticker, a string column, turning into NaN. What actually happened, and what's the one-line fix?

Think first, then tap
corePortfolio Construction

Overlapping multi-day returns inflate the apparent sample size behind a covariance estimate

Question

To get more "data" for a covariance matrix with only 2 years of daily history, a teammate computes 5-day overlapping rolling returns (each day's trailing week) instead of daily returns, giving roughly 5x as many rows. Does this actually give you a more reliable covariance estimate?

Think first, then tap
coreData Assembly

Tagging vendor origin with pd.concat(keys=...)

Question

You're combining daily bars from two vendors (Bloomberg and a cheaper alt-data provider) into one DataFrame for a reconciliation check. How do you stack them so you can still tell, row by row, which vendor a given observation came from -- without adding a manual "source" column yourself?

Think first, then tap
coreFeature Construction

Lagging features vs returns

Question

Features and returns live in the same daily panel. Walk me through how you align a feature with the return it is supposed to predict. Where exactly does shift() go, and what is the off-by-one that kills backtests?

Think first, then tap
coreData Assembly

Building an ID crosswalk across ticker, CUSIP, and PERMNO

Question

You're joining three vendor feeds: prices keyed by ticker, fundamentals keyed by CUSIP, and a returns database keyed by PERMNO. None of the three feeds share a common key column. How do you build a research panel from all three without producing silent mismatches?

Think first, then tap
coreBacktest Mechanics

The paper-vs-live gap

Question

Your fund's strategies consistently realize about 60 percent of backtested Sharpe once live. Break the gap into its causes and tell me which you can fix in the backtest itself.

Think first, then tap
warmupPortfolio Construction

Short vs long lookback window for estimating the covariance matrix

Question

You're choosing how many days of history to use for the covariance matrix that feeds a mean-variance optimizer -- 60 days, or 3 years. What's the actual tradeoff, and is there a reason to prefer neither extreme?

Think first, then tap
warmupPerformance Analytics

Vectorized max drawdown

Question

Compute maximum drawdown from a daily return series without a loop, and tell me what a drawdown actually measures that volatility does not.

Think first, then tap
coreStatistics

Comparing a new execution algo against the old one: a paired same-day test has far more power than a before/after comparison

Question

You ran the old execution algorithm for three months, then switched to a new one for the next three months, and want to know if the new algo's average slippage is really lower. A two-sample t-test on the two periods' daily slippage comes back insignificant. Before concluding there's no improvement, what's wrong with the setup itself?

Think first, then tap
warmupPerformance Analytics

Information ratio vs Sharpe ratio: skill relative to a benchmark's active risk vs return per unit of total risk

Question

A long-only equity strategy benchmarked against the S&P 500 has a Sharpe ratio of 0.9 and an information ratio of 1.4. Your PM says the IR is the more relevant number here. Why would that be true, and what exactly is each ratio measuring?

Think first, then tap
hardPoint-in-Time

A spin-off's new entity must enter the point-in-time universe on its first trading day, not before -- and the price history being clean doesn't guarantee the universe logic is

Question

Parent company A spins off subsidiary C, which starts trading independently on day T. You're backtesting a strategy that would have wanted to hold C starting from T. Your point-in-time universe construction builds each day's eligible universe from a master reference table that already lists C, built using current, fully up-to-date reference data. What's the lookahead risk here, and how do you fix the universe construction itself, separately from fixing C's price history?

Think first, then tap
coreBacktest Mechanics

Rolling OLS hedge ratio for a pairs trade, without lookahead

Question

You are backtesting a pairs trade: spread equals price of A minus beta times price of B, and you trade the spread's mean reversion. Beta is a hedge ratio estimated by regressing A on B. What is wrong with fitting one beta on the full sample and using it throughout the backtest, and how do you compute it correctly?

Think first, then tap
corePortfolio Construction

Cross-sectional regression betas vs sorted long-short deciles: two ways to turn a characteristic into a factor return, and why they don't agree

Question

You want to estimate the daily return to a "value" characteristic across your universe. One teammate runs a cross-sectional (Fama-MacBeth style) regression of next-day returns on today's value score each day and uses the regression slope as the factor return. Another sorts stocks into value deciles and uses the long-short decile 10-minus-decile-1 spread. Both are legitimate, standard techniques -- why can they give meaningfully different day-to-day factor return estimates from the exact same underlying data?

Think first, then tap
coreData Assembly

merge()'s indicator=True column: diagnosing which rows a join actually dropped, not just how many

Question

You merge a daily returns panel against a reference table on (date, ticker) and the result has fewer rows than the left frame. merge() didn't raise or warn. What's the fastest way to find out WHICH rows were dropped and why, without writing a manual anti-join by hand?

Think first, then tap
warmupBacktest Mechanics

Charging transaction cost on the position LEVEL instead of the TRADE triples the apparent cost of a static book

Question

Your vectorized backtest computes daily transaction cost as cost = weight.abs() * cost_bps, applied every day the position is held, and subtracts it from gross return to get net return. A strategy that picks a handful of positions and HOLDS them for months shows surprisingly low net Sharpe compared to a teammate's version of the same strategy. What's the bug in the cost formula, and what should it be instead?

Think first, then tap
hardStatistics

Deflated Sharpe Ratio: correcting for both trials and non-normal returns

Question

You've backtested 200 variants of a signal, and the best one shows an in-sample Sharpe of 1.8. The Probabilistic Sharpe Ratio test for that one signal, done in isolation, doesn't know you tried 199 others first. What does the Deflated Sharpe Ratio add on top of PSR, and how would you actually compute it?

Think first, then tap
coreCalendars & Alignment

Futures contract roll: calendar-based fixed offset vs volume/open-interest crossover roll dates

Question

You're building a continuous front-month futures price series and need to decide when to roll from the expiring contract to the next one. One teammate wants to roll a fixed N business days before expiration, another wants to roll on the day open interest (the second contract's outstanding contract count) first exceeds the front contract's. What's the tradeoff, and why can a fixed calendar rule and a volume-based rule roll on genuinely different dates for the same contract?

Think first, then tap
hardStatistics

Pooling two strategies' daily returns into one combined volatility estimate assumes they have equal variance -- Levene's test checks that before you average, a t-test for means doesn't

Question

You want one blended volatility estimate for two sub-strategies that you're about to combine into a single book, so you pool both return series together and take the sample standard deviation of the pooled data. A teammate objects that this implicitly assumes the two strategies have the same variance, and asks how you'd actually check that assumption before pooling. What test would you reach for, and why doesn't a t-test tell you anything about it?

Think first, then tap
hardFeature Construction

Neutralizing a factor against sector first, then market cap, isn't the same as one joint regression on both -- unless you partial cap against sector too

Question

You neutralize a value factor against sector first (regress out sector dummies, keep the residual), then neutralize that residual against market cap (regress out cap, keep the residual again). A colleague instead runs ONE regression with both sector dummies and market cap as regressors simultaneously. Do these two approaches give the same residual, and does it matter which you use?

Think first, then tap
hardPoint-in-Time

First-print vs revised macro data (non-farm payrolls)

Question

You backtest a strategy that trades off the monthly US non-farm payrolls number, joined onto your daily panel by the release date. Your vendor's database stores only the CURRENT (most revised) value for each reference month, not what was originally reported. Why is this a point-in-time violation even though you correctly used the release date for the join, and how large is the problem typically?

Think first, then tap
hardPoint-in-Time

A nightly batch ETL job overwrites each record's true arrival time with one shared load timestamp

Question

Your fundamentals vendor delivers data throughout the day as filings get processed, but your ETL pipeline runs once nightly and stamps every single row it ingests that night with the same load_timestamp (the batch job's run time). You then merge_asof using load_timestamp as the availability column. What's wrong with this, and in which direction does the error run?

Think first, then tap
corePoint-in-Time

merge_asof's allow_exact_matches: same-timestamp data isn't always available yet

Question

You join intraday trade signals to the most recent news-sentiment score using pd.merge_asof(trades, sentiment, on="ts", direction="backward"). Both feeds are occasionally stamped with the identical timestamp because your ingestion layer rounds to the nearest second. Is a sentiment row with the same timestamp as a trade row safe to use for that trade?

Think first, then tap
hardFeature Construction

Multiplying two z-scored features for an interaction term quietly creates a feature correlated with that day's dispersion, not just co-movement

Question

You z-score a value signal and a momentum signal cross-sectionally each day, then multiply them to build an interaction feature meant to capture "cheap stocks with momentum." On high-dispersion days you notice the interaction feature's magnitude is systematically larger than on calm days, even for a stock holding the exact same relative rank on both signals. Why does that happen, and does it bias anything downstream?

Think first, then tap
coreStatistics

Kendall's tau vs Spearman for signals with ties

Question

You're computing a rank correlation between a discrete credit-rating-style signal (only 7 distinct values across 500 names, so heavy ties) and forward returns. You default to Spearman's rank-IC, the usual choice. A teammate suggests Kendall's tau instead for this specific signal. What's the difference, and why does tie-heaviness matter for the choice?

Think first, then tap
hardPoint-in-Time

Earnings timing: BMO vs AMC and same-day misattribution

Question

You're building an earnings-surprise feature: actual EPS minus consensus estimate, joined to that day's return to check if the market reacted as expected. Backtested IC looks great, but a colleague points out you may be misattributing the reaction. What's the issue, and how do you fix the join?

Think first, then tap
warmupPerformance Analytics

Tracking error measured against an infrequently-reconstituted benchmark understates true active risk between reconstitution dates

Question

Your fund tracks a small-cap benchmark that's reconstituted (its constituent list refreshed) once a quarter. You compute daily tracking error as the standard deviation of (portfolio return minus benchmark return) using the benchmark's current constituent weights throughout the quarter. A colleague argues this quietly understates your true active risk in the weeks right before the next reconstitution. Why would that be true?

Think first, then tap
corePerformance Analytics

Tearsheet essentials

Question

You get one page to convince a skeptical risk committee about a strategy. What goes on the tearsheet, and what is each panel there to catch?

Think first, then tap
coreBacktest Mechanics

(1 + returns).cumprod() breaks when a levered short's own daily return passes -100% -- a modeling decision, not a code bug

Question

Your vectorized backtest tracks NAV as (1 + daily_returns).cumprod(). A levered short position has a catastrophic day where its own return is -140% (the underlying gapped up violently overnight past your stop). What happens to your NAV series the instant that return gets multiplied in, and why is that actually informative rather than just "a bug to clip away"?

Think first, then tap
coreCleaning & Corp Actions

Reconciling daily closes when two vendors disagree by more than a tolerance

Question

You pull daily closes for the same universe from two vendors, A and B. Most tickers agree to the penny on any given day, but a handful differ by more than 1%. How do you decide, in a repeatable way, which vendor's price to trust for those tickers -- and what do you do with the ones you can't confidently resolve?

Think first, then tap
coreStatistics

Comparing a new signal to an old one on the same stock-days needs a paired t-test, not an unpaired one -- the shared market noise doesn't cancel otherwise

Question

You want to know if a new version of a signal beats the old one. Both are evaluated on the exact same set of stock-days, giving you two paired return series. Your colleague runs an unpaired (independent two-sample) t-test comparing the two return distributions. What's wrong with that, and what should they run instead?

Think first, then tap
corePoint-in-Time

The rolling center=True trap

Question

Someone smooths a signal with rolling(21, center=True).mean() and the strategy's Sharpe doubles. What happened?

Think first, then tap
warmupCleaning & Corp Actions

Consolidated tape duplicate trades across reporting exchanges

Question

You pull US equity trade prints from a consolidated feed (the SIP), and your daily volume totals for a stock come in noticeably higher than the exchange's own reported volume. A teammate suspects duplicate trades. Why would the same trade appear more than once, and why can't you fix it by just calling drop_duplicates() on price, size, and timestamp?

Think first, then tap
coreBacktest Mechanics

The short-sale rebate: crediting interest on short-sale proceeds, not just charging the borrow fee

Question

Your long-short backtest charges a borrow fee (in bps per year) on every short position, which your PM says is correct but incomplete. What's missing, and why does leaving it out bias your Sharpe ratio specifically on the short book?

Think first, then tap
coreCalendars & Alignment

Aligning a weekly-reported series onto a daily trading calendar

Question

The CFTC's Commitment of Traders (COT) report is published once a week, as of every Tuesday's close, but you want to use it as a daily feature in a panel that trades every business day. How do you get a weekly-frequency series correctly onto a daily calendar without introducing lookahead?

Think first, then tap
hardPerformance Analytics

P&L concentration risk

Question

A strategy shows Sharpe 1.5 over five years, but you suspect a handful of days drive everything. How do you test that, and how do you avoid the trap of concluding every strategy is fragile?

Think first, then tap
corePoint-in-Time

An index addition announced after today's close but effective several trading days later: using the EFFECTIVE date as your 'in the index' timestamp throws away the days the predictive signal was actually live

Question

You're building a feature that flags stocks about to receive passive index-fund buying pressure. Your data has both an ANNOUNCED date and an EFFECTIVE date for every index addition, several trading days apart. You timestamp the feature using the EFFECTIVE date, reasoning that's when the flow actually happens. What's point-in-time wrong with that choice, and which date should you actually use?

Think first, then tap
hardBacktest Mechanics

Modeling fill probability for passive limit orders instead of assuming certain execution

Question

You're backtesting a market-making-style strategy that posts passive limit orders at the best bid and ask rather than crossing the spread. Your vectorized backtest currently assumes every posted order fills whenever the market trades through that price level. Why is that assumption dangerous specifically for a passive strategy, and how would you model it more realistically?

Think first, then tap
coreData Assembly

Nullable Int64 dtype vs float64 for an integer column with missing values

Question

You've got a column of share counts (integers) coming from a vendor feed, but some rows are missing because the vendor didn't report that day. Loading it naively into pandas silently turns the column into float64. Why does that happen, what breaks because of it, and how do you keep the column as an integer type?

Think first, then tap
corePerformance Analytics

VaR vs CVaR (Expected Shortfall) for tail risk

Question

Risk asks you to report both 1-day 99% VaR and 1-day 99% CVaR for the book. VaR comes back at -2.1%, CVaR at -3.8%. Explain what each number means, why CVaR is larger, and which one you would want to control if you specifically cared about tail-risk management rather than a single headline number.

Think first, then tap
hardBacktest Mechanics

Sizing today's trade off today's own NAV

Question

Your vectorized backtest computes each day's target dollar position as target_weight * nav, where nav is the portfolio's net asset value built with nav = nav0 * (1 + strategy_returns).cumprod(). A teammate sizes today's trade using that SAME row's nav. The backtest's returns look suspiciously smooth. What's the bug?

Think first, then tap
hardPoint-in-Time

Free-float share data arriving weeks late: a lookahead in your cap-weighted universe cutoff

Question

You compute free-float-adjusted market cap for a cap-weighted universe using the free-float percentage from your vendor's CURRENT snapshot, applied across your whole backtest history. A company did a large secondary offering in 2019 that meaningfully changed its free float, and you're now getting suspiciously good backtest performance around trades sized off that stock's float in the years before 2019. What's wrong, and how do you fix it?

Think first, then tap
hardBacktest Mechanics

Double-counting the bid-ask spread: paying it as a cost AND in the execution price

Question

Your vectorized backtest reconstructs execution prices as ask-when-buying and bid-when-selling, marks daily P&L off those prices, then separately subtracts a per-trade cost model that includes half the bid-ask spread. A teammate says this is double-counting the spread. Are they right?

Think first, then tap
corePerformance Analytics

Six months of Sharpe 2

Question

A pod shows you six months of live returns with an annualized Sharpe of 2 and wants an allocation. Statistically, what do you actually know about their skill?

Think first, then tap
coreData Assembly

Splitting a composite vendor identifier field with str.extract instead of a Python loop

Question

A vendor sends every instrument as one string field like "AAPL US Equity" or "700 HK Equity" -- ticker, then a country/exchange code, then a security type, separated by spaces. You need three clean columns (ticker, exchange, sec_type) out of 5 million rows. How do you do it without a Python-level loop?

Think first, then tap
hardStatistics

Serial correlation inflates the naive Sharpe ratio

Question

Two strategies both show a daily Sharpe of 0.12, about 1.9 annualized via the standard sqrt(252) scaling. Strategy A's daily returns are close to independent day to day; Strategy B's returns have first-order autocorrelation of about 0.3, typical of a slow-turnover strategy holding positions for several days at a time. Should you trust the same annualized Sharpe for both?

Think first, then tap
coreBacktest Mechanics

Sizing positions by a fixed share count vs target dollar exposure silently changes a backtest's realized leverage as prices move

Question

Your vectorized backtest sizes each position ONCE at entry: a fixed share count chosen so the position is exactly $10,000 notional that day, then holds that share count unchanged until exit. Over a multi-month hold where the price doubles, what happens to that position's actual dollar exposure and the book's realized leverage, and why might that silently invalidate a backtest that claims to target 1x gross exposure?

Think first, then tap
warmupBacktest Mechanics

Averaging two sub-strategies' daily percent returns isn't the same as combining their dollar P&L and dividing by total capital -- once capital allocation varies, the two diverge

Question

You run two sub-strategies, each with its own daily return series. A teammate proposes combining them into one portfolio return series with (return_A + return_B) / 2 every day. Another teammate insists you should instead sum daily dollar P&L across both and divide by total capital employed. When do these two approaches give the same answer, and when do they diverge?

Think first, then tap
warmupFeature Construction

A thin trading day makes cross-sectional z-scores blow out from noise, not news

Question

Your daily cross-sectional z-score feature, computed as (value - mean) / std across all names trading that day, looks fine on a normal day with 2,000 names in the universe. On a day where a data outage drops coverage to just 15 names, a handful of z-scores blow out to +/-4 even though nothing unusual happened to those stocks. What's going on, and what would you check or change?

Think first, then tap
hardPoint-in-Time

K-fold cross-validation leaks the future

Question

A researcher trains a return-prediction model with scikit-learn's KFold(n_splits=5, shuffle=True) on five years of daily cross-sectional data, reports a strong out-of-fold R-squared, and wants to ship it. What is wrong with that validation, specifically, and what should replace it?

Think first, then tap
hardBacktest Mechanics

A halted-then-reopened stock's pct_change() silently computes a multi-day return as if it were a single trading day's return

Question

Your daily-bar backtest computes returns with prices.pct_change(). A stock gets halted for two full trading days and reopens with a 15% move from where it was last seen. The resulting return row looks like one ordinary day's return -- nothing flags it as unusual. What's actually happening, and why does it distort the backtest?

Think first, then tap
hardPerformance Analytics

GRS test: jointly testing whether an entire set of strategies' alphas are all zero, not eyeballing each one's t-stat

Question

You've built 15 sector-neutral sub-strategies, each with its own CAPM alpha regression against the market. Individually, three of the fifteen show a significant alpha t-stat at the 5% level. A skeptical PM asks: "with 15 tries, wouldn't you expect about one false positive by chance alone -- how do I know these three are real and not just noise?" What's the right joint test here, rather than re-running multiple-testing corrections on the individual t-stats one more time?

Think first, then tap
corePoint-in-Time

A company changes its fiscal year-end mid-stream, and a PIT join keyed on fiscal quarter number silently skips or duplicates a quarter

Question

Your fundamentals database keys each filing by (ticker, fiscal_year, fiscal_quarter) and joins it onto a trading calendar using the filing's availability date, which you believe is fully point-in-time safe. One company changed its fiscal year-end from January 31 to December 31 a few years ago, filing a short "stub" transition period instead of a normal quarter. What breaks in your PIT pipeline, and how do you detect it?

Think first, then tap
warmupCalendars & Alignment

Time-based rolling windows: rolling('30D') vs rolling(30)

Question

Your daily price panel has occasional missing trading days -- a holiday a vendor didn't flag, a listing that started mid-year. Should a 20-day momentum feature use df["close"].rolling(20) or df["close"].rolling("20D"), and what actually differs between them?

Think first, then tap
corePortfolio Construction

Why position size should scale with expected_return / variance for one name, before the covariance matrix ever enters the picture

Question

Forget the full optimizer for a second. For a single, standalone position with no other holdings to worry about, why does the "right" size scale as expected return divided by variance, rather than just scaling with expected return alone?

Think first, then tap
hardPoint-in-Time

merge_asof's by= key whose own mapping changes over time

Question

You compute a sector-neutral feature with merge_asof(..., by="sector") to join each stock's return onto its sector's same-day benchmark return, where "sector" comes from a static ticker-to-sector lookup table you built once at the start of the project. Six months into a 10-year backtest, a stock gets reclassified into a different sector. What breaks, and why doesn't merge_asof's by= parameter catch it?

Think first, then tap
corePerformance Analytics

Active share vs tracking error

Question

Two long-only funds both benchmark against the same index and both report a tracking error of 4% annualized. Fund A holds every index name at roughly its index weight, plus or minus a little. Fund B holds a much smaller set of names, several not in the index at all, with big over- and under-weights. Can two funds this different really have the same tracking error, and what number would actually distinguish them?

Think first, then tap
coreData Assembly

MultiIndex.from_product to build a complete (ticker, date) skeleton before reindexing a sparse panel

Question

You have a ticker-date panel where not every ticker has a row for every date (some tickers listed later, some had trading halts). Before computing rolling features, you want every ticker to have a row for every date in your date range, with NaN where data is missing. A plain df.set_index(["ticker","date"]) doesn't give you that. What's the right tool and the subtle trap in how you'd reindex onto it?

Think first, then tap
hardCleaning & Corp Actions

Stock-for-stock merger: splicing two price histories together

Question

Company A acquires Company B in an all-stock deal: each B share converts to 0.6 shares of A at the close of the deal. B stops trading; A continues under its own ticker. Your database still has a row for "B" whose price history simply ends on the deal-close date. How should B's history be handled for a backtest that held B going into the deal, and what's the usual wrong way this gets modeled?

Think first, then tap
hardStatistics

Block bootstrap vs IID bootstrap for a Sharpe ratio confidence interval under autocorrelated returns

Question

You want a 95% confidence interval on a strategy's annualized Sharpe ratio using the bootstrap -- resample the daily return series with replacement, recompute Sharpe each time, take the 2.5th/97.5th percentiles. The strategy's returns show meaningful day-to-day autocorrelation (slow signal, overlapping holding periods). Does a standard IID bootstrap give you a valid interval here, and if not, what's the fix?

Think first, then tap
coreCalendars & Alignment

BMonthEnd vs a real exchange calendar for the last trading day of the month

Question

You need the LAST TRADING DAY of each month over a multi-year history to mark rebalance dates, but your universe includes both US and Hong Kong listings with different holiday calendars. Using pandas' pd.tseries.offsets.BMonthEnd() on a plain date_range gives you dates that don't match either exchange's actual last trading session in several months. Why, and what's the fix?

Think first, then tap
hardPoint-in-Time

A vendor that only snapshots once a day, joined into an intraday backtest

Question

Your fundamentals vendor publishes one snapshot per data field per calendar day, timestamped at some fixed batch time like 06:00 UTC. You're building an intraday strategy that trades every 30 minutes and wants that day's fundamentals feature at each bar. What's wrong with just forward-filling the daily snapshot across all of that day's intraday bars, and what does "point-in-time" even mean when the source data itself is coarser than your trading frequency?

Think first, then tap
warmupBacktest Mechanics

Open-to-open vs close-to-close returns: which convention matches when your signal actually fires

Question

Your signal is computed from data available as of yesterday's close, and you plan to trade at today's open. A teammate's backtest computes daily returns as close-to-close (today's close over yesterday's close) and multiplies by the shifted signal. What's the mismatch, and how should the return series be built instead?

Think first, then tap
warmupPerformance Analytics

Gain-to-Pain ratio: a smoother alternative to Sharpe for lumpy P&L

Question

A strategy trades infrequently -- long stretches of flat P&L punctuated by occasional big moves -- and its Sharpe ratio swings wildly depending on the exact sample window because the standard deviation is dominated by just a few days. A risk manager mentions the Gain-to-Pain ratio instead. What is it, and why might it behave better here?

Think first, then tap
coreCleaning & Corp Actions

When a negative price is real: WTI crude, April 2020

Question

Your bad-tick filter has a rule: any price at or below zero is a data error, mask it. In April 2020 the front-month WTI crude oil futures contract traded as low as -37.63 dollars per barrel. Was your filter right to mask that, and what does the episode teach about hardcoding sign-based sanity checks?

Think first, then tap
hardPoint-in-Time

A forward-return label that spans a stock split

Question

You're building a 20-day forward-return label for a supervised model: label(t) = price(t+20) / price(t) - 1. One ticker announces and executes a 2-for-1 split partway through that 20-day window. If the pipeline computes the label off the raw, unadjusted price series, what does it produce, and how do you actually fix it?

Think first, then tap
corePerformance Analytics

The Omega ratio: using the whole distribution

Question

A PM asks why you would ever compute the Omega ratio when Sharpe and Sortino already exist on the tearsheet. Define Omega, explain what it captures that both of the others miss, and name a place it can still mislead you.

Think first, then tap
coreFeature Construction

groupby().rolling(): the extra index level trap

Question

You compute a 20-day rolling mean of returns per ticker with df.groupby("ticker")["ret"].rolling(20).mean() and try to assign it straight back as a new column, df["ret_ma20"] = result. It throws or silently misaligns. What's going on, and what's the fix?

Think first, then tap
warmupPerformance Analytics

A single outlier trade can make average trade P&L a misleading headline number

Question

A strategy's tearsheet reports an average trade P&L of $4,200. Looking at the distribution, one single trade made $380,000 and the other 199 trades averaged slightly negative. Is $4,200 a fair headline number?

Think first, then tap
hardCleaning & Corp Actions

Back-adjusting a price history for a stock split without accidentally double-adjusting an already-adjusted vendor feed

Question

You maintain your own split-adjusted price history, multiplying every pre-split price by the split ratio whenever a new split event arrives. You onboard a new vendor feed for a subset of tickers, and your adjusted prices for those names come out roughly half of what they should be after a 2-for-1 split. What's the likely cause, and what check would have caught it before it went live?

Think first, then tap
hardCleaning & Corp Actions

A consolidated-tape print with volume=0 (an administrative message, not a trade) silently pollutes a 'last price' calc that assumes every row is a trade

Question

Your raw tick file has a "trade" table where almost every row has volume greater than zero, but a small fraction have volume equal to zero. You've been computing each stock's daily "last price" as the price of the last row for that day, sorted by timestamp. What's probably going on with the volume-zero rows, and why does ignoring them bias your last price?

Think first, then tap
coreCleaning & Corp Actions

Pre-market and after-hours prints polluting the 'daily close'

Question

Your vendor's daily bar file defines "close" as the last trade price of the day. For a handful of illiquid small-caps, that close is sometimes wildly different from the 4:00pm regular-session print -- because the last trade of the day was a single after-hours execution at a stale, thinly-traded price. How do you detect and fix this before it corrupts your returns series?

Think first, then tap
hardPoint-in-Time

A split is announced but not yet effective: when do prices actually need adjusting?

Question

A company announces a 2-for-1 stock split on March 1st, with the split becoming effective (shares actually double, price actually halves) on March 15th. Your PIT pipeline is building a feature as of March 10th. Does the March 10th row need any split adjustment yet, and what breaks if you get the timing wrong in either direction?

Think first, then tap
warmupCleaning & Corp Actions

Exchange suffix noise: AAPL vs AAPL.O vs AAPL.OQ for the same stock

Question

You're joining a price feed that tags US-listed stocks as "AAPL.O" (Nasdaq) with a fundamentals vendor that just uses "AAPL", and a third feed that uses "AAPL.OQ". A naive merge on ticker returns almost no matches even though all three cover the same universe. What is actually going wrong, and how do you fix it durably rather than patching this one join?

Think first, then tap
warmupFeature Construction

ddof in a cross-sectional z-score with a small universe

Question

You cross-sectionally z-score a signal on a day when your universe has shrunk to just 12 names (a sector-specific book). A teammate notices the z-scores look slightly different depending on whether they use pandas' default std() or NumPy's default std(). Why do the two disagree, and does it matter here?

Think first, then tap
hardPoint-in-Time

Earnings announcement timing: BMO/AMC and same-day lookahead

Question

Your fundamentals vendor tags each earnings report with just a date, e.g. 2026-07-22, no time. You build a feature that trades off the earnings surprise on that date's close. Some companies report before market open (BMO) that day, others after market close (AMC) that same calendar date. What's the point-in-time bug, and how do you fix it?

Think first, then tap
corePortfolio Construction

Diagnosing which constraint is actually binding: sector cap vs single-name cap

Question

Your optimizer has both a single-name position cap (no more than 5% gross in any one name) and a sector cap (no more than 25% gross in any one sector). The portfolio comes back looking underweight its highest-conviction tech names. A PM asks: is that the name cap or the sector cap doing that? How do you actually answer that, rather than guess?

Think first, then tap
hardCalendars & Alignment

pytz vs zoneinfo: diverging historical DST rules for the same timezone name

Question

You localize a timestamp from 2015 to "America/Sao_Paulo" using pandas, and get a different UTC offset depending on whether your environment's tz data library is pytz or the newer zoneinfo-backed data. Why would the SAME historical date and the SAME named timezone give two different answers depending on which backend is active, and what should you actually trust?

Think first, then tap
hardStatistics

Benjamini-Hochberg false discovery rate vs Bonferroni when screening hundreds of signals

Question

You've screened 200 candidate signals and want to flag which ones have a statistically significant IC without being so conservative that you throw out everything. A teammate suggests Bonferroni correction; another suggests Benjamini-Hochberg. What's the actual difference in what each one controls, and why does it matter which one you pick at this scale?

Think first, then tap
warmupPortfolio Construction

A portfolio stop-loss rule changes the shape of the return distribution, not just its tail

Question

A PM wants a simple portfolio-level rule: if the book is down 5% from its high-water mark, cut gross exposure in half until it recovers. Backtested, this improves the Sharpe and shrinks max drawdown. Before recommending it, what should you check about HOW the rule changes the return distribution, beyond just "it cuts losses"?

Think first, then tap
hardPerformance Analytics

Jensen's alpha vs average excess return: why regression-based alpha differs once beta isn't exactly 1

Question

Two people compute "alpha" for the same strategy: one just takes the average of (strategy return minus benchmark return) each period; the other regresses strategy return on benchmark return and reports the intercept (Jensen's alpha). For a strategy with a beta of 0.7, these two numbers come out meaningfully different. Why, and which one should go in the tearsheet headline?

Think first, then tap
coreStatistics

Fama-MacBeth: why average per-date regressions instead of pooling

Question

You want to estimate how much a stock's forward return is explained by its book-to-market ratio and its size, across a panel of 2,000 stocks and 10 years of monthly data. A colleague proposes pooling all (stock, month) observations into one big OLS regression. You suggest Fama-MacBeth instead. What's the difference, and why does it matter for the standard errors?

Think first, then tap
hardPortfolio Construction

Denoising a covariance matrix with Marchenko-Pastur eigenvalue clipping

Question

You estimate a 500-asset sample covariance matrix from 750 days of returns for a mean-variance optimizer. Ledoit-Wolf shrinkage helps, but you want to understand mechanically WHY the sample covariance's eigenvalues are unreliable in the first place. Walk through the argument and an alternative fix.

Think first, then tap
corePortfolio Construction

Partial rebalancing toward target weights under a turnover budget

Question

Your optimizer outputs a new target weight vector every day, but your desk caps turnover at 5% of gross notional per day for cost reasons. Today's target weights imply 12% turnover from your current holdings. How do you decide what to actually trade, and does simply scaling every trade down to 5/12 of its size solve the problem?

Think first, then tap
warmupCleaning & Corp Actions

Forward-filling vs interpolating missing daily closes

Question

Your daily close price series has a few missing days scattered through it, not holidays, presumably a data outage. Should you forward-fill the last known price, linearly interpolate between the surrounding prices, or drop the rows? Walk through the tradeoff.

Think first, then tap
hardCleaning & Corp Actions

A stock goes to literal zero after Chapter 11 -- what breaks and how do you handle it

Question

A company you hold files for bankruptcy and its shares are cancelled; the vendor feed shows the price going to exactly 0.00 and then the ticker disappears. Walk through what this does to your log-return calculation and your delisting-return convention, and how you would handle it so the event doesn't silently corrupt a rolling feature built from log prices.

Think first, then tap
warmupPerformance Analytics

Sharpe and the sqrt(252)

Question

Define the Sharpe ratio precisely, compute it from daily returns, and explain where the square root of 252 comes from - what assumption is it smuggling in?

Think first, then tap
warmupFeature Construction

Don't z-score one-hot sector dummies alongside your continuous features

Question

You're building a design matrix for a cross-sectional regression: a momentum feature, a value feature, and sector membership one-hot-encoded into 10 dummy columns. A teammate suggests running the whole matrix through a single StandardScaler so "everything is on the same scale." What goes wrong if you z-score the one-hot columns too?

Think first, then tap
warmupPerformance Analytics

K-ratio: rewarding a smooth equity curve, not just its endpoint

Question

Two strategies end the year at the identical cumulative return. Strategy A climbs in a nearly straight line all year. Strategy B is flat for ten months, then makes almost the entire year's gain in one lumpy two-month burst. Daily-return Sharpe on the two might not clearly separate them. What single metric specifically rewards "the straight line," and how is it built?

Think first, then tap
hardStatistics

Block bootstrap for autocorrelated strategy returns

Question

You want a bootstrap confidence interval for your strategy's annualized Sharpe ratio. Your daily returns have first-order autocorrelation of about 0.15 from overlapping signal decay. A teammate resamples individual days with replacement, the standard iid bootstrap. What's wrong with that, and what should you do instead?

Think first, then tap
warmupCalendars & Alignment

pd.bdate_range's default weekmask is Monday-Friday with ZERO holiday awareness -- it will happily hand you Christmas and Thanksgiving as valid trading days

Question

You generate a daily index for a backtest with pd.bdate_range(start, end) and reindex your price panel onto it. On December 25th, every price column is NaN. Is that a bug in your data, or a bug in your calendar?

Think first, then tap
coreCleaning & Corp Actions

When-issued trading: a bond trading before its official issue date pollutes your price history

Question

You're building a price history for newly auctioned Treasury notes. A note auctioned on a Wednesday for settlement the following Thursday already has trade prints in your feed starting the day of the auction -- a full week before its official issue date. Your loader keys each series by issue date and drops anything dated earlier as "pre-issue noise." What's actually going on, and why is dropping those rows wrong?

Think first, then tap
corePerformance Analytics

Ulcer Index: a drawdown-based risk metric that penalizes depth and duration together

Question

Max drawdown tells you the worst single peak-to-trough loss. It doesn't tell you whether that strategy spent one bad week underwater or three grinding years. What single number captures both depth AND duration of drawdowns, and how do you compute it?

Think first, then tap
coreStatistics

Fisher z-transformation: testing whether an IC is significantly different from a benchmark, not just from zero

Question

Your new signal has an average IC of 0.04 over 500 days. Your existing production signal has an IC of 0.03 over the same period. You want to know if the new signal's IC is statistically distinguishable from the OLD signal's IC -- not just whether either is different from zero. How do you test that?

Think first, then tap
hardStatistics

White's Reality Check: bootstrapping the MAX Sharpe ratio across many candidate strategies, not testing the winner in isolation

Question

You backtested 200 variants of a signal (different lookback windows, different universes) and the best one has a Sharpe of 1.8 with a p-value of 0.01 against the usual null of zero mean return. Your manager asks: is that p-value actually meaningful, given you tried 200 things? What test accounts for this correctly, and how does it differ from just Bonferroni-correcting the single best p-value?

Think first, then tap
corePerformance Analytics

Expected Shortfall (CVaR) vs VaR: why risk managers prefer the tail average

Question

Your risk report shows 95% VaR of -2.3% for the book's daily return. A risk manager asks for the 95% Expected Shortfall too, and says VaR alone isn't a reliable risk measure to base limits on. What's the difference, and why is VaR the weaker measure?

Think first, then tap
warmupBacktest Mechanics

A single flat transaction-cost assumption applied to every name understates costs on illiquid small caps and overstates them on liquid large caps

Question

Your backtest charges a flat 5 basis points of trade value as transaction cost on every trade, regardless of which stock it is. The strategy trades both liquid mega-caps and thinly-traded small caps in roughly equal dollar amounts. What does a single flat cost assumption get systematically wrong, and in which direction for each group?

Think first, then tap
hardStatistics

James-Stein shrinkage: why pulling every IC estimate toward the group mean helps

Question

You've estimated the information coefficient (IC, the correlation between a signal and forward returns) separately for 40 related signals, each from a modest sample. Several come back surprisingly high, several surprisingly low or even negative, and you suspect some of that spread is just estimation noise rather than genuine differences in signal quality. A colleague suggests shrinking each estimate toward the group average before trusting it. Why would that actually help, and what's the counterintuitive part?

Think first, then tap
hardBacktest Mechanics

A vectorized backtest double-charges commission when turnover is computed on gross dollar flow instead of net share delta

Question

Your vectorized backtest computes trading cost each rebalance as a flat rate times the GROSS dollar value of all buys plus all sells that period. On a rebalance where you sell $10,000 of a name and simultaneously the signal says to buy $10,000 of the SAME name (say, your target weight for it didn't actually change, but your rebalancing code sells the old lot and buys a fresh one every period regardless), the cost model charges commission on $20,000 of gross flow. What's the actual bug, and how should cost be computed instead?

Think first, then tap
hardPerformance Analytics

Smooth returns, inflated Sharpe

Question

A credit fund reports monthly returns with lag-one autocorrelation of 0.4 and a Sharpe of 2.1. Why is that Sharpe inflated, roughly how much, and what does the autocorrelation itself tell you?

Think first, then tap
coreBacktest Mechanics

Tick-size rounding: a vectorized backtest assuming continuous prices misprices penny-stock fills

Question

Your vectorized backtest computes target dollar positions and continuous fractional share counts for a universe that includes several sub-$2 stocks. On paper the strategy shows a healthy Sharpe, but you suspect the P&L is partly fictional for the cheap names. What's the mechanism, and how would you check it?

Think first, then tap
hardPortfolio Construction

Weight-averaging each position's days-to-liquidate understates how long the WHOLE book actually takes to unwind

Question

Your risk report shows a weighted-average days-to-liquidate of 1.2 days for a 150-name book, computed as the dollar-weighted average of each position's own (position size / (ADV x participation cap)) days-to-liquidate. A risk manager says this materially understates how long a full book liquidation would actually take. Why would a per-position weighted average be too optimistic?

Think first, then tap
coreCalendars & Alignment

CustomBusinessHour: modeling a trading session that isn't midnight-to-midnight

Question

Your intraday backtest for a single-session futures product needs to know elapsed trading minutes since session open, but the product trades 09:30 to 16:15 ET, not midnight to midnight, and pandas' business-day offsets only know about whole days. How do you encode the actual trading HOURS, not just trading days?

Think first, then tap
corePerformance Analytics

Decomposing P&L by holding-period length to find where the edge lives

Question

Your tearsheet shows an overall Sharpe of 1.8, and the PM wants to know whether that edge comes from fast trades or from names you hold for a while. You have entry and exit timestamps for every closed round trip. How do you decompose the book's P&L by holding-period length to answer that, and what's the catch in only looking at closed trades?

Think first, then tap
coreBacktest Mechanics

Auction-only slippage: modeling market-on-close orders when there's no continuous order book to walk

Question

Your continuous-session backtest models slippage with a square-root market impact function calibrated on ADV and order size, walking a simulated order book. You now want to backtest a strategy that executes exclusively via market-on-close (MOC) orders at the closing auction. Why does the continuous-session impact model not transfer, and what should replace it?

Think first, then tap
hardCleaning & Corp Actions

Deduplicating ticks from a redundant primary/backup feed by (timestamp, price, size) both merges distinct trades and misses true duplicates -- exchange sequence number is the only reliable key

Question

Your tick database ingests the same exchange's trades from two redundant feeds (primary and backup) for failover, so every real trade should appear twice, back to back. You dedup by dropping rows with the same (timestamp, price, size). After dedup, your trade count is noticeably off from the exchange's official daily volume, in both directions on different days. What's wrong with the dedup key, and what should replace it?

Think first, then tap
hardStatistics

Simpson's paradox: an aggregate correlation that reverses sign once you split by subgroup

Question

Pooling all sectors together, your value factor shows a positive correlation with forward returns. But when you compute the correlation separately within each sector, it's negative in every single sector. Both numbers came from the same data and the same computation, just aggregated differently. Which one do you trust, and what caused the flip?

Think first, then tap
coreFeature Construction

Why control for log(market cap), not raw market cap, when neutralizing size

Question

You want to strip out the size effect from a signal by regressing it on market cap and keeping the residual. Your first attempt uses raw market cap as the regressor and the neutralization barely changes anything for large-cap names but does something odd to micro-caps. What's wrong, and what should the regressor be?

Think first, then tap
corePoint-in-Time

Using a 10-Q's fiscal period-end date instead of its actual filing date as the point-in-time timestamp introduces 30-45 days of lookahead

Question

You're building a point-in-time fundamentals table from quarterly filings. The data has a "period_end" column (e.g., 2024-03-31 for Q1) and a "filed_date" column (e.g., 2024-05-08, when the 10-Q actually hit EDGAR). Which one should control when a feature built from that filing becomes usable in a backtest, and what breaks if you pick wrong?

Think first, then tap
warmupCalendars & Alignment

isocalendar() week numbers at the year boundary

Question

You build a weekly momentum feature by grouping daily returns with df["date"].dt.isocalendar().week. On December 29, 2025 (a Monday), the week number comes back as 1, not 52 -- and .dt.year on that same date still says 2025. A groupby(["year", "week"]) then silently merges that Monday with days from January 2026's week 1. What's going on, and how do you fix the grouping key?

Think first, then tap
warmupPoint-in-Time

Point-in-time credit ratings: press-release timestamp vs effective timestamp

Question

Your credit desk ingests a ratings-history file where each row has a rating, an effective_date, and the bond's CUSIP. You join this to your position history by effective_date to flag any downgrade that happened while you held the position. Backtests show suspiciously good timing on avoiding downgrades right before they happen. What's the likely point-in-time bug?

Think first, then tap
hardPoint-in-Time

Split-adjusting historical prices with a factor not known until the split occurs

Question

Your price database stores split-adjusted prices, recomputed nightly: whenever a split happens, the entire historical price series for that ticker gets multiplied by the new adjustment factor so today's prices and 5-year-old prices stay comparable. You backtest a strategy using this database naively over history. Where exactly does lookahead bias sneak in, and does it matter for a strategy that only trades on returns, not price levels?

Think first, then tap
coreFeature Construction

Estimating a signal's natural half-life

Question

Your cross-sectional ranks for a signal change somewhat every day. Before picking a rebalance frequency, how do you estimate the signal's own natural holding period from its autocorrelation, and how does that number discipline your turnover budget?

Think first, then tap
coreData Assembly

Integers with missing values

Question

You load a volume column that should be whole numbers, but df["volume"].dtype comes back float64, and 1000000 prints as 1000000.0. What happened, and what are your options?

Think first, then tap
corePortfolio Construction

Netting offsetting trades from independent signals before execution

Question

Your book runs two independent signals, each producing its own target weights. Combined, signal A wants to buy 200bp of AAPL while signal B, independently, wants to sell 150bp of AAPL. If you send each signal's trades to execution separately, what goes wrong, and how should target weights actually reach the trading desk?

Think first, then tap
coreCleaning & Corp Actions

Bid-ask bounce: spurious negative autocorrelation in trade prices

Question

You compute the lag-1 autocorrelation of trade-by-trade price changes for a liquid stock and find it's reliably negative, around -0.3, even over calm periods with no news. A junior researcher gets excited that this looks like a tradeable short-term reversal signal. Should they be?

Think first, then tap
coreBacktest Mechanics

Square-root market impact model for scaling slippage with trade size

Question

Your backtest currently charges a flat basis-point cost per trade regardless of size. A colleague points out that a $50M order in a $200M ADV name should cost far more per share than a $500K order in the same name. How do you model that, and why square root specifically rather than a linear relationship with size?

Think first, then tap
coreData Assembly

explode() for one-to-many child fills

Question

Your execution log has one row per parent order, and a column called fills that holds a Python list of (price, size, ts) tuples -- one entry per CHILD fill that order received throughout the day. You need one row per fill to compute slippage against arrival price. How do you get there, and what do you check afterward?

Think first, then tap
warmupCalendars & Alignment

date_range(freq='B') vs a real exchange calendar: business days aren't trading days

Question

A teammate builds their master date index with pd.date_range(start, end, freq="B") and calls it the trading calendar. What's wrong with that, and what would you use instead?

Think first, then tap
warmupCalendars & Alignment

SemiMonthEnd / freq='SM' for twice-a-month rebalance schedules

Question

Your desk rebalances twice a month: the 15th (or nearest valid day) and the last trading day of the month. You want to generate that exact date series for the next two years without hand-coding month lengths. What's the idiomatic pandas tool, and what's the gotcha around "nearest valid trading day"?

Think first, then tap
corePortfolio Construction

Dollar-neutral vs beta-neutral long-short construction

Question

You run a long-short equity book and want zero net market exposure. One version of "neutral" is making the dollar value of your longs exactly equal to your shorts (dollar-neutral). Another is making the weighted beta of your longs equal the weighted beta of your shorts (beta-neutral). Are these the same thing, and what actually happens to your book in a sharp market selloff if you only did the first one?

Think first, then tap
warmupCalendars & Alignment

Reindexing to a master calendar

Question

You have closes for 500 stocks in a wide DataFrame, but each column came from a separate query and some are missing random days. How do you get every series onto one common set of dates, and what does reindex actually do?

Think first, then tap
corePortfolio Construction

Two books with identical gross leverage can have very different realized volatility

Question

Both Book A and Book B run 3x gross leverage (sum of absolute weights = 3.0). The PM assumes they're carrying similar risk. Is that assumption safe?

Think first, then tap
warmupData Assembly

assign() for building several derived columns in one non-mutating chain

Question

You're building a small feature table from a raw prices DataFrame: a daily return column, a rolling volatility column, and a boolean "high_vol" flag, each derived from the one before it. A teammate writes df["ret"] = ...; df["vol"] = ...; df["high_vol"] = ... as three separate mutating lines. What's the assign()-based alternative, and why would you prefer it in a shared research notebook?

Think first, then tap
coreFeature Construction

groupby().transform() vs groupby().apply() for a per-sector cross-sectional z-score: one guarantees the output re-aligns to df's original row order, the other doesn't

Question

You compute a per-sector, per-day z-score of a factor two ways: a groupby(...).transform(lambda x: (x - x.mean()) / x.std()) and a groupby(...).apply(lambda x: (x - x.mean()) / x.std()). On most days they give identical numbers in a different shape. Under what condition can the apply() version come back in an order that no longer lines up with df's original rows if you grab its .values directly, and why doesn't transform() have that problem?

Think first, then tap
coreFeature Construction

Group-demeaning vs regression-residual for sector-neutralizing a signal

Question

You need to sector-neutralize a raw signal (say, earnings yield) before using it, because it's structurally higher in some sectors (energy) than others (tech) for reasons that have nothing to do with the signal's predictive content. One approach: subtract each stock's sector's cross-sectional mean. Another: regress the signal on sector dummy variables and keep only the residual. Are these the same thing, and when would you pick one over the other?

Think first, then tap
hardPoint-in-Time

merge_asof without a tolerance happily matches a fundamentals row from months ago when nothing recent exists

Question

You join daily prices to the most recent quarterly fundamentals using pd.merge_asof(prices, fundamentals, on="date", by="ticker", direction="backward") -- the standard point-in-time pattern. For a ticker that stopped filing (went private mid-process, or a data feed broke) six months ago, every day after that silently matches against that same six-month-old fundamentals row instead of getting a clear gap. Is this a bug in merge_asof, and how do you catch it?

Think first, then tap
coreStatistics

Block bootstrap for autocorrelated returns

Question

You want a confidence interval on a strategy's annualized Sharpe ratio via bootstrap. If you resample daily returns with the standard iid bootstrap (drawing individual days with replacement), what goes wrong when the strategy's returns are autocorrelated -- say, a slow-moving trend strategy -- and how does a block bootstrap fix it?

Think first, then tap
warmupStatistics

What a p-value of 0.03 actually means

Question

Your backtest gives a factor a p-value of 0.03 on its Sharpe ratio. Walk me through, in plain language, exactly what that 0.03 means -- and what it does NOT mean.

Think first, then tap
warmupFeature Construction

Rolling vs EWM

Question

What is the difference between a 20-day rolling mean and an exponentially weighted mean (EWM) with a 20-day halflife? When would you prefer each for a trading feature?

Think first, then tap
hardPortfolio Construction

A sample covariance matrix with more assets than time periods is singular -- shrinkage (Ledoit-Wolf) fixes it, not just more lookback

Question

You're building a covariance matrix for 500 stocks but only have 300 days of return history. The sample covariance matrix is singular -- not invertible -- which breaks a mean-variance optimizer that needs its inverse. Getting more lookback isn't an option (you don't have more history). What do you do?

Think first, then tap
coreFeature Construction

Combining signals: rank-average vs z-score-average

Question

You have three raw signals, differently scaled and with different tail behavior, and you want one composite score per name per day. Walk me through rank-averaging versus z-score-averaging, and when you would pick one over the other.

Think first, then tap
coreFeature Construction

groupby.rank(pct=True) and NaN: where do missing values land?

Question

You compute a cross-sectional percentile rank of a value factor with df.groupby("date")["value_score"].rank(pct=True), but about 15% of names are missing value_score on any given day because fundamentals haven't been reported yet. You feed the result straight into a long-short portfolio construction step. What happens to the missing names, and why is that dangerous if you don't check for it?

Think first, then tap
warmupPortfolio Construction

A dollar-neutral long-short book (weights summing to zero) is not the same thing as a market-neutral book

Question

Your long-short portfolio's weights sum to exactly zero -- for every dollar long, there's a dollar short, so net exposure is zero. Your PM asks whether that means the book is market-neutral. Is it, and what additional number would you actually need to check?

Think first, then tap
corePortfolio Construction

Why maximizing Sharpe and minimizing variance for a target return land on the same weights

Question

Your optimizer has two modes: "maximize Sharpe ratio" and "minimize variance subject to a target expected return." A junior researcher is surprised that for every choice of target return, the minimum-variance solution turns out to be just a rescaled (leveraged up or down) version of the single portfolio that maximizes Sharpe. Why is that true, and what does it tell you about what the optimizer is actually doing?

Think first, then tap
coreData Assembly

merge()'s validate param: catching a many-to-many join you didn't intend

Question

You join a trades DataFrame (one row per trade) to a reference table of (ticker, sector) on ticker, expecting a clean many-to-one join -- many trades map to exactly one sector row each. After the merge the trades DataFrame has grown from 10,000 rows to 10,400. What likely happened, and how do you catch this kind of bug before it reaches production, rather than noticing it from a suspicious row count?

Think first, then tap
hardStatistics

Variance ratio test: mean reversion or trending beyond lag-1 autocorrelation

Question

You've checked lag-1 autocorrelation of daily returns and it's near zero, so you conclude the series is a random walk. A colleague says that's not enough -- you need a variance ratio test. What does the variance ratio test check that lag-1 autocorrelation misses, and how do you compute it?

Think first, then tap
coreCalendars & Alignment

CustomBusinessDay: encoding an exchange's own holiday calendar

Question

You start covering LSE-listed stocks and build your date index with pd.bdate_range(start, end) -- the same call you've always used for US names. The resulting dates include UK bank holidays like the late-May and August bank holidays, where your vendor has no data at all. What's wrong with the calendar, and how do you fix it per-exchange?

Think first, then tap
coreBacktest Mechanics

Index reconstitution day volume is not liquidity you can trade against

Question

Your capacity model estimates each stock's tradable size from its 21-day average daily volume (ADV). One name in your book got added to a major index last quarter, and its reported volume spiked to 5x normal for a single day -- the reconstitution effective date -- before falling back. Your rolling ADV window still has that day baked in, quietly propping up the name's estimated capacity. What is wrong with that volume, and how do you handle it?

Think first, then tap
coreFeature Construction

Hampel filter: a rolling-median-based outlier flag that doesn't need a fixed global threshold

Question

You want to flag outliers in a feature using a rolling window instead of one full-sample MAD z-score (which can't run online and gets dominated by regime shifts). What's the Hampel filter, and why might it behave better than a rolling mean +/- k*std band?

Think first, then tap
corePoint-in-Time

Index addition announcement date vs effective date: which one flips a membership flag

Question

A stock is announced as being added to the S&P 500 after market close on a Thursday, with the addition taking effect before market open the following Monday. You're building a point-in-time feature "is this name currently an S&P 500 member" for a signal that uses index membership. Which date do you use to flip that flag, and what breaks if you get it wrong?

Think first, then tap
warmupFeature Construction

Winsorizing before z-scoring a cross-sectional feature

Question

You're building a cross-sectional z-score of a valuation feature (like earnings yield) across roughly 2000 names for today's date. A handful of names have extreme values -- a stock with near-zero earnings can blow the ratio up to 500x normal. If you z-score first, what breaks, and how does winsorizing fix it?

Think first, then tap
corePerformance Analytics

Factor exposure decomposition

Question

Your market-neutral fund returned 12 percent. How do you determine how much was true alpha versus riding factors like momentum or value - and what are the two ways to do it?

Think first, then tap
hardPerformance Analytics

The Deflated Sharpe Ratio: adjusting an in-sample Sharpe for how many strategy variants you actually tried, plus the return series' own skew and kurtosis

Question

You tested 200 variants of a strategy (different lookbacks, thresholds, universes) during research and are presenting the single best one's Sharpe ratio to your PM. The PM asks: "how do I know this isn't just the best of 200 noisy draws?" What's the Deflated Sharpe Ratio, and what two things does it adjust for that a plain Sharpe ratio with a t-stat doesn't?

Think first, then tap
corePortfolio Construction

Turnover penalty: trading off alpha capture against transaction costs in the optimizer

Question

Your mean-variance optimizer re-solves every day and, given noisy alpha estimates, wants to make large trades to chase small forecast changes -- realized transaction costs eat most of the paper alpha. How do you fix this inside the optimization itself, rather than by hand-tuning trade thresholds after the fact?

Think first, then tap
coreCleaning & Corp Actions

Special dividends in a total-return adjustment

Question

A stock trading at $50 pays a one-time special dividend of $5 (10% of price) alongside its regular $0.30 quarterly dividend. Your total-return adjustment pipeline applies the same ex-date adjustment factor formula to both. Is that correct, and does anything downstream still need to treat the special dividend differently?

Think first, then tap
hardPoint-in-Time

Survivorship bias in an options chain snapshot

Question

You're building a backtest of a covered-call strategy and pull "the AAPL options chain" from your vendor's database for every historical date in your sample, using their live chain endpoint with a date parameter. What's wrong with that data source for a backtest, and how does the failure mode resemble equity survivorship bias but with a wrinkle specific to options?

Think first, then tap
warmupCalendars & Alignment

The normalize() trap when merging date-only data onto timestamped data

Question

You have daily closes indexed by pd.Timestamp("2026-08-14") (implicitly midnight) and a second dataframe of macro releases whose date column was parsed from a CSV as pd.Timestamp("2026-08-14 08:30:00") -- release time included. You merge on that column and get almost no matches, even though both cover the same days. What happened, and what's the one-line fix?

Think first, then tap
coreFeature Construction

Rolling Spearman correlation: why .rolling().corr() isn't it

Question

You want a feature that tracks the rolling 60-day rank correlation between a signal and forward returns, to see if the signal's monotonic relationship with returns is strengthening or weakening over time. A teammate writes signal.rolling(60).corr(fwd_ret). Does that give you rolling Spearman correlation?

Think first, then tap
hardPoint-in-Time

merge_asof across mismatched timestamp precision: second-level vs millisecond-level feeds

Question

You're joining a news-sentiment feed, timestamped to the second, onto a tick feed timestamped to the millisecond, using merge_asof with direction="backward" to attach "most recent sentiment as of this tick." Two sentiment stories and a tick all land in the same wall-clock second. Walk through what merge_asof actually does here and where the point-in-time risk is.

Think first, then tap
hardCalendars & Alignment

Fiscal year vs calendar year: resampling on a non-standard fiscal year end

Question

A company's fiscal year ends June 30, not December 31 -- plenty of retailers and several large caps report this way. You need to resample its quarterly fundamentals into fiscal-year buckets to compute year-over-year growth. Using pandas' default resample("YE") would bucket by calendar year instead. How do you resample correctly on a custom fiscal year end, and why does getting this wrong quietly corrupt YoY comparisons?

Think first, then tap
coreCalendars & Alignment

rolling(window, closed=...): the edge-inclusion trap

Question

You compute a trailing realized-volatility feature on irregular intraday timestamps with price.rolling("2D", closed="right").std() so it can run on ticks that don't land on a fixed grid. A colleague says closed="right" is dangerous here -- it might leak the current tick's own price into its own window, or worse, leak future ticks. Is that right, and what does closed actually control on a time-offset window?

Think first, then tap
warmupFeature Construction

NaN propagation when averaging several z-scored features into one composite

Question

You build a composite alpha score as the simple average of five z-scored features. One stock is missing two of the five features today (say, a fundamentals feature not yet reported this quarter). Using composite = features_df.mean(axis=1) to average across columns, what actually happens to that stock's score, and is it what you want?

Think first, then tap
corePortfolio Construction

Shrinkage: Ledoit-Wolf intuition

Question

Explain Ledoit-Wolf shrinkage to me like I am a PM: what is being averaged with what, and why does a deliberately biased covariance estimate produce better portfolios?

Think first, then tap
hardPortfolio Construction

Hierarchical Risk Parity: allocating without inverting

Question

Your covariance matrix is already Ledoit-Wolf shrunk, but mean-variance optimization on a 200-stock universe still produces concentrated, unstable weights. A colleague suggests Hierarchical Risk Parity instead of any matrix-inversion-based optimizer. What is the core idea, and why does avoiding inversion actually help?

Think first, then tap
hardPerformance Analytics

Christoffersen's independence test: catching clustered VaR breaches Kupiec's test misses

Question

Your daily 99% VaR model breaches its threshold on exactly 1% of days over a 3-year sample, so it passes Kupiec's proportion-of-failures test cleanly. A risk committee member is still uneasy and asks you to check whether the breaches are CLUSTERED in time rather than scattered randomly. Why does that matter beyond what Kupiec's test already checks, and how do you test for it?

Think first, then tap
corePortfolio Construction

Per-position stop-loss orders bolted onto a mean-variance-optimized book quietly fight the optimizer's own risk allocation

Question

Your optimizer sizes each position so that its marginal contribution to portfolio risk matches your target risk budget, given the covariance matrix at rebalance time. Risk management then overlays a hard rule: any position down more than 8% since entry gets automatically closed. Why can that rule work against the optimizer rather than alongside it, even though both are nominally "risk management"?

Think first, then tap
warmupPerformance Analytics

Sharpe on gross vs net notional: why the denominator can change the number by 2x

Question

A market-neutral long-short book runs 100% long and 100% short -- 200% gross notional, 0% net notional. Two people on the desk quote different Sharpe ratios for the same P&L series because one scales returns by gross exposure and the other by net exposure. Walk through why the choice of denominator matters here and which convention you would default to.

Think first, then tap
warmupData Assembly

reindex's fill_value: turning missing rows into fake zeros

Question

You reindex a Series of daily trading volume onto a full calendar of dates with df["volume"].reindex(full_dates, fill_value=0) so every date lines up. A teammate reindexes the CLOSE price column the same way. What's the difference, and why is one of these calls dangerous?

Think first, then tap
coreStatistics

Shapiro-Wilk and Jarque-Bera both miss the threat that actually matters

Question

You want to check whether your strategy's daily returns are normal before trusting a plain t-test's p-value on the Sharpe ratio. You run both a Shapiro-Wilk test and a Jarque-Bera test on 500 days of returns; neither rejects normality. Should you now trust the t-test?

Think first, then tap
corePoint-in-Time

Filtering your universe by average daily volume over a CENTERED window is a liquidity lookahead, not just an approximation

Question

Your backtest restricts the tradable universe each month to names with average daily dollar volume above $5 million. You compute that average using a trailing-and-leading 252-day window centered on the rebalance date, since it "gives a more stable liquidity estimate." What's wrong with that, and what would you check?

Think first, then tap
coreFeature Construction

A single outlier in the neutralization control variable corrupts the whole slope

Question

You neutralize your signal against log market cap using the closed-form single-regressor OLS slope from earlier in this module. On one date, a data error makes one stock's market cap look 100x too large. What does that do to that day's neutralization, and what's a cheap fix that doesn't require rebuilding the whole thing as a robust regression?

Think first, then tap
hardCleaning & Corp Actions

Decimal-comma vs decimal-point locale mismatch silently misparsing prices

Question

A European data vendor sends you a CSV where numbers are formatted "1.234,56" -- period as the thousands separator, comma as the decimal point -- instead of the US convention. Your loader reads these columns without raising an error, but every price comes out wrong. What's actually happening, and what's the fix?

Think first, then tap
warmupCleaning & Corp Actions

4pm last-trade print vs the closing-auction print: two different numbers called 'close'

Question

Two vendor files both have a column named close for the same ticker and date, but the values differ by a few cents most days and by much more around index rebalance dates. What's actually different between them, and which one should your backtest use?

Think first, then tap
hardPortfolio Construction

Flooring idiosyncratic risk in a factor-model covariance so illiquid names don't get implausibly tiny variance

Question

Your factor-model covariance matrix is built as Sigma = B F B' + D, where B is factor exposures, F is the factor covariance, and D is a diagonal matrix of idiosyncratic variances estimated by regressing each stock's returns on the factors. For one thinly-traded name, the estimated idiosyncratic variance comes out near zero. The optimizer responds by piling into it far past any reasonable position limit. What went wrong with D, and how do you fix it?

Think first, then tap
coreStatistics

Wilcoxon signed-rank test: a nonparametric check when daily returns aren't normal

Question

You want to test whether a strategy's daily returns are centered above zero, but a histogram shows them visibly skewed and fat-tailed, and a paired t-test's normality assumption feels shaky with only 150 observations. What's a nonparametric alternative, and what exactly does it test?

Think first, then tap
warmupBacktest Mechanics

Turning a market-neutral book's daily dollar P&L into a return percentage: starting capital, ending capital, or today's own gross notional?

Question

Your long-short backtest produces a daily dollar P&L series. To report a Sharpe ratio you need daily RETURNS, not dollar P&L. What do you divide each day's P&L by, and why does the choice matter for a strategy whose gross exposure isn't constant?

Think first, then tap
warmupCalendars & Alignment

pd.Timestamp.today() silently drops the time-of-day, unlike pd.Timestamp.now()

Question

You're computing "minutes since this alert fired" as pd.Timestamp.today() minus the alert's timestamp, and the number comes out far too large whenever you run it in the afternoon. What's wrong?

Think first, then tap
warmupBacktest Mechanics

Plotting a backtest's Sharpe across a grid of nearby lookback and holding-period values to check for a stable plateau vs a lucky spike

Question

Your backtest with a 20-day lookback and 5-day holding period shows a Sharpe of 1.8. Before trusting that specific combination, how do you check -- cheaply, with the same vectorized backtest you already have -- whether you've found a genuinely good region of parameter space or just a lucky spike at one exact setting?

Think first, then tap
corePortfolio Construction

Uniform position scaling preserves risk contributions; trimming only the largest names does not

Question

Your book is running slightly over its gross exposure cap and you need to trim it back down by 5%. One junior PM suggests just cutting the five largest positions until gross exposure is back in bounds. Why is uniformly scaling every position down by the same factor usually the better choice?

Think first, then tap
corePortfolio Construction

Volatility targeting with trailing realized vol

Question

Your strategy's raw signal produces a position, but its realized volatility swings between 8% and 25% annualized across different market regimes, making risk hard to budget for. You're asked to add volatility targeting so it runs at a steady 12% annualized vol. How do you implement it, and what's the main pitfall?

Think first, then tap
hardPoint-in-Time

Merger-arb deal terms amended mid-deal: using today's final terms is a lookahead

Question

You're backtesting a merger-arbitrage strategy that trades the spread between a target's price and the deal consideration (cash and/or acquirer shares per target share). Your deal database stores one row per deal with the FINAL, completed terms. Many deals get amended mid-process -- a bump in the cash component, a changed exchange ratio, a collar renegotiated under a financing shortfall. What's wrong with joining your spread calculation against that one-row-per-deal table, and how do you fix it?

Think first, then tap
hardCleaning & Corp Actions

LSE prices quoted in pence (GBX), not pounds -- a vendor mismatch that's silently off by exactly 100x

Question

You're blending a position-sizing model's cash P&L across a US book (prices in USD) and a UK book (prices from your vendor for LSE-listed names). The UK side's P&L contribution looks exactly 100x too large or too small depending on the day. What's going on?

Think first, then tap
warmupPoint-in-Time

A date-only fundamentals field secretly means midnight

Question

Your fundamentals vendor gives each quarterly filing a single column, report_date, with no time component -- e.g. 2026-07-15. You join it to daily prices with merge_asof(prices, fundamentals, on="date", by="ticker"). What hidden assumption does that join make about WHEN on 2026-07-15 the filing became knowable, and why does it matter?

Think first, then tap
coreStatistics

Heteroskedasticity-robust standard errors for a cross-sectional regression

Question

You regress next-month return on your value and momentum signals cross-sectionally, once per month, using ordinary least squares, and read off the t-stats from statsmodels' default output. A colleague points out that small, illiquid stocks have much noisier returns than large caps -- the regression residuals are clearly heteroskedastic, fanning out with size. Does that bias your coefficient estimates? Does it bias your t-stats? What do you do about it?

Think first, then tap
hardBacktest Mechanics

A vectorized backtest assumes any resting limit order at the best price gets filled -- ignoring queue position

Question

Your backtest places a passive limit order at the best bid every time your signal says to buy, and assumes it fills whenever the market trades at that price afterward. Live, the same strategy fills far less often than the backtest predicts. What assumption is the backtest making that live trading doesn't grant you for free?

Think first, then tap
coreData Assembly

pd.concat with ignore_index=False leaves duplicate index labels across frames, and a later .loc[] lookup silently returns multiple rows

Question

You concat three daily DataFrames, each internally indexed 0..N-1 by row, using pd.concat([...], ignore_index=False) because you want to preserve each frame's original row index for debugging. Later, df.loc[5] is supposed to fetch "the 6th row of whichever frame it came from" but instead returns three rows stacked together. What happened, and how do you fix the concat call?

Think first, then tap
warmupData Assembly

A join key containing NaN silently drops rows in an inner merge

Question

You maintain a sector-mapping table keyed by ticker and merge it onto today's returns panel with pd.merge(returns, sectors, on="ticker", how="inner"). The reference table has a handful of rows where ticker came back NaN from a broken vendor load. After the merge, your row count is lower than the returns panel's row count, and a few tickers you know exist in both frames are missing from the result. What's actually happening, and how do you defend against it?

Think first, then tap
coreBacktest Mechanics

A flat bps-per-trade cost model misses that market impact scales nonlinearly with trade size relative to ADV

Question

Your backtest charges every trade a flat 5 basis points of transaction cost regardless of size. The strategy looks profitable at a $10M book. A PM asks what happens if you scale it to $500M. Why might a flat-bps cost model give a dangerously wrong answer to that question, and what should replace it?

Think first, then tap
warmupBacktest Mechanics

Filling trades at the bid-ask midpoint silently understates cost even before any market-impact model

Question

Your backtest fills every trade at that bar's midpoint between bid and ask, reasoning that this is a fair, unbiased estimate of where you'd actually trade. A colleague says this alone, even before adding any market-impact model, already makes the backtest too optimistic. Why?

Think first, then tap
coreFeature Construction

Neutralizing a signal against market cap with WLS

Question

Your value signal (book-to-market) is strongly correlated with market cap -- it's really a disguised small-cap bet. How do you neutralize a signal against a continuous characteristic like log market cap, and why use weighted least squares instead of plain OLS for the regression?

Think first, then tap
warmupPortfolio Construction

Long-only constraints and the corner solution problem

Question

Your unconstrained mean-variance optimizer wants to short several names to hedge the book, but the fund is long-only. You add the constraint weights >= 0 and re-optimize. The resulting portfolio holds a large position in just a handful of names and zero in most others, even though your alpha signal was smoothly graded across the whole universe. Why does that happen, and is it a bug?

Think first, then tap
coreCleaning & Corp Actions

Flagging a fat-finger print without deleting real flash-crash moves

Question

A trade print shows a price 40% away from the trade a millisecond earlier, then the very next print reverts back. Fat-finger error, or a real (if brief) move? Design a rule that catches the former without silently deleting genuine spikes and crashes.

Think first, then tap
warmupData Assembly

loc/iloc vs at/iat: scalar access in a hot loop

Question

You're running a stateful simulation in a for-loop over dates and need to read and write single cells of a wide DataFrame of positions thousands of times per run. df.loc[date, ticker] = value works but profiling shows the loop dominates runtime. What's slow about .loc here, and what's the fix that doesn't require restructuring the whole engine?

Think first, then tap
coreCalendars & Alignment

pd.Period vs Timestamp: representing a reporting period unambiguously

Question

You store quarterly fundamentals with a single date column holding values like 2026-03-31, meant to mean "the quarter ending March 2026." You join that column against another company's fundamentals on exact date match to compare same-quarter figures. One company's fiscal quarter actually ends March 28, not March 31. What's the underlying design mistake, and how does pd.Period fix it?

Think first, then tap
coreCalendars & Alignment

pandas_market_calendars: schedule() vs a hand-rolled calendar

Question

Your intraday backtest needs the exact market open and close time for NYSE on a random historical date, including early closes around Thanksgiving and July 3rd. You've been hardcoding "09:30" and "16:00" with a manual list of early-close dates you update by hand once a year. What's wrong with that approach at scale, and what's the standard fix?

Think first, then tap
warmupCleaning & Corp Actions

Detecting a stale (frozen) price feed hiding inside flat price action

Question

A junior researcher notices a thinly-traded small-cap's close price is 12.40 for six straight trading days and concludes "very low volatility name." How do you tell a genuinely flat, low-volatility price apart from a feed that has simply frozen and stopped updating?

Think first, then tap
coreBacktest Mechanics

Assuming you can always fill at the historical VWAP, regardless of your own order size

Question

A backtest sizes every trade to fill at that day's realized VWAP, with no adjustment for order size. At small size this is a reasonable approximation. What goes wrong as the strategy scales up, and what's a simple fix that doesn't require a full market-impact model?

Think first, then tap
warmupData Assembly

read_csv's chunked dtype guessing (low_memory)

Question

You load a 3 GB CSV with pd.read_csv and pandas raises DtypeWarning: Columns (7) have mixed types. You silence it by passing low_memory=False and move on. What was actually happening, and did that fix the problem or hide it?

Think first, then tap
warmupPerformance Analytics

Asymmetric beta: does your book have more downside than upside market exposure?

Question

Your long-short book reports a full-sample beta to the market of 0.05 -- essentially neutral. A risk committee member asks you to compute beta separately on days the market was up versus days it was down. Why would that number differ from the full-sample 0.05, and what would a big gap tell you?

Think first, then tap
corePortfolio Construction

Pairwise-complete correlation matrices aren't guaranteed positive semi-definite

Question

You compute a correlation matrix across 500 assets with different listing histories using df.corr(), which by default uses pairwise-complete observations -- each pair's correlation is computed only from the dates both assets have data. Your mean-variance optimizer then fails with a Cholesky decomposition error. What's the connection, and how do you fix it?

Think first, then tap
hardPoint-in-Time

A vendor backfills a brand-new field using today's methodology, then stamps it onto past report dates

Question

Your fundamentals vendor emails you: starting this quarter, they're adding a new field, adjusted_ebitda, and as a courtesy they've backfilled it for the last 10 years of history using their current methodology. You join it onto your existing point-in-time fundamentals table by report date like everything else. What's wrong with treating this backfilled history as point-in-time?

Think first, then tap
corePerformance Analytics

Rolling Sharpe honestly

Question

You plot a 63-day rolling Sharpe and it swings between minus 1 and plus 4. What is that plot actually good for, how do you pick the window, and what statistical mistake do people make with it?

Think first, then tap
warmupPoint-in-Time

Fiscal period end date vs filing date: the classic fundamentals lookahead

Question

You're joining quarterly revenue onto daily prices using the fiscal quarter's period-end date as the join key -- e.g. Q2 revenue gets the key 2026-06-30. What's wrong with that for a point-in-time backtest, and what should the join key be instead?

Think first, then tap
warmupFeature Construction

rolling(center=True) uses future observations -- fine for a chart, forbidden for a live feature

Question

A teammate's rolling 5-day average smooths a price series for a chart using .rolling(5, center=True).mean(). You copy that same line into a feature used by a live trading signal. What breaks, and why does the problem only show up once the signal goes live?

Think first, then tap
hardCleaning & Corp Actions

A special dividend and a regular dividend landing on the same ex-date break a (ticker, ex_date) join-key assumption

Question

Your corporate-actions feed has two rows for the same ticker on the same ex-date: one tagged "regular" dividend of $0.50/share and one tagged "special" dividend of $2.00/share. Your total-return adjustment code joins corporate actions onto the price panel on (ticker, ex_date) and expects at most one row per key. What breaks, and how do you fix the join?

Think first, then tap
warmupCalendars & Alignment

BQuarterEnd vs QuarterEnd: picking the last TRADING day of the quarter, not the last calendar day

Question

You need a list of quarter-end rebalance dates for a US equity book. You generate them with pd.date_range(..., freq="Q"). What's wrong with that for an actual trading calendar, and what should you use instead?

Think first, then tap
corePortfolio Construction

Targeting a deliberate factor tilt instead of full neutralization

Question

Your alpha signal has a natural positive correlation with the momentum factor, and the desk wants to keep a modest, deliberate momentum tilt rather than neutralizing it away entirely. How do you set that up in the optimizer, as opposed to the usual "constrain this exposure to zero"?

Think first, then tap
coreBacktest Mechanics

Computing turnover before position limits understates -- or overstates -- true trading

Question

Your backtest builds raw target weights, clips them to a 2% per-name position limit with the iterative clip-and-rescale from the portfolio module, THEN computes turnover as the day-over-day change in the RAW pre-clip weights for the cost line. Why is that turnover number wrong, and in which direction?

Think first, then tap
warmupPerformance Analytics

Up-capture and down-capture ratios

Question

A PM asks for your strategy's up-capture and down-capture ratios versus the S&P 500. What are they, how do you compute them, and what does an up-capture of 60% with a down-capture of 40% tell you that a single overall Sharpe ratio doesn't?

Think first, then tap
hardStatistics

Trying a signal at ten different lookback windows and reporting the best one's t-stat is the same multiple-testing problem as trying ten different signals -- the window is a trial, not a free dial

Question

You're not sure whether a mean-reversion signal works best over a 5-day, 10-day, or 20-day lookback, so you backtest it at ten different windows from 5 to 50 days and report the best-performing one's t-stat of 2.6. Your manager points out that's basically the same mistake as testing ten unrelated signals and reporting only the best. Is that fair, and what should you report instead?

Think first, then tap
coreCalendars & Alignment

Custom business-day calendars per exchange: why USFederalHolidayCalendar is the wrong default for a non-US book

Question

You're building a trading-day index for a book that includes Hong Kong-listed names, and either reindex the panel with plain pd.bdate_range (which only excludes weekends, no holidays) or, as a quick fix, pandas.tseries.offsets.CustomBusinessDay(calendar=USFederalHolidayCalendar()). What goes wrong with each choice specifically for the HK names, and what should you use instead?

Think first, then tap
hardBacktest Mechanics

Hedging with a correlated proxy instrument introduces basis risk your backtest usually ignores

Question

Your backtest hedges a basket of small illiquid regional bank stocks by shorting a large regional-bank ETF, sized so the ETF's dollar beta offsets the basket's. The backtested Sharpe looks excellent. What's the backtest likely missing that live trading would expose immediately?

Think first, then tap
coreFeature Construction

Asymmetric winsorization for a bounded, right-skewed signal like short-interest ratio

Question

Short-interest ratio (days-to-cover) is naturally skewed: it's bounded at zero on the low side but can spike to 20+ on a heavily shorted, illiquid name. Your usual symmetric winsorization (clip at the 1st and 99th percentile on both sides) barely touches the low side, since there's nowhere for it to go, but it clips off exactly the extreme high readings that are often the most informative part of the signal -- a name everyone's crowding to short. How do you winsorize this without discarding the signal you actually care about?

Think first, then tap
coreCalendars & Alignment

Hardcoding NYSE's open as a fixed UTC offset instead of converting from tz-aware US/Eastern breaks for roughly half the year

Question

A teammate filters intraday data to "the trading session" by keeping rows where the UTC timestamp falls between 13:30 and 20:00 (NYSE's 9:30am-4:00pm ET translated to UTC assuming EST, UTC-5). The filter is correct in January but silently wrong in July. What's going on, and what should the filter do instead?

Think first, then tap
coreFeature Construction

Winsorizing features

Question

Before z-scoring a fundamental feature, you winsorize it at the 1st and 99th percentiles per date. What is winsorizing, why per date, and why before the z-score rather than after?

Think first, then tap
coreData Assembly

pd.concat()'s sort parameter: silently reordering columns when input frames don't share the same column set

Question

You concat three daily vendor files into one DataFrame with pd.concat(). Each day's file has a mostly-overlapping but not identical set of columns -- one day is missing a column that got added later in the week. A downstream step references columns by position with iloc instead of by name, and after the concat it starts reading the wrong field for some rows. What happened, and how do you prevent it?

Think first, then tap
hardPortfolio Construction

Cleaning a covariance matrix with the Marchenko-Pastur eigenvalue bound

Question

You've already applied Ledoit-Wolf shrinkage to a 400-stock covariance matrix estimated from 3 years of daily data, but you want a more principled way to decide which of the matrix's eigenvalues represent real, tradeable common factors versus which are indistinguishable from pure sampling noise. What does Random Matrix Theory give you here, and how do you use it?

Think first, then tap
warmupBacktest Mechanics

Signal timestamp vs execution timestamp: the classic same-bar lookahead

Question

Your vectorized backtest computes today's momentum signal from today's close, and computes today's return as today's close over yesterday's close, then multiplies signal times return to get today's P&L. What's wrong with that pairing, and what's the one-line fix?

Think first, then tap
coreStatistics

Pooling all (date, IC) pairs into one correlation vs averaging per-day ICs: these are not the same number

Question

You can compute a signal's IC two ways: stack every (signal, forward_return) pair across all dates and names into one long vector and take a single correlation, or compute a separate cross-sectional correlation for each date and average those. Why do these two numbers usually differ, and which one do practitioners actually report as "the IC"?

Think first, then tap
corePerformance Analytics

Skewness and kurtosis: what Sharpe hides

Question

Two strategies both have an annualized Sharpe of 1.5 and similar drawdown stats. Strategy A sells short-dated options (collects small premiums most days, occasionally takes a large loss). Strategy B is a diversified trend-following book. An allocator asks you to distinguish them using the return distribution itself, beyond Sharpe. What do you compute, and what do you expect to see?

Think first, then tap
warmupData Assembly

Checking two DataFrames for equality: == vs .equals() vs assert_frame_equal

Question

You refactor a data-loading pipeline and want to prove the new code produces the exact same price panel as the old one before deleting the old path. A teammate proposes (new_df == old_df).all().all(). Why is that check unreliable here, and what should you use instead?

Think first, then tap
coreFeature Construction

Undefined ratio features: NaN, a sentinel, or sector-median fill?

Question

You're building a value factor from trailing P/E = price / earnings. About 15% of your universe has negative trailing earnings, making P/E either negative or nonsensical as a "cheapness" signal. Do you leave those as NaN, set them to some large sentinel value, or fill with the sector median P/E? Walk through the tradeoffs.

Think first, then tap
hardFeature Construction

Beta neutralization via regression

Question

Your signal is correlated with market beta, so the "alpha" is partly a disguised market bet. Neutralize the signal to beta with a cross-sectional regression, fully vectorized -- no loop over dates. Walk me through it.

Think first, then tap
coreCleaning & Corp Actions

Trade busts: an exchange retroactively cancels a print you already ingested

Question

Three minutes after ingesting a print of $2.10 on a stock that had been trading around $45, you see a retroactive "trade bust" message from the exchange cancelling that exact print. Your tick database already has it, and any feature computed off that minute's bar (VWAP, high/low, realized vol) is now built on a trade that officially never happened. What do you do?

Think first, then tap
corePerformance Analytics

A tearsheet's headline Sharpe mixes a since-inception return with a trailing-one-year volatility -- why using different time windows in the numerator and denominator breaks the ratio

Question

A tearsheet reports annualized return as the strategy's since-inception CAGR (3 years of history) and annualized volatility as the trailing 1-year realized vol, then divides one by the other to headline "Sharpe 2.1." What's wrong with that number, and why isn't it a real Sharpe ratio?

Think first, then tap
warmupData Assembly

Melt: wide back to long

Question

A vendor sends you a spreadsheet where each row is a date and there are 500 columns, one per ticker. You need it in a database table with columns date, ticker, close. How do you reshape it, and what do you check afterwards?

Think first, then tap
warmupFeature Construction

EWMA half-life decay vs a simple rolling window for a momentum feature

Question

You're building a 20-day momentum feature. One teammate computes it as a simple rolling mean of daily returns over the last 20 days; another uses an exponentially-weighted mean with a half-life tuned to roughly match. What's the actual difference in what these two features capture, and when would you prefer one over the other?

Think first, then tap
corePortfolio Construction

Idle cash from unfilled or trimmed orders quietly turns a 'dollar-neutral' book net long

Question

Your target weights are built to sum to exactly zero every rebalance -- textbook dollar-neutral. But several short-leg orders get partially filled or skipped entirely (thin borrow, a risk-check reject), while the long leg fills completely. The desk ends the day holding more long notional than short, funded by cash that was never actually deployed into the missing shorts. Is the "dollar-neutral" target weight file wrong, or is something else going on?

Think first, then tap
warmupData Assembly

Exploding a list-valued column

Question

Your feed has one row per (date, ticker) with a "flags" column that's a Python list, like ["late_print", "odd_lot"] -- empty list if nothing was flagged that day. You want one row per (date, ticker, flag) so you can group by flag type and count occurrences. What operation gets you there, and what happens to the rows that had an empty list?

Think first, then tap
hardPoint-in-Time

A silent 10-K/A amendment restating prior fundamentals eighteen months later

Question

A company files a 10-K, then eighteen months later quietly files a 10-K/A (an amendment) restating two lines of the prior-year balance sheet -- no press release, and most vendor feeds don't flag it. Your point-in-time fundamentals pipeline keys off (ticker, fiscal_period, filing_date) and keeps the latest filing per period. What breaks, and how do you catch it?

Think first, then tap
warmupCalendars & Alignment

A hardcoded holiday list vs a maintained trading-calendar library

Question

A teammate builds a trading calendar for a backtest by hardcoding NYSE holidays as a python list of date strings, one year at a time. What breaks about this approach, and what would you use instead?

Think first, then tap
corePerformance Analytics

Returns-based style analysis vs holdings-based attribution

Question

You're asked to explain a fund's Sharpe ratio and factor exposures, but you only have its daily NAV return series -- no position-level holdings. Can you still do factor attribution without holdings data, and what's fundamentally different about what you're able to conclude compared to having the actual positions?

Think first, then tap
corePerformance Analytics

Summing each position's standalone volatility to 'explain' total portfolio volatility ignores correlation entirely -- marginal contribution to risk (MCTR) is the number that actually adds up to total risk

Question

A PM asks which three positions are driving most of the portfolio's volatility. You rank positions by their own standalone annualized vol and report the top three. The PM points out that one of those three is a small, well-hedged position that barely moves the total number, while a much bigger driver of portfolio risk isn't even on your list. What's wrong with ranking by standalone vol, and what should you compute instead?

Think first, then tap
hardPortfolio Construction

A sector-neutral optimizer with no country constraint can quietly build a large net country bet in a global universe

Question

Your long-short equity optimizer is constrained to be dollar-neutral and sector-neutral across a global developed-markets universe. After a rebalance, the book ends up net long Japan and net short Europe by a sizeable margin, even though nothing in the signal or the optimizer explicitly targets country. How did that happen, and is it a bug?

Think first, then tap
hardPoint-in-Time

SEC EDGAR's acceptance timestamp vs the filing's cover-page date

Question

You're building a point-in-time feature off 10-Q filings and your vendor gives you a "filing_date" column. A company's 10-Q for the quarter ended June 30 has a filing_date of August 5 in your data. Is August 5 actually when that data first became available to someone trading live, and what specifically would you check?

Think first, then tap
hardPoint-in-Time

Bar timestamp convention: does a 9:31 bar start or end at 9:31?

Question

You're building a minute-bar momentum feature and your vendor's 1-minute OHLCV file has a row timestamped 09:31:00. Before writing a single line of feature code, what do you need to establish about that timestamp, and what breaks if you assume wrong?

Think first, then tap
coreBacktest Mechanics

A single bad high/low print in OHLC data can trigger a backtested stop that never actually happened

Question

Your vectorized backtest checks, for every bar, whether that day's low price touched your stop-loss level, and exits if so. On one specific date your strategy shows a stop-out that hugely hurts performance, but when you look at the actual exchange tape for that day, price never traded anywhere near your stop level. What's the likely explanation, and how do you guard against it?

Think first, then tap
warmupData Assembly

Merge suffix collisions: spotting silent _x/_y columns from overlapping non-key columns

Question

You merge a prices table and a fundamentals table on ["ticker","date"], but both tables also happen to have a "source" column recording which vendor fed that row. After pd.merge(), your code references df["source"] and gets a KeyError. What happened, and how do you handle it?

Think first, then tap
coreFeature Construction

A plain shift(1) on a stacked panel leaks yesterday's OTHER ticker into today's lag feature

Question

You have a long-format panel sorted by ["ticker", "date"] and build a lagged feature with df["lag_ret"] = df["return"].shift(1), intending "yesterday's return for this ticker." For most rows it works, but the first row of every ticker except the very first one in the DataFrame gets a nonsensical value. What's the bug, and what's the fix?

Think first, then tap
hardPoint-in-Time

Whether a backtested trade is entitled to a dividend depends on the EX-DIVIDEND date against the TRADE date, not the settlement date -- getting this backwards silently credits or strips dividends on the wrong side of a trade

Question

Your backtest buys a stock the day before its ex-dividend date and sells it three days later. Does that trade earn the dividend? What point-in-time timestamp actually governs the answer, and where do backtests typically get this wrong?

Think first, then tap
coreData Assembly

groupby().idxmax() to find each date's top performer, and the multi-column trap

Question

Given a long panel of date, ticker, and daily return, write a one-liner that returns the ticker with the highest return on each date. Then explain why the naive version breaks the moment you want to pull back more than one column for that winning row.

Think first, then tap
coreFeature Construction

Decaying a feature's weight by information age (freshness-weighting stale fundamentals)

Question

You're building a value factor from quarterly earnings data joined point-in-time onto daily prices. A name that reported 85 days ago and one that reported yesterday both get the full weight of their latest EPS number, even though the older number is closer to being replaced by the next release. How would you incorporate the age of the underlying data into the feature itself?

Think first, then tap
warmupData Assembly

combine_first() to backfill a primary vendor's gaps from a secondary source

Question

Two vendors cover the same universe of daily closing prices. Vendor A is your primary feed but has occasional missing days from feed outages; Vendor B is a cheaper backup that's less reliable overall but happens to have data on exactly the days Vendor A is missing. How do you build one "best available" price series that prefers A everywhere A has data, and only falls back to B where A is missing?

Think first, then tap
corePoint-in-Time

The bfill trap

Question

A teammate fills missing values in a feature panel with df.bfill() because "it fills the gaps and the backtest improves". Explain what bfill does on a time axis and why the improvement is fake.

Think first, then tap
hardCleaning & Corp Actions

Detecting a price series that's been split-adjusted twice

Question

You pull a 10-year daily price history for a stock that's had two 2-for-1 splits, and the earliest prices look implausibly low -- like the stock IPO'd near $2 when an old prospectus says the real price was about $8. What's the likely bug, and how would you detect it systematically across a whole universe rather than by spot-checking one name you happen to know well?

Think first, then tap
warmupCalendars & Alignment

resample vs asfreq

Question

You want month-end prices from a daily series. Both px.resample("ME").last() and px.asfreq("ME") seem to work. What is the difference, and when does asfreq quietly give you the wrong answer?

Think first, then tap
coreBacktest Mechanics

Adding short borrow cost to a backtest that only charges cost on turnover

Question

Your backtest charges transaction costs only on turnover -- the day-over-day change in weights, times a flat cost rate. A colleague points out that a persistently short position pays borrow fees every single day it's held, not just on the days you trade it. How does that change your P&L line, and what happens if you ignore it for a strategy that holds concentrated short positions for weeks?

Think first, then tap
corePortfolio Construction

A hard turnover cap forces a portfolio away from its target weights for multiple periods -- measuring the resulting tracking error cost

Question

Your optimizer computes new target weights every day, but a hard constraint caps total turnover at 5% of portfolio value per day to control trading costs. Prices move and signals update daily, so the portfolio can never fully reach its target in one step. How do you think about what this constraint actually costs you, and how would you measure it?

Think first, then tap
hardCleaning & Corp Actions

Delisting returns

Question

Your point-in-time universe includes stocks that later delist, but the price feed just stops on the last trading day. Your backtest currently drops the position at its final price as if you sold there. What is wrong with that, and what should you do?

Think first, then tap
hardPoint-in-Time

Sharpe 3.1 -- what do you check first?

Question

A new hire shows you a daily equity long-short backtest with a Sharpe of 3.1 on a simple price-based signal. What do you check, in what order, and why that order?

Think first, then tap
coreBacktest Mechanics

Using one shared random seed for synthetic signal noise and a stochastic cost model makes it impossible to tell which one drove a result

Question

You're stress-testing a strategy by adding simulated noise to a synthetic signal AND running a stochastic fill/slippage model in the same backtest, both drawing from np.random.default_rng(42). A colleague says this setup can't actually isolate how much of your Sharpe degradation comes from signal noise versus execution cost randomness. Why not, and how would you fix it?

Think first, then tap
coreFeature Construction

Winsorizing a ratio feature's numerator and denominator independently, then dividing, doesn't bound the resulting ratio the way winsorizing the ratio directly would

Question

You're building a valuation ratio feature, something like earnings divided by price. A teammate winsorizes the earnings column at the 10th/90th percentile, separately winsorizes the price column at the 10th/90th percentile, and THEN divides to get the ratio. You instead winsorize the ratio itself after computing it on raw inputs. Do these two approaches give you the same protection against outliers?

Think first, then tap
corePortfolio Construction

Gross exposure vs net exposure

Question

Your long-short book has weights summing to +0.08 net but the risk desk flags it as running 1.4x gross. Explain the difference between those two numbers to a risk manager who's only seen the net figure, and why both matter.

Think first, then tap
coreData Assembly

Downcasting an int64 order-ID column to int32 to save memory can silently overflow and corrupt the join key

Question

Your order-event table has 400 million rows and an order_id column stored as int64. A teammate suggests downcasting it to int32 to cut the DataFrame's memory footprint in half before a join. Walk me through whether that's safe here, and what you'd check first.

Think first, then tap
coreData Assembly

pivot vs pivot_table

Question

You pivot a vendor file of daily closes from long to wide and pandas raises: "Index contains duplicate entries, cannot reshape". A colleague says just switch pivot to pivot_table, it handles that. Do you take the advice?

Think first, then tap
warmupStatistics

Standard deviation vs standard error: what shrinks with sample size

Question

A colleague says "the daily returns have a standard deviation of 1.5 percent, and with 500 observations the standard error is small, so we can be confident the mean return is really positive." Are standard deviation and standard error the same idea, and why does having more observations change the second number but not the first?

Think first, then tap
hardPoint-in-Time

groupby().apply() reordering rows: a silent PIT-corruption bug

Question

Your feature pipeline does df.groupby('ticker').apply(compute_rolling_feature) and the output looks fine per-ticker, but when you re-merge it back onto the master panel by position, some rows end up with the wrong date's feature value. What happened?

Think first, then tap
coreCleaning & Corp Actions

Duplicate rows that differ only in the 10th decimal place

Question

You pulled the same day's price file from a vendor twice (an automated nightly job re-ran accidentally) and concatenated both pulls into one DataFrame. df.duplicated().sum() reports zero duplicates, even though you're confident the two pulls are the same underlying data. What's happening, and how do you actually find these near-duplicate rows?

Think first, then tap
warmupCalendars & Alignment

Minutes-since-open as a calendar-aware intraday feature

Question

You want an intraday feature "minutes since the open" for every 1-minute bar, to capture the well-known U-shaped volume pattern across the trading day. Naively you compute it as the bar's timestamp minus midnight. What's wrong with that, and how do you compute it correctly?

Think first, then tap
hardCalendars & Alignment

tz_localize's ambiguous and nonexistent parameters: DST transition edge cases

Question

You tz_localize a timestamp index of intraday trade timestamps to America/New_York. Twice a year this raises -- once with an AmbiguousTimeError, once with a NonExistentTimeError. What's actually happening at each transition, and how do you handle it without silently corrupting timestamps?

Think first, then tap
hardPoint-in-Time

A vendor overwriting its factor-exposure file in place destroys point-in-time reproducibility

Question

A factor-exposure vendor refreshes its file every night, overwriting the same path in place rather than writing a new dated file. Three months ago you ran a backtest pulling from that path and got a Sharpe of 1.4. You try to reproduce the exact same run today and get a different number. What's the likely cause, and how do you prevent it going forward?

Think first, then tap
coreBacktest Mechanics

Hardcoding one risk-free rate constant across a 10-year backtest biases Sharpe differently in 2008-2015 than in 2022-2024

Question

Your backtest spans 2015 through 2025 and computes Sharpe as (mean excess return) / (vol), using a hardcoded risk_free_rate = 0.02 for every single day. Rates were near zero for most of that window and above 5% by the end. What exactly is wrong with the resulting Sharpe series, and is the bias the same sign throughout?

Think first, then tap
hardStatistics

A hypothesis you formed BEFORE looking at the data needs no multiple-testing correction; one you found BY looking at the data always does -- the distinction matters more than which test you run

Question

A colleague tests a single signal's IC, gets a t-stat that clears the usual 2.0 bar, and argues no multiple-testing correction is needed because they "only tested one thing." Is that defensible?

Think first, then tap
coreData Assembly

Flattening nested vendor JSON

Question

A new vendor's REST API returns each day's data as nested JSON: a list of records where each record has a flat date and ticker but the fundamentals are nested three levels deep, e.g. record["financials"]["income_statement"]["revenue"]. You need this as a flat DataFrame with columns like financials.income_statement.revenue for downstream joins. Walk me through building it and what to check.

Think first, then tap
warmupPerformance Analytics

Max drawdown from the NAV curve vs from cumulative log-returns: why they diverge

Question

You compute max drawdown two ways on the same strategy: once from the NAV curve directly (peak-to-trough percentage decline), and once from cumulative log-returns (peak-to-trough decline in the cumulative sum of log returns). For a strategy with a large drawdown, the two numbers disagree noticeably. Which one is right, and why do they diverge?

Think first, then tap
warmupCalendars & Alignment

between_time() for extracting a fixed intraday window

Question

You have a DataFrame of 1-minute bars for one trading day, indexed by a tz-aware DatetimeIndex, and you need just the last 5 minutes before the close (15:55 to 16:00 ET) to compute a closing-auction proxy. What's the right tool, and what two things can silently break it?

Think first, then tap
warmupFeature Construction

shift() before rolling() vs rolling() before shift(): do they give the same feature?

Question

You want a 5-day moving average of returns, known only as of yesterday (no lookahead). One teammate writes df["ret"].rolling(5).mean().shift(1); another writes df["ret"].shift(1).rolling(5).mean(). Do these produce the same feature?

Think first, then tap
warmupPerformance Analytics

Sortino ratio vs Sharpe ratio: penalizing only downside deviation

Question

A strategy has a mediocre Sharpe ratio because of a few sharp UPSIDE days that make its return distribution choppy, even though it almost never has a bad down day. Someone suggests reporting Sortino ratio instead. What does Sortino actually change relative to Sharpe, and is swapping to it here a legitimate improvement or cherry-picking a better-looking number?

Think first, then tap
hardCleaning & Corp Actions

Self-crossing (wash) trades inflating consolidated volume without moving the price

Question

You're building a liquidity feature from consolidated tape volume, and one mid-cap name shows a sudden 5x volume spike on a day where the price barely moved and no news was released. A colleague suggests it's just a quiet accumulation day. What else should you check before accepting that explanation, and how would you check it programmatically?

Think first, then tap
coreFeature Construction

rolling().rank(pct=True) ranks each day against a window that includes itself -- is that a lookahead, and is it the feature you actually want?

Question

You build a feature as df["close"].rolling(252).rank(pct=True) to get "today's close as a percentile of its trailing year." A colleague flags it as a possible lookahead because the window ending at today technically includes today's own value in the percentile calculation. Is that actually a lookahead, and does including today's own value change what the feature means?

Think first, then tap
coreCalendars & Alignment

Business-day arithmetic

Question

A trade executes on Wednesday July 3, 2024, and settles T+1 (one business day later). July 4 is a market holiday. How do you compute settlement dates for a whole column of trades, correctly and vectorized?

Think first, then tap
hardCleaning & Corp Actions

Using today's S&P 500 constituent list to build a 10-year historical backtest universe

Question

You pull "today's S&P 500 constituents" from your data vendor and use that same list of 500 tickers to build your entire backtest universe going back 10 years. Your backtest's returns look unusually good. What's wrong with this setup, and what's the actual fix?

Think first, then tap
hardPerformance Analytics

Comparing a USD strategy's Sharpe against a JPY strategy's Sharpe using the same risk-free rate silently penalizes whichever currency has the lower rate

Question

You're comparing two strategies for capital allocation: one trades US equities and reports returns in USD, the other trades Japanese equities and reports in JPY. Both tearsheets subtract a risk-free rate to compute excess returns before the Sharpe calculation, and both used the SAME risk-free rate for convenience. What's wrong with that, and how should it actually be done?

Think first, then tap
hardCalendars & Alignment

A half-day session's 1:00pm close gets treated as a normal 4:00pm close, biasing any feature built from 'the close'

Question

The day before Thanksgiving, NYSE closes at 1:00pm instead of 4:00pm. Your pipeline pulls "the daily close" for every ticker off a vendor feed keyed only by date, with no session-length flag. What specifically goes wrong on that day, and in which features does it show up?

Think first, then tap
corePoint-in-Time

A feature built with merge_asof assumes data arrives in timestamp order -- what happens when live out-of-order network arrivals silently diverge it from the backtest replay

Question

Your backtest computes a feature with merge_asof(direction="backward"), joining each price bar to the most recent fundamentals row available by timestamp, and it replays perfectly against history. In production, the same feature sometimes comes out different for the same nominal timestamp. You find that fundamentals updates occasionally arrive at your system a few hundred milliseconds OUT of timestamp order, due to network jitter across redundant lines. Why does that break the match with the backtest, and what's the fix?

Think first, then tap
warmupBacktest Mechanics

Cherry-picking a backtest's start date

Question

Two teammates backtest the same signal on the same universe. One reports results starting in 2015 with a Sharpe of 1.6; the other found the same signal looked poor from 2008 to 2014 and excluded those years, saying "the market regime was different back then." What's wrong with that reasoning, and what should the writeup actually show?

Think first, then tap
hardStatistics

Partial correlation: are two signals' ICs really independent, or both just proxies for the same risk factor?

Question

Signal A and signal B each have a standalone IC (information coefficient, the cross-sectional correlation between a signal and forward returns) of about 0.04, and their ICs are only weakly correlated with each other over time, which a teammate takes as proof they're two independent sources of alpha worth combining. Both signals, though, are known to load on the market-beta factor. How do you actually test whether their alpha is independent, and why might low correlation between their TIME SERIES of ICs not be enough?

Think first, then tap
warmupPerformance Analytics

Rolling max drawdown vs since-inception max drawdown for live risk monitoring

Question

A tearsheet reports "max drawdown: -18%" for a strategy that's been live for five years. Is that number still useful for monitoring risk day to day right now, and what would you look at instead on a live dashboard?

Think first, then tap
hardFeature Construction

Z-scoring a zero-inflated feature like buyback yield treats 'no buyback' as a real number, not a missing category

Question

You build a buyback-yield feature (dollars repurchased divided by market cap, trailing twelve months) for your value composite. On any given day, roughly 80% of your universe has a buyback yield of exactly zero -- no program -- and the remaining 20% have a continuous positive value. If you cross-sectionally z-score this feature every day like your other continuous features, what goes wrong?

Think first, then tap
hardPoint-in-Time

Point-in-time index weights, not just membership

Question

You backtest a strategy that goes long the top-weighted names in an index and rebalances quarterly using a point-in-time membership file -- so you correctly know WHO was in the index on each historical date. But you assign weights using each stock's CURRENT (as of your data pull) index weight, held fixed between rebalances. What's leaking, and why doesn't fixing membership alone fix it?

Think first, then tap
hardFeature Construction

Order of operations: sector-demean then divide by std, or the other way

Question

One analyst sector-neutralizes a raw signal by subtracting each stock's sector mean, then divides by the global standard deviation of the resulting residual. A second analyst instead divides the raw signal by its global standard deviation first, then subtracts each stock's sector mean from those scaled values. Do the two end up with the same feature, and does it matter which global standard deviation gets used?

Think first, then tap
coreStatistics

Testing whether a strategy's edge comes from entry timing skill or just from being in the market during an uptrend: permuting entry labels, not returns

Question

Your long-only strategy enters and exits a single asset based on a timing signal, and its total return beats buy-and-hold over the backtest period. Before concluding the entry signal has skill, how would you design a permutation test that isolates timing skill specifically, separate from the simple fact that the asset trended up over the period?

Think first, then tap
corePerformance Analytics

Sterling and Burke ratios: smoothing out Calmar's single-worst-drawdown problem

Question

You have already flagged that Calmar's max-drawdown denominator is a single extreme statistic that grows with track length. A colleague suggests the Sterling ratio or Burke ratio instead. What do they change about the denominator, and what new problem does averaging multiple drawdowns introduce?

Think first, then tap
warmupData Assembly

DataFrame.explode() for unnesting a list-valued column

Question

A corporate-actions feed gives you one row per announcement, but the affected_tickers column holds a list like ["AAPL", "AAPL.B"] when one announcement covers multiple share classes. You need one row per (announcement, ticker) pair to join against your price table. How do you do this without writing a Python loop?

Think first, then tap
corePoint-in-Time

An 8-K filed at 3:55pm is same-day material news your 2pm backtest trade couldn't have seen -- a date-only PIT timestamp hides the intraday ordering that decides whether it's a lookahead

Question

A company files an 8-K (a disclosure of a material event, timestamped by the SEC to the minute) on a given trading day. Your fundamentals/event feed only stores the filing's DATE, not the time, and your PIT discipline treats any event dated day T as "known as of day T." Does that correctly avoid lookahead for every trade your backtest might simulate on day T?

Think first, then tap
coreCalendars & Alignment

T+1 settlement dates with a holiday calendar

Question

You need to compute each trade's settlement date under T+1 (one business day after trade date), and the trading calendar has US market holidays plus weekends to respect. A naive trade_date + pd.Timedelta(days=1) is wrong whenever the trade lands on a Friday or just before a holiday. How do you compute this correctly and vectorized across a whole trade blotter?

Think first, then tap
coreStatistics

In-sample vs out-of-sample

Question

Define in-sample and out-of-sample, explain why out-of-sample performance almost always disappoints, and describe how a disciplined research process protects its out-of-sample data.

Think first, then tap
coreData Assembly

A many-to-one rename() dict silently creates duplicate column labels

Question

You're normalizing three vendors' column names into one canonical schema. Vendor A's field is px_last, vendor B's is closing_px, vendor C's is last_trade_price -- all three should map to your canonical "close" column. You build the rename dict by hand, but a copy-paste mistake points two DIFFERENT source columns at the same canonical name. What happens when you call df.rename(columns=...), and how do you catch this systematically instead of by accident?

Think first, then tap
hardStatistics

Standard error of the Sharpe ratio, and Lo's autocorrelation correction

Question

You report an annualized Sharpe ratio of 1.2 on 3 years of daily returns and want a confidence interval around it, not just the point estimate. What is the standard error formula under i.i.d. returns, and why does it understate uncertainty for a strategy with autocorrelated returns, like one holding positions for several days?

Think first, then tap
warmupBacktest Mechanics

Computing trades as weights.diff() in a vectorized backtest leaves the FIRST row NaN, and fillna(0) silently assumes day one was never actually a trade

Question

Your vectorized backtest computes each day's trade as trades = weights.diff(), then does trades = trades.fillna(0) so the math doesn't break on day one. Under what setup is that fillna(0) exactly right, and under what setup does it silently erase a real trade and understate your very first transaction cost?

Think first, then tap
hardStatistics

Purging and embargo in time-series cross-validation, not just walk-forward ordering

Question

You switch from a single train/test split to k-fold cross-validation to get more stable performance estimates for a return-predicting model, keeping folds in chronological blocks so you're never training on data from after the test block. Your cross-validated Sharpe still looks too good relative to live performance. What's still leaking, and what do "purging" and "embargo" fix?

Think first, then tap
warmupBacktest Mechanics

Cash drag in a long-short backtest

Question

Your dollar-neutral long-short backtest (100% long notional, 100% short notional, net zero) computes daily strategy return as (long P&L + short P&L) divided by gross exposure (the sum of both legs). A teammate says this understates the strategy's true return because it ignores cash. Are they right?

Think first, then tap
warmupCalendars & Alignment

resample's label and closed: which end of the bar gets the timestamp

Question

You resample tick-level trade data into 5-minute bars with df.resample("5min").agg(...). Your colleague says the bar timestamped 09:35:00 should contain trades from 09:30:00 up to but not including 09:35:00. Does resample do that by default, and what controls it?

Think first, then tap
corePoint-in-Time

A benchmark provider restates yesterday's index level after correcting one constituent's price

Question

You compute daily active return as your portfolio's return minus the benchmark index's return, pulled fresh each morning from the index provider's API. Three weeks later you notice last month's active-return numbers in your tearsheet have quietly changed from what you reported in real time, even though you never touched your own portfolio data. What's going on, and what does it mean for any backtest that re-pulls benchmark levels on demand?

Think first, then tap
coreBacktest Mechanics

Double-counting dividends: reinvesting cash AND using total-return prices

Question

Your backtest holds a long position and, on each ex-dividend date, (1) credits the position's cash account with dividend_per_share times shares_held, simulating reinvestment, and separately (2) marks the position's value using a "total-return" price series that the data vendor already adjusts upward to reflect reinvested dividends. A teammate notices the backtest's realized return is suspiciously higher than a simple buy-and-hold check on the raw split-adjusted price series would suggest. What's the bug?

Think first, then tap
coreFeature Construction

Cross-sectional rank(pct=True) tie-breaking on a day with many halted names compresses a factor's effective dispersion

Question

You build a daily cross-sectional rank feature with df.groupby("date")["momentum"].rank(pct=True). On a day where 200 of 3,000 names are halted and report a flat (zero) return, all 200 tie on the momentum factor. How does pandas's default tie-handling affect their ranks, and why can that quietly weaken the feature on exactly the days you'd most want it to behave normally for the other 2,800 names?

Think first, then tap
warmupPerformance Analytics

Sterling ratio: return relative to average drawdown, and how it differs from Calmar

Question

You already report Calmar ratio (annualized return over max drawdown) on your tearsheet. A colleague suggests adding the Sterling ratio too, saying Calmar is "too sensitive to a single bad day." What does Sterling actually change, and is the criticism fair?

Think first, then tap
coreData Assembly

groupby().resample() on a panel produces an extra index level that breaks a plain reset_index

Question

You have a long panel of trades indexed by a DatetimeIndex, with a "ticker" column, and you want each ticker's daily OHLC bars. You run df.groupby("ticker").resample("1D")["price"].ohlc() and then call .reset_index() to flatten it before merging onto another daily table. The merge comes back with far fewer matching rows than expected. What happened to the index, and how do you fix the merge?

Think first, then tap
hardPortfolio Construction

Ledoit-Wolf shrinkage: taming covariance-matrix estimation error when names outnumber observations

Question

You estimate a sample covariance matrix from 500 names using 2 years of daily returns (about 500 observations). The optimizer that consumes it produces extreme, concentrated, high-turnover weights that look nothing like a sensible risk allocation. The number of names is comparable to the number of observations. What's the statistical problem, and how does shrinkage fix it?

Think first, then tap
coreFeature Construction

Sector neutralization by demeaning

Question

Your value factor is persistently long banks and short tech. How do you sector-neutralize it, and what is the simplest implementation?

Think first, then tap
warmupPerformance Analytics

Bridging a Sharpe ratio from one period to the next: return effect vs volatility effect

Question

Last quarter's annualized Sharpe was 1.4; this quarter it dropped to 0.75. A PM asks you to explain the drop in one sentence beyond "returns were worse." How do you decompose the change in Sharpe into how much came from weaker returns versus how much came from higher volatility?

Think first, then tap
coreFeature Construction

A ratio feature blowing up to inf when the denominator is near zero

Question

You build an earnings yield feature as earnings / price for your cross-sectional model. A handful of penny-stock rows come back as inf, and your z-score for the whole date is now NaN because the mean of a column containing inf is inf, -inf, or nan depending on which signs appear. How do you fix this properly, not just mask the symptom?

Think first, then tap
hardPortfolio Construction

Factor-model covariance

Question

You need a covariance matrix for a 3,000-stock universe and the sample estimate is hopeless. Walk me through the factor-model construction and why it is both estimable and invertible.

Think first, then tap
hardPoint-in-Time

Excluding a stock because it later went bankrupt is a lookahead bias in universe construction

Question

A colleague builds their backtest universe by taking today's list of currently-listed S&P 500 constituents and pulling ten years of history for exactly those names, reasoning "I already handle survivorship bias by including delisted returns for names that dropped out." Is that enough? Where's the remaining bias?

Think first, then tap
coreFeature Construction

Winsorizing a cross-sectional feature globally across history, instead of per-date, lets one volatile regime set the clipping bounds for every other day

Question

You winsorize (clip extreme values to a percentile cutoff, rather than deleting them, so outliers are tamed without losing the row) a raw factor at the 1st/99th percentile before z-scoring it cross-sectionally each day. You compute those percentile cutoffs once, over the entire multi-year panel. A teammate says this is backwards. What's the actual bug, and does it show up as a lookahead problem or something else?

Think first, then tap
coreFeature Construction

IC-weighted signal combination

Question

You have three cross-sectional signals with different historical mean ICs -- 0.04, 0.02, and 0.01. A teammate proposes weighting each signal by its own historical mean IC before averaging, instead of equal-weighting. What does that implicitly assume, and what is a better scheme once the signals also differ in IC volatility and pairwise correlation?

Think first, then tap
warmupData Assembly

convert_dtypes(): one call, several dtype fixes, no guarantees

Question

You just loaded a CSV of trade records with read_csv using all default settings. Several numeric columns that should be ints are float64 because of missing values, a boolean-looking column is object dtype holding the strings "True"/"False", and a low-cardinality id column is still generic object. A teammate suggests just calling df.convert_dtypes() and moving on. What does that actually do, and is it safe to blindly apply?

Think first, then tap
hardStatistics

Cointegration: why correlated is not enough for pairs trading

Question

Two stocks in the same industry show 0.85 correlation of daily returns. A junior researcher wants to build a mean-reverting pairs trade on their price spread using that correlation as justification. Why is high return correlation not sufficient, what does cointegration actually require, and how do you test for it?

Think first, then tap
corePortfolio Construction

Blending signals with different universe coverage

Question

You have two alpha signals to blend into one composite: signal A (a value ratio) covers your full 3,000-stock universe, signal B (an alternative-data sentiment score) only has usable data for about 500 large, heavily-covered names. A teammate proposes composite = (z_A + z_B) / 2 across the whole universe. What does that do to the 2,500 stocks B doesn't cover, and how should partial coverage be handled?

Think first, then tap
hardPoint-in-Time

The retroactively-backfilled field

Question

Your alt-data vendor adds an ESG controversy score to their product in 2024 and, as a value-add, backfills scores for every company back to 2015 using their CURRENT scoring methodology, each one carrying a clean as-of date matching its historical period. You want to use this score in a backtest starting 2016. Why isn't "the vendor gave me point-in-time dates back to 2015" the same as the data being point-in-time-safe, and how do you handle it?

Think first, then tap
warmupData Assembly

nlargest/nsmallest vs sort_values().head(): same answer, different cost and tie-breaking

Question

A teammate ranks a 3,000-row daily cross-section by a signal column with df.sort_values("score", ascending=False).head(20) to grab the top 20 names. You suggest df.nlargest(20, "score") instead. Is this just a style preference, or does it actually change the result and the cost?

Think first, then tap
coreFeature Construction

Double-sorting: building an independent two-way bucket feature

Question

You want a feature that captures "cheap AND small" -- stocks in the bottom tercile on both a value score and a size score, in the tradition of Fama-French style double sorts. A teammate just multiplies the two z-scored signals together. What's the problem, and how does an actual double sort differ?

Think first, then tap
hardPoint-in-Time

Purging a walk-forward split when the label horizon crosses the cutoff

Question

You're training a model to predict 20-day forward returns, walk-forward style: fit on everything up to date T, test on everything after T. A row dated T minus 5 needs prices through T plus 15 to compute its label, which is after the fit cutoff -- but you included it in training anyway since its FEATURE date is safely before T. What went wrong, and how do you fix the split boundary?

Think first, then tap
coreCalendars & Alignment

Calling tz_localize on an already timezone-aware timestamp raises, and catching the error to fall back is a worse fix than it looks

Question

A vendor's fill timestamps arrive as strings like "2026-11-05T14:30:00-05:00" -- already timezone-aware, with the offset embedded. Your ingestion code runs pd.to_datetime(raw) then .dt.tz_localize("America/New_York") to tag every timestamp with the exchange's timezone, and it raises TypeError: Already tz-aware. A teammate suggests wrapping the call in try/except and falling back to .dt.tz_convert() whenever it raises. Is that a safe fix, or does it paper over something worse?

Think first, then tap
warmupCalendars & Alignment

What a trading calendar is

Question

You need the list of days the US stock market was open in 2024. A teammate suggests pd.date_range with freq="B". Is that right, and what is the correct mental model for a trading calendar?

Think first, then tap
coreStatistics

Multicollinearity in a multi-factor regression: VIF and unstable coefficients

Question

You run a weekly cross-sectional regression of stock returns on five factors, including value and quality, which have a correlation of about 0.85 with each other. The value and quality coefficients flip sign from week to week and carry huge standard errors, even though the regression's overall R-squared is stable. What's happening, and how would you diagnose and address it?

Think first, then tap
hardPoint-in-Time

Delisting returns: why dropping a stock at its last traded price understates losses

Question

Your backtest's price history simply ends on the day a stock is delisted -- you compute that day's return from the last available close and then drop the ticker from the panel. What's the hidden bias here, and how would you fix it point-in-time?

Think first, then tap
coreCleaning & Corp Actions

Dark-pool prints inflating consolidated volume without moving price

Question

You notice a stock's daily volume spikes 3x on a day with no news and no unusual intraday price range or spread widening. Looking closer, the consolidated tape shows a single large print reported well after it actually executed, tagged with an off-exchange sale condition. What's going on, and why does it matter for a liquidity feature built from raw consolidated volume?

Think first, then tap
hardStatistics

Granger causality for a lead-lag signal claim -- why quants are wary

Question

A researcher claims stock A's returns "Granger-cause" stock B's returns based on a Granger causality test with a significant p-value, and wants to build a signal trading B off A's lagged returns. Should that p-value convince you the lead-lag relationship is real and tradeable? What would you check first?

Think first, then tap
hardPortfolio Construction

Hedging currency risk on a foreign equity sleeve: why full FX hedging usually reduces portfolio variance even though it adds a position, not removes one

Question

Your fund holds a sleeve of Japanese equities, and the position is denominated in yen, so your dollar-based return is (1 + local equity return) times (1 + yen/dollar FX return) minus one -- you're exposed to BOTH the stock picks and the currency. A teammate argues that adding a currency hedge (shorting yen forward against the sleeve's notional) adds a second position and therefore adds risk. Walk through whether that's actually true, and what determines the answer.

Think first, then tap
coreCleaning & Corp Actions

ISIN check-digit validation: catching a transcription error before it corrupts a join

Question

A vendor feed occasionally has a single mistyped character in its ISIN column, maybe from an upstream OCR step on scanned documents. A corrupted ISIN doesn't crash your pipeline; it just fails to match your reference security master on that row, and you've been treating those rows as "name not covered yet." How would you catch these before ingestion, using the ISIN's own structure?

Think first, then tap
hardPoint-in-Time

A same-day implied vol surface can still be a lookahead if it hasn't landed yet

Question

You're backtesting an options-based signal that uses the implied volatility surface (IV by strike and expiry) as an input feature. Your vendor provides one vol surface snapshot per day, taken at the 4pm market close. Your signal computation pulls the surface dated to the SAME trading day it fires on, reasoning "it's the day's close, so it's available." Is that actually point-in-time safe, and what's the subtlety?

Think first, then tap
warmupData Assembly

Merging on a key that's int64 on one side and object (string) on the other: a silent empty-result join

Question

You merge a trades DataFrame (account_id loaded as int64) against an accounts reference table (account_id loaded from a CSV as a string, dtype object) on "account_id". The merge runs without error and comes back with zero matched rows. What actually happened, and how do you catch this before it reaches production?

Think first, then tap
warmupBacktest Mechanics

Spot the bug: crediting positive slippage on both legs of a round trip

Question

A backtest applies slippage by adjusting the fill price: buys fill at price * (1 + slip_bps/10000), sells fill at price * (1 - slip_bps/10000), meant to make every fill worse than the mid by slip_bps. On a long round trip (buy then later sell to close), the strategy's realized costs come out lower than expected. What's the bug?

Think first, then tap
hardFeature Construction

The cost of neutralization

Question

Neutralization always throws away part of your signal. How do you decide whether a factor should be sector- and beta-neutralized, rather than doing it by default?

Think first, then tap
warmupPerformance Analytics

CAPM alpha and beta from a rolling regression, and why short-window alpha is nearly meaningless

Question

Compute a strategy's alpha and beta against a market benchmark from its daily return series, and explain why quoting alpha from a 3-month rolling window is a much shakier number than quoting beta from the same window.

Think first, then tap
corePoint-in-Time

Imposing a reporting lag

Question

Your fundamentals vendor provides only fiscal period end dates -- no announcement dates. You cannot buy better data this week. How do you make this usable with minimal lookahead risk?

Think first, then tap
coreCalendars & Alignment

Merging two vendor feeds with mismatched timestamp units (ms vs ns)

Question

You're merging a trades feed from vendor A, whose timestamp column is int64 nanoseconds since epoch, with a quotes feed from vendor B, whose timestamp column is int64 milliseconds since epoch. A naive merge_asof on the raw integer columns runs without error, but every matched quote looks wrong. What happened, and how do you fix it?

Think first, then tap
coreCalendars & Alignment

Aligning US and Japanese equities

Question

You are researching a US-listed stock against its Japanese parent company. Japan has Golden Week and other holidays the US does not, and vice versa. How do you align the two daily series for a spread analysis?

Think first, then tap
hardPerformance Analytics

VaR backtesting: Kupiec's POF test for breach-rate validation

Question

Your daily 99% VaR model says true losses shouldn't exceed the reported VaR level more than about 1% of days. Over the last 250 trading days you observe 7 breaches. Is that model broken, or is 7 within normal statistical noise for a 99% VaR?

Think first, then tap
coreBacktest Mechanics

Sizing today's position off today's own realized volatility is lookahead

Question

A vol-targeting overlay sizes each day's position as target_vol / realized_vol, where realized_vol is computed from a rolling window that includes THAT SAME day's return. The backtest shows suspiciously smooth, well-controlled realized portfolio volatility. What's wrong with the vol estimate, and what should change?

Think first, then tap
corePoint-in-Time

Earnings before-market-open vs after-market-close: which trading session is actually the first reaction day

Question

A company reports earnings "before market open" (BMO) on Tuesday. Another reports "after market close" (AMC) on Tuesday. You're building a signal that reacts to the earnings surprise on the next available trading session. Why can't you treat both companies' "reaction day" the same way just because they both reported on the same calendar date?

Think first, then tap
hardStatistics

Multiple testing over backtest date ranges, not just signals

Question

A researcher reports a fantastic backtest but mentions in passing that they "tried a few different start and end dates before settling on 2015-2023 because it looked cleanest." Why is that sentence more concerning than a mediocre single-window Sharpe ratio, and how do you think about correcting for it?

Think first, then tap
hardPortfolio Construction

Tracking-error-constrained optimization vs a benchmark

Question

You're building a long-only portfolio benchmarked against the S&P 500 under a mandate that caps annualized tracking error at 4%. How does adding that constraint change the optimization compared to a plain min-variance or max-Sharpe formulation, and what happens at the constraint boundary?

Think first, then tap
warmupCalendars & Alignment

tz_localize vs tz_convert: attaching a timezone to naive timestamps vs converting an already-aware one

Question

A CSV of exchange trade timestamps loads as naive datetimes, but the underlying numbers are actually already US/Eastern wall-clock time. You need everything in UTC to join against a UTC-timestamped feed. Calling .tz_convert("UTC") on the naive column raises an error. What should you call instead, and why does the distinction matter?

Think first, then tap
coreCleaning & Corp Actions

Odd-lot trades double-counted in a vendor's volume field, inflating ADV-based filters

Question

You use a 20-day average daily volume (ADV) filter to decide which names are liquid enough to trade. After a vendor switch, several thinly-traded small caps suddenly pass the filter that shouldn't. You find the new feed's consolidated volume includes odd-lot trades (under 100 shares) that the old feed excluded, AND the new feed double-reports some odd-lots once on the originating venue's tape and once on the consolidated SIP tape. How do you even detect this, and what do you fix?

Think first, then tap
corePerformance Analytics

Rolling beta: catching time-varying market exposure

Question

A strategy's full-sample beta to the market is 0.97 -- looks close to a 1x-market strategy, nothing alarming. But you suspect its market exposure actually shifted meaningfully partway through the sample. How do you check, and why might the full-sample number be misleading you?

Think first, then tap
coreCleaning & Corp Actions

Free-float adjustment: why market-cap weighting uses free float, not shares outstanding

Question

You're building a market-cap-weighted universe. A company has 500M shares outstanding, but its founder holds a locked, non-traded stake of 300M shares. Do you weight the position using all 500M shares or only the roughly 200M that actually trade? Why does it matter?

Think first, then tap
coreFeature Construction

pd.qcut's 'Bin edges must be unique' error from a mass of tied values

Question

You try to bucket a cross-sectional feature into quintiles with pd.qcut(feature, 5) and it raises ValueError: Bin edges must be unique. Investigating, you find 40% of the stocks in today's cross-section have a feature value of exactly zero (a "no signal" default for names missing the underlying data). Why does that break qcut, and how do you fix the bucketing without just suppressing the error?

Think first, then tap
coreData Assembly

groupby().filter(): dropping whole groups that fail a group-level condition

Question

You have a panel of daily trades keyed by ticker, and you want to keep only tickers that traded on at least 200 of the last 252 days -- drop every row for any ticker that doesn't clear that bar, not just the thin days themselves. A teammate writes a mask on individual rows with df["n_trades"] > 0. Why is that the wrong tool, and what should they use instead?

Think first, then tap
warmupPoint-in-Time

Imposing a point-in-time reporting lag in calendar days instead of trading days silently shrinks across a weekend

Question

Your pipeline imposes a fixed "2-day lag" on earnings data to be conservative about when a number was actually knowable: available_date = report_date + 2 days. A company reports on a Friday. When does your pipeline say the data becomes available, and is that actually a safe point-in-time assumption?

Think first, then tap
hardFeature Construction

12-1 momentum: why skip the most recent month, and how to build the skip without lookahead

Question

The classic academic momentum factor uses the trailing 12-month return but deliberately SKIPS the most recent month (a "12-1" or "t-12 to t-1" formation), rather than just using the full trailing 12-month return ending today. Why is the skip there, and how do you implement it in pandas without accidentally reintroducing the very effect you're trying to exclude?

Think first, then tap
warmupCalendars & Alignment

Counting the Nth trading day of the month for a turn-of-month feature, without counting calendar days

Question

You want a feature flagging "this is the 1st, 2nd, or 3rd trading day of the month" to capture a turn-of-month effect (institutional flows tend to cluster right after month-end). Why can't you just use the date's calendar day-of-month number, and how do you build the real trading-day counter in pandas?

Think first, then tap
coreData Assembly

pivot_table with a list of aggfuncs and margins=True for a summary panel

Question

You have a long DataFrame of trades with columns desk, symbol, and pnl, and a PM wants one summary table: for each desk-symbol pair, both the total pnl and the trade count, plus a grand total row and column. How do you build that in one call, and what shape does the result actually come back in?

Think first, then tap
hardStatistics

Bootstrapping a Sharpe ratio confidence interval by resampling individual daily returns with replacement understates the true uncertainty when returns are autocorrelated

Question

You bootstrap a 95% confidence interval for a strategy's Sharpe ratio by resampling individual days with replacement 10,000 times and taking percentiles of the resulting Sharpe distribution. Your returns have mild but real day-to-day autocorrelation (partial fills bleeding into the next day, a slow-moving signal). Why does the ordinary i.i.d. bootstrap give you a confidence interval that's too narrow here, and what do you do instead?

Think first, then tap
coreCalendars & Alignment

date_range's inclusive parameter: off-by-one errors at range boundaries

Question

You build a backtest window with pd.date_range(start="2024-01-01", end="2024-01-31", freq="B") intending to include both endpoints, then elsewhere filter your price panel to dates strictly before a rebalance date using the same style of range. You keep hitting off-by-one mismatches -- one extra or one missing day -- between different parts of the codebase. What behavior do you need to standardize on?

Think first, then tap
warmupPerformance Analytics

Sortino ratio vs Sharpe ratio: a strategy with large positive skew can look much better on one than the other, and that's not a bug in either number

Question

Two strategies have the same Sharpe ratio. Strategy A has a smooth, roughly symmetric return distribution. Strategy B has frequent small losses and occasional large gains (positive skew). A teammate computes the Sortino ratio for both and finds B's is noticeably higher than A's, even though their Sharpes match. Is this a sign something's wrong with the calculation?

Think first, then tap
warmupCleaning & Corp Actions

Negative prices are not always errors

Question

Your cleaning pipeline has a rule: any price less than or equal to zero is a data error, drop the row. On April 20, 2020, the front-month WTI crude oil futures contract settled at about minus 37 dollars a barrel. Was your rule right to drop it?

Think first, then tap
corePerformance Analytics

Annualizing a Sharpe ratio computed from weekly returns

Question

A strategy only rebalances weekly, so you compute its Sharpe from a series of weekly returns instead of daily. A teammate takes that weekly Sharpe and multiplies by sqrt(252) out of habit, since that's what they always do. What's wrong with that, and what should they do instead?

Think first, then tap
coreData Assembly

merge()'s validate= parameter: catching a silent duplicate-key blowup

Question

You're merging a price panel (one row per ticker per day) against a static reference table that's supposed to have exactly one row per ticker. The merge runs fine, no error, but afterward you notice the row count roughly tripled and P&L numbers are impossible. What likely happened, and how do you make this fail loudly next time instead of silently?

Think first, then tap
hardCalendars & Alignment

DST transitions: ambiguous and nonexistent local timestamps in tz_localize

Question

You localize a column of naive US market-hours timestamps to America/New_York with tz_localize, and the job crashes twice a year -- once in spring, once in fall -- with errors about ambiguous or nonexistent times. What's actually going on, and how do you make the localization robust?

Think first, then tap
coreCalendars & Alignment

The midnight-UTC daily bar

Question

A new vendor delivers "daily" bars for global equities, every row stamped 00:00:00 UTC. Before using this in research, what questions do you ask, and what can go wrong if you don't?

Think first, then tap
warmupData Assembly

DataFrame.compare() for auditing what changed between two loader runs

Question

Your daily loader reprocesses the same vendor file and writes a fresh price table. You want to confirm today's rerun matches yesterday's output exactly, and if it does not, see precisely which cells differ and how. What do you reach for besides eyeballing two frames side by side or subtracting them?

Think first, then tap
hardCleaning & Corp Actions

A corporate-action feed mislabels a reverse split as a spinoff, and trusting the TYPE field instead of the price/volume ratio corrupts the whole series

Question

Your corporate-actions feed has a row for ticker XYZ on a given date with action_type="SPINOFF" and a ratio field of 0.1. You apply your spinoff-handling logic (which adjusts shares outstanding but leaves price alone) instead of your split-handling logic (which would divide historical prices by the ratio). The resulting price series has a 10x discontinuity on that date. What's actually happening, and why shouldn't the fix be "handle spinoffs better"?

Think first, then tap
coreBacktest Mechanics

Spot the bug: costs on notional

Question

A junior's backtest charges 5 bps times gross exposure as the daily cost. The strategy rebalances weekly. What is wrong, how big is the distortion, and which strategies does this bug favor?

Think first, then tap
coreBacktest Mechanics

Mark-to-market P&L in a vectorized backtest vs realized lot-based P&L in the live book

Question

Your vectorized backtest computes daily P&L as yesterday's position times today's price change, summed across the book -- the standard approach. When you go live, the accounting system's reported daily P&L doesn't match your backtest's historical number for the same trades, even on days with no new signal and no bug you can find. Where might a real, structural mismatch come from, and is it actually a bug?

Think first, then tap
hardCalendars & Alignment

Crypto perpetual funding timestamps: snapping to a fixed UTC schedule, not an exchange calendar

Question

You are building a feature from a crypto perpetual swap's funding rate, which most exchanges settle at fixed instants -- 00:00, 08:00, and 16:00 UTC, every single day including weekends and holidays. How do you align a continuous trade and quote tick stream to those funding timestamps in pandas, and why would reaching for an exchange trading calendar here be the wrong tool entirely?

Think first, then tap
coreCalendars & Alignment

Combining separate date and time-of-day columns into a tz-aware session timestamp

Question

A tick vendor ships two separate columns: trade_date (a date string, exchange-local calendar day) and trade_time (a time-of-day string like "14:32:07.500", also exchange-local). You need one tz-aware UTC timestamp per row for merging against a UTC-timestamped feed. Walk through building it correctly, especially around a DST transition day.

Think first, then tap
hardStatistics

Benjamini-Hochberg assumes independence your signal tests probably violate

Question

You ran 200 candidate signals through Benjamini-Hochberg to control the false discovery rate at 5%. Many are variants of the same idea (different lookback windows on one underlying signal), so their p-values are highly correlated, not independent. Does BH's 5% FDR guarantee still hold, and what's the fix?

Think first, then tap
corePortfolio Construction

Volatility targeting: scaling gross exposure to hit a target annualized vol

Question

Your raw signal produces a portfolio with realized annualized volatility that swings between 8% and 22% across different market regimes. Risk wants a strategy that runs at a steady 10% target vol. How do you scale exposure to get there, and what's the danger of estimating the scaling factor from too short a lookback window?

Think first, then tap
warmupStatistics

Why a return-forecasting regression with R-squared of 0.001 can still be a valuable signal

Question

You regress next-day return on a new signal and get an R-squared of 0.001 -- the signal explains one-tenth of one percent of return variance. A junior researcher wants to scrap it as useless. Is R-squared the right metric to judge a return-forecasting signal by, and what should you look at instead?

Think first, then tap
corePortfolio Construction

Why MV is an error maximizer

Question

People call mean-variance optimization an "error maximizer". Show me the intuition with two highly correlated assets whose expected returns differ by ten basis points.

Think first, then tap
coreData Assembly

pandas' nullable Float64 dtype vs plain float64 for a column with missing values that still needs comparisons, not just arithmetic

Question

Your returns column is plain float64 and already has NaN for missing days -- arithmetic like .mean() and .sum() handles that fine via NaN propagation. A teammate suggests converting it to pandas' nullable "Float64" extension dtype instead. What does that actually buy you that NaN propagation on a regular float64 doesn't?

Think first, then tap
hardStatistics

Testing for a structural break in a signal's IC over time

Question

A signal's rolling IC looks strong for the first three years of your sample and noticeably weaker for the last two. Eyeballing a rolling-IC chart is suggestive but not a test. How would you formally test whether the signal's relationship to forward returns actually changed at some point, versus this just being noise around one stable relationship?

Think first, then tap
coreFeature Construction

diff() vs pct_change(): additive vs multiplicative level sensitivity when building a momentum feature

Question

You're building a 20-day price-change feature across a universe spanning a $4 penny stock and a $400 large-cap. Someone on the team used .diff(20) (a plain price difference) instead of .pct_change(20). What goes wrong cross-sectionally, and in what situation would diff() actually be the right choice instead?

Think first, then tap
warmupData Assembly

pd.util.hash_pandas_object: fingerprinting a whole DataFrame to decide whether to invalidate a downstream cache

Question

You've just rebuilt a daily price panel from a fresh vendor pull and want to confirm it's identical to yesterday's cached version before deciding whether to invalidate three hours of downstream feature computation. Comparing column by column with == is slow and fiddly with NaNs. What's a fast way to get one comparable fingerprint for an entire DataFrame?

Think first, then tap
coreFeature Construction

np.where vs Series.where/.mask for a conditional feature: who propagates NaN and who doesn't

Question

You build a feature: positive_momentum = np.where(momentum > 0, momentum, 0). A teammate says you should use momentum.where(momentum > 0, 0) instead. Functionally these look like they do the same thing -- when does it actually matter?

Think first, then tap
coreStatistics

Clustering standard errors by date in a panel regression

Question

You regress daily stock returns on a signal across your whole panel -- thousands of stocks, hundreds of dates -- pooled into one big OLS regression, and report the standard OLS standard errors. A colleague says you need to cluster by date. What is that fixing, and why does it usually make your t-stats smaller rather than larger?

Think first, then tap
coreCalendars & Alignment

np.searchsorted on a trading-day index for a fast vectorized 'N trading days ago' lookup

Question

You need "the price from exactly 20 trading days ago" for every row in a long daily panel, millions of rows. Using df.index.get_loc(date) - 20 in a loop over every date is too slow. What's a faster vectorized approach?

Think first, then tap
warmupPerformance Analytics

Max drawdown DURATION (time spent underwater) vs max drawdown DEPTH -- two different risk numbers that get conflated

Question

Strategy A has a max drawdown of -8% that took 14 months to fully recover from. Strategy B has a max drawdown of -15% that recovered in 3 months. An allocator says Strategy B is "riskier" because -15% is the bigger number. Is that the full picture?

Think first, then tap
corePoint-in-Time

The full-sample z-score trap

Question

A researcher normalizes a time-series feature as x minus x.mean() over x.std(), computed over the whole 15-year sample, before backtesting. What is the leak, and what should they do instead?

Think first, then tap
warmupFeature Construction

Averaging log market cap (around 20-25) and daily volatility (around 0.01-0.05) into one composite score lets the larger-magnitude feature dominate by raw numeric scale, not by design

Question

You build a simple composite signal as the unweighted average of two raw features: log market cap and 20-day realized volatility. Backtesting it, the composite's returns look almost identical to trading log market cap alone, even though you intended a 50/50 blend. Why?

Think first, then tap
warmupPoint-in-Time

A company reorganizes its reporting segments, and the vendor retroactively reclassifies old quarters into the new structure -- the historical number you pull today isn't what a quant saw at the time

Question

A retailer used to report "North America" and "International" segments. Starting this quarter, it reports "E-commerce" and "Stores" instead, and your fundamentals vendor helpfully reclassifies the prior three years of quarterly segment revenue into the new E-commerce/Stores split so your historical panel stays "consistent." Why is pulling that reclassified history for a backtest starting two years ago still a point-in-time violation, even though the filing date and fiscal period on each row look completely unchanged?

Think first, then tap
coreCalendars & Alignment

Third-Friday-of-month arithmetic and quad witching

Question

Your options desk needs the exact date of each month's standard monthly expiration -- the third Friday of the month -- for all of 2026. They also flag that March, June, September, and December expirations ("quad witching") coincide with additional index-future and index-option expiries and reliably produce unusual volume. How do you compute "third Friday of month" vectorized for a whole calendar with no loop, and what data-quality implication does the quad-witching flag carry?

Think first, then tap
hardPerformance Analytics

Comparing Calmar ratios across strategies with different track-record lengths mechanically penalizes the longer one

Question

You're comparing two strategies' Calmar ratios (annualized return divided by maximum drawdown over the full track record) to decide which has a better risk-adjusted profile. Strategy A has 3 years of history; Strategy B has 12 years, including the same underlying return process as A plus 9 earlier years. B's Calmar ratio looks worse. Is that necessarily telling you B's strategy is worse, or could the comparison itself be unfair?

Think first, then tap
corePerformance Analytics

Annualizing volatility with the autocorrelation-adjusted scaling factor, not just sqrt(252)

Question

You annualize daily volatility as daily_std * sqrt(252), the standard formula. Your strategy's daily returns show meaningful positive autocorrelation -- today's return predicts tomorrow's, common when marks are stale or a signal decays slowly. Is sqrt(252) still the right scaling factor?

Think first, then tap
corePerformance Analytics

Decomposing portfolio variance into systematic and idiosyncratic pieces

Question

Your book's realized annualized vol is 18%. The PM wants to know how much of that is coming from your intentional factor bets (market, value, momentum) versus genuine idiosyncratic stock-picking risk you didn't intend to take. How do you split total portfolio variance into those two pieces, and why can't you just add up each stock's own idiosyncratic vol?

Think first, then tap
corePortfolio Construction

Liquidity-adjusted position sizing: capping by days-to-liquidate, not a flat ADV fraction

Question

Your optimizer currently caps every position at 10% of the stock's average daily volume (ADV). A PM points out this treats a mega-cap and a small-cap identically even though unwinding the mega-cap position takes half a day and the small-cap takes a week, at the same dollar size. How would you fix the constraint, and why does a flat ADV-fraction rule fail here?

Think first, then tap
hardPoint-in-Time

A merge_asof tolerance window set too wide lets a late-arriving but PIT-labeled record leak forward

Question

You join analyst estimate revisions onto a daily returns panel with pd.merge_asof(returns, revisions, on="date", by="ticker", direction="backward", tolerance=pd.Timedelta("10D")). The revisions table's "date" column is correctly the record's own as-of/effective date, so you believe this is a safe point-in-time join. A backtest using this joined estimate shows an implausibly strong signal. What's the actual failure mode, and is it a timestamp problem or something else?

Think first, then tap
corePerformance Analytics

Implementation shortfall: decomposing paper alpha vs realized net return

Question

Your signal's paper backtest (trading at that day's close with no cost) shows a 12% annual return. The live book, trading the same signal, realizes 7%. The PM wants the gap explained, not just accepted. How do you decompose that 5% into distinct, actionable pieces rather than lumping it all into "costs"?

Think first, then tap
coreStatistics

Non-normal daily returns and the sign test as an alternative to a t-test on Sharpe

Question

A strategy's daily returns are heavily right-skewed -- lots of small losses, occasional large gains, like a long-volatility overlay. A standard t-test on whether mean daily return is greater than zero assumes roughly normal (or at least symmetric) returns. What breaks, and what's a distribution-free alternative for just testing "is the median return positive"?

Think first, then tap
warmupPortfolio Construction

Measuring turnover

Question

Given a DataFrame of daily portfolio weights, how do you compute turnover, and roughly what level should make you nervous for an equity strategy paying 5 bps a trade?

Think first, then tap
warmupCalendars & Alignment

DateOffset(months=1) walks the calendar by month; Timedelta(days=30) just adds 30 days -- they agree in some months and silently diverge in others

Question

You need "the price one month ago" for a momentum feature. One engineer writes date - pd.Timedelta(days=30), another writes date - pd.DateOffset(months=1). Do they return the same date, and does it matter which one you pick?

Think first, then tap
warmupData Assembly

Chained indexing and SettingWithCopyWarning

Question

You clean a price panel with df[df["volume"] == 0]["close"] = np.nan to null out closes on zero-volume days. Pandas raises a SettingWithCopyWarning, and when you check afterward the closes are unchanged. What happened, and how do you fix it?

Think first, then tap
coreData Assembly

Numbers stored as text: thousands separators and currency symbols

Question

A vendor's CSV has a "market_cap" column that looks numeric in Excel but pandas reads it as object dtype: values like "1,234,567.89" and elsewhere a price column with "$45.20". read_csv gives you strings. What causes this, and how do you fix it without silently corrupting values?

Think first, then tap
coreBacktest Mechanics

Stress-testing with block-bootstrapped synthetic price paths

Question

Your backtest looks great on the one historical price path you have. How do you test whether that result is robust rather than a strategy that happens to work on this particular sequence of historical returns -- using only the data you already have, with no new data?

Think first, then tap
warmupFeature Construction

Log returns vs simple returns as the base for a multi-day momentum feature

Question

You're building a 20-day momentum feature: the total return over the trailing 20 trading days. One teammate computes it by summing daily log returns; another by compounding daily simple returns. Do these give the same number, and which should the feature actually use?

Think first, then tap
coreBacktest Mechanics

Linear vs square-root impact

Question

When is a flat per-dollar cost model good enough, and when do you need square-root market impact? What actually changes in the backtest's conclusions?

Think first, then tap
hardPortfolio Construction

Dollar- and sector-neutral at once: why sequential neutralization isn't the same as joint

Question

You need a portfolio that's both dollar-neutral (net exposure zero) and sector-neutral (zero net exposure within each sector). A teammate first demeans weights to zero sum overall, then demeans again within each sector. Does that sequence actually deliver both constraints simultaneously, and if not, what does?

Think first, then tap
coreFeature Construction

ewm()'s adjust=True vs adjust=False changes the effective weights near the start of each ticker's history, biasing young names

Question

You compute a 20-day-halflife EWM average of daily returns per ticker with groupby("ticker").ewm(halflife=20).mean(), using the default adjust=True. A name that IPO'd eight days ago has a materially different EWM value than one computed with adjust=False on the exact same eight returns. Why, and which one would you want for a feature that gets compared across tickers with very different listing ages?

Think first, then tap
corePerformance Analytics

Reporting a daily-return Sharpe next to an intraday-equity-curve max drawdown mixes two different sampling frequencies

Question

Your tearsheet reports a Sharpe of 2.1 computed from end-of-day returns, and a max drawdown of -8% computed from your intraday (1-minute) equity curve, because that's the data each metric happened to be easiest to compute from. A PM asks why the drawdown looks so much worse than what the daily P&L series alone would suggest. What's the mismatch, and does it mean one of the two numbers is wrong?

Think first, then tap
corePortfolio Construction

Stacking a sector-neutral constraint on top of a factor-neutral constraint in the same optimizer can leave so little feasible room that the solver shrinks toward flat, quietly erasing the alpha it was built to express

Question

Your optimizer is set up to be both sector-neutral (zero net exposure to each of 11 sectors) and factor-neutral (zero net exposure to value, momentum, size, and three other style factors) at every rebalance, on top of your usual gross and position-size limits. Expected active risk keeps coming in far below target, and the realized portfolio barely resembles the alpha ranking you fed it. What's the likely mechanism, and how would you diagnose it?

Think first, then tap
hardCleaning & Corp Actions

Spin-offs: a corporate action that isn't a split or dividend

Question

Company A spins off its cloud division as a new public company B: every holder of A receives 0.25 shares of B for each share of A, and A's price drops by roughly the value of what was distributed. Your adjustment pipeline only knows how to handle splits (a ratio factor) and cash dividends (add back the cash). What breaks, and how do you adjust for a spin-off correctly?

Think first, then tap
coreCalendars & Alignment

Adding 'one day' across a DST change: Timedelta vs DateOffset

Question

You need the timestamp exactly 24 hours after a given intraday trade time, and separately, the timestamp for "the same wall-clock time tomorrow" for a daily rebalance. You write ts + pd.Timedelta(days=1) for both. One of them is correct across a daylight-saving transition and one silently isn't. Which is which, and why?

Think first, then tap
hardPortfolio Construction

Horizon mismatch: feeding a daily covariance matrix and a monthly-horizon alpha into the same optimizer

Question

Your covariance matrix is estimated from daily returns over the trailing year and feeds a mean-variance optimizer, but your expected-return forecast (alpha) is generated at monthly horizon and represents "expected return over the next month" directly, un-annualized. You plug both straight into the optimizer's w = Sigma^-1 * mu. What's wrong with combining them this way, and how do you fix it?

Think first, then tap
hardFeature Construction

Orthogonalizing a new signal against an existing one via regression residuals

Question

Your firm already trades a value signal. You've built a new signal that backtests with a strong IC, but a scatter plot shows it's highly correlated with value cross-sectionally. How do you find out how much of the new signal's predictive power is genuinely incremental, and how do you construct a version of it that's safe to combine with the existing value book?

Think first, then tap
corePortfolio Construction

Risk budgeting across strategies: capital allocation by risk contribution, not dollar notional

Question

You run three sub-strategies with annualized volatilities of 5%, 12%, and 20%, and allocate them equal dollar notional (one-third each). Is each sub-strategy contributing roughly a third of the total portfolio's risk? If not, how would you size them so each one does?

Think first, then tap
corePerformance Analytics

The Fundamental Law of Active Management: IR ~ IC x sqrt(breadth)

Question

Two signals both have an information coefficient of 0.03. Signal A rebalances the full 3,000-stock universe monthly. Signal B trades the same universe but effectively re-bets on only about 50 independent names at a time because most of its positions are highly correlated with each other. Which one should you expect to produce a better information ratio, and why does IC alone not answer that?

Think first, then tap
warmupPoint-in-Time

Building today's tradable universe from today's own close is a lookahead

Question

Your universe filter keeps any stock with market cap above 500 million dollars, computed as today's closing price times shares outstanding, and applies that filter to decide which names are eligible to trade TODAY. What is wrong with using today's own close for that decision, and what should the filter use instead?

Think first, then tap
warmupCleaning & Corp Actions

Gross vs net dividend: a vendor field that silently doubles your total return

Question

A vendor's corporate-actions file has two columns for the same ex-dividend event: dividend_gross and dividend_net, net of withholding tax. Your total-return adjustment sums both columns as the day's payout. What is wrong with that, and how should you actually pick the dividend amount to use?

Think first, then tap
coreCleaning & Corp Actions

When forward-fill is right vs deadly

Question

Give me the cases where forward-filling financial data is correct, the cases where it is catastrophic, and the underlying principle that separates them.

Think first, then tap
corePerformance Analytics

Profit factor: gross profits over gross losses, and how position sizing games it

Question

A strategy reports a profit factor of 3.5 -- gross profits are 3.5 times gross losses -- and the researcher presents this as strong evidence of an edge. What does profit factor actually measure, and why should you immediately ask how position sizes were set before trusting that number?

Think first, then tap
coreStatistics

Welch's t-test vs Student's t-test for comparing two strategies

Question

You want to test whether Strategy A's mean daily return is significantly different from Strategy B's. A has 3 years of history, B only launched 9 months ago, and A's returns look noticeably more volatile. Your teammate reaches for scipy.stats.ttest_ind with default settings. What's wrong with that, and what should change?

Think first, then tap
corePoint-in-Time

Earnings 'reported on date T' hides whether it was before the open or after the close -- and that decides which day's return it explains

Question

Your earnings calendar feed has one column, report_date, with no time attached. A company reports on report_date = 2026-10-15. If you align the earnings-day return as the close-to-close return ENDING on report_date, you get a strategy test that looks noisy and unprofitable around earnings -- flip to the close-to-close return STARTING on report_date and the same event suddenly shows a strong, consistent reaction. What's going on, and which one is actually point-in-time correct?

Think first, then tap
warmupData Assembly

pd.NA vs np.nan vs None: three missing-value sentinels

Question

A DataFrame column ends up with pd.NA in some rows, np.nan in others (depending on which upstream pipeline touched it), and a stray None slipped in from a raw JSON load. A teammate asks: are these the same missing value under the hood, and does it matter which one shows up in a numeric column?

Think first, then tap
corePortfolio Construction

Checking a covariance matrix's condition number before it hits the optimizer

Question

Before feeding a 300-asset sample covariance matrix into a mean-variance optimizer, a colleague suggests checking its condition number first. What does the condition number tell you here, and what's a reasonable threshold for deciding the matrix needs shrinkage or denoising before you trust the optimizer's output?

Think first, then tap
warmupCalendars & Alignment

weekday() vs isoweekday(): an off-by-one when encoding day-of-week as a feature

Question

You add a day-of-week feature by calling .dt.weekday on a DatetimeIndex to test for a "Monday effect" in returns. A coworker's version uses .dt.isoweekday() instead. Do the two features actually agree, and why does it matter which one you pick?

Think first, then tap
warmupBacktest Mechanics

Chaining daily returns multiplicatively for CAGR vs averaging them arithmetically: why the arithmetic mean overstates true compounded growth

Question

A strategy's daily returns average +0.05% with a standard deviation of 1.5%. A junior analyst multiplies 0.05% by 252 and reports an annualized return of 12.6%. What's wrong with that, and what should the actual annualized return look like?

Think first, then tap
warmupCalendars & Alignment

tz_convert vs tz_localize: converting an already-aware timestamp vs assigning a timezone to a naive one

Question

You have two DatetimeIndexes: one loaded from a vendor file with no timezone info (tz-naive, but you know the values are already in US/Eastern wall-clock time), and one that's already tz-aware in UTC from your own database. You need both in UTC before you can compare them. Which pandas method do you use for each, and what happens if you use the wrong one?

Think first, then tap
corePoint-in-Time

Short interest data's settlement-date vs publish-date reporting lag

Question

FINRA short interest data is reported for settlement dates roughly twice a month, but the actual numbers aren't published until about a week and a half after each settlement date. Your pipeline joins short interest to price data by settlement date. What's wrong with that, and how do you fix it for a backtest?

Think first, then tap
corePoint-in-Time

merge_asof by-groups and tolerance

Question

You merge_asof quarterly fundamentals onto daily prices for 3000 tickers. Why do you need the by argument, and what problem does tolerance solve?

Think first, then tap
warmupPoint-in-Time

Availability date vs effective date

Question

A company's Q4 earnings cover the quarter ending December 31 but are announced on February 15. Which date do you use when joining earnings onto your daily price panel, and what are these two dates called?

Think first, then tap
warmupData Assembly

np.select for multi-branch labeling instead of nested np.where

Question

You need to label each row of a daily returns panel into one of four buckets -- "big_up" (>2%), "up" (0% to 2%), "down" (-2% to 0%), "big_down" (below -2%) -- based on that day's return. A teammate nests three np.where calls inside each other. What's cleaner, and does it change behavior?

Think first, then tap
hardCleaning & Corp Actions

A vendor silently switches a column from basis points to percent, inflating values by 100x

Question

Your fixed-income vendor's daily_spread_change field has always been in basis points (1 bp = 0.01%). After a vendor platform migration, you notice your spread-change-based signal's z-scores have exploded in magnitude starting from a specific date, but nothing else in the file format changed -- same column name, same dtype, no documentation update. What's the most likely explanation, and how do you confirm it?

Think first, then tap
warmupPerformance Analytics

Historical simulation VaR vs parametric VaR when returns have fat tails

Question

Your risk team computes daily VaR two ways for the same book: parametric VaR assumes returns are normally distributed and uses the book's estimated mean and standard deviation directly in a closed-form formula; historical simulation VaR instead takes the actual historical daily P&L outcomes and reads off the empirical percentile directly, no normality assumed. On a book with a history including a few sharp crash days, the two methods disagree substantially. Which one do you trust more, and why?

Think first, then tap
corePoint-in-Time

Nonfarm payrolls get revised twice after the first print -- using today's 'final' number is a lookahead

Question

Your macro signal reacts to the US nonfarm payrolls number on its release date. Your data vendor's history table stores only one value per month: the most recently revised figure. Why does backtesting against that one column overstate the signal's real historical performance, and what do you actually need instead?

Think first, then tap
corePoint-in-Time

Restatements and first-reported data

Question

A company reports Q4 EPS of 2.10 in February, then restates it to 1.40 in June. Your vendor's current database shows 1.40 for Q4. What is wrong with backtesting on that, and how should the data be structured?

Think first, then tap
warmupPortfolio Construction

Correlation vs covariance in mean-variance inputs

Question

A junior on your team builds a portfolio optimizer that takes a correlation matrix as its risk input instead of a covariance matrix, reasoning that correlation is "cleaner" since it's bounded between -1 and 1. What breaks?

Think first, then tap
warmupStatistics

Confidence interval for a correlation: Fisher's z-transform

Question

You measure a correlation of 0.35 between two signals using 100 paired daily observations and want an honest confidence interval on it. Why can't you just apply a normal approximation directly to the correlation itself, and what does Fisher's z-transform do instead?

Think first, then tap
warmupCleaning & Corp Actions

Volume reported in round lots (100-share units) vs raw shares: a silent 100x scale mismatch

Question

You're building an ADV (average daily volume) feature for position sizing, blending two vendor feeds. One ticker's ADV from Vendor A is consistently about 100 times smaller than Vendor B's for the exact same stock on the exact same days, while price and returns line up fine between the two. What's the likely explanation, and how would you confirm it before trusting either number?

Think first, then tap
warmupFeature Construction

Why min_periods matters

Question

You compute a 60-day rolling z-score and the first 59 rows are NaN, so a teammate changes it to rolling(60, min_periods=1) to "fix the NaNs". What do you tell them?

Think first, then tap
coreData Assembly

pd.read_csv inferring a leading-zero ID column (CUSIP, ticker padding) as int64 silently strips the leading zeros

Question

You load a vendor file with read_csv() where one column holds 9-character CUSIPs like "000957100". After loading, df["cusip"] shows 957100 instead. What happened, and how do you prevent it?

Think first, then tap
hardPoint-in-Time

A vendor's 'historical' API endpoint silently serves today's restated values, not what was knowable on that date

Question

Your fundamentals vendor exposes a REST endpoint get_history(ticker, as_of_date) that you call to pull point-in-time data for backtesting. You assume it returns the values that were known as of that historical date. A research teammate notices a backtested trading rule performs suspiciously well right after earnings restatements. What's the likely failure, and how do you verify it?

Think first, then tap
coreData Assembly

Categorical dtype for tickers

Question

Your long-format panel has 3,000 tickers and 10 years of daily rows -- about 7.5 million rows -- and the ticker column alone dominates memory. What dtype change helps, how does it work, and where can it bite you?

Think first, then tap
hardCleaning & Corp Actions

Winsorizing outliers: percentile clip vs MAD vs z-score

Question

A daily feature has occasional extreme values that you want to cap rather than delete, so a handful of fat-fingered prints don't dominate a cross-sectional regression. A teammate proposes clipping at the 1st and 99th percentile every day. Walk through that choice against z-score capping and MAD-based capping, and where each breaks.

Think first, then tap
hardStatistics

Confidence interval for a rank-IC: Spearman's own standard error, not Pearson's Fisher z-transform plugged in unmodified

Question

You measured a rank-IC (Spearman correlation between a factor's cross-sectional rank and forward return rank) of 0.05 over 400 independent dates and want a 95% confidence interval. A teammate plugs 0.05 straight into the standard Fisher z-transform formula built for Pearson correlation. What's wrong with that, and what should change?

Think first, then tap
hardPerformance Analytics

Brinson-style attribution: splitting active return into allocation effect vs selection effect

Question

Your portfolio beat its benchmark by 150 bps last quarter. The PM wants to know how much of that came from being overweight the right sectors versus picking the right stocks within each sector. What's the standard decomposition for this, and what does each piece actually isolate?

Think first, then tap
corePortfolio Construction

Market impact scales roughly with the SQUARE ROOT of trade size relative to volume, not linearly -- a linear cost-per-share model understates the cost of your largest trades and overstates the cost of your smallest ones

Question

Your backtest charges a flat cost-per-share for every trade, calibrated to match the average cost you've seen in live execution. The strategy's live Sharpe keeps coming in worse than backtested, and the gap is worst on the days when you trade the biggest size. What's the likely modeling error, and what's the standard fix?

Think first, then tap
warmupData Assembly

df.sample() without a fixed random_state makes a 'deterministic' backtest silently non-reproducible across reruns

Question

You're asked to pull a random 20% holdout of names from today's universe to sanity-check a feature's distribution, using df.sample(frac=0.2). You rerun the exact same notebook cell an hour later and get a different holdout set. Why, and what's the fix?

Think first, then tap
hardStatistics

Is an IC of 0.02 any good?

Question

A signal shows a mean daily rank-IC of 0.02 over five years on a 2000-stock universe. Talk me through whether that is statistically real and whether it is economically worth trading.

Think first, then tap
hardBacktest Mechanics

Capping trade size to a fraction of ADV

Question

Your vectorized backtest computes target position sizes from a signal and assumes every trade fills completely, same day, at no market impact beyond your cost model. For a strategy that would need to trade 50,000 shares against a name with only 100,000 shares of average daily volume, is that realistic, and how do you cap it in a vectorized way?

Think first, then tap
hardPortfolio Construction

CVaR optimization instead of mean-variance

Question

Your desk runs a strategy with visibly negatively-skewed, fat-tailed returns (short-vol flavored), and mean-variance optimization -- which only cares about variance -- sizes it as if a 3% daily swing up and a 3% daily swing down were equally bad. A colleague proposes optimizing directly on CVaR (expected shortfall) instead of variance. What does that change about the optimization, and what makes it tractable despite CVaR looking like a much harder object to optimize than a quadratic variance term?

Think first, then tap
warmupData Assembly

groupby().nth() for picking a specific observation per group

Question

You have a tick-level trade log with multiple prints per (ticker, date). You need the FIRST print of each day per ticker to use as an opening reference price. A teammate writes df.groupby(["ticker", "date"]).first(). Why might .nth(0) be the more honest tool here than .first(), and what actually differs between them?

Think first, then tap
hardCleaning & Corp Actions

Detecting an unflagged stock split from raw price and volume

Question

Your corporate-actions vendor missed a 2-for-1 split for one ticker. The raw price series shows an overnight drop of almost exactly 50%, and volume roughly doubles that same day, with no earnings release or news event around it. How would you programmatically flag this as a probable unflagged split rather than a real crash, and how would you backfill the adjustment?

Think first, then tap
warmupPerformance Analytics

Reconciling trade-based P&L against mark-to-market P&L to the penny

Question

Your tearsheet computes daily P&L two independent ways: trade-based (sum of realized P&L from each executed trade) and mark-to-market (change in position value using start- and end-of-day prices, plus cash flows). For a clean day with no data issues, should these two numbers match exactly, and what does it mean if they don't?

Think first, then tap
hardStatistics

Is the signal dead, or did the market switch regimes? A Markov regime-switching model tells them apart

Question

A signal's rolling 1-year IC has dropped from 0.04 to near zero over the trailing six months. One PM says the signal has decayed and should be retired; another says the market is simply in a "regime" where this type of signal doesn't work, and it will come back. How would you actually distinguish decay from regime-switching, rather than debating priors?

Think first, then tap
warmupCalendars & Alignment

tz_convert vs tz_localize: relabeling a clock vs shifting it

Question

You have a Series of trade timestamps. One teammate calls tz_localize("America/New_York") on it, another calls tz_convert("America/New_York"). Both produce timestamps that print with a New York offset, but on different inputs one of them is silently wrong. What's the actual difference?

Think first, then tap
hardStatistics

Regime dependence

Question

A signal backtests with a Sharpe of 1.0 over 12 years, but a breakdown shows nearly all the P&L came from 2020-2022. How do you think about whether this signal is real, and would you allocate to it?

Think first, then tap
hardCleaning & Corp Actions

Applying your own split-ratio adjustment on top of a vendor's already-adjusted close silently double-adjusts historical prices

Question

Your vendor's "close" field is already split- and dividend-adjusted, but your pipeline also maintains its own corporate-actions table and multiplies historical prices by cumulative split ratios before computing returns, a step that made sense when you used a different, unadjusted data source. After switching vendors, a 2-for-1 split date shows a ~75% one-day "return" instead of ~0%. What happened, and how do you confirm which of two adjustment steps is the redundant one?

Think first, then tap
warmupCleaning & Corp Actions

A phantom trading day: when your price file and the exchange calendar disagree

Question

A daily price file has a row for a date the exchange was actually closed, for an unscheduled event like a national day of mourning. That row's close price is identical to the prior day's close. How do you detect this kind of phantom row, and why is it worse than an ordinary missing date?

Think first, then tap
warmupCalendars & Alignment

Lunar New Year and other non-fixed-date holidays breaking a hardcoded calendar

Question

Your Hong Kong equities pipeline hardcodes a list of market holiday dates, refreshed once a year by copy-pasting the exchange's holiday circular. Every January it needs manual updating or the pipeline silently misaligns. Why does this specific market break a "just hardcode the list" approach worse than, say, US equities, and what's the more robust fix?

Think first, then tap
warmupPerformance Analytics

Active return over a multi-year horizon isn't portfolio CAGR minus benchmark CAGR

Question

A PM asks for "our active return since inception" and a junior analyst reports portfolio CAGR minus benchmark CAGR over the three-year period. Is subtracting the two compounded annual growth rates the right way to measure cumulative active return, and if not, what should they compute instead?

Think first, then tap
warmupCalendars & Alignment

Frequency alias deprecation: 'M' becomes 'ME', 'Q' becomes 'QE'

Question

You pull up an old backtest notebook and resample(df, "M").last() throws a FutureWarning, or on a newer pandas an outright error, about a deprecated frequency alias. What changed, why, and what should replace "M" and "Q" going forward?

Think first, then tap
coreCleaning & Corp Actions

Why a leveraged ETF's multi-day return diverges from N times the underlying's return

Question

A 2x leveraged ETF tracks its underlying index by rebalancing its exposure back to exactly 2x every day. Over one volatile month the underlying index is roughly flat, but the leveraged ETF is down 8%. Is that a data error in your feed, and what should you check before assuming so?

Think first, then tap
coreCleaning & Corp Actions

Filtering bad ticks

Question

In intraday trade data you occasionally see a print far off the market -- say 50% away for one observation -- after which prices continue as before. Design a bad-tick filter and tell me how you avoid deleting real jumps.

Think first, then tap
warmupFeature Construction

rank(pct=True) vs z-scoring for combining heterogeneous features

Question

You want to combine raw 21-day momentum with several other features that live on very different scales, without a full cross-sectional z-score. What's the simplest scale-free transform, and when should you reach for it instead of a z-score?

Think first, then tap
coreCleaning & Corp Actions

Identifier drift: when a CUSIP or ISIN gets reassigned mid-history

Question

You join ten years of fundamentals to price history using CUSIP as the key. A single stock's time series shows a clean price history but its fundamentals abruptly go missing for a three-year stretch in the middle, then reappear. Ticker and company name are unchanged throughout. What's the likely cause, and how do you confirm it?

Think first, then tap
corePoint-in-Time

Point-in-time identifier mapping: tickers and CIKs that change over time

Question

You're joining a fundamentals table keyed by CIK (the SEC's permanent filer ID) to a price table keyed by ticker, over a 15-year history. A single company can have multiple tickers over that window -- a ticker change, a delisting and relisting, or a ticker getting recycled years later to a completely different company. A naive join on ticker alone produces some clearly wrong matches. What's going on, and what's the right way to key this join?

Think first, then tap
warmupPoint-in-Time

shift(-1) deliberately builds a forward-return label -- the same call left on a feature column is the classic injected lookahead bug

Question

Code review: someone wrote returns.shift(-1) to build tomorrow's return as today's label. Is that correct, and what would make the exact same line of code a serious bug somewhere else in the pipeline?

Think first, then tap
corePortfolio Construction

The Epps effect: why intraday correlation looks lower than daily

Question

You estimate the correlation between two similar large-cap tech stocks using 1-minute bars and get 0.35, but using daily bars over the identical period you get 0.75. Which number should you trust, and what's actually causing such a large gap?

Think first, then tap
hardPoint-in-Time

The cached-feature lookahead: memoizing a rolling feature over full history

Question

To speed up your walk-forward research loop, an engineer precomputes every rolling feature ONCE over the entire 15-year history and saves it to a parquet file that every fold then reads from. The features themselves use only trailing windows -- rolling(252).mean(), properly shift()-ed. Each individual fold's train/test split still looks correct. Is the cached file actually point-in-time safe, and if not, where exactly does the leak enter?

Think first, then tap
hardStatistics

Lo (2002)'s analytic Sharpe ratio standard error under autocorrelated returns, instead of assuming i.i.d.

Question

You report an annualized Sharpe ratio and want a standard error for its t-stat, without running a full bootstrap. The strategy's daily returns have a known, meaningfully positive first-lag autocorrelation. Is there a closed-form adjustment for this, and what does skipping it do to your t-stat?

Think first, then tap
coreCleaning & Corp Actions

NaN vs zero in a returns panel

Question

In your daily returns matrix, some cells are NaN -- names not yet listed, halted, or with feed gaps. A teammate proposes fillna(0) so "the math stops breaking". What does that decision actually do, and what is your policy?

Think first, then tap
corePortfolio Construction

Factor exposure drift between rebalances: a beta-neutral book that isn't, by the next rebalance

Question

You rebalance a market-neutral book monthly, targeting exactly zero net beta at each rebalance date using that day's estimated betas. A risk report mid-month shows the book running a meaningfully positive net beta, even though you haven't traded anything since the last rebalance. How does that happen with zero new trades, and what does it imply about how often you should be checking exposure versus how often you trade?

Think first, then tap
coreFeature Construction

pd.qcut with duplicate values: the bin-edge collapse

Question

You bucket a cross-sectional signal into quintiles each day with pd.qcut(sig, 5, labels=False), and it works fine most days but raises "Bin edges must be unique" on days when a large fraction of stocks share the exact same signal value -- say, an accruals ratio that is exactly zero for many small-caps with no reported accruals. What is happening, and how do you handle it without silently distorting the buckets?

Think first, then tap
hardPortfolio Construction

No-trade bands

Question

Every day your book drifts slightly from target and your execution desk asks whether to trade it back. Costs are real. Describe a no-trade band policy and how you would size the band.

Think first, then tap
coreData Assembly

DataFrame.values vs .to_numpy() vs .array: three ways to drop into numpy, and which one silently upcasts

Question

You call .values on a DataFrame that has one nullable integer column and one float column, then feed the result into a numpy function. What actually comes back, and how is that different from .to_numpy() or pulling .array off a single column?

Think first, then tap
coreStatistics

Overlapping returns and Newey-West

Question

You evaluate a signal against 21-day forward returns, sampled DAILY, and get a t-stat of 6. Why is that t-stat inflated, and what is the Newey-West correction doing about it?

Think first, then tap
coreCalendars & Alignment

DST fall-back creates a duplicate wall-clock hour in intraday timestamps

Question

You're joining two intraday feeds on their local wall-clock timestamp (tz "America/New_York") around the first Sunday in November. One ticker's trades near 1:30am local time join to TWO different rows instead of one on the other feed. Markets are closed at 1:30am anyway, but the same bug shows up in a different form during exchange hours in other timezones. What's happening, and how do you avoid it?

Think first, then tap
hardBacktest Mechanics

A vectorized backtest can't see the intrabar price path, so a stop-loss rule systematically misprices its own fills

Question

You add a 5% stop-loss to a vectorized daily backtest: close the position if today's CLOSE is down more than 5% from entry. A colleague says this understates how a real stop-loss would behave. What's missing, and does switching from using the close to using the day's low fix it?

Think first, then tap
hardStatistics

Attenuation bias: why a noisily-measured signal understates its own true IC

Question

You regress forward returns on a signal that is itself estimated with error -- say, an analyst-revision score built from a small, noisy sample of estimates for many names. The measured IC comes back at 0.02, weaker than a cleaner version of the same idea on the largest, most-covered names, where it's 0.05. Before concluding the small-cap version of the signal is genuinely weaker, what statistical effect should you rule out?

Think first, then tap
warmupPerformance Analytics

CAGR vs arithmetic mean return: which belongs in the tearsheet headline?

Question

A strategy's daily returns average +0.05% arithmetic mean per day. Annualized naively (times 252), that's about +13.4%. But the actual compounded return over the year was only +9%. Both numbers are "correct" -- so which one do you put at the top of the tearsheet, and why do they diverge?

Think first, then tap
corePoint-in-Time

Point-in-time FX conversion: the rate you'd have actually had, not the rate today

Question

You're converting a basket of European stock prices, quoted in EUR, into USD for a global backtest, using a single EUR/USD rate pulled from each trading day's 4pm close. Your PM points out that your signal actually fires and trades at 9:35am New York time, well before the European close and well before the day's FX fixing. What's the lookahead risk here, and how do you fix it?

Think first, then tap
hardPerformance Analytics

Annualizing a daily regression's alpha intercept by multiplying by 252 ignores compounding -- the arithmetic scaling quietly overstates true annualized alpha

Question

You regress daily strategy returns against daily benchmark returns and get a daily alpha intercept of 0.0003 (3 basis points a day). You report "annualized alpha" as 0.0003 times 252, about 7.6%. Is that actually how much extra annual return the 3bps/day alpha compounds to, and if not, which number is right?

Think first, then tap
corePortfolio Construction

Netting two sleeves' opposite orders in the same name saves execution cost, but netting their POSITIONS for risk reporting hides how much gross risk each is actually running

Question

Sleeve A's model wants to buy 10,000 shares of XYZ today. Sleeve B, trading an entirely independent model, wants to sell 10,000 shares of the same name. Your desk nets this internally and sends zero net order to the broker, saving the full round-trip cost. Your end-of-day risk report shows XYZ's net position as unchanged. Is that an accurate picture of the firm's risk in XYZ, and what's missing?

Think first, then tap
hardStatistics

Fama-MacBeth: cross-sectional regressions done right

Question

You want to estimate the risk premium -- the average return per unit of exposure -- for three characteristics (value, momentum, size) using a panel of stock returns and characteristics. Walk through the Fama-MacBeth two-pass procedure, and explain why its standard errors differ from just pooling everything into one big panel regression.

Think first, then tap
corePoint-in-Time

merge_asof's tolerance argument in the wrong time unit silently drops valid matches instead of raising

Question

You use pd.merge_asof to attach the most recent fundamentals snapshot onto a daily price panel, with tolerance=pd.Timedelta(90) to allow fundamentals up to roughly a quarter old. After running it, most rows that should clearly have a recent match within 90 days come back NaN. What's wrong?

Think first, then tap
warmupData Assembly

merge()'s validate= parameter catches an accidental many-to-many join before it silently inflates row count

Question

You join a positions table onto a reference table with pd.merge(positions, ref, on="cusip", how="left") expecting one reference row per position. After a vendor update, the reference table picks up a duplicate cusip (two rows, same identifier, different stale load dates). Your merged DataFrame now has more rows than positions did, and downstream P&L is double-counted. How do you catch this class of bug before it reaches production, rather than after?

Think first, then tap
warmupData Assembly

concat vs merge

Question

You have 2023 prices in one DataFrame and 2024 prices in another, same columns. Separately, you have a table mapping ticker to sector. Which operation combines each pair, and how do you decide between concat and merge in general?

Think first, then tap
warmupPortfolio Construction

Computing covariance pairwise over each pair's own overlapping dates can produce a matrix that isn't positive semi-definite

Question

You build a covariance matrix for 50 names by computing each pairwise covariance using only the dates where BOTH of those two names have a return (some names have gaps from different listing dates and halts). Your optimizer then throws an error about a non-positive-semi-definite matrix. Why does computing it this way break that property?

Think first, then tap
warmupPerformance Analytics

Which risk-free rate, and why it matters more since rates rose

Question

For years your desk computed Sharpe ratios using raw returns with no risk-free subtraction, since short rates were near zero it barely mattered. Rates are now well above 4%. A colleague says just keep doing it the old way "for consistency." What's the actual mistake, and why does it matter more now than it did a decade ago?

Think first, then tap
coreFeature Construction

Momentum 12-1 and short-term reversal

Question

The classic momentum factor is the 12-month return EXCLUDING the most recent month. Why skip the last month, and how do you build both momentum and short-term reversal features?

Think first, then tap
coreCalendars & Alignment

Computing the third Friday of the month for options expiration

Question

You need a rebalance schedule that fires on monthly equity options expiration -- the third Friday of each month -- across several years, adjusted for the rare case that Friday is a holiday. How do you compute that date reliably with pandas, and what is the one thing you must not hardcode?

Think first, then tap
warmupCalendars & Alignment

pd.offsets.BDay() vs Timedelta(days=1): two different things both called 'add one day'

Question

You write ts + pd.Timedelta(days=1) to get "tomorrow", and elsewhere in the same codebase someone writes ts + pd.offsets.BDay(1). On a Friday timestamp, these give different answers. Why, and which one do you actually want for "the next trading day"?

Think first, then tap
warmupPerformance Analytics

Deflated Sharpe Ratio: discounting a backtested Sharpe for the number of trials and non-normal return moments

Question

A researcher reports a backtested Sharpe ratio of 2.1 for their best strategy. You find out they actually tried 80 different signal variations before landing on this one, and the strategy's returns are notably skewed and fat-tailed, not close to normal. Should you trust the 2.1 Sharpe at face value, and if not, what adjustment accounts for both problems at once?

Think first, then tap
warmupData Assembly

Long vs wide format

Question

You load daily closing prices as a table with three columns: date, ticker, close -- one row per ticker per day. Your teammate says "make it wide before you compute returns." What does wide format mean here, and why does each shape exist?

Think first, then tap
warmupFeature Construction

Decile buckets built before your universe reaches full size

Question

You bucket a signal into deciles (10 equal-population groups) with pd.qcut every day back to 2010, but your universe only had 40 names until 2014 and grew to 2000 by 2020. What goes wrong with the early-history decile buckets, and how does it bias a long-run backtest?

Think first, then tap
warmupStatistics

The runs test: detecting non-random streakiness in trade outcomes

Question

A strategy has a 55% win rate over 200 trades, which looks solid on its own. But a teammate points out the wins and losses come in long unbroken streaks -- 15 wins in a row, then 12 losses in a row, and so on -- rather than being scattered through the sequence. Why does that pattern matter, and how would you test for it formally?

Think first, then tap
hardCleaning & Corp Actions

Outlier or real event?

Question

Your robust filter flags a -40% daily return in a mid-cap. It might be a data error; it might be a real collapse -- a fraud revelation, a failed drug trial. You cannot eyeball 3,000 stocks. Design the decision process.

Think first, then tap
warmupBacktest Mechanics

The shift(1) discipline

Question

Your signal is computed from day t closing prices. Show me the exact pandas line that turns weights into P&L without lookahead, and tell me what goes wrong if you skip the shift.

Think first, then tap
corePoint-in-Time

Options open interest is reported end-of-day T but not available until T+1 morning

Question

You're adding an options open-interest feature (total outstanding contracts per strike) to a signal, joining it onto the underlying's daily bar using the same calendar date. The open-interest number for date T reflects contracts outstanding at the close of day T. Why is a same-date join still a lookahead, and when does that number actually become available to you?

Think first, then tap
coreCleaning & Corp Actions

FX mismatches for cross-listed shares

Question

You're comparing a stock's ADR (American Depositary Receipt, trades in USD on a US exchange) to its home-market listing (trades in EUR on the Frankfurt exchange), expecting the two to move together after adjusting for the ADR ratio. Some days show a large, unexplained gap. What's the likely cause, and how do you fix the comparison?

Think first, then tap
coreBacktest Mechanics

Reshuffling trade SEQUENCE (not returns) to test for lucky-early-compounding fragility

Question

Your backtest's annualized return looks great, but you suspect the result is driven by a lucky handful of early trades compounding into a big base rather than genuine, repeatable skill. A permutation test on shuffled RETURNS already confirmed the strategy beats random chance. What's a DIFFERENT robustness check that specifically targets your "lucky early compounding" worry, and why doesn't the returns-shuffle already cover it?

Think first, then tap
warmupPortfolio Construction

Measuring portfolio concentration with the Herfindahl-Hirschman Index and effective number of names, not just a position count

Question

Two long-only portfolios both hold exactly 50 names. Is "number of positions" actually telling you how concentrated they are? What's a better single number, and how do you compute it?

Think first, then tap
warmupPortfolio Construction

An unconstrained minimum-variance optimizer piles into one low-vol name

Question

You run a basic minimum-variance optimization (minimize w'Sigma w subject only to sum(w)=1) on 50 stocks, and the output puts 80% of the portfolio in one utility stock with unusually low historical volatility. Is the optimizer malfunctioning?

Think first, then tap
warmupPerformance Analytics

A tearsheet says 'annualized turnover: 18x' -- what that number means and why it can't be judged as high or low on its own

Question

A tearsheet reports "annualized turnover: 18x" for an equity long-short strategy. A PM who isn't a quant asks you: is that a lot? What do you tell them?

Think first, then tap
coreData Assembly

MultiIndex.from_product to build a complete date x ticker panel skeleton

Question

You have a raw trades table that's sparse -- not every ticker has a row on every date, since some names didn't trade or weren't listed yet. Before you can compute rolling features you need a fully-populated (date, ticker) panel where every combination exists, with NaN standing in for genuinely missing data. How do you build that skeleton and merge the raw data onto it?

Think first, then tap
warmupPortfolio Construction

Portfolio variance as a quadratic form: why you can't just average individual variances

Question

A new analyst computes portfolio volatility by taking a weighted average of each holding's individual standard deviation. Why is that wrong, and what's the correct formula?

Think first, then tap
warmupPoint-in-Time

M&A deal completion date vs when the target's fundamentals actually update in your data

Question

Company X announces it's acquiring Company Y, and the deal officially closes (completion date) three months later. Your fundamentals table switches Y's parent/ownership flag to X on the completion date, but Y's own standalone revenue and earnings rows keep appearing in your data, unchanged, for two more quarters after that, because the combined entity's first consolidated filing hasn't happened yet. If a feature depends on "is this a standalone reporting company," what's the PIT risk here, and what should the feature actually check?

Think first, then tap
warmupData Assembly

pd.concat(keys=...) to tag multiple vendor sources without a manual column

Question

You're combining daily closes from three vendors (A, B, C) into one DataFrame for a reconciliation study, and you want every row traceable to its source vendor without manually adding a "vendor" column to each frame first. A teammate suggests pd.concat([a, b, c], keys=["A","B","C"]). What does keys= actually do, and what should you check before using it downstream?

Think first, then tap
warmupPortfolio Construction

Minimum variance vs maximum diversification

Question

Two "risk-based" portfolio construction methods that don't need expected returns are minimum-variance and maximum-diversification. Both sound like "spread the risk around" - what is actually different about what each one optimizes?

Think first, then tap
hardPortfolio Construction

Robust optimization: hedging the optimizer against its own return-forecast error

Question

Your mean-variance optimizer takes point estimates of expected returns and the covariance matrix as if they were known exactly, then produces weights that can swing wildly if you perturb the return forecast by a tiny, statistically insignificant amount. A colleague proposes robust optimization: instead of optimizing against one point estimate, optimize against the WORST CASE return vector within some uncertainty set around your estimate. What problem does this actually fix, and what's the tradeoff?

Think first, then tap
hardStatistics

Two-way clustered standard errors for panel regressions

Question

You regress daily stock returns on a signal in a pooled panel -- every stock, every date, stacked into one big regression -- and get a t-stat of 8 using ordinary OLS standard errors. A colleague says you need to cluster by BOTH date and firm, not just one or the other. Why would clustering on only one dimension still leave the t-stat inflated, and what does two-way clustering actually do differently?

Think first, then tap
coreFeature Construction

A rolling skewness feature for crash risk needs a much longer window than a rolling mean or vol before it stops being pure noise

Question

You want a feature flagging stocks with negatively-skewed recent returns, as a proxy for crash risk. You compute it as df.groupby("ticker")["ret"].rolling(20).skew(). Is a 20-day window reasonable here, the same way it might be for a 20-day rolling volatility?

Think first, then tap
hardCleaning & Corp Actions

A stuck price feed repeating its last tick looks identical to a genuinely illiquid name that just didn't trade

Question

A thinly-traded small-cap's daily close shows the exact same print for 11 consecutive trading days. It could be a feed bug repeating its last tick, or it could be a genuinely illiquid name that simply had no trades. Both produce an identical flat line in the raw price series. How do you tell them apart programmatically, without a human eyeballing every flagged name?

Think first, then tap
warmupPoint-in-Time

Matching your backtest's data latency to production

Question

Your backtest uses end-of-day vendor files that land in your S3 bucket at 6pm ET, fully adjusted and cleaned, and assumes you can trade at that day's close. In production the same vendor's live feed for that day's close isn't available until 7:30pm, after most crossing networks have shut for the day. Is this a point-in-time bug, and how do you fix the backtest?

Think first, then tap
hardStatistics

Autocorrelated returns inflate a naive Sharpe-ratio t-stat; Newey-West standard errors correct it

Question

A strategy's daily returns have a Sharpe ratio of 1.8 computed the usual way, and you compute a t-stat for "is the mean return significantly different from zero" using the standard formula mean / (std / sqrt(n)), assuming independent daily returns. A colleague points out the strategy's returns have positive day-to-day autocorrelation (around 0.15) because of how slowly it trades into positions. Why does that autocorrelation make your t-stat too optimistic, and how do you fix it?

Think first, then tap
coreCalendars & Alignment

FX spot settlement date: T+2 that's a good business day in BOTH currencies

Question

You're computing the settlement (value) date for a EUR/USD spot trade executed on a Thursday, using a naive T+2 = trade_date + 2 business days rule off a single calendar. The following Monday is a US holiday but not a Eurozone holiday. What's wrong with settling off one calendar, and how should the spot date actually be computed?

Think first, then tap
hardPortfolio Construction

Ledoit-Wolf covariance shrinkage vs the raw sample covariance when the number of names approaches the number of observations

Question

You're building a minimum-variance portfolio over 400 names using 500 days of returns. The sample covariance matrix inverts without error, but the optimizer's weights look extreme and swing wildly if you add just one more day of data. What's actually going on, and how does shrinkage fix it?

Think first, then tap
warmupFeature Construction

pd.cut vs pd.qcut: equal-width bins vs equal-population bins

Question

You want to bucket a cross-sectional signal into 5 groups for a simple decile-style long-short test. A teammate uses pd.cut(signal, 5) and gets wildly uneven group sizes -- one bucket with 400 names, another with 12. What's the mismatch, and which function should they have used?

Think first, then tap
warmupData Assembly

factorize() vs Categorical dtype for encoding a high-cardinality ID column

Question

You have a trades DataFrame with millions of rows and a cusip column with about 8,000 distinct values. You want a compact integer encoding for a model input, and you're deciding between pd.factorize(df["cusip"]) and just casting the column to a pandas Categorical dtype. What's actually different between them, and which do you reach for?

Think first, then tap
warmupData Assembly

Constructing a DataFrame from a dict of Series with mismatched indexes silently aligns instead of raising

Question

You build a DataFrame like pd.DataFrame({"price": price_series, "volume": volume_series}) where price_series and volume_series come from two different upstream steps. The call succeeds with no error or warning. What exactly did pandas do with the two indexes, and how do you check the result is actually what you wanted?

Think first, then tap
coreData Assembly

Interleaving trades and quotes into one ordered event stream

Question

Your trades feed and your quotes feed each arrive as separate DataFrames with millisecond timestamps -- trades has (ts, symbol, price, size), quotes has (ts, symbol, bid, ask). To compute quote-based metrics like effective spread at the moment of each trade, you first need a single, correctly time-ordered event stream across both feeds. How do you build it, and what breaks if two events share the exact same timestamp?

Think first, then tap
warmupData Assembly

Downcasting dtypes to shrink a large panel's memory footprint

Question

You load a panel of 10 years of daily data for 3,000 tickers -- about 7.5 million rows -- and pandas reports it's using 2.3 GB of RAM, mostly float64 and object columns. Your laptop starts swapping. How do you cut memory usage without changing the values?

Think first, then tap
warmupData Assembly

value_counts(normalize=True) as a five-second sanity check before trusting a categorical column

Question

You're handed a new vendor's equity panel with a "listing_status" column you plan to filter on before building your universe. Before you write a single line of feature code, what's the first thing you check about that column, and how?

Think first, then tap
hardCleaning & Corp Actions

Ticker symbol reuse: a delisted company's symbol reassigned to a new, unrelated company

Question

You're building a 10-year history keyed by ticker symbol. You notice ticker "XYZ" has a return of +400% in one month in 2019, then a gap, then resumes trading with completely different fundamentals (market cap 50x smaller) in 2021. What's the likely explanation, and why is ticker the wrong join key for this?

Think first, then tap
coreBacktest Mechanics

Mixing adjusted and raw close across a split creates a sizing discontinuity

Question

A teammate's vectorized backtest computes entry/exit signals off the split-and-dividend-ADJUSTED close series (so returns and momentum features stay clean across corporate actions), but sizes each day's position using shares = target_dollar_exposure / raw_close, pulled from a separate unadjusted price table. The backtest looks fine until a 2-for-1 split day, where position sizing and recorded cash P&L both go haywire for that name. What's wrong, and what's the fix?

Think first, then tap
corePortfolio Construction

Aggregating position-level betas estimated from DIFFERENT regression windows into one portfolio beta silently breaks the additivity that makes the aggregation valid in the first place

Question

You compute portfolio beta as the weighted sum of each position's own beta, sum(w_i * beta_i). One analyst's names were all estimated with 1-year daily regressions, but a recently-added sleeve's betas came from a vendor using 5-year monthly regressions. Is the combined weighted-average beta still meaningful?

Think first, then tap
warmupPerformance Analytics

Realized-to-forecast volatility ratio: is your risk model actually calibrated?

Question

Your risk model forecasts a portfolio's volatility each day before it's realized. Six months in, a risk manager asks: how do you actually check whether this forecast is any good, rather than just trusting that the model "looks reasonable"? What's the simple diagnostic, and what does it look like when the model is miscalibrated?

Think first, then tap
warmupCalendars & Alignment

tz_localize on a DST fall-back day: the ambiguous hour that exists twice

Question

You're localizing a column of naive timestamps (no timezone attached) to America/New_York so you can align intraday fills with an exchange calendar. One night a year, clocks fall back an hour and the local time between 1:00 and 2:00 AM happens twice. What does tz_localize do by default when it hits one of those naive timestamps, and why does it matter even for a desk that only trades during the regular 9:30-4:00 session?

Think first, then tap
coreStatistics

Hurst exponent: testing whether a return series is trending, mean-reverting, or a random walk

Question

A colleague claims a price series "clearly mean-reverts" just from eyeballing a chart. How would you test that quantitatively, and what does the Hurst exponent actually measure?

Think first, then tap
coreFeature Construction

Cap-weighted vs equal-weighted cross-sectional demeaning

Question

You sector-neutralize your value signal by subtracting the equal-weighted mean of the signal within each (date, sector) group, same as the standard sector-demeaning recipe. Your PM points out that within the tech sector, a handful of mega-caps dominate the sector's actual risk and market exposure, but they count exactly the same as a micro-cap in your demeaning average. Does that matter, and what's the fix?

Think first, then tap
coreBacktest Mechanics

Futures overnight electronic session boundaries mismatching a signal computed on calendar-day bars

Question

Your equities backtest signal fires at midnight UTC, calendar-day aligned, and it works fine. You add a futures overlay (say, E-mini S&P) to the same backtest using the same midnight-aligned daily bars, and the futures leg's P&L looks subtly wrong around overnight moves. What's different about how a futures "trading day" is defined, and what breaks?

Think first, then tap
coreStatistics

Fisher's method: combining p-values from a signal's related sub-tests

Question

Your value signal has three components -- earnings yield, book-to-price, and sales-to-price -- and you've tested each one's IC for significance separately, getting p-values of 0.08, 0.12, and 0.09. None clears the conventional 0.05 bar alone. A colleague says "combine them with Fisher's method to get one significant p-value for the whole value family." What does Fisher's method actually compute, and why is applying it here dangerous?

Think first, then tap
coreCalendars & Alignment

Non-nanosecond datetime resolution and the 1677-2262 overflow

Question

You try to load a table of century-old delisted-company incorporation dates, and one row for a company founded in 1500 raises OutOfBoundsDatetime when pandas parses it. A teammate says "pandas dates just can't go that far back." What's actually going on, and how do you handle it?

Think first, then tap
hardBacktest Mechanics

Almgren-Chriss: scheduling a large order against impact vs timing risk

Question

You need to unwind a large position over the course of one trading day. Dumping it all at the open crushes the price -- market impact. Spreading it perfectly evenly across the day (a TWAP-style schedule) avoids that, but leaves you exposed to the price drifting against you for hours before you finish -- timing risk. How do you think about that tradeoff, and what shape does the resulting optimal trade schedule actually take?

Think first, then tap
hardCalendars & Alignment

Aligning a 24/7 crypto asset against a 6.5-hour equity session calendar before computing a daily cross-asset correlation

Question

You want the daily correlation between BTC and SPX. BTC trades continuously, so its "close" is whatever price happens to exist at midnight UTC. SPX only trades 9:30am-4pm Eastern. If you naively take each series' midnight-UTC snapshot and SPX's own 4pm close and line them up by calendar date, what's wrong with the resulting correlation, and how do you fix the alignment?

Think first, then tap
corePortfolio Construction

Why a covariance matrix for an optimizer is built from returns, not price levels -- price series share trend, not risk

Question

You're about to build the covariance matrix Sigma that feeds your mean-variance optimizer. A friend suggests skipping the return calculation and just using the cached daily price levels directly -- same data, one less step. What breaks if you build Sigma from prices instead of returns?

Think first, then tap
corePerformance Analytics

Splitting a tearsheet by volatility regime: why a good blended Sharpe can hide a bad story

Question

Your strategy's full-sample Sharpe is 1.4, which looks solid, but a colleague asks you to split the tearsheet by realized-volatility regime -- say, terciles of trailing 20-day market vol -- before presenting it to allocators. Why would they ask for that, and what's a scenario where it changes the story?

Think first, then tap
warmupCalendars & Alignment

pd.Timestamp.now() returns naive local machine time, silently breaking a UTC-based pipeline

Question

Your feature pipeline runs on a cloud server and stamps each batch with pd.Timestamp.now() to record "as of when this feature was computed," which later gets compared against UTC-timestamped market data for a staleness check. The staleness check sometimes fires incorrectly even right after a fresh run. What's wrong?

Think first, then tap
hardPoint-in-Time

What does the date on a row mean?

Question

You are handed a new vendor dataset with a single date column and asked to add it to the research database. What questions do you ask before a single join is written, and how should the table be stored?

Think first, then tap
corePortfolio Construction

Ledoit-Wolf shrinkage vs the sample covariance matrix

Question

You estimate a 500-stock covariance matrix from 3 years of daily returns, about 750 observations, and feed it straight into a mean-variance optimizer. The resulting weights are wild and concentrated in a handful of names with suspiciously tiny estimated variance. What is going wrong, and how does shrinkage estimation like Ledoit-Wolf fix it?

Think first, then tap
coreData Assembly

merge()'s default suffixes silently rename a non-key column you never meant to collide

Question

You merge a prices table and a fundamentals table on ["ticker", "date"]. Both tables happen to also have a column called "sector" (one from a pricing vendor's static reference data, one from the fundamentals vendor's own classification). After the merge, your code that reads df["sector"] throws a KeyError. What actually happened, and how do you decide which "sector" column should win?

Think first, then tap
warmupBacktest Mechanics

A backtest that includes a stock's IPO day using the full day's close-to-close return overstates what you could have captured, because the stock didn't open until a delayed opening auction mid-morning

Question

Your universe construction adds a stock to the backtest on its first day of trading and computes that day's return the same way as any other day: today's close divided by yesterday's close, minus one. For an IPO, "yesterday's close" is the offering price set the night before. What's unrealistic about including that full first-day return in a strategy that trades on signals computed from intraday data, and how would you handle it instead?

Think first, then tap
coreCleaning & Corp Actions

A thinly-traded corporate bond's daily 'price' is a matrix-priced estimate, not a traded print -- treating it like an equity close inflates apparent liquidity and understates risk

Question

You're building a cross-asset factor panel that includes corporate bonds alongside equities, using each instrument's vendor-supplied daily close. The bond closes look smooth and well-behaved day to day -- smoother, in fact, than the equities. Should that smoothness reassure you, and what do you check before trusting a bond's daily return the way you'd trust a stock's?

Think first, then tap
warmupCalendars & Alignment

Timestamp.is_quarter_end and is_month_end flag calendar boundaries only -- useless for a company whose fiscal year doesn't start in January

Question

You want to flag each date in a price panel that lines up with a retailer's fiscal quarter-end. The retailer's fiscal year ends January 31, not December 31. You write mask = df.index.is_quarter_end. Does this give you what you want?

Think first, then tap
coreData Assembly

Deduplication policy

Question

Your daily loader appends vendor files into one price table. Today you discover about 2% of (date, ticker) pairs appear twice, sometimes with different closes. Walk me through how you deduplicate.

Think first, then tap
coreFeature Construction

A cross-sectional percentile rank can move for a stock whose own signal value didn't change at all

Question

You compute a daily cross-sectional percentile rank of a value signal with df.groupby("date")["value_score"].rank(pct=True). A teammate flags that AAPL's rank jumped from the 40th to the 55th percentile between Monday and Tuesday even though AAPL's own value_score is identical on both days, to several decimal places. Is this a bug?

Think first, then tap
corePortfolio Construction

Risk parity applied independently to each sleeve, then combined, double-counts risk the sleeves share -- equal risk contribution per sleeve isn't equal risk contribution in the combined book

Question

You run three strategy sleeves and want each to contribute equal risk to the overall book. Your approach: size each sleeve so its own STANDALONE volatility is equal to the others', then run them together. Does that actually give you equal risk CONTRIBUTION once the three sleeves are combined into one portfolio?

Think first, then tap
corePoint-in-Time

Form 4 insider filings: transaction date vs SEC filing date, and the disclosure lag between them

Question

You build a signal off insider buying: an executive purchasing shares of their own company. Your data has both a "transaction_date" (when the exec actually bought) and a "filing_date" (when the SEC received the Form 4). Which one do you join your backtest on, and why would using the wrong one overstate the signal's live performance?

Think first, then tap
warmupBacktest Mechanics

Sizing a fill against today's FULL daily volume as a participation cap is a point-in-time violation, not just an approximation

Question

Your backtest caps each day's simulated fill at 10% of that day's total volume, a standard participation-rate constraint meant to keep fills realistic. The volume number you use is the day's final, full-session volume. What's wrong with using that number to decide how much of an order could have filled starting at, say, 10am that same day?

Think first, then tap
coreCalendars & Alignment

A fixed 6.5-hour session assumption for intraday VWAP silently breaks on early-close half days

Question

You compute each day's volume-weighted average price (VWAP, a benchmark price weighted by how much traded at each level, not a simple average) by resampling intraday bars from 9:30am to a fixed 4:00pm close. On the day before Thanksgiving and on Christmas Eve, the NYSE closes early at 1:00pm. What goes wrong if your resample window doesn't know that, and does it silently produce a wrong number or an obviously broken one?

Think first, then tap
hardCleaning & Corp Actions

Ticker recycling: when a symbol changes companies

Question

Ticker "XYZ" belonged to a company that went bankrupt and delisted in 2011. In 2019, an unrelated company IPO'd and was assigned the same now-available ticker "XYZ". Your price database is keyed by ticker alone, sorted by date. What breaks, and how should the data actually be keyed?

Think first, then tap
coreStatistics

An IID bootstrap of autocorrelated daily returns understates uncertainty in a Sharpe ratio confidence interval; a block bootstrap fixes it

Question

You want a confidence interval on a strategy's Sharpe ratio, so you bootstrap it: resample daily returns with replacement 10,000 times, recompute Sharpe each time, and take the 2.5th/97.5th percentiles. Your strategy's returns have meaningful day-to-day autocorrelation (a mean-reverting book, slow fills, or overlapping signals). Why does the standard IID bootstrap give you a confidence interval that's too narrow, and what should you do instead?

Think first, then tap
warmupData Assembly

pd.qcut raises on duplicate bin edges when a factor has many tied values

Question

You're bucketing a liquidity factor (average daily dollar volume) into deciles with pd.qcut(adv, 10, labels=False) across 3,000 stocks. On most days it works fine, but on days right after a market-wide trading halt, it raises ValueError: Bin edges must be unique. Why does a column of perfectly legitimate values suddenly break qcut, and what's the fix?

Think first, then tap
hardStatistics

A factor's pooled IC looks solid, but splitting the test by market-cap decile shows it only works in micro-caps

Question

A value factor shows a pooled rank-IC of 0.04 across your full universe, comfortably significant. When you split the cross-section into market-cap deciles and compute IC within each decile separately, the signal is 0.09 in the smallest decile and statistically indistinguishable from zero in the top five deciles. How do you interpret this, and does it change how you'd size or deploy the factor?

Think first, then tap
hardPortfolio Construction

Cardinality constraints: capping the number of names

Question

Compliance or operational limits require your book to hold no more than 50 names at once, but your mean-variance optimizer naturally wants to spread risk across several hundred. Why does adding "hold at most K names" break the clean convex optimization you had, and what do practitioners actually do about it?

Think first, then tap
hardStatistics

Fama-MacBeth two-step regression for cross-sectional risk premia

Question

You want to estimate the average risk premium (expected return per unit of exposure) for a factor across your universe, using T months of cross-sectional data. Why not just pool all (ticker, month) observations into one big panel regression of return on factor exposure? What does the Fama-MacBeth procedure do instead, and why?

Think first, then tap
coreFeature Construction

Computing a cross-sectional rank before vs after dropping names with insufficient history changes every other name's rank value

Question

You compute rank(pct=True) across the day's full universe, then separately drop newly-listed names that don't have enough history for a 252-day lookback feature. A teammate instead drops those names first, then ranks. Both seem reasonable -- do they give the same feature?

Think first, then tap
corePerformance Analytics

Volatility drag: why doubling leverage doesn't double CAGR

Question

A strategy has an arithmetic mean daily return of 10bp and daily volatility of 150bp, for a healthy unlevered Sharpe. A PM asks: "if we lever this 2x, does the Sharpe stay about the same and CAGR just double?" What's your answer?

Think first, then tap
hardData Assembly

Choosing a panel shape strategy

Question

You are designing the data layer for a small research stack: 5,000 stocks, daily data, prices plus 40 signal columns. Long format, wide format, or one wide matrix per field? Argue for a layout and tell me where it hurts.

Think first, then tap
coreFeature Construction

Moving-average crossover as a cross-sectional feature

Question

You want to turn the classic fast-vs-slow moving-average crossover (fast MA above slow MA means uptrend) into a cross-sectional ranking feature across 1,000 stocks. Why can't you just rank the raw difference fast_ma minus slow_ma, and what should you rank instead?

Think first, then tap
hardStatistics

The probabilistic Sharpe ratio

Question

A colleague reports an observed Sharpe of 1.4 over three years, and in the same breath a Probabilistic Sharpe Ratio (PSR) of 0.55 against a benchmark Sharpe of 1.0. Explain what PSR is doing that a plain t-test on the Sharpe does not, and why the 0.55 should worry you more than the headline 1.4 reassures you.

Think first, then tap
warmupPerformance Analytics

Attributing P&L between the long and short book

Question

Your market-neutral book returned 1.8% last month. The PM wants to know: did the longs make money, did the shorts make money, or both -- and is that split by itself enough to tell you whether the strategy is working as designed?

Think first, then tap
hardCalendars & Alignment

The stale-alignment leak

Question

A researcher reindexes 40 global assets to the union of all their calendars, forward-fills everything, and reports a beautiful risk model: low volatilities, smooth correlations, great diversification. Why should you distrust every one of those numbers?

Think first, then tap
coreData Assembly

Sparse dtypes for mostly-zero factor exposure matrices

Question

You've built a factor-exposure matrix for 3000 stocks against 200 industry/country dummy factors -- each stock loads on exactly one industry and one country, so the matrix is more than 99% zeros. Loading it as a normal float64 DataFrame eats tens of gigabytes and makes every downstream regression slow. What do you do differently, and what's the catch?

Think first, then tap
hardStatistics

Re-running the same single signal's IC test every month as new data arrives inflates the false-positive rate just like testing many different signals does

Question

You have one candidate signal. Instead of testing its IC once on a fixed historical sample, you re-run the significance test every month as new data rolls in, and you plan to greenlight the signal the first month its p-value crosses 0.05. Six months in, it crosses. Is that a valid discovery? Why does testing the SAME signal repeatedly over time create the same statistical problem as testing many DIFFERENT signals once?

Think first, then tap
hardBacktest Mechanics

Look-ahead from checking a stop against the same bar's own high or low

Question

Your vectorized daily backtest checks whether a stop-loss was hit by comparing the stop level to that same day's low: if low <= stop_price, you book an exit fill at the stop price on that day. What's the lookahead here, and why does it inflate the backtest's apparent performance?

Think first, then tap
hardBacktest Mechanics

Backtest says Sharpe 3

Question

A fresh backtest of your new idea prints Sharpe 3. Before showing anyone, what is your ordered checklist - and in your experience of these bugs, what is the base rate that the 3 is real?

Think first, then tap
coreStatistics

Spurious regression: two trending price series fitting an implausibly good R-squared

Question

You regress one stock's raw price level on another's raw price level over five years and get an R-squared of 0.93 with a wildly significant t-stat. A teammate is excited about the "relationship." What's actually going on, and what should you have regressed instead?

Think first, then tap
coreCalendars & Alignment

A weekly Friday rebalance signal lands on an exchange holiday

Question

Research computes a signal every Friday close; the desk rebalances at Monday's open. Your pipeline picks signal dates with df[df.index.dayofweek == 4]. One Friday is a market holiday (Good Friday). What happens to that week's rebalance, and what's the right fix?

Think first, then tap
corePerformance Analytics

Splitting a daily strategy's total return into its overnight (close-to-open) and intraday (open-to-close) components can reveal that the real edge lives somewhere you didn't expect

Question

A daily-rebalanced equity strategy shows a healthy total Sharpe. Before presenting it, your PM asks you to split the return into the part earned overnight (yesterday's close to today's open) versus intraday (today's open to today's close). Why would a PM ask for that specific split, and what would a result like "all the Sharpe is overnight, intraday is flat-to-negative" imply?

Think first, then tap
warmupData Assembly

Series.map() with a dict turns any key missing from the mapping into NaN; Series.replace() leaves it untouched

Question

You're mapping a column of raw exchange codes ("XNYS", "XNAS", "XLON") to human-readable names using a dict and .map(). A new exchange code shows up in a later data pull that isn't in your dict yet. What happens to those rows, and why would .replace() with the same dict have behaved differently?

Think first, then tap
coreCleaning & Corp Actions

Share-count adjustments: buybacks and secondary offerings distorting market-cap history

Question

You're building a historical market-cap panel (price times shares outstanding) to use as a size factor. A company you're tracking bought back 15% of its shares over the past two years through steady open-market repurchases. What breaks if you just multiply today's price by today's shares-outstanding and apply it across the whole history, and how do you fix it?

Think first, then tap
warmupPoint-in-Time

merge_asof with no tolerance will happily match today's price to a filing that's years stale once a company stops reporting

Question

You merge_asof a daily price panel against a quarterly fundamentals table (most recent filing as of each date) to build a value signal. The company goes dark -- stops filing, maybe pre-bankruptcy -- but you keep merging forward anyway. What happens to the fundamentals your signal sees on day 500 after the last real filing, and how do you stop it?

Think first, then tap
hardCleaning & Corp Actions

A stock split correctly adjusts your price and volume history, but the separately-sourced shares-outstanding field doesn't -- silently corrupting historical market cap

Question

A ticker did a 4-for-1 split last month. Your price vendor retroactively adjusted the entire price history (divided by 4) and volume history (multiplied by 4), as expected. But market_cap = price * shares_outstanding, and shares_outstanding comes from a separate fundamentals feed that still reports the PRE-split share count for every date before the split. What does this do to market-cap-weighted features computed over history that straddles the split date, and how do you catch it?

Think first, then tap
warmupFeature Construction

Thresholding a signal with np.sign(): a value hovering near zero flips the discrete feature between -1 and +1 run to run on pure noise

Question

You build a discrete directional feature as np.sign(momentum_score), where momentum_score is a continuous, z-scored value. For names whose momentum_score sits very close to zero, you notice the sign feature flips between -1 and +1 day to day even when the underlying z-score barely moved -- say from 0.01 to -0.01. Why does this happen, and what's a simple fix?

Think first, then tap
warmupPoint-in-Time

What lookahead bias does

Question

What is lookahead bias, and why does it INFLATE backtest performance rather than just adding noise?

Think first, then tap
warmupPerformance Analytics

Annualizing with the wrong sqrt(N): mismatched observation frequency

Question

Your strategy trades a weekly-rebalanced signal, so you have weekly returns, but the number of weekly observations per calendar year varies and occasionally you're missing a week due to a data gap. A teammate annualizes Sharpe with a hardcoded multiply by the square root of 52. When is that wrong, and what should you use instead?

Think first, then tap
coreCalendars & Alignment

Forward-fill limits

Question

After reindexing single stocks to your master calendar you forward-fill gaps with ffill(). A colleague says always pass a limit. What is the argument, and how do you choose the number?

Think first, then tap
corePortfolio Construction

Correlation breakdown in crises: why a calm-period covariance matrix underestimates crash risk

Question

Your risk model estimates the covariance matrix from the trailing 2 years of daily returns, which happen to have been unusually calm. A colleague argues the portfolio is well-diversified because average pairwise correlation in that window is only 0.15. Why might that number be dangerously misleading for tail risk specifically?

Think first, then tap
corePortfolio Construction

Naive inverse-vol weighting hides concentration within a correlated cluster

Question

You build a "risk parity" portfolio across 10 individual tech stocks by weighting each one inversely to its own volatility, so every name contributes roughly equal risk on a standalone basis. Your PM looks at it and says it isn't actually risk parity at all. What did the naive approach miss?

Think first, then tap
warmupData Assembly

GroupBy transform vs apply: the silent shape trap

Question

You need to demean a return column within each sector and keep every row aligned to its original position for a later merge. A teammate writes df.groupby(sector)[ret].apply(lambda g: g - g.mean()) and it runs fine today. Why do you ask them to use transform instead, and what could go wrong later if they do not?

Think first, then tap
warmupStatistics

The information coefficient

Question

What is the information coefficient (IC) of a signal, how do you compute it on a daily panel, and what is a realistic magnitude for a good equity signal?

Think first, then tap
hardStatistics

Dead signal or bad year?

Question

A production signal that earned a Sharpe of 1.0 for six years has now returned roughly zero for 18 months. The PM asks: is it dead or just unlucky? How do you reason about this, and what do you recommend?

Think first, then tap
hardPerformance Analytics

The marginal Sharpe contribution of adding a new strategy to an existing book

Question

A candidate strategy has a standalone Sharpe of 0.6 -- mediocre on its own. It has -0.3 correlation with your existing book, which runs at Sharpe 1.5. Is a standalone Sharpe of 0.6 a reason to reject it, and how would you actually evaluate whether it belongs in the book?

Think first, then tap
hardCleaning & Corp Actions

The IPO first-day pop: a return your model shouldn't see

Question

You compute a short-term reversal feature (bet against last month's return) across your whole universe, and it consistently loses money on names that IPO'd in the last few weeks -- while working fine everywhere else. What is happening, and how do you handle new listings in a return-based feature?

Think first, then tap
warmupData Assembly

explode() for a column holding multiple delimited values per row

Question

A vendor's reference table has one row per ticker with a "sectors" column like "Tech;Semiconductors" for dual-classified names, and you need one row per (ticker, sector) to join cleanly onto a sector-level exposure table. What's the idiomatic pandas way to do this, and what should you check afterward?

Think first, then tap
warmupPerformance Analytics

Treynor ratio: dividing by beta instead of total volatility

Question

Sharpe divides excess return by total volatility. The Treynor ratio instead divides excess return by beta. When would you reach for Treynor over Sharpe, and what is it assuming about the portfolio being evaluated?

Think first, then tap
corePortfolio Construction

Blending the mean-variance optimizer's weights with 1/N as an explicit combination estimator, instead of picking one or the other

Question

Your optimizer's output beats 1/N in-sample but has underperformed it for the last two quarters live, consistent with the well-known result that estimation error can make an optimizer's point-estimate weights worse out-of-sample than just splitting capital equally. Rather than abandoning the optimizer or ignoring the live underperformance, how would you combine the two into a single, more robust set of weights?

Think first, then tap
warmupPortfolio Construction

Portfolio volatility as w' Sigma w, and why you can't just weight-average the individual vols

Question

Given a vector of position weights and a covariance matrix of asset returns, how do you compute the portfolio's volatility? Why can't you just take a weighted average of each position's own volatility?

Think first, then tap
coreBacktest Mechanics

Rebalancing on stale signals

Question

Your earnings-based signal is forward-filled so every stock has a value every day. One stock stopped reporting eighteen months ago but stays listed. What is your backtest doing, and how do you cap staleness?

Think first, then tap
coreFeature Construction

Measuring a feature's own turnover before it goes in the book

Question

Two candidate features have identical IC (information coefficient) against forward returns. One is a value ratio that barely moves week to week; the other is a short-term flow signal that reshuffles the cross-sectional ranking almost daily. Same predictive power on paper -- why might you strongly prefer one over the other, and how do you quantify the difference before backtesting?

Think first, then tap
warmupCleaning & Corp Actions

Spotting a silent 100x scale error (cents vs dollars) in a vendor feed

Question

One ticker's close price column jumps from the 40-60 range to the 4000-6000 range on a single date, then stays there for the rest of history, with no split or corporate action on record. What's the most likely cause, and how do you check for it fast across an entire universe rather than by eyeballing one chart at a time?

Think first, then tap
warmupFeature Construction

EWM z-score vs rolling-window z-score

Question

You z-score a feature using a rolling 60-day mean and stdev, and it lags badly right after the feature's regime shifts abruptly, say after an earnings surprise. A teammate suggests an exponentially weighted (ewm) mean and stdev instead. What's the actual tradeoff, and does ewm fix the lag for free?

Think first, then tap
hardBacktest Mechanics

Computing daily returns straight across a naive stitched continuous futures series injects a fake one-day return on every roll date unless the series is back-adjusted for the roll gap

Question

You build a "continuous" futures price series by simply concatenating the front-month contract's prices up to its roll date, then switching to the next contract's prices from that date forward -- no adjustment, just a straight splice. On each roll date, pct_change() shows an anomalously large return that has nothing to do with the market actually moving. What's happening, and how do you fix the series?

Think first, then tap
warmupCleaning & Corp Actions

Berkshire Hathaway's B shares join fine against one vendor as 'BRK.B' and silently fail against another using 'BRK-B' or 'BRK/B'

Question

You're joining your signal frame (tickers from vendor A, which writes share classes as "BRK.B") against a prices frame (vendor B, which writes "BRK-B") on a plain ticker merge. What happens to multi-class tickers, and would you even notice?

Think first, then tap
warmupData Assembly

Method chaining with .pipe() for readable multi-step feature pipelines

Question

Your feature pipeline does five sequential steps: filter to a liquid universe, clean outliers, compute a rolling feature, cross-sectionally rank it, then merge in a sector tag. How would you structure that in pandas so a reviewer can read it top to bottom instead of hunting through six reassigned variable names?

Think first, then tap
warmupCleaning & Corp Actions

Winsorize, clip, or drop

Question

Your cross-sectional signal -- say earnings yield across 2,000 stocks -- has a handful of extreme values each day that dominate any regression you run. Compare winsorizing, clipping, and dropping. Which default do you pick and why?

Think first, then tap
hardPortfolio Construction

Sizing two correlated signals to the SAME standalone vol target and summing their positions overshoots the combined portfolio's actual risk

Question

You have two alpha signals, each independently scaled so its own book runs at 10% annualized vol. You combine them by simply adding the two position vectors together. The combined book's realized vol comes in well above 10%. Your PM expected roughly 10% still, or maybe a bit more from diversification. What went wrong in the sizing logic, and how would you fix it?

Think first, then tap
coreFeature Construction

Converting an irregular event into a smooth 'time since' decay feature

Question

You want a feature that captures how recently a stock had an earnings surprise, decaying in relevance as time passes, to feed into a daily cross-sectional model. Earnings happen roughly once a quarter and your panel is daily. How do you turn "days since the last earnings surprise" into something your model can actually use well, instead of a raw day-count?

Think first, then tap
hardPerformance Analytics

Expected drawdown grows with time

Question

A 12-year-old strategy shows a 28 percent max drawdown; a 2-year-old one shows 9 percent. The allocator prefers the second on risk grounds. Make the statistical case that this comparison is broken.

Think first, then tap
hardCalendars & Alignment

Resampling intraday timestamps across a DST fall-back transition: the hour that occurs twice, and why naive tz_localize throws

Question

You're resampling intraday tick data for a US-listed instrument into 1-minute bars across the daylight-saving fall-back transition in November, where the local clock goes from 2:00 AM back to 1:00 AM. What breaks, and how do you handle it?

Think first, then tap
corePortfolio Construction

Enforcing sector dollar-neutrality inside the optimizer, not after

Question

Your long-short portfolio is supposed to be sector neutral -- each sector's long dollar exposure roughly equal to its short dollar exposure. You currently run an unconstrained mean-variance optimization and then manually true up each sector's net exposure afterward by scaling that sector's positions. Why does that after-the-fact fix leave something on the table, or worse undo the optimizer's work, and how would you build the constraint into the optimization itself instead?

Think first, then tap
warmupCleaning & Corp Actions

Survivorship bias

Question

A backtest buys the cheapest decile of today's S&P 500 constituents, rebalanced monthly since 2005, and shows a spectacular Sharpe. Before reading a line of code, why are you skeptical?

Think first, then tap
hardBacktest Mechanics

A vectorized backtest crediting a stop-loss fill at its exact trigger price through an overnight gap

Question

Your backtest closes a position the instant its return since entry breaches a -5% stop-loss threshold, computed on daily closes, and books the exit fill at exactly that -5% price. A name gaps down 12% overnight on bad news between yesterday's close and today's open. What does your backtest quietly get wrong, and how should the fill be modeled instead?

Think first, then tap
hardStatistics

Overlapping confidence intervals don't mean two signals' ICs aren't significantly different

Question

Signal A has a mean daily IC of 0.030 with a 95% confidence interval of [0.010, 0.050]. Signal B has a mean daily IC of 0.045 with a 95% CI of [0.025, 0.065]. The intervals overlap. Can you conclude the two signals' true ICs are not significantly different?

Think first, then tap
hardPoint-in-Time

Differential reporting lag across market cap: one fixed lag is itself a look-ahead problem

Question

Your point-in-time pipeline applies a fixed 90-day lag to fundamentals before they enter the universe, a common conservative buffer for the SEC's 10-K filing deadline. A large-cap tech company actually reports 30 days after quarter-end; a small-cap reports 89 days after quarter-end, right at its deadline. What's wrong with using the fixed 90-day lag for both, and what does that do to a fundamentals-based strategy's backtest?

Think first, then tap
hardPoint-in-Time

Index reconstitution: announcement date vs effective date

Question

S&P Dow Jones announces on a Thursday after the close that a stock will be added to the S&P 500, effective the following Monday. Your backtest includes the stock in the S&P 500 universe starting Thursday's close instead of Monday's. What bias does this introduce, and why is it worse than it sounds?

Think first, then tap
hardCleaning & Corp Actions

Negative prices and the log-return computation that breaks

Question

In April 2020, WTI crude oil front-month futures traded at roughly minus 37 dollars a barrel for one day before recovering. Your cleaning pipeline computes daily log returns as log(price_t / price_t-1) for every instrument in the universe, uniformly. What happens on and around that day, and how do you handle instruments where price can genuinely go negative?

Think first, then tap
hardFeature Construction

Neutralizing a signal against latent PCA factors instead of named sector/beta factors

Question

You've been sector- and beta-neutralizing your signal by regressing out GICS sector dummies and market beta. A colleague suggests instead residualizing against the top few principal components of the return covariance matrix. What does that buy you, and what's the tradeoff?

Think first, then tap
hardCleaning & Corp Actions

A negative price breaks a log-return calculation (WTI, April 2020)

Question

On April 20, 2020, the front-month WTI crude futures contract settled at -$37.63 -- storage was full, and holders paid to avoid taking physical delivery. Your pipeline computes daily log returns as np.log(price / price.shift(1)) for every instrument uniformly. What happens to this contract's return that day and the day after, and how do you handle negative prices in a returns pipeline generally?

Think first, then tap
corePortfolio Construction

Mean-variance optimizers as 'error maximizers': tiny changes in expected-return estimates produce wildly different optimal weights

Question

You run a textbook mean-variance optimizer on 50 names using your best estimates of expected return and covariance. A colleague points out the resulting weights are wildly concentrated in just 3-4 names with the highest estimated expected returns, and warns this isn't really "optimal" in any sense you should trust. What's the actual mechanism behind that warning?

Think first, then tap
warmupPerformance Analytics

Mean vs median daily P&L: surfacing a tail-loss-driven skew that an identical average hides

Question

Two strategies both show the same average daily P&L on their tearsheet. Strategy A's daily P&L is tightly clustered around that average every day. Strategy B makes small steady gains most days and occasionally takes one huge loss on an earnings surprise, averaging out to the same number. Why does reporting only the MEAN daily P&L hide this difference, and what's a simple second number that surfaces it?

Think first, then tap
warmupStatistics

A signal with a highly significant t-stat but no economic significance

Question

You test a signal on 15 years of daily cross-sectional data and get an IC t-stat of 6.2 (very significant), but the raw IC itself is 0.008. Your PM is unimpressed and says it's not worth trading. Who's right, and what's the distinction being made?

Think first, then tap
hardPoint-in-Time

Macro data vintages: using the originally-published GDP print, not the revised one

Question

Your signal uses quarterly US GDP growth as a macro feature. The vendor feed you're pulling from gives you the LATEST revised GDP figure for every historical quarter. Why is that a lookahead problem even though GDP itself is dated correctly, and how do you fix it?

Think first, then tap
corePerformance Analytics

Sortino and asymmetric returns

Question

When does Sharpe actively mislead, what does Sortino change, and give me a strategy type where BOTH numbers look great right up until the blowup.

Think first, then tap
coreCleaning & Corp Actions

Detecting stale prices

Question

Some series in your vendor's small-cap file show the identical close for days or weeks. How do you detect staleness systematically, and why is it more dangerous than missing data?

Think first, then tap
hardFeature Construction

Mean target encoding leaks a row's own label into its encoded feature unless computed leave-one-out

Question

You're encoding a high-cardinality "originating desk" categorical feature by replacing each desk with the mean of your training label within that desk: df.groupby("desk")["label"].transform("mean"). A teammate flags that this feature is suspiciously predictive in training but far weaker out of sample. What's wrong with the encoding, and how do you fix it?

Think first, then tap
coreFeature Construction

EWMA vs SMA: halflife choice and warm-up bias

Question

You are building a volatility feature and deciding between a simple rolling window (equal weight over the last N days) and an exponentially weighted moving average with a halflife. Why would you pick one over the other, and what is the warm-up problem each has at the start of a series?

Think first, then tap
corePortfolio Construction

Factor-mimicking portfolios: isolating exposure to one factor

Question

You run a cross-sectional regression of stock returns on momentum, value, and size characteristics each month, and get back a monthly momentum coefficient -- "the momentum factor's return." Your PM wants an actual tradable portfolio whose realized returns track that factor cleanly, not just a number that falls out of a regression. How do you build it?

Think first, then tap
coreFeature Construction

pd.qcut and ties: when quantile buckets aren't equal size

Question

You bucket a cross-sectional signal into quintiles each day with pd.qcut(sig, 5), and on some days one bucket ends up with twice as many names as the others, or the call raises an error entirely. What is going on, and how do you handle it?

Think first, then tap
hardBacktest Mechanics

Modeling FX hedging carry cost in an international long-short backtest

Question

You're backtesting a long-short equity strategy that trades both US and Japanese names, hedging the JPY currency exposure back to USD on every position. Your backtest currently just uses USD-converted prices and ignores the hedge entirely. What's missing, and why can it change whether the strategy looks profitable?

Think first, then tap
corePortfolio Construction

Dollar-neutral vs beta-neutral

Question

Your long-short book has equal dollars long and short, yet it loses money almost every time the market sells off. What is going on, and how do you fix the weights?

Think first, then tap
hardPerformance Analytics

Brinson attribution: allocation effect vs selection effect

Question

Your long-only portfolio outperformed its benchmark by 150bps last quarter. The PM wants to know how much of that came from overweighting the right SECTORS versus picking the right STOCKS within sectors. Walk through the Brinson decomposition.

Think first, then tap
warmupCalendars & Alignment

Half-day and early-close sessions

Question

Your trading calendar marks every weekday as either "open" or "holiday". December 24th is neither -- it is a half-volume session that closes at 1pm instead of 4pm. An intraday feature that normalizes by "fraction of the session elapsed" looks broken only on this one day, every single year. What is wrong, and how do you fix the calendar?

Think first, then tap
corePoint-in-Time

Using a stock's current sector instead of its sector at the time, in a backtest

Question

Your feature engineering demeans each stock's factor score by its GICS sector average before ranking. You join sector from a static reference table keyed only by ticker -- today's sector, not the sector as of each historical date. A company reclassified from Industrials to Information Technology last year is now demeaned against Tech in 2019 too. Is this a lookahead bug, and does it matter?

Think first, then tap
coreCleaning & Corp Actions

Bid-ask bounce: last-trade price vs midpoint

Question

You're building a returns series from tick data and have both the last-trade price and the bid/ask quotes at each timestamp. Using last-trade price, your high-frequency return series looks noisier than the underlying quotes suggest it should be. What's going on, and what do you use instead?

Think first, then tap
coreData Assembly

concat(axis=1) aligns on the index, not row position

Question

You're combining two engineered signal matrices for the same universe -- a momentum score DataFrame and a value score DataFrame, each date-indexed -- into one wide feature table with pd.concat([momentum, value], axis=1). The value score lags one day because its vendor publishes after market close. What does concat do here, and what should you check before trusting the result?

Think first, then tap
hardPoint-in-Time

The knowledge-date vs ingestion-timestamp trap in vendor 'as of' fields

Question

A vendor's fundamentals feed has a column called as_of_date that you've been using as the point-in-time cutoff for merge_asof. During a data audit you discover that for about 15% of rows, as_of_date is actually the date the vendor's system loaded the record into their database -- sometimes days after the filing was genuinely public -- not the date the information became knowable to the market. What's the risk, and how do you investigate and fix it?

Think first, then tap
coreCalendars & Alignment

FX/crypto trading-day boundary: the 5pm New York rollover

Question

You are building daily bars for a 24-hour FX pair (EURUSD) and naively bucket ticks by calendar date in UTC. A teammate says FX desks define the trading day as rolling over at 5pm New York time, not midnight UTC. Why does that convention exist, and what breaks if you ignore it?

Think first, then tap
hardPoint-in-Time

Using restated fundamentals instead of the originally reported figures

Question

Your fundamentals vendor gives you a single "revenue" column per (ticker, fiscal_quarter), but that value has actually been overwritten three times as the company issued restatements over the following two years. You build a backtest that joins today's static fundamentals table to historical prices by fiscal_quarter. What's wrong with that, and what does the vendor table need to look like instead?

Think first, then tap
warmupPoint-in-Time

Look-ahead bias from z-scoring with the full-sample mean and std

Question

You're backtesting a strategy that trades a z-scored version of a feature. To compute the z-score, you use (feature - feature.mean()) / feature.std() where mean() and std() are taken over the entire historical sample, once, at the start of the backtest. What's wrong with that, and what should you do instead?

Think first, then tap
hardCleaning & Corp Actions

A Treasury bond price quoted in points-and-32nds (101-16) parsed as a plain decimal (101.16) silently misprices it by a fraction of a point

Question

Your fixed-income feed reports a Treasury price as the string "101-16", meaning 101 and 16/32nds of a point (101.5). Your ingestion script does price = float(raw.replace("-", ".")), producing 101.16. How far off is that, is the error economically significant, and how do you parse it correctly?

Think first, then tap
coreCleaning & Corp Actions

A delisted company's ticker symbol gets reassigned to a new, unrelated company years later -- corrupting any price lookup keyed on ticker alone

Question

You're building a 15-year historical price panel keyed by ticker symbol. A teammate points out that "NOV" referred to one company in 2011 and an entirely different, unrelated one by 2015, after the exchange reassigned the ticker following a delisting. What breaks in your pipeline, and what's the actual fix?

Think first, then tap
corePerformance Analytics

Converting gross fund returns to what an investor actually keeps, once a 20% incentive fee with a high-water mark is applied

Question

A fund reports gross monthly returns. Its fee structure charges a 20% performance fee on any NEW net asset value gain above the investor's prior HIGH-WATER MARK (the highest NAV ever previously reached), with no fee at all on a month that doesn't clear that mark, and never a refund when NAV falls. Given a sequence of monthly gross returns, how do you compute the investor's NAV path net of fees, and why can a fund with a strong-looking average gross return still leave an investor with mediocre net performance?

Think first, then tap
coreStatistics

Autocorrelation and effective sample size

Question

Your daily IC series has autocorrelation of 0.5 at lag 1. What does that mean concretely, and how does it change the significance of the mean IC?

Think first, then tap
coreCalendars & Alignment

Building a multi-asset master calendar

Question

You are building a daily dataset covering US equities, European equities, and a crypto series that trades every day. What master calendar do you put them on, and what are the options?

Think first, then tap
coreBacktest Mechanics

A flat basis-point cost assumption underestimates trading cost exactly when volatility spikes

Question

Your backtest charges a flat 5bps per trade, calibrated from average historical spreads during a calm period. The strategy trades more (higher turnover) during volatile regimes because your signal reacts to bigger price moves. What's wrong with carrying that same flat 5bps assumption through the volatile periods in your backtest, and how would you fix it?

Think first, then tap
hardPerformance Analytics

The Fundamental Law of Active Management: why a mediocre signal with high breadth can beat a brilliant one with low breadth

Question

Two signals are being compared. Signal A trades 500 independent bets a year with a modest forecasting skill. Signal B trades 5 independent bets a year with a much higher forecasting skill per bet. Which one is actually easier to make into a strong strategy, and what's the quantitative relationship that tells you that?

Think first, then tap
coreFeature Construction

Winsorizing before vs after cross-sectional z-scoring changes which names get clipped

Question

Your feature pipeline z-scores a raw signal cross-sectionally each day, then winsorizes the z-scores at +/-3. A teammate instead winsorizes the RAW signal at its 1st/99th percentile first, then z-scores the winsorized values. Both "handle outliers," but do they produce the same result, and which order would you actually pick?

Think first, then tap
hardPerformance Analytics

Time-weighted return vs dollar-weighted (money-weighted) return: why an investor's experienced return can differ from the strategy's own

Question

Your backtest reports a clean time-weighted annual return of 14%. The actual investor in the fund, who added a large chunk of new capital right before a strong month and pulled money out right before a weak one, says their own account only grew 9% over the same period. Both numbers can be correct at once -- what's the difference, and which one does the backtest actually measure?

Think first, then tap
hardPoint-in-Time

Restated fundamentals: using the first-reported number instead of the later-revised one

Question

Your fundamentals vendor gives you a single "net_income" value per company per quarter -- whatever the LATEST value is when you query the database today. You backtest a signal using this value as of each quarter's original filing date. The backtest looks great. What's wrong with this setup, and what should the data look like instead?

Think first, then tap
corePortfolio Construction

No-trade bands: damping turnover from a noisy signal without an explicit optimizer penalty

Question

Your target weights are recomputed daily straight from a signal, and the signal is noisy enough that a position's target weight jitters up and down even when nothing fundamentally changed. Turnover and transaction costs are eating the strategy's edge. Without adding a full transaction-cost term to the optimizer, what's a simple fix?

Think first, then tap
hardStatistics

Updating a prior belief about a signal's true IC with three months of live data, instead of trusting either number on its own

Question

Your backtested signal had an IC of 0.04 over eight years. Three months live, it's showing an IC of 0.01 -- noticeably worse. A PM asks "so is the true IC 0.01 now?" How do you combine the long backtested prior with the short live sample into a single honest estimate, instead of either ignoring the live data or overreacting to it?

Think first, then tap
corePortfolio Construction

Blending a fast mean-reversion signal with a slow momentum signal

Question

You have two working signals for the same universe: a 2-day mean-reversion signal that decays fast and a 6-month momentum signal that decays slowly. Naively averaging their z-scores into one combined alpha and feeding that straight into the optimizer produces way more turnover than either signal alone would need. Why does combining them this way blow up turnover, and how do you fix the construction?

Think first, then tap
warmupBacktest Mechanics

Compounding vs additive returns

Question

One analyst sums daily returns to get a 10-year cumulative number; another compounds them. The answers differ badly. Who is right, when does the gap matter, and which should a backtest report?

Think first, then tap
coreFeature Construction

Rolling window by row count vs by calendar time

Question

You write price.rolling(20).mean() to build a 20-day moving-average feature. The ticker had a 3-day trading halt last month, and your data only has rows for days it actually traded. Is this a "last 20 calendar days" average or something else, and does the halt change what the feature actually computes?

Think first, then tap
warmupCalendars & Alignment

pd.bdate_range() generates generic Monday-Friday business days, not actual NYSE trading days -- holidays and half days silently diverge from it

Question

You use pd.bdate_range(start, end) to build the set of "expected" trading dates for a US equities backtest, then flag any date in your price data NOT in that range as a bad extra row. Over a multi-year span, this flags a bunch of real trading days as bad and never flags some genuine market holidays. What's wrong with using bdate_range as your trading calendar, and what should you use instead?

Think first, then tap
coreStatistics

A single-factor cross-sectional regression of forward returns on your signal overstates alpha when an obvious confound (market beta) is omitted

Question

You regress next-month return on your value signal, cross-sectionally, across 500 names, and get a significant positive coefficient. Your PM asks: "did you control for beta?" You hadn't. Why does that matter, and what exactly changes if you add it?

Think first, then tap
hardPoint-in-Time

Market cap computed with today's shares outstanding

Question

You need historical market cap to build a size factor: market_cap = price times shares_outstanding. Your data provider gives you one shares_outstanding number per ticker -- the CURRENT value -- and you multiply it against the entire historical price series to save a join. Six months later a stock did a large buyback that cut its share count by 15%. What did that shortcut do to your historical size factor, and how do you fix it?

Think first, then tap
corePortfolio Construction

The 1/N equal-weight portfolio as a hard-to-beat benchmark

Question

You build a mean-variance optimized portfolio, estimate expected returns and a shrunk covariance matrix carefully, and backtest it against a naive equal-weight (1/N) portfolio of the same universe. The optimizer loses out-of-sample. Is that necessarily a sign of a coding bug?

Think first, then tap
hardBacktest Mechanics

Applying a stock split to open positions and cash P&L inside a running backtest, not just the price series

Question

Your price data is already split-adjusted, so you assume splits are a non-issue for your backtest. On the day of a real 2-for-1 split, your simulated portfolio's share count and market value both look wrong for one day. What did the split-adjustment of the PRICE series fail to account for?

Think first, then tap
warmupCalendars & Alignment

A vendor's 32-bit epoch field silently wraps around in 2038

Question

A legacy vendor feed stores trade timestamps as a 32-bit signed integer count of seconds since 1970-01-01 (the classic Unix epoch). Your desk wants to backtest strategies on contracts expiring in 2040. What breaks, and why does it fail silently instead of throwing an error?

Think first, then tap
hardFeature Construction

Window-length sensitivity: is your best lookback a real signal or overfit noise?

Question

You backtest a momentum feature across lookback windows from 20 to 120 days and find that a 47-day window produces the highest Sharpe. Your PM asks if you should ship the 47-day version. How do you reason about whether that specific number is meaningful, and what would you report instead?

Think first, then tap
corePerformance Analytics

Calmar and its length problem

Question

Define the Calmar ratio, and explain why comparing the Calmar of a 3-year track record against a 15-year one is unfair - in whose favor?

Think first, then tap
warmupBacktest Mechanics

Benchmark-relative backtest: active return and active risk instead of absolute P&L

Question

Your long-only strategy backtest reports an absolute Sharpe of 0.9. Your mandate is actually to beat a sector benchmark, and the benchmark itself had a Sharpe of 1.1 over the same period purely from broad market moves. How should the backtest actually be evaluated, and what changes in how you compute it?

Think first, then tap
warmupData Assembly

Series.map with a dict vs a Series: the silent NaN when a key is missing

Question

You're mapping a column of three-letter sector codes to full sector names using a Python dict via df["sector_name"] = df["sector_code"].map(sector_dict). A few rows come back NaN. What's happening, and how do you catch it before it ships?

Think first, then tap
hardCleaning & Corp Actions

A venue reports daily volume in notional currency while another reports raw share count, silently breaking a cross-market ADV comparison

Question

You're building a universe filter that requires average daily volume (ADV) above some threshold, pulling volume from two different vendor feeds -- one for US equities, one for a European market. The filter looks fine for US names but keeps including European penny-stock-like names that should obviously fail a liquidity screen. What's the likely cause?

Think first, then tap
warmupPortfolio Construction

Bringing an optimizer back under a gross exposure cap: constrain, or just scale down?

Question

Your long-short book is capped at 200% gross exposure (longs plus the absolute value of shorts, at most 2x NAV) by fund policy. Your unconstrained mean-variance optimizer wants 340% gross to hit its target risk level. What's the correct way to bring it back under the cap, and why isn't uniformly scaling every position down by the same factor quite the same as re-optimizing?

Think first, then tap
hardBacktest Mechanics

Sizing a trade off today's volume to estimate today's own impact cost

Question

Your vectorized backtest estimates each day's market impact with impact = k * sqrt(trade_size / today_volume), then sizes today's trade as a fraction of today_volume to keep impact bounded -- using the SAME day's realized volume for both. What's circular about this, and how does it bias the cost estimate?

Think first, then tap
hardCleaning & Corp Actions

A vendor silently switches from split-adjusted to raw prices partway through history

Question

You're building a 10-year daily price history for a stock from one vendor's flat file. Sanity-checking it, you find three price halvings that line up exactly with real historical splits in your reference table -- except a fourth halving, on a date with no matching entry in that table at all. What's the likely explanation, and how do you confirm it before deciding how to handle it?

Think first, then tap
coreFeature Construction

Cross-sectional imputation: sector median vs zero-fill

Question

Your 12-month momentum feature is NaN for about 3% of names on any given day -- recent IPOs without enough history, halted stocks, data gaps. A teammate proposes df["mom_12m"].fillna(0) right before the cross-sectional z-score. Why is that a bad default, and what should you do instead?

Think first, then tap
warmupData Assembly

Flattening MultiIndex columns after groupby.agg

Question

You compute daily per-ticker stats with df.groupby("ticker").agg({"close": ["mean", "std"], "volume": "sum"}) and the result's columns come back as a confusing two-level MultiIndex like ("close", "mean"). Downstream code that expects a column named avg_close breaks. What is happening and how do you get flat, readable column names?

Think first, then tap
coreBacktest Mechanics

Monthly signal, daily prices

Question

Your signal updates monthly but you have daily returns. How do you build the daily weight matrix for the backtest, and what subtle error does the obvious forward-fill introduce?

Think first, then tap
corePortfolio Construction

Marginal contribution to risk (MCTR) vs standalone volatility: why a high-vol stock can barely move the book's risk, and a low-vol one can dominate it

Question

You're sizing a new position in an existing book. The candidate stock has higher standalone annualized volatility than most of your current holdings, and a PM objects to adding it on that basis. What's the flaw in judging a new position by its standalone volatility alone, and what should you look at instead?

Think first, then tap
warmupCleaning & Corp Actions

Ticker symbol recycling: the same ticker string refers to two unrelated companies across your history

Question

You load five years of daily prices keyed by ticker string. A sanity check shows "XYZ" has a huge, unexplained price discontinuity and a sudden change in sector classification partway through the history, with no corporate action on record. What's the likely cause, and what key should you actually be joining on?

Think first, then tap
warmupFeature Construction

Median/MAD z-scores instead of mean/std for a heavy-tailed cross-section

Question

Your raw feature has a handful of extreme cross-sectional outliers -- one stock's value is 40 standard deviations from the mean. A standard (x - mean) / std z-score leaves the other 998 names barely moving even though the outlier is obviously distorting things. What's going wrong and what's the fix?

Think first, then tap
warmupFeature Construction

groupby().cumcount() for a 'trading days since listing' feature, and its silent sort-order assumption

Question

You want a "trading days since this ticker started trading" feature, to down-weight or exclude very newly-listed names from a signal. You write df.groupby("ticker").cumcount() on a long panel. What does cumcount() actually give you here, and what's the one thing you need to get right before trusting it?

Think first, then tap
hardPortfolio Construction

Combining signals of different reliability with inverse-variance weighting

Question

You have three alpha signals for the same universe, each already turned into a z-scored cross-sectional rank, but they have very different track records: signal A has a stable historical IC of 0.06, signal B has IC 0.03 but noisier month to month, and signal C is new with only 6 months of history. A naive average weights all three equally. How would you combine them more sensibly, and what's the risk with the new signal?

Think first, then tap
hardBacktest Mechanics

Square-root market impact vs a flat bps cost assumption at larger order sizes

Question

Your backtest charges a flat 5 bps transaction cost on every trade regardless of size, and shows a strategy comfortably profitable at the position sizes you're planning to run live. A colleague warns the backtest is going to be too optimistic specifically at larger sizes. What's wrong with a flat-bps cost assumption, and what does a more realistic cost model look like?

Think first, then tap
coreBacktest Mechanics

Point-in-time benchmark weights for relative return

Question

Your backtest reports active return as portfolio return minus benchmark return, where the benchmark is reconstructed each day as cap-weighted using TODAY'S market caps applied across the whole history. What is wrong with that benchmark construction, and how does it bias your reported alpha?

Think first, then tap
hardBacktest Mechanics

A same-day end-of-day average spread is a cost-side lookahead, not just a signal-side one

Question

Your vectorized backtest computes today's trade cost as half of today's closing bid-ask spread times trade size. A teammate points out the spread column in your data was actually computed as an end-of-day AVERAGE spread observed over the full trading session. What's wrong with using it as today's cost estimate, and does it matter?

Think first, then tap
hardBacktest Mechanics

Sizing positions off current account equity (including unrealized P&L) makes a backtest compound its own wins and losses into future bet size -- realistic for a live fund, but easy to get backwards when comparing two backtests

Question

Two versions of the same vol-targeting backtest produce different Sharpe ratios on identical signals and identical price data. One sizes every day's trade off a FIXED initial capital base; the other sizes off CURRENT equity, which includes whatever unrealized gains or losses have accumulated so far. Why do these diverge, and which one actually matches how a real fund operates?

Think first, then tap
corePoint-in-Time

shift(1) lags by row POSITION, not calendar time -- a halt with no placeholder rows silently changes the lag length right after the gap

Question

You lag a daily feature by one trading day with feature.shift(1) so today's row only sees yesterday's value. The ticker was halted for two full trading days last month, and your panel simply has no rows for those two halted dates. On the row right after the halt, does shift(1) return the value from one trading day before, or something else -- and why does that matter for point-in-time correctness?

Think first, then tap
warmupPerformance Analytics

Longest losing streak and risk of ruin

Question

Your strategy has a 55 percent daily hit rate and a healthy payoff ratio, giving it solidly positive expectancy and a respectable Sharpe. A PM asks a different question: what's the longest losing streak you should realistically expect to see, and could a bad enough streak actually threaten the fund even though the long-run expectancy is positive? How do you answer both halves?

Think first, then tap
warmupFeature Construction

expanding() vs rolling(): a strictly no-lookahead growing baseline

Question

You're building a z-score feature and need a mean and std to standardize against. A teammate suggests expanding().mean() and expanding().std() instead of a rolling(60)-day window, arguing it sidesteps having to pick an arbitrary lookback and can never look ahead by construction. Do you agree, and what's the tradeoff?

Think first, then tap
warmupBacktest Mechanics

Sizing today's trade off today's own volume

Question

Your vectorized backtest caps each day's trade size at 10% of that day's traded volume, to keep the simulation realistic about liquidity. The code does size_cap = 0.10 * volume.loc[today], computed and applied within the same day's loop iteration. What's the lookahead problem here, and how do you fix it?

Think first, then tap
warmupData Assembly

Boolean masks: & vs and, and precedence

Question

You write df[df["sector"] == "tech" and df["mktcap"] > 1e9] to filter big tech names and pandas raises ValueError: The truth value of a Series is ambiguous. What's actually going wrong, and what's the fix -- including a precedence trap that bites even after you fix the first part?

Think first, then tap
hardPoint-in-Time

A feature-store join using '<=' instead of merge_asof silently returns ALL historical rows instead of the latest one

Question

Someone wrote a point-in-time fundamentals join as a merge on ticker plus a filter data['report_date'] <= price['date'], intending to grab the most recently available fundamental for each price date. What actually comes out of that, and why is it so much worse than just "a bit slow"?

Think first, then tap
corePerformance Analytics

Separating gross alpha from net-of-cost alpha in a tearsheet

Question

A strategy's tearsheet shows a gross Sharpe of 2.1, but after transaction costs the net Sharpe is 1.3 -- a big gap. A PM asks you to break down WHERE that gap comes from: is it concentrated in a few names, a few time periods, or spread evenly? How do you attribute the cost drag rather than just reporting the two headline numbers?

Think first, then tap
hardStatistics

Is the decile spread real, or just top-bucket luck? Testing for monotonicity

Question

You sort stocks into deciles by a signal each month and the top-minus-bottom decile spread has a healthy t-stat. But when you plot the average return of each of the 10 buckets, buckets 2 through 8 look like a flat, noisy line -- only decile 10 stands out. Is this signal doing what you think it's doing, and how would you formally test whether the decile returns are actually monotonic in the signal, not just top-bucket noise?

Think first, then tap
coreFeature Construction

Winsorizing before vs after cross-sectional z-scoring: order changes the answer

Question

You're building a daily cross-sectional feature: z-score (subtract the mean, divide by the standard deviation) a raw signal across all 2000 names, then winsorize -- clip extreme values to a bound -- the z-scores at +/-3 before feeding a model. A colleague says winsorize the RAW signal first, then z-score. Does order matter, and which do you prefer?

Think first, then tap
hardPoint-in-Time

The adjusted-price-level leak around a pending split

Question

A stock announces a 4-for-1 split on June 1st, effective June 20th. Your vendor's price file is fully back-adjusted through all of history and refreshed nightly, so by the time you pull it for research, June 10th already shows a price divided by four. You are backtesting a decision made on June 10th, ten days before the split takes effect. What lookahead risk does that carry, given that the split ratio itself was already public knowledge on June 10th?

Think first, then tap
coreData Assembly

align(): controlling how two mismatched panels combine before an arithmetic op

Question

You have a signal matrix (dates x tickers) and a price matrix (dates x tickers) built from different universes -- the signal only covers 800 names, prices cover the full 3,000-name universe, and a few dates differ too. You write signal * prices to compute dollar exposure. What actually happens, and how do you take control of it?

Think first, then tap
corePerformance Analytics

Decomposing futures P&L into price return, roll yield, and collateral return

Question

Your tearsheet for a commodity futures overlay strategy reports "return" as simply the front-month contract's price change. A PM asks why the strategy's realized P&L doesn't match that price-return number even when directionally right. What components of futures P&L is the price-return number missing, and how do you decompose it correctly?

Think first, then tap
warmupFeature Construction

Cross-sectional z-score

Question

What does it mean to z-score a signal cross-sectionally, and why is it usually the first thing you do to a raw factor?

Think first, then tap
warmupBacktest Mechanics

A backtest that stops accruing P&L the day a position is opened, instead of the day it's closed, silently truncates the last trade

Question

Your vectorized backtest runs from 2020-01-01 to 2026-10-09. You compute daily P&L as position.shift(1) * daily_return and sum it over the whole date range. A position opened on the very last day in the range, 2026-10-09, contributes exactly zero P&L to the backtest no matter how it performed. Is that a bug?

Think first, then tap
warmupCalendars & Alignment

pd.date_range(freq='B') only skips weekends -- it has no idea what a holiday is

Question

You build a daily trading calendar with pd.date_range(start, end, freq="B") to reindex a US equities panel, and it runs without error. A teammate points out that Thanksgiving Day and Christmas Day both show up as valid trading days in the output. What's freq="B" actually doing, and what should you use instead?

Think first, then tap
warmupData Assembly

duplicated(keep=...): choosing which duplicate row survives

Question

Your vendor's daily price file occasionally has two rows for the same (ticker, date) -- a preliminary print and a corrected print a few minutes later, both timestamped in a load_time column. You want to drop the duplicates and keep only the corrected version. What's the one-line fix, and what's the trap if you get the keep argument backwards?

Think first, then tap
hardStatistics

Augmented Dickey-Fuller test: checking stationarity before trusting a regression between two price levels

Question

Before running a linear regression of one stock's price level on another's to estimate a hedge ratio for a pairs trade, a colleague suggests running an ADF test on each price series first. Why does that matter, and what exactly does a failure to reject the ADF null tell you?

Think first, then tap
hardBacktest Mechanics

rolling(window, center=True) looks like an innocent smoothing choice -- in a signal computation it quietly leaks future prices into today's value

Question

Your signal is a 5-day rolling average of price, computed as df['price'].rolling(5, center=True).mean(), and you use that value directly as the day's signal with no further shift. The backtest's Sharpe looks great. What's wrong with how that rolling average was computed, and why does it matter for a backtest specifically?

Think first, then tap
hardStatistics

Bonferroni vs Benjamini-Hochberg for a signal search

Question

You backtested 200 candidate signals overnight and 11 of them show a t-stat above 2 (the usual "significant" bar). Before telling anyone you found 11 real signals, how do you correct for the fact that you ran 200 tests, and how do Bonferroni and Benjamini-Hochberg differ in what they protect against?

Think first, then tap
hardPortfolio Construction

Ledoit-Wolf shrinkage for a noisy sample covariance matrix

Question

You estimate a 500-stock covariance matrix from 2 years of daily returns -- about 500 observations for 500 assets. Your mean-variance optimizer produces wild, concentrated weights that look like they're exploiting estimation noise rather than real risk structure. What's going wrong numerically, and how does shrinkage address it?

Think first, then tap
hardFeature Construction

Monitoring feature drift in production with the Population Stability Index

Question

A momentum feature that's been stable in your backtest for years suddenly starts producing much more extreme cross-sectional values in live trading over the past two weeks. Before assuming the underlying signal broke, how would you quantify whether the feature's live distribution has actually shifted from its historical training distribution, in a way you could alert on automatically?

Think first, then tap
coreCalendars & Alignment

Southern Hemisphere DST: Sydney's clock change happens on the opposite months from New York's

Question

You're aligning ASX (Sydney) trading hours with NYSE hours for an overnight futures strategy, using fixed UTC offsets for each exchange. The alignment is correct in January but drifts by an hour in April and again in October. What's going on?

Think first, then tap
coreFeature Construction

Cross-sectional rank vs z-score normalization: robustness to fat-tailed outliers

Question

You normalize a raw feature cross-sectionally each day two different ways: a z-score ((x - mean) / std) and a percentile rank scaled to [-1, 1]. On a day with one extreme outlier (a data error ten standard deviations out), the two normalized versions of the feature look very different for every OTHER name in the universe, not just the outlier. Why, and which one would you trust more by default?

Think first, then tap
warmupPortfolio Construction

Equal weight vs the optimizer

Question

Equal-weight, rank-weight, and mean-variance optimization all exist. When would you pick each - and why does the dumb equal-weight portfolio so often beat the optimizer out of sample?

Think first, then tap
warmupStatistics

Stationarity: prices vs returns

Question

Why do we model returns rather than prices? Explain stationarity in plain terms and what goes wrong statistically when you correlate two price series.

Think first, then tap
hardPoint-in-Time

A 10-K/A restates last year's earnings months later -- backfilling the corrected number into the original filing date is a textbook lookahead, even though it's the 'more accurate' number

Question

A company originally reported Q2 EPS of $1.20. Five months later it files a 10-K/A (an amended annual report) that restates that same quarter's EPS to $0.95, correcting an accounting error. Your fundamentals table only has one row per (ticker, fiscal quarter) and a teammate updates that row in place with the restated $0.95 value, since "it's the correct number." What breaks if you backtest a feature built on this fundamentals table?

Think first, then tap
hardPerformance Analytics

Unsmoothing autocorrelated, stale-priced returns (Getmansky-Lo-Makarov) to recover a strategy's true Sharpe ratio instead of trusting the raw reported volatility

Question

A credit strategy reports monthly returns with suspiciously low volatility and a Sharpe ratio north of 3. You notice its return series has strong positive first-order autocorrelation, around 0.4. What does that autocorrelation suggest about how the strategy is actually being marked, and how do you adjust the reported Sharpe to reflect true economic risk?

Think first, then tap
corePortfolio Construction

Cutting turnover without killing alpha

Question

Your target weights jump around day to day and trading costs are eating most of the alpha. How do you cut turnover, and how do you decide how much smoothing is too much?

Think first, then tap
coreFeature Construction

Standardize per date, not per asset

Question

A junior researcher z-scores each stock's signal against that stock's own full history instead of against the cross-section each date. Give two distinct reasons this is wrong for a cross-sectional strategy.

Think first, then tap
hardCleaning & Corp Actions

Forward-filling a NaN close price treats a trading halt and a vendor's missing print as the same kind of gap, when only one of them actually means 'the price did not move'

Question

A stock's close price is NaN for three consecutive days in your vendor feed. You ffill() it and move on. Under what circumstance is that actually the right thing to do, and under what circumstance does it quietly corrupt your data in a way that's hard to detect later?

Think first, then tap
hardBacktest Mechanics

Using today's index membership list inside a historical backtest loop

Question

Your backtest loops over five years of history and, at each date, selects the "S&P 500 members" by querying a static CSV of the CURRENT 500 constituents, then computes cross-sectional ranks within that set. What's wrong with this, and what does it do to your results?

Think first, then tap
hardData Assembly

Merging two vendors safely

Question

You are combining daily closes from two vendors into one master table: vendor A is your primary, vendor B fills A's gaps and cross-checks. Design the merge. What must you verify before, during, and after?

Think first, then tap
corePerformance Analytics

M-squared (Modigliani-Modigliani): comparing Sharpe ratios on a common risk footing

Question

Strategy A has an annualized Sharpe of 1.5 at 8% volatility. Strategy B has a Sharpe of 1.2 at 20% volatility. Which one is "better," and how does M-squared express that comparison in units a PM actually cares about, like a return number, instead of a dimensionless ratio?

Think first, then tap
hardCleaning & Corp Actions

GICS sector reclassification mid-history

Question

GICS periodically restructures its sector definitions -- the 2018 split of Telecom into a broadened Communication Services sector pulled in names like Google and Netflix from Technology and Consumer Discretionary. If your sector-neutralization step joins every stock to TODAY'S static GICS sector for its entire history, what breaks, and how do you fix it?

Think first, then tap
coreFeature Construction

Rank ties: average, first, or dense?

Question

Two stocks tie on today's signal value. You call .rank() cross-sectionally to build a factor. What are the three common ways pandas can break that tie, and which one should you pick for a factor that feeds a quantile-bucketed long-short book?

Think first, then tap
coreData Assembly

pd.NA vs np.nan vs None: three missing-value markers

Question

You're cleaning a mixed-type DataFrame -- a float column, an integer column stored as nullable Int64, and an object column of strings -- and you notice missing values print differently in each: NaN, <NA>, and None. A teammate asks whether these are the same thing and whether df.isna() catches all three. What do you tell them?

Think first, then tap
coreCalendars & Alignment

Flagging opening and closing auction prints with a time-of-day mask

Question

You have a DataFrame of intraday trade timestamps (tz-aware, America/New_York) for a US equity and want to exclude the opening auction (9:30:00 exact) and closing auction (16:00:00 exact) prints before computing continuous-session VWAP, since auction prints can have outsized size and a different price-formation process. How do you build that mask correctly, and what's the subtlety with using .dt.time?

Think first, then tap
hardPoint-in-Time

Point-in-time discipline for analyst estimate revisions

Question

You're building a consensus-EPS feature from a vendor table of (estimate_date, analyst_id, ticker, fiscal_period, eps_estimate) -- one row every time any analyst issues or revises an estimate. You need "the consensus (average) next-quarter EPS estimate as of date d" for every d in your backtest, with no lookahead. Walk me through building it, and name the classic mistake.

Think first, then tap
corePerformance Analytics

Sortino ratio: only downside deviation, and the MAR choice that quietly changes the number

Question

You report both Sharpe and Sortino ratios on a tearsheet. The Sortino is much higher than the Sharpe for a strategy with a lot of small positive returns and a few larger losses. Explain why, and explain the one input choice in Sortino people usually leave at a lazy default without thinking about it.

Think first, then tap
warmupCalendars & Alignment

Counting trading days with np.busday_count

Question

You need the number of trading days between a signal date and its 5-trading-day-later evaluation date, skipping weekends and a holiday calendar. Someone on the team just does (end - start).days. What's wrong, and what's the fix?

Think first, then tap
warmupBacktest Mechanics

The sign of shift(): a one-character lookahead bug

Question

A teammate's backtest computes signal.shift(-1) * returns instead of signal.shift(1) * returns, and it runs without any error -- no NaN explosion, no crash, just a suspiciously good Sharpe. What did the sign flip actually do, and why doesn't a typo this small announce itself the way you'd expect a bug to?

Think first, then tap
hardStatistics

Choosing a winsorization threshold AFTER seeing its effect on the t-stat is multiple testing, even with no explicit grid search

Question

A researcher builds one signal, runs it through one backtest, and reports one t-stat of 2.8 -- no explicit search over multiple signals or lookback windows. But along the way they tried winsorizing at the 1st/99th percentile, then at the 2nd/98th, then dropped winsorization entirely for a hard clip instead, picking whichever preprocessing choice gave the cleanest-looking result before finalizing the writeup. Is this still a multiple-testing problem, even though only one "final" signal and one t-stat ever got reported?

Think first, then tap
hardCleaning & Corp Actions

Adjusting for a rights issue

Question

A company announces a rights issue: existing holders may buy 1 new share for every 4 held, at a subscription price of 60 when the stock trades at 100 -- a discount meant to guarantee uptake. On the ex-rights date the stock mechanically drops even though nobody who exercises loses value. Your adjustment pipeline handles splits (ratio) and dividends (cash) but has never seen a rights issue. What is the correct adjustment, and how does it differ from a plain split?

Think first, then tap
warmupCalendars & Alignment

Union vs intersection of trading days for a global multi-exchange universe

Question

You're building one master date index for a book that trades US, UK, and Japanese equities together. Should that master calendar be the union of all three exchanges' trading days, or the intersection (days all three are open)? Walk through the tradeoff.

Think first, then tap
hardPoint-in-Time

Series.asof: the same PIT footgun as merge_asof, better disguised

Question

A teammate writes a quick point-in-time lookup with s.asof(some_date) on a Series of quarterly book values indexed by report date, instead of setting up a full merge_asof. It runs and returns a value. Is this safe to use in a backtest, and what would make it silently wrong?

Think first, then tap
coreCleaning & Corp Actions

Back-adjusting a price series

Question

You have raw daily closes and a table of corporate-action adjustment factors, one per ex-date (0.5 for a 2:1 split, 0.98 for a 2% dividend, etc). Build the back-adjusted price series and explain the mechanics.

Think first, then tap
warmupData Assembly

Boolean masks with pd.NA: three-valued Kleene logic, not True/False

Question

A trades DataFrame has a nullable "boolean" column is_internal with some pd.NA rows (unmatched counterparty records). You build mask = (df.qty > 0) & (df.is_internal == False) and run df[mask]. What does pandas actually compute when pd.NA meets & or |, and what does indexing with a mask that still contains NA actually do?

Think first, then tap
coreData Assembly

merge_ordered for combining a dense series with a sparse one

Question

You have two data sources for the same instrument: a daily closing-price series from your pricing vendor, and a much sparser quarterly-updated shares-outstanding series. You need one row per trading day with both price and the latest known shares outstanding carried forward, but a plain merge on date drops every day the shares table didn't update. What's the right tool, and what's the gotcha around how far it carries a value forward?

Think first, then tap
coreCleaning & Corp Actions

Reverse stock splits: telling a 1-for-10 consolidation from a genuine 90% crash

Question

A small-cap name's raw (unadjusted) closing price jumps from $2.10 to $21.40 overnight with no earnings, news, or halt -- and the very next day it resumes trading normally. Your corporate-actions feed hasn't flagged anything for this ticker. Is this a data error, a real 10x rally, or something else, and how do you confirm it programmatically?

Think first, then tap
corePoint-in-Time

As-of-then universe reconstruction

Question

You backtest a strategy from 2010 using today's S&P 500 members as the universe. Why is the result inflated, and how do you build the universe correctly?

Think first, then tap
warmupBacktest Mechanics

The leading NaN from pct_change() at the start of a backtest panel: drop it or fill it with zero?

Question

You compute daily returns with pct_change() on a price panel and feed it straight into a vectorized backtest. The very first row of your P&L series comes out as NaN, and a teammate suggests just filling it with fillna(0) so the sum() doesn't propagate NaN through later aggregation. Is that the right fix?

Think first, then tap
corePortfolio Construction

Risk parity intuition

Question

A classic 60/40 stock-bond portfolio is often called a disguised equity bet. What does risk parity do differently, and what is the actual quantity it equalizes?

Think first, then tap
warmupPerformance Analytics

RAROC-style return-on-risk-capital: comparing books with very different leverage on common footing

Question

Your fund runs a 1.2x-gross equity long-short book next to a futures overlay book that runs 8x gross notional, since futures are capital-efficient and a small margin deposit controls a large notional. Comparing the two books' returns on NAV makes the futures book look dramatically better. Is that a fair comparison, and what would you report instead?

Think first, then tap
warmupData Assembly

pd.concat's sort parameter: column order when schemas don't quite match

Question

You are concatenating five years of yearly price files with pd.concat, and one year's file has an extra column ("adj_close") the others don't have. After concat, the columns come out reordered even though you never asked for that, and some downstream code that references columns by position instead of name starts pulling the wrong values. What is going on, and how do you prevent it?

Think first, then tap
coreFeature Construction

rank()'s method parameter -- average vs first vs dense -- changes which names look like outliers when many values tie, and ties are common in a thin universe

Question

You're building a cross-sectional rank feature on a day where a small-cap universe has only 40 names, and 6 of them report the exact same analyst rating score. With rank(pct=True)'s default method, what rank do those 6 tied names get, and why might that default be the wrong choice for a feature that feeds a long-short decile split?

Think first, then tap
coreData Assembly

wide_to_long for multi-horizon columns

Question

A signal file has columns permno, ret_1m, ret_3m, ret_12m, vol_1m, vol_3m, vol_12m -- one row per stock, horizon baked into the column name. You need long format: permno, horizon, ret, vol. melt alone turns every column into its own row and loses the pairing between ret_3m and vol_3m. What do you use instead, and how does it know which columns belong together?

Think first, then tap
warmupBacktest Mechanics

Rounding target weights to whole shares in a vectorized backtest

Question

Your vectorized backtest computes target weights as continuous floats and converts straight to notional dollars, implicitly assuming fractional shares. In live trading you can only send whole-share (or worse, round-lot) orders. How much does this matter, and how do you check?

Think first, then tap
coreFeature Construction

Permutation importance for a cross-sectional feature: shuffle within date, not globally across the stacked panel

Question

You want to measure a feature's importance to a cross-sectional ranking model by permutation importance: shuffle the feature's values and see how much the model's rank-IC degrades. A teammate shuffles the feature column globally across the whole stacked (date, ticker) panel. Why does that overstate the feature's true importance, and what should you shuffle instead?

Think first, then tap
hardCleaning & Corp Actions

Stock dividends: a dividend paid in shares, not cash

Question

A company declares a 5% stock dividend -- holders get 1 extra share for every 20 held, paid in stock rather than cash. Your pipeline already handles cash dividends (total-return bump) and splits (ratio adjustment). Which of those two machineries does a stock dividend need, and what breaks if you file it under the wrong one?

Think first, then tap
hardPerformance Analytics

Decomposing portfolio CVaR into each position's marginal contribution

Question

Your risk report shows portfolio CVaR (Expected Shortfall) at the 95% level is 2.1% of NAV. The desk head wants to know which positions are actually driving that tail risk, not just the headline number. How do you decompose CVaR by position?

Think first, then tap
corePortfolio Construction

Capping net style-factor exposure inside the optimizer

Question

Your optimizer, handed an alpha signal and a covariance matrix and left unconstrained, finds a portfolio with heavy net exposure to the momentum factor -- basically making a directional bet on momentum itself rather than expressing your stock-specific alpha. How do you stop that without gutting the optimizer's freedom?

Think first, then tap
warmupCleaning & Corp Actions

Why interpolate() is a lookahead crime for prices

Question

A price series has a 3-day gap from a feed outage, and a teammate proposes df["close"].interpolate() to smoothly fill it instead of ffill(), arguing a straight line between the two known prices is more realistic than a flat line. Do you agree?

Think first, then tap
coreCalendars & Alignment

resample().ohlc() for building bars from tick data

Question

You have a tick-level trade log with a price column and a size column, timestamped to the millisecond. You need one-minute OHLC bars for a research feature: open, high, low, close, plus total traded volume per bar. Walk me through building it, and what breaks if you handle price and volume the same way.

Think first, then tap
corePerformance Analytics

Brinson attribution: splitting active return into allocation and selection effects

Question

Your portfolio beat its benchmark by 150 basis points last quarter. The PM wants to know how much of that came from overweighting the right SECTORS versus picking the right STOCKS within sectors. How do you decompose it?

Think first, then tap
coreCleaning & Corp Actions

Detecting a frozen/stale price feed vs a genuinely quiet trading day

Question

A small-cap's daily close has printed exactly 14.32 for the last 9 trading days in a row. Is that a real, extremely quiet stock, or a feed that's stuck returning yesterday's value? How do you tell the two apart systematically across a whole universe rather than eyeballing one name you happened to notice?

Think first, then tap
warmupCalendars & Alignment

The incomplete final bar in a live resample

Question

You resample a live stream of tick trades into 5-minute OHLC bars with trades.resample("5min").agg(...) and feed the bars straight into a feature pipeline running throughout the trading day. What is wrong with the very last bar every time you pull the data mid-session, and how do you guard against it?

Think first, then tap
warmupCleaning & Corp Actions

Computing dollar volume from a split-adjusted price and an un-adjusted volume column

Question

You compute daily dollar volume as price times volume to rank stocks by liquidity, using your vendor's price and volume columns. For one name, the HISTORICAL dollar volume before a 2-for-1 split looks exactly half of what the raw trade tickets show, even though nothing about how that stock traded back then actually changed. What went wrong, and how do you fix the calculation?

Think first, then tap
coreCleaning & Corp Actions

Auction imbalance messages mistaken for executed trades print phantom volume at the open and close

Question

Your opening-auction volume for a liquid name looks 5x larger on some mornings than others with no news to explain it, and the spike always lands in the same few seconds right at 9:30. What's actually going on, and how do you fix the feed?

Think first, then tap
warmupData Assembly

Parsing mixed epoch-timestamp units (seconds vs milliseconds vs nanoseconds)

Question

A vendor's tick file has a column called ts that is just a plain integer -- no units documented. Some values look like 1760200800 (10 digits) and some look like 1760200800123 (13 digits). Your teammate wants to run pd.to_datetime(df["ts"]) and move on. What's actually going on, and how do you parse it correctly?

Think first, then tap
coreStatistics

Breusch-Pagan: checking you actually need robust standard errors before defaulting to HC3

Question

You're running a cross-sectional regression of forward returns on several factor exposures, and you've gotten in the habit of always requesting HC3 robust standard errors "just to be safe." A colleague asks: how would you actually know, for a given regression, whether that's doing anything versus being cargo-culted boilerplate? What test would you run, and what does it tell you?

Think first, then tap
coreCalendars & Alignment

Day-count conventions: Act/360 vs Act/365 vs 30/360

Question

You are computing the interest accrued on a repo funding leg between two dates and a colleague asks which day-count convention the calculation uses. What do Act/360, Act/365 (Fixed), and 30/360 each mean, why do they give different numbers for the identical two dates, and which corners of the market default to which?

Think first, then tap
coreCalendars & Alignment

Daily to weekly returns

Question

You have daily simple returns and need weekly returns for a lower-frequency model. Someone writes r.resample("W-FRI").sum(). What is wrong, what is right, and what happens in weeks where Friday is a holiday?

Think first, then tap
coreCalendars & Alignment

Resampling to week-ending Friday: the label-vs-holiday off-by-one

Question

You compute weekly returns with close.resample("W-FRI").last().pct_change(). On a week where Friday is a market holiday, the resulting "Friday" bar's value turns out to equal Thursday's close -- but when you merge this weekly series onto a table indexed by actual trading dates, that row silently fails to match anything. What's going on, and how do you fix it?

Think first, then tap
coreData Assembly

Auditing a DataFrame's memory

Question

A colleague's research notebook dies with an out-of-memory error loading a 2 GB CSV that "should easily fit" in 32 GB of RAM. How do you audit where the memory goes, and what are the standard fixes, in order of impact?

Think first, then tap
warmupBacktest Mechanics

Floating-point noise in a weight calculation creates phantom near-zero trades when computing trades as weights.diff() in a vectorized backtest

Question

You compute each day's trade as weights.diff() in a vectorized backtest -- today's target weight minus yesterday's. On a day your signal genuinely didn't change, you still see a tiny nonzero "trade" like 1e-16 instead of exactly zero. Does this matter, and what's actually causing it?

Think first, then tap
coreStatistics

Why 5 of 100 signals look great

Question

A summer intern tests 100 candidate signals and excitedly reports that 5 are significant at the 5% level. What do you tell them -- and what result WOULD have been interesting?

Think first, then tap
hardCleaning & Corp Actions

A delisted stock's feed keeps repeating its last traded price forward -- a 'zombie' price quietly muting its own drawdown

Question

You're building a universe of all stocks that were ever in the Russell 3000 over the past 15 years, including names that went bankrupt or were acquired. For a bankrupt name, the price feed shows the stock trading at $0.85 every single day for six months after what was actually its last real trade, with zero volume on every one of those days. What's wrong with using this data as-is, and what should happen to the series instead?

Think first, then tap
warmupPortfolio Construction

Why scaling a portfolio's leverage doesn't change its Sharpe ratio (ignoring financing costs)

Question

Your strategy runs at 1x gross exposure with a Sharpe of 1.2. An interviewer asks: if you doubled every position size to 2x gross (same relative weights, just scaled up), what happens to the Sharpe ratio, ignoring borrowing costs for a moment?

Think first, then tap
hardStatistics

Probability of Backtest Overfitting (PBO)

Question

You searched over 200 parameter combinations for a strategy and are about to ship the one with the best in-sample Sharpe. Your manager asks: how do you actually know that specific configuration will still be the best one out-of-sample, rather than just the luckiest of the 200? What is the Probability of Backtest Overfitting, and how would you estimate it?

Think first, then tap
hardPoint-in-Time

merge_asof with duplicate timestamps on the right side: which row wins?

Question

You're merge_asof-ing minute bars (left) against a news-sentiment feed (right) keyed by ticker, matching each bar to the most recent sentiment score. Two sentiment records for the same ticker share the exact same timestamp -- your vendor sometimes emits a correction record at the identical published time as the original. Which one does merge_asof attach to your bar, and is that even deterministic?

Think first, then tap
coreCalendars & Alignment

Detecting a forward-filled phantom bar when reindexing an illiquid asset onto a liquid asset's calendar

Question

You reindex a small-cap's daily price series onto the S&P 500's trading calendar with a forward-fill so every stock in your panel shares the same date index. Three months later a research teammate finds a "flat return" day for that small-cap that never actually traded. What happened, and how do you keep forward-fill from manufacturing bars that look like real observations?

Think first, then tap
warmupBacktest Mechanics

A bps-of-notional cost model that forgets small fixed regulatory fees (SEC Section 31 fee, FINRA TAF) understates costs most at high turnover, exactly where the omission matters most

Question

Your backtest charges 2 bps of notional per trade to approximate commissions and spread, calibrated against your broker's statement. Live trading comes in a few bps worse per round-trip than the backtest predicted, and the gap is worse for your highest-turnover names. What's a commonly-missed cost category, and why does it hit high-turnover names hardest?

Think first, then tap
corePoint-in-Time

Point-in-time lag for alt-data with irregular arrival latency, not a fixed T+1

Question

You have a satellite-imagery signal (estimated retail foot traffic per store) where the vendor's processing pipeline takes anywhere from 2 to 11 days after the image date to deliver a value, depending on cloud cover and processing backlog. Your PIT framework assumes a fixed lag per field. How do you handle this signal correctly?

Think first, then tap
warmupCalendars & Alignment

Trading days vs calendar days for lookback windows

Question

Your spec says "60-day momentum" but doesn't say which kind of day. You write df["close"].pct_change(60) directly on a price series indexed only by trading days. What are you actually computing, and where would a naive calendar-day approach go wrong instead?

Think first, then tap
hardPoint-in-Time

Feed timestamp vs receipt timestamp: when could you actually have seen this row?

Question

An alt-data vendor's file has an "event_time" column marking when something happened (say, a satellite image was captured), but your backtest joins on event_time as if that were also when the data became available to you. Production only receives the processed file, with a "delivered_at" timestamp, hours or days later. Your backtest looks great; production has never matched it. Diagnose the bug and fix the join.

Think first, then tap
warmupPortfolio Construction

A long-only equity mandate still wants to hedge market risk -- shorting an index future isn't a 'short position' in the portfolio's stocks, so why is it allowed

Question

A fund's mandate says "long-only" -- it can't sell any of its stocks short. But the PM wants to reduce the portfolio's exposure to a broad market selloff without selling the actual stock positions. Shorting an S&P 500 future is on the table. Why doesn't that violate the long-only mandate?

Think first, then tap
coreBacktest Mechanics

Warm-up period leakage: starting P&L before the lookback window is full

Question

Your signal needs a 60-day rolling window to compute (e.g. a 60-day momentum feature). You load 5 years of price history, compute the rolling feature over the whole series, and start your backtest's P&L accounting on day 1 of the loaded data. What's wrong with that, and what actually needs to happen?

Think first, then tap
coreStatistics

Rank-IC vs Pearson IC

Question

Most desks quote rank-IC (Spearman) rather than plain Pearson IC. What is the difference and why is rank-IC the default?

Think first, then tap
hardPoint-in-Time

IPO lockups and when a new listing enters the universe

Question

A stock IPOs and you have clean daily prices from day one. Your universe-construction rule includes any stock with valid price and volume data. The stock enters your backtest immediately and your momentum signal trades it within the first month, well before the standard 180-day IPO lockup expires. What's wrong with including it that early, and how do you fix the universe rule?

Think first, then tap
hardPortfolio Construction

Resampled efficient frontier (Michaud resampling): smoothing an unstable optimizer with bootstrap

Question

Your mean-variance optimizer produces wildly different weights when you nudge the expected-return inputs by amounts well within their estimation error. A colleague suggests Michaud resampling. What does it actually do, and why would it help?

Think first, then tap
hardStatistics

Hansen's SPA test: fixing White's Reality Check's conservative bias

Question

You ran White's Reality Check on 200 candidate strategies against a benchmark and it says none are significant, even though your best strategy's raw Sharpe looks genuinely good. A colleague says the Reality Check is known to be conservative and suggests Hansen's SPA test instead. What's actually different, and why would it change the conclusion?

Think first, then tap
hardBacktest Mechanics

Limit order fills in a vectorized backtest: touch vs cross

Question

Your vectorized backtest fills a resting buy limit order whenever that bar's low is less than or equal to the limit price -- price <= limit means filled. Live trading, the same strategy fills noticeably less often at that price than the backtest predicts. What's the gap, and how do you model it without dropping to bar-by-bar simulation?

Think first, then tap
coreStatistics

Ljung-Box test: leftover autocorrelation in strategy returns

Question

Your daily strategy return series looks roughly i.i.d. by eye, but before you compute a plain (non-Newey-West) standard error on its mean anywhere, you want a formal check for autocorrelation. How does the Ljung-Box test work, and what does a small p-value actually tell you?

Think first, then tap
hardPoint-in-Time

A feature store's cache key collision serves yesterday's point-in-time snapshot for today's query

Question

Your firm's feature store caches expensive point-in-time feature computations keyed by (ticker, feature_name, as_of_date) so a backtest re-run doesn't recompute everything from scratch. One day a researcher notices a feature's value for a given as_of_date silently changed between two runs a week apart, even though no new data should have arrived for that historical date. How could a cache even produce a DIFFERENT answer for the same point-in-time key, and what does that imply about trusting the cache at all?

Think first, then tap
hardPoint-in-Time

Reconstructing point-in-time index membership

Question

You are backtesting a strategy on "the Russell 2000" over 15 years, but the only membership list you have is today's constituent list. You use it for the whole backtest. What bias does that introduce, how large is it typically, and how do you fix it properly?

Think first, then tap
coreCleaning & Corp Actions

A/B feed arbitration: deduplicating redundant trade prints across two multicast lines without a naive value-based dedupe

Question

Your exchange publishes every trade twice -- once on a primary multicast line (feed A), once on a redundant backup line (feed B) -- so you can recover a trade if one line drops a packet. Your raw tick capture subscribes to both for safety and now has roughly double the trade count it should. What field do you dedupe on, and why is a naive dedupe on (timestamp, price, size) unsafe?

Think first, then tap
hardPerformance Analytics

Measuring alpha decay: does a signal survive going from daily to weekly rebalancing

Question

Your signal has an IC of 0.04 at a 1-day holding period. How do you measure how much of that edge survives if you can only rebalance weekly instead of daily, and why does this matter for choosing a trading frequency?

Think first, then tap
warmupPoint-in-Time

FOMC minutes are dated by the meeting they describe, not by when they were actually published three weeks later

Question

You're building a feature from the tone of FOMC meeting minutes -- say, a simple hawkish/dovish word count -- and your vendor's data table has one column: "meeting_date." You join this feature onto your daily backtest using meeting_date as the timestamp. What's the lookahead here, and how big is the gap?

Think first, then tap
coreBacktest Mechanics

Flat bps slippage vs spread-derived slippage: where a constant assumption misprices small caps

Question

Your backtest charges a flat 5 bps of slippage on every trade, regardless of ticker. It looks fine in aggregate P&L for a large-cap-heavy book, but a colleague suspects it's badly wrong for the small-cap sleeve specifically. What's the mechanism, and how do you fix it?

Think first, then tap
warmupPerformance Analytics

Two strategies can share the same max drawdown magnitude while one takes 7x longer to recover -- why time underwater is a separate risk dimension

Question

Two strategies both have a maximum drawdown of exactly -15%. Strategy A recovers to a new equity high within 2 months. Strategy B takes 14 months to recover. The tearsheet only reports the -15% number for both. What are you missing, and why would an allocator care?

Think first, then tap
coreFeature Construction

Quantile bucketing vs continuous z-scoring

Question

You have a raw value signal, book-to-price, that you want to turn into a tradeable cross-sectional feature. One teammate cross-sectionally z-scores it every day; another buckets it into deciles with qcut and assigns each decile a fixed score. When would you prefer bucketing over the continuous z-score, and what does bucketing cost you?

Think first, then tap
warmupPerformance Analytics

Max drawdown reported in percent terms vs in dollar terms can rank two strategies in opposite order once their NAVs have grown very differently

Question

Strategy A started at 10 million and is now at 50 million, with a worst drawdown of 8%. Strategy B started at 10 million and is now at 12 million, with a worst drawdown of 15%. Your PM asks "which one has had the worse drawdown?" Does percent or dollar terms give the more useful answer, and why might they disagree?

Think first, then tap
warmupPortfolio Construction

A name can look diversified sleeve-by-sleeve while the book holds a concentrated net position in it

Question

Your long-only equity sleeve and your separately-optimized long-short overlay sleeve each report comfortable position limits on AAPL. Why can the combined book still end up dangerously concentrated in AAPL, and what's the simple fix?

Think first, then tap
coreStatistics

Your IC's 95% confidence interval is twice as wide as you'd like -- how many MORE years of data does halving it actually require

Question

You've measured a factor's IC over 5 years of daily data and its 95% confidence interval comes out wider than you'd like -- specifically, twice as wide. Your PM asks how long you'd need to wait to cut that interval's width in half. What's the actual answer, and why is it not "wait 5 more years"?

Think first, then tap
hardCleaning & Corp Actions

A delisted company's ticker gets reassigned to an unrelated new company years later, and a ticker-keyed join silently splices two companies' histories together

Question

You join a fundamentals table to a prices table on ticker alone, across many years of history. Later you notice one "company's" time series shows a sharp, permanent change in share count, sector, and country of incorporation on a specific date, with no corporate action recorded anywhere. What's the likely cause, and how do you guard against it?

Think first, then tap
corePerformance Analytics

Linking single-period Brinson attribution across many periods without residual error

Question

You've computed monthly Brinson attribution (allocation and selection effects) for a portfolio over a full year, and want to report cumulative annual allocation and selection effects. Just summing the twelve monthly allocation effects together doesn't equal the true multi-period allocation effect implied by the cumulative return difference. Why not, and what's the standard fix?

Think first, then tap
warmupData Assembly

Exploding list-valued columns with explode()

Question

A positions feed gives you one row per (date, trader) with an "instruments" column holding a Python list of tickers held that day, plus a "notional" column for the trader's total exposure. You need one row per (date, trader, ticker) to join against a per-ticker return series. What's the pandas call, and what's the catch with the notional column afterward?

Think first, then tap
hardBacktest Mechanics

Sizing an earnings-day volatility trade off that same day's REALIZED move is a lookahead -- the move isn't known until after the session closes

Question

A backtest sizes an earnings-day straddle position as a function of how large the stock's move ended up being that day -- bigger realized move, bigger position -- and shows a suspiciously great Sharpe. What's wrong with the sizing logic?

Think first, then tap
hardPortfolio Construction

Full Kelly sizing maximizes long-run growth but is rarely tradeable -- why funds run fractional Kelly instead

Question

A strategy has a known edge: 55% win probability, symmetric 1:1 payoff per bet. The Kelly criterion says the growth-optimal fraction of capital to bet each time is 2p - 1 = 0.10, or 10% of capital per bet. A PM running this strategy at full Kelly says the realized drawdowns are unacceptable even though the strategy is working exactly as modeled. What's the disconnect between "growth-optimal" and "acceptable to actually run," and why does running a FRACTION of Kelly fix it disproportionately?

Think first, then tap
hardPoint-in-Time

Joining EOD close against intraday alt-data timestamps

Question

You're joining a daily close-price table against an alternative-data feed that arrives at various times during the trading session (news sentiment, say). Your close table stores one row per (ticker, date) with no time component. You backward-asof-join alt data to the nearest prior close. A sentiment score that arrived at 2pm on trading day T gets matched to T's own close price. Is that a leak, and why?

Think first, then tap
hardPoint-in-Time

Mechanical lookahead detection

Question

Design an automated test that catches lookahead in a feature pipeline you did not write -- treat the pipeline as a black box.

Think first, then tap
corePoint-in-Time

merge_asof's allow_exact_matches: same-timestamp data is not always fair game

Question

You join daily prices to fundamentals with merge_asof(prices, fundamentals, on="date", by="ticker", direction="backward") -- the default allow_exact_matches=True. Your fundamentals feed stamps each filing with its publication DATE only, which is sometimes the same calendar date as the price row you're joining it to. Is that exact-date match always safe, and what does allow_exact_matches actually control?

Think first, then tap
coreStatistics

Bootstrap confidence intervals

Question

Your strategy's Sharpe is 1.1 over eight years. Build a confidence interval for it without assuming returns are normal -- how does the bootstrap work and where does the naive version break for financial data?

Think first, then tap
hardStatistics

White's Reality Check: testing many strategies without overfitting the winner

Question

You backtested 200 variants of a strategy (different lookback windows, thresholds, universes) and the best one has a Sharpe of 2.1 with a p-value of 0.01 against the null of zero mean return. Your manager asks: is that p-value even meaningful given you tried 200 things? What's the right way to test the BEST strategy's significance accounting for the whole search?

Think first, then tap
hardPortfolio Construction

Baking an asymmetric hard-to-borrow cost into the optimizer, not a flat short financing assumption

Question

Your long-short optimizer currently assumes a single flat financing spread applies to every short position. In reality a handful of names are "special" -- hard to borrow, with stock loan fees running into the hundreds of basis points annually instead of a typical general-collateral rate near zero. How do you change the optimizer so it actually accounts for this, and what happens to the portfolio if you don't?

Think first, then tap
hardBacktest Mechanics

Estimating capacity

Question

Your backtest assumes 100 million of capital. The PM asks: how much money can this strategy actually run? Give me a defensible first-pass capacity estimate from the backtest's own trade data.

Think first, then tap
coreData Assembly

merge()'s suffixes= parameter: resolving duplicate column names instead of silently getting _x/_y

Question

You merge a primary price table with a secondary vendor's corrective-adjustment table on (ticker, date). Both tables happen to have a "volume" column with different values, and the merge silently produces volume_x and volume_y instead of raising any error. What is actually happening, and how do you make the intent explicit instead of letting pandas guess?

Think first, then tap
hardPerformance Analytics

Kappa ratio: generalizing Sortino's downside deviation to higher-order lower partial moments for skew-sensitive risk ranking

Question

Sortino ratio penalizes only downside deviation below some minimum acceptable return. For a strategy that sells options and has a return profile with a thin, usually-fine left tail but an occasional severe blowup, does Sortino actually capture what makes that strategy risky, or is it missing something?

Think first, then tap
warmupFeature Construction

Sign orientation before combining value and quality signals

Question

You're combining five value and quality signals into one composite score: earnings yield, book-to-price, and two profitability ratios are "higher is better," but a leverage ratio (debt-to-equity) is "lower is better." You average their z-scores directly and the composite performs worse than earnings yield alone. What's the likely bug?

Think first, then tap
coreCalendars & Alignment

WeekOfMonth for a 'third Wednesday' rebalance rule, and why a hardcoded day-of-month fails

Question

A strategy rebalances on the third Wednesday of every month. Generate that schedule for a year of dates in pandas, and explain what goes wrong if someone implements this rule as "the 15th to 21st of each month, take the first Wednesday in that range" using plain integer day-of-month arithmetic.

Think first, then tap
warmupPortfolio Construction

Portfolio beta as the weighted average of position betas vs regressing portfolio returns directly

Question

You need your book's overall beta to the market. One analyst computes it as the weight-weighted average of each position's own individually-estimated beta. Another regresses the portfolio's own daily returns directly against the market. Do these two methods give the same number, and if not, which one should you trust more?

Think first, then tap
coreBacktest Mechanics

A permutation test for whether the backtest beats random chance

Question

Your signal-return pairing backtest shows a Sharpe of 1.1 over 5 years. Before trusting it, you want a test that doesn't rely on any normality or overlapping-returns assumption -- just a direct answer to "could a signal with zero real predictive power have produced this by chance, given how this exact strategy trades?" How do you build that test, and what exactly do you randomize?

Think first, then tap
warmupData Assembly

The .str accessor vs .apply for string cleaning: who survives a NaN in the column

Question

You have a ticker column that's mostly clean strings but has a handful of NaN from unmatched vendor rows. You need to uppercase and strip whitespace from every entry. Why does df['ticker'].apply(lambda x: x.strip().upper()) crash, and what should you write instead?

Think first, then tap
warmupData Assembly

groupby().size() vs .count(): counting groups vs counting non-null values

Question

You group a DataFrame of trade records by ticker and call two different methods to count rows per ticker: one gives you a Series, the other gives a DataFrame with one column per field. Why do df.groupby('ticker').size() and df.groupby('ticker').count() sometimes report different numbers for the same ticker, and when would you reach for each one?

Think first, then tap
warmupCalendars & Alignment

Period vs Timestamp for fiscal quarters

Question

You are storing which fiscal quarter each earnings report covers -- "Q1 2026", "Q2 2026", and so on. A teammate suggests just storing it as a string, another suggests a Timestamp for the quarter's last day. What does pandas' Period dtype offer over either, and when does it matter?

Think first, then tap
coreCleaning & Corp Actions

A total-return series with a price drop but no matching dividend record

Question

You reconstruct total-return series by adding back each day's dividend to the raw price return. For one stock, you notice a single day with a sharp negative raw-price return that doesn't correspond to any row in your dividends table, and the total-return series shows a permanent, uncorrected drop from that day onward. What's the likely cause, and how do you catch this systematically instead of one ticker at a time?

Think first, then tap
corePortfolio Construction

Marginal contribution to risk: which position is actually driving your vol?

Question

Your long-short book has 40 positions and an annualized portfolio vol of 18%. One position is only 3% of gross exposure but you suspect it's contributing far more than 3% of the risk. How do you actually compute each position's contribution to total portfolio volatility, and why doesn't weight alone tell you this?

Think first, then tap
corePortfolio Construction

Position limits and sector caps

Question

Your optimizer hands you a book with 15 percent in one small cap and 60 percent of gross in tech. What constraints do you impose, and how do you actually enforce a per-name cap on a weight vector?

Think first, then tap
warmupPerformance Analytics

Splitting hit rate by long leg vs short leg reveals a book that's actually only good at picking longs

Question

Your long-short book has an overall hit rate (percentage of winning days) of 58%, which looks solid. Your PM asks you to break that down by leg. What would computing hit rate separately for the long and short legs potentially reveal, and why would you bother?

Think first, then tap
hardFeature Construction

Orthogonalizing a new signal against an existing one

Question

You already trade a value signal. A researcher proposes a new quality signal, and its cross-sectional correlation with value is 0.6. Before you consider quality as an independent addition to the book, what do you do, and why not just combine them with a rank-average like usual?

Think first, then tap
warmupPerformance Analytics

Hit rate vs payoff ratio

Question

A PM says a 48 percent hit rate makes a strategy a coin flip that loses to costs. The strategy is profitable. Reconcile that - what two numbers together determine expectancy?

Think first, then tap
hardPerformance Analytics

Capacity-driven Sharpe decay vs genuine alpha decay

Question

A strategy's live Sharpe has drifted down from 2.1 to 1.1 over three years, tracking almost exactly the period over which AUM allocated to it grew from $20M to $400M. Is this alpha decay -- the signal stopped working -- or something else, and how would you tell the difference?

Think first, then tap
corePerformance Analytics

A long-short book's Sharpe ratio doesn't decompose into the long leg's Sharpe plus the short leg's Sharpe, because their covariance changes the combined variance

Question

Your long leg earns a Sharpe of 1.2 and your short leg (as its own standalone P&L stream) earns a Sharpe of 0.9. Someone suggests the combined long-short book should have a Sharpe somewhere between the two, maybe their average. Is that a reasonable estimate, and what would you actually need to compute instead?

Think first, then tap
coreBacktest Mechanics

Modeling execution latency in a vectorized backtest

Question

Your signal fires at the 3:55pm close-approaching snapshot, and your vectorized backtest assumes the fill happens instantly at that exact price. In reality, order routing, exchange matching, and your own risk checks add roughly 200-500ms of latency before the order reaches the book. Does this matter for a daily-rebalance equity strategy, and how would you stress-test it without abandoning vectorization?

Think first, then tap
hardPoint-in-Time

Computing a feature off a bar that hasn't closed yet

Question

Your research backtest computes a 5-minute momentum feature using each 5-minute bar's close, then trades at the START of the next bar. In production, the live system computes the "current 5-minute bar's close" using whatever the last print is AT THE MOMENT the trading decision fires -- which is partway through that bar, not after it closes. What's the mismatch, and why does the backtest look better than production as a result?

Think first, then tap
coreFeature Construction

Combining a partially-covered feature without creating a hidden size/geography bet

Question

You've built a filings-based feature that's only available for about 60% of your investable universe on any date -- small caps and foreign issuers are systematically the ones missing it. If you cross-sectionally z-score it the normal way, using the mean and std of only the names that have it, and then rank-average it with other features that ARE covered everywhere, what goes wrong?

Think first, then tap
coreBacktest Mechanics

Delisted names and vanishing losses

Question

Your vendor file only contains currently listed stocks, and separately, returns go NaN after a name delists mid-backtest. What do these two problems do to your results, and how do you handle a delisting day properly?

Think first, then tap
coreBacktest Mechanics

A minimum-trade-size filter that silently drops small trades understates both turnover and transaction costs

Question

Your vectorized backtest computes target weight changes every day but only "submits" a trade if the notional change clears some minimum threshold, mimicking a desk that doesn't bother with tiny trades. Where does this silently bias the backtest's reported turnover and cost estimates, and in which direction?

Think first, then tap
hardPoint-in-Time

A full-session VWAP computed once at end-of-day and joined back onto that morning's intraday bars is a lookahead, even though the join timestamp looks intraday

Question

A vendor sends one row per symbol per day with a "vwap" field and an intraday-looking timestamp of, say, 10:00am. You join it onto your 10:00am bars thinking it's a point-in-time intraday VWAP. What's actually in that field, and what breaks if you trade on it?

Think first, then tap
coreCalendars & Alignment

Half-day (early close) sessions breaking a fixed bar-count intraday feature

Question

You build an intraday feature as "volume in the last 30 one-minute bars of the session." It works fine most days, but on the day after Thanksgiving and Christmas Eve -- early-close half days -- the feature looks wrong. What's happening and how do you fix it?

Think first, then tap
warmupCalendars & Alignment

Bucketing microsecond timestamps into fixed bars: floor vs round vs ceil

Question

You have raw trade timestamps with microsecond precision and need to bucket them into 1-minute OHLCV bars. What's the idiomatic pandas way to get each trade's bar boundary, and does it matter whether you floor, round, or ceil?

Think first, then tap
warmupCalendars & Alignment

Generating month-end rebalance dates

Question

You need the list of actual trading dates your monthly-rebalanced strategy trades on -- the last trading day of each calendar month, not the calendar's last day of the month, which is frequently a weekend or holiday. How do you generate that list correctly from a price panel's trading calendar?

Think first, then tap
warmupFeature Construction

Pooling rare categorical levels into 'Other' before one-hot encoding a sector feature

Question

You one-hot encode a "sector" categorical feature for a cross-sectional model. One micro-cap sub-sector has only 3 names in a universe of 2,000. What's wrong with one-hot encoding it as-is, and what's the simple fix?

Think first, then tap
hardBacktest Mechanics

Partial fills when order size exceeds available volume at the target price

Question

Your vectorized backtest fills every order at the bar's VWAP regardless of order size, computed as target_shares * bar_vwap for cost. For a large-cap name this is fine, but for a small-cap position sized at 8% of a bar's total volume, live trading shows you never actually get fully filled within one bar. How do you adjust the backtest to reflect that, and what does it do to your realized entry price and timing?

Think first, then tap
warmupCalendars & Alignment

The Tokyo lunch break: a scheduled gap, not missing data

Question

You are building 5-minute intraday bars for a Japanese equity and computing a rolling "minutes since last trade" feature. Every day around midday the feature spikes to roughly 90 minutes even though nothing is wrong with the feed. What is happening, and how should the calendar handle it?

Think first, then tap
coreBacktest Mechanics

Square-root market impact model: why slippage scales with sqrt of order size

Question

Your backtest currently charges a flat basis-point slippage cost per trade regardless of size. A colleague says that's wrong for anything beyond small orders -- real market impact scales roughly with the square root of order size relative to daily volume, not linearly. Why square root, and what does ignoring this do to a backtest that trades larger size than your historical fills reflect?

Think first, then tap
coreFeature Construction

Rank-gauss transform for a heavy-tailed cross-sectional feature

Question

A raw feature like short-interest ratio is extremely right-skewed cross-sectionally every day -- a handful of names have enormous values compared to everyone else. Standard z-scoring still leaves those few names dominating the transformed feature's magnitude. A teammate suggests a "rank-gauss" transform. What is it, why does it fix this specific problem, and what does it give up?

Think first, then tap
coreStatistics

Is Strategy A's Sharpe really better than Strategy B's?

Question

Strategy A shows a 3-year annualized Sharpe of 1.4; Strategy B shows 0.9 over the same 3 years, and the two return streams have a 0.6 correlation with each other. A PM wants to allocate only to A. Is the gap statistically meaningful, and how do you test it properly?

Think first, then tap
warmupFeature Construction

ewm's span, halflife, and alpha: three parameterizations of the same decay, easy to mismatch across a codebase

Question

You're building a fast/slow EWMA crossover feature. A teammate's existing code uses .ewm(span=20) for the fast average; your new code uses .ewm(halflife=10). Are those two the same decay rate just written differently, and how would you check?

Think first, then tap
hardFeature Construction

Industry-neutralizing a factor: demeaning within group is regression on group dummies in disguise

Question

A teammate neutralizes a momentum factor against industry by subtracting each stock's industry-group mean (df.groupby("industry")["momentum"].transform(lambda x: x - x.mean())). Another runs an explicit OLS regression of momentum on a full set of industry dummy variables and uses the residuals. Are these actually doing different things, and does the answer change once you add a SECOND continuous control variable like market cap to the regression?

Think first, then tap
hardStatistics

Grid-searching a lookback window is multiple testing, even with one signal

Question

You have one momentum signal idea and you're not sure whether to use a 20-day, 60-day, or 120-day lookback, so you backtest everything from 20 to 180 days in steps of 10 and report the Sharpe ratio of whichever lookback did best. Your PM asks whether this counts as "testing multiple signals" and needs a multiple-testing correction, even though you only ever had one signal idea. What do you tell them?

Think first, then tap
corePerformance Analytics

Beta estimation breaks when your asset and benchmark return frequencies don't match

Question

You want your strategy's beta to the S&P 500. Your strategy only rebalances and marks P&L monthly, but you have the S&P 500's daily closes. A teammate resamples the index to monthly too, then regresses strategy returns on index returns. Is matching the frequency enough, or is there a subtler issue in how the monthly benchmark return gets computed?

Think first, then tap
warmupPoint-in-Time

Series.asof() vs merge_asof(): when a simple as-of lookup is enough, and when it silently isn't

Question

You need the most recently available value of a slowly-updating reference series (say, a risk-free rate) as of each date in your daily panel. A teammate writes a one-liner using Series.asof() instead of reaching for merge_asof(). When is that a fine shortcut, and when does it quietly break?

Think first, then tap
coreCalendars & Alignment

resample's origin parameter for anchoring intraday bars that don't start at midnight

Question

You have raw tick data for a futures contract that trades nearly 24 hours but whose session actually rolls over at 17:00 Chicago time, not midnight. When you resample('1D') the tick data, pandas buckets by calendar midnight-to-midnight by default, splitting each trading session across two calendar days. How do you get resample to bucket by the exchange's actual session boundary instead?

Think first, then tap
warmupBacktest Mechanics

A vectorized backtest that fills a limit order during a trading halt

Question

Your vectorized backtest checks, for each bar, whether a resting limit buy order's price is greater than or equal to that bar's low, and if so marks it filled at the limit price. On one date, a stock is halted mid-session for a pending news announcement, then reopens down 8%. Your backtest still shows a fill at the pre-halt limit price on that bar. What's wrong, and what would a real trader have experienced?

Think first, then tap
corePortfolio Construction

Black-Litterman: blending views with the prior

Question

Your team has a signal-implied expected return vector, but you know raw mean-variance on top of it produces the usual corner-heavy, unstable weights. Someone suggests Black-Litterman. Explain the core idea in a minute, without the matrix algebra.

Think first, then tap
coreFeature Construction

Soft-clipping a feature with tanh instead of hard winsorization

Question

A raw feature -- say, a 1-day dollar-volume spike ratio -- has a few genuinely extreme values that would dominate a cross-sectional regression if left alone. Hard winsorizing (clipping at the 1st/99th percentile) is the usual fix, but it piles every extreme value up at the exact same boundary number and throws away how extreme each one actually was. What's an alternative that keeps the ordering and a smoother tail?

Think first, then tap
warmupData Assembly

pd.crosstab vs groupby().size().unstack() for a two-way count table

Question

You want a quick table of how many trades fall into each (exchange, trade_type) combination, to sanity-check a new SIP feed before building anything on it. What's the fastest way to get that two-way count table in pandas, and is there a difference between reaching for pd.crosstab versus groupby().size().unstack()?

Think first, then tap
coreStatistics

How much data do you need to detect an IC of 0.02?

Question

Before running a multi-year backtest to test a new signal, your PM asks: if this signal's TRUE mean IC is 0.02 (a realistic, modest edge) and daily IC volatility is around 0.10 as usual, how many days of data do you need for an 80% chance of detecting it as statistically significant at all -- rather than complaining afterward the backtest wasn't long enough?

Think first, then tap
coreFeature Construction

Cross-sectional z-scoring when a signal only covers part of the universe

Question

Your value factor needs a book-to-price ratio, but only 1,800 of your 2,500-stock universe have current fundamentals -- the rest are recent IPOs, foreign filers on a different reporting cadence, or names with negative book value you've excluded. You cross-sectionally z-score the signal each day. What do you do with the 700 uncovered names, and what happens if you get it wrong?

Think first, then tap
hardStatistics

How much history do you need to detect an IC of 0.03?

Question

A colleague claims their new signal has a true IC of about 0.03 against 1-day forward returns. Assuming that's really the population value, roughly how many independent daily observations would you need to reject the null of zero IC at the 5% level with reasonable power? Walk through the calculation.

Think first, then tap
warmupData Assembly

df.query() and df.eval() for readable, faster filters on a wide panel

Question

Your screening code has grown into df[(df["adv_usd"] > 5_000_000) & (df["sector"] == "Tech") & (df["mom_21d"] > 0) & (df["pe"] < 30)] -- four conditions deep and hard to review in a diff. How would you clean this up, and does it change performance on a large panel?

Think first, then tap
hardCleaning & Corp Actions

A country-wide multi-day trading suspension leaves a calendar gap your reindex logic doesn't expect

Question

A single-country ETF you hold went dark for six consecutive trading days after a coup attempt froze the local exchange -- no prints, no quotes, nothing -- then it reopened down 40% in one print. Your pipeline's gap-fill logic forward-fills any missing daily bar for up to 5 days before flagging a stale price. What breaks, and what should actually happen to those six days?

Think first, then tap
warmupCalendars & Alignment

pd.Timestamp.today() still carries a nonzero time-of-day, so using it as a 'today's date' dict key silently never matches midnight-normalized dates

Question

You write price_by_date[pd.Timestamp.today()] to look up today's row in a dict keyed by midnight-normalized dates (every key has 00:00:00 as its time component). The lookup raises a KeyError every single day, even though "today" is obviously a valid key. Why, and what's the one-line fix?

Think first, then tap
hardCleaning & Corp Actions

A vendor quietly re-adjusts the ENTIRE historical price series after a new corporate action -- diffing today's pull against yesterday's to catch it

Question

You refresh your price database nightly, pulling split/dividend-adjusted closes for the whole history each time. One morning you notice a backtest that hasn't changed its code gives slightly different Sharpe ratios on a run from a year ago than it did last week. Nothing in your pipeline changed. What's actually going on, and how do you catch it going forward?

Think first, then tap
hardPoint-in-Time

Fiscal quarter misalignment in PIT joins

Question

You join point-in-time fundamentals onto a daily price panel across a universe where companies use different fiscal year ends -- most report calendar quarters, but a chunk of retailers and some tech names run fiscal years ending in January or June. Your merge_asof by ticker, on report date, looks timing-correct. What can still go wrong, and how would you catch it?

Think first, then tap
corePoint-in-Time

An earnings call's event timestamp is known immediately, but the transcript text your NLP feature actually reads isn't available until hours later

Question

Your data vendor timestamps each earnings call transcript with the call's START time, e.g. 2026-10-23 08:00 ET. The call runs an hour, and transcription plus QA means the actual transcript text isn't posted to your feed until 11:30 ET the same day. If you build a same-day sentiment feature and join it to prices using the call's start timestamp, what's the point-in-time violation, and what timestamp should you actually use instead?

Think first, then tap
hardStatistics

Wild bootstrap for a heteroskedastic cross-sectional regression

Question

You run a cross-sectional regression of next-month return on a signal, across a few hundred stocks, and want a bootstrap confidence interval for the signal's coefficient. Small-cap stocks have visibly higher residual variance than large-caps in your residual plot. Why does a standard pairs (case) bootstrap actually handle this fine, but a plain i.i.d. residual bootstrap doesn't -- and what's the residual-based alternative that also handles it?

Think first, then tap
corePortfolio Construction

500 assets, 252 days: singular

Question

You estimate a sample covariance matrix for 500 stocks from one year of daily returns and hand it to an optimizer. It explodes. Why is that matrix guaranteed to be unusable?

Think first, then tap
warmupPortfolio Construction

Maximum diversification portfolio vs risk parity

Question

You've built risk parity weights (equal risk contribution) for a multi-asset book. A colleague suggests trying the maximum diversification portfolio instead, saying it optimizes a genuinely different objective. What is the maximum diversification portfolio actually maximizing, and how is that different from what risk parity targets?

Think first, then tap
coreCalendars & Alignment

Week(weekday=...) for a fixed-weekday rebalance calendar

Question

Your strategy rebalances every Wednesday. A teammate builds the rebalance calendar with pd.date_range(start, end, freq="W"), and every date that comes back is a Sunday. What went wrong, and how do you actually anchor a weekly date range to Wednesdays?

Think first, then tap
coreCalendars & Alignment

np.busday_offset's roll parameter: what happens when the anchor date is a holiday

Question

You need "the trading day exactly 3 business days after each rebalance announcement date," computed with np.busday_offset(dates, 3, roll="raise"). On one row the announcement date itself falls on a Saturday. What happens, and what roll value would you actually want in production?

Think first, then tap
coreCalendars & Alignment

pd.Grouper for a combined ticker-and-month group-by without an index

Question

You have a long panel on a plain integer RangeIndex with columns date, ticker, and daily pnl, and you want each ticker's TOTAL pnl per calendar month, without first setting date as the index. Your first attempt, df.groupby(["ticker", df["date"].dt.month])..., gets month confused across different years. What's the right tool, and what does it buy you over the index-based resample you've used before?

Think first, then tap
hardFeature Construction

An interaction feature built from two already-neutralized signals can quietly reintroduce the very exposure neutralization was supposed to remove

Question

You have a value signal and a momentum signal, each cross-sectionally z-scored and sector-neutralized separately, so neither one carries a net sector bet by construction. You build an interaction feature as value_z times momentum_z to capture "cheap AND improving" stocks together. Does the interaction feature inherit that sector-neutral property automatically, and if not, why not?

Think first, then tap
hardBacktest Mechanics

A broker recalls your borrow: modeling a forced buy-in mid-backtest

Question

Your long-short backtest assumes any short position can be held as long as the signal wants, paying a constant borrow fee. In reality, a lender can recall shares at any time, forcing you to buy back the position within a day or two regardless of price -- sometimes during a squeeze, at a very adverse price. How do you add that risk to a vectorized backtest, and why does ignoring it bias your Sharpe?

Think first, then tap
coreData Assembly

stack, unstack, and MultiIndex

Question

You have a DataFrame indexed by (date, ticker) -- a MultiIndex -- with columns close and volume. Explain what unstack does here, what stack does, and when you'd reach for them instead of pivot and melt.

Think first, then tap
warmupFeature Construction

pd.qcut's duplicate bin-edge crash when too many names tie at the same feature value

Question

You rank a cross-sectional feature into deciles each day with pd.qcut(df["feature"], 10, labels=False), and it works fine most days but occasionally raises a ValueError about duplicate edges. What's causing that, and what's the simplest fix that doesn't just hide the problem?

Think first, then tap
hardPortfolio Construction

Black-Litterman: why the posterior returns don't just equal your views

Question

You have a market-cap-weighted equilibrium and a view that stock A will outperform stock B by 3%. Naively, you might think Black-Litterman just plugs your 3% view directly into the optimizer as stock A's expected return. Why doesn't it, and what does BL actually do differently from that naive approach?

Think first, then tap
coreCleaning & Corp Actions

MAD vs standard deviation

Question

You flag outliers as observations more than 4 standard deviations from the mean. On the worst data days -- fat-finger prints, flash events -- the filter catches almost nothing. Why does it fail exactly when needed, and what is the robust alternative?

Think first, then tap
corePortfolio Construction

Risk parity weighting (equal risk contribution per position) systematically overweights low-volatility assets relative to equal-dollar weighting -- and that's only harmless if vol and expected return are uncorrelated

Question

You're choosing between equal-dollar weighting and risk-parity weighting (each position contributes equal risk to the book) for a basket of uncorrelated assets with very different volatilities. Walk through what risk-parity weighting actually does to the dollar allocation, and when that reallocation is close to a free lunch versus when it quietly costs you expected return.

Think first, then tap
coreCleaning & Corp Actions

A limit-up/limit-down circuit breaker halt is a real move, not an outlier to clip

Question

A stock you track drops 18% in two minutes, triggers a trading halt, then reopens 15 minutes later. Your outlier filter, built to catch fat-finger prints, flags the drop and clips it. Is that the right call?

Think first, then tap
hardPoint-in-Time

Joining two point-in-time series with different reporting lags at the same date hides that one of them is always staler

Question

You build a "days to cover" short-squeeze feature by dividing short interest by average daily volume, both stamped as of the same date in your panel. Short interest is reported biweekly with a multi-day settlement lag; ADV is a trailing average you compute fresh every day. What's wrong with joining them "as of the same date", and how do you fix it?

Think first, then tap
hardData Assembly

Silent dtype drift in pipelines

Question

A daily job concatenates each new day's file onto a growing price table. Months later, someone notices df["close"].dtype is object and everything downstream is slow. Nothing ever raised an error. Reconstruct what likely happened and how to make this fail loudly.

Think first, then tap
hardStatistics

Fama-MacBeth two-pass regression: why averaging monthly coefficients fixes the standard error, not just running them monthly

Question

You want to estimate the premium the market pays for a characteristic (say, a value factor) across your universe over a 10-year panel. A teammate suggests just pooling every (stock, month) observation into one giant cross-sectional regression. You suggest Fama-MacBeth instead -- running a separate cross-sectional regression each month, then averaging the monthly coefficients. Why does the averaging approach matter here, not just the running of monthly regressions?

Think first, then tap
coreCleaning & Corp Actions

A single fat-finger trade blows up a std-based outlier filter -- median absolute deviation doesn't

Question

You flag outlier prints in a trade tape using abs(price - mean) / std > 5. One fat-finger trade at 10x the normal price slips through undetected even though it's an obvious error by eye. Why does a single extreme value make a std-based filter MORE likely to miss it, not less, and what should you use instead?

Think first, then tap
coreFeature Construction

One-hot vs target encoding for a categorical sector feature

Question

You want to feed GICS sector as a model input alongside your numeric features. One-hot encoding it gives you ~11 sparse binary columns; a teammate suggests target encoding instead -- replacing each sector with the historical mean forward return for stocks in that sector. Which do you use, and what's the risk with the second approach?

Think first, then tap
coreFeature Construction

Interaction features

Question

A PM suspects value works better among high-quality companies. How do you build an interaction feature to capture that, and what discipline keeps interaction-mining from becoming overfitting?

Think first, then tap
corePoint-in-Time

merge_asof's direction= parameter: 'nearest' silently reaches into the future

Question

A teammate's feature pipeline uses pd.merge_asof(prices, fundamentals, on="date", direction="nearest") to attach the closest available fundamentals snapshot to each price date, reasoning that "nearest" just means the best match. What's wrong with that choice for a point-in-time pipeline, and what should it use instead?

Think first, then tap
hardCleaning & Corp Actions

Merging two already-adjusted vendor price histories can double-apply the same dividend

Question

You splice a legacy vendor's total-return price history with a new vendor's series going forward, and both claim to already be dividend-adjusted. Months after the splice date, the combined series' cumulative return looks too high relative to the raw price change plus known dividends. What's the likely mechanism, and how would you check for it?

Think first, then tap
warmupFeature Construction

Winsorizing a feature cross-sectionally (per day) vs over the whole panel history: why per-day is almost always the right default

Question

You have a raw feature -- say, a value multiple -- computed for every stock on every day over 5 years, and some values are extreme outliers you want to clip before feeding the model. Would you winsorize using percentile cutoffs computed over the ENTIRE panel's history, or separately for EACH day's cross-section? Why does it matter?

Think first, then tap
hardCleaning & Corp Actions

Negative prices and why log returns break

Question

In April 2020, front-month WTI crude oil futures traded to about -37 dollars a barrel -- a genuine, real print, not a data error. Your pipeline computes daily log returns as np.log(price_t / price_t_minus_1) for every instrument uniformly. What happens on that day, and how do you handle an asset class where price can legitimately go negative?

Think first, then tap
hardStatistics

Deflated Sharpe ratio: correcting for having tried many strategy configurations before picking the best one

Question

You backtested 200 variants of a signal (different lookback windows, different universes) and the best one has a Sharpe ratio of 1.8. How do you adjust your confidence in that 1.8 for the fact that you tried 200 things and only reported the winner?

Think first, then tap
warmupPortfolio Construction

Kelly criterion: why full Kelly is too aggressive

Question

For a repeated bet with edge (probability of winning p, even-money payoff), the Kelly criterion says bet a fraction f = 2p - 1 of your bankroll to maximize long-run growth rate. A junior researcher proposes sizing every position at its full Kelly fraction. What goes wrong in practice, and what do practitioners actually do?

Think first, then tap
coreData Assembly

groupby().cummax() for a per-ticker running high, and why the running max staying NaN-safe doesn't make the rest of the row NaN-safe

Question

You need a "distance from the running high" feature across a panel of (date, ticker) rows. A teammate writes a Python loop tracking each ticker's max-so-far by hand. How do you do this with cummax() instead, and what actually breaks if the panel has rows missing for days a ticker didn't trade?

Think first, then tap
coreData Assembly

DataFrame.align()'s default join='outer' silently widens your universe to the UNION of two panels' tickers

Question

You have a prices panel covering 480 tickers today and a signal panel covering 460 tickers (20 names dropped for thin history). You call prices.align(signal, axis=1) to line up columns before computing signal-weighted returns. How many columns does the result have, and what's sitting in the extra ones?

Think first, then tap
corePortfolio Construction

Baking an ADV-based position size cap directly into the optimizer

Question

Your mean-variance optimizer keeps proposing a position in a small-cap name that's 3x the stock's own 20-day average daily volume (ADV). You could just clip the weight after the fact, but your interviewer asks why that's worse than building the constraint into the optimization itself.

Think first, then tap
hardFeature Construction

Choosing lookback windows

Question

How do you choose the lookback window or halflife for a feature -- say a volatility estimate or a momentum signal? "Grid search the backtest" is not an acceptable answer.

Think first, then tap
coreCalendars & Alignment

tz-naive vs tz-aware

Question

Explain the difference between a tz-naive and tz-aware timestamp in pandas, and the difference between tz_localize and tz_convert. Your intraday file has timestamps like "2024-03-08 16:00:00" with no zone -- what do you do?

Think first, then tap
hardBacktest Mechanics

Ex-date reinvestment fiction: total-return prices vs cash you don't actually have yet

Question

Your long-short backtest uses total-return-adjusted prices (dividends already baked into the adjustment factor) and runs P&L off day-over-day price changes as usual. A teammate points out this implicitly assumes dividends are reinvested on the ex-date, but real cash dividends aren't received and available to deploy until the pay date, sometimes 3-6 weeks later. Does this matter, and how do you fix it without abandoning total-return-adjusted prices?

Think first, then tap
hardStatistics

Diebold-Mariano test: is Model A's forecast really more accurate than Model B's?

Question

You have two competing return-forecasting models scored out-of-sample over the same 500 days, and Model A has a lower mean squared forecast error than Model B. Your PM asks if that difference is statistically meaningful or could be noise. A plain paired t-test on the two error series is tempting -- what's the more appropriate test here, and what does it fix that the paired t-test doesn't?

Think first, then tap
hardPerformance Analytics

Treynor-Mazuy: testing whether a strategy dynamically times its market exposure

Question

A strategy shows a strong Sharpe ratio and a market beta near zero from a standard single-factor regression. Your PM asks: is this genuine stock-selection alpha, or is the manager secretly increasing market exposure right before up-moves and cutting it before down-moves -- timing skill that a plain linear regression can't distinguish from selection skill? How do you actually test for that?

Think first, then tap
coreCleaning & Corp Actions

Filtering a single fat-finger print with a rolling median and MAD, instead of a fixed percent-move threshold

Question

A single bad print -- a trade reported at 10x the surrounding price, probably a fat-finger or feed glitch -- shows up in your tick data. A fixed threshold like "reject any tick more than 5% away from the previous tick" works for liquid names but constantly false-positives on names that are legitimately volatile intraday. What's a better filter?

Think first, then tap
hardBacktest Mechanics

Whole-share rounding: the gap between simulated and tradable weights

Question

Your vectorized backtest computes target weights as continuous fractions of a 10 million dollar book and multiplies directly by returns -- standard weight-space P&L. For a strategy trading mostly small-caps priced around 8 dollars a share with 1 percent average position size (100,000 dollars per name), how might the simulated return differ from what a real, whole-share-only portfolio would have earned, and how do you estimate the gap?

Think first, then tap
hardCalendars & Alignment

CustomBusinessDay's rollforward vs rollback: snapping an arbitrary date to the nearest valid trading day

Question

You need to snap an arbitrary settlement date -- which might fall on a weekend or an exchange holiday -- forward to the next valid trading day for a rebalance schedule. What's the right tool, and what's the subtle trap that causes an off-by-one here?

Think first, then tap
hardStatistics

Permutation test for a signal's IC significance, as an alternative to Newey-West

Question

You've computed a signal's average IC (information coefficient -- the rank correlation between the signal's cross-section and next-period returns) over 5 years of monthly rebalances, and it's 0.03, positive. Instead of relying on a Newey-West-adjusted t-stat, your interviewer asks you to test significance with a permutation test. Walk through it.

Think first, then tap
coreData Assembly

Slicing a MultiIndex safely with pd.IndexSlice

Question

You've pivoted a panel into a DataFrame with a MultiIndex on the columns (level 0 = field, like "close" or "volume"; level 1 = ticker). How do you select every ticker's "close" column at once, and why does df["close", "AAPL"] sometimes work fine while a partial slice across levels breaks?

Think first, then tap
corePerformance Analytics

Attributing P&L to factor exposures

Question

Your book returned 2.3% last month. The PM wants to know how much of that came from your stock-picking versus how much came from unintentional exposure to well-known factors like momentum and value that happened to do well. How do you decompose the P&L, and what does the leftover residual actually mean?

Think first, then tap
hardStatistics

Minimum Backtest Length: is 3 years even enough data to trust a Sharpe found via search

Question

A colleague backtested 200 variations of a signal (different lookback windows, different neutralization schemes) and is excited about the one with a Sharpe of 1.8 over 3 years of daily data. Before even looking at the Deflated Sharpe Ratio math, is 3 years of data even long enough to trust ANY Sharpe estimate found this way, regardless of how many trials you correct for?

Think first, then tap
hardStatistics

Comparing two correlated strategies' Sharpe ratios: the Jobson-Korkie/Memmel test

Question

Strategy A has a backtested Sharpe of 1.8, Strategy B has 1.3, both estimated on the same 5 years of daily returns. The two return series are correlated at about 0.6, since they trade overlapping instruments. Can you use a plain two-sample t-test (or Welch's) to say A's Sharpe is significantly higher than B's, and if not, what should you use instead?

Think first, then tap
corePoint-in-Time

Grouping a fundamentals panel by fiscal-period-end alone, without also respecting each company's own filing date, mixes information sets that were never actually simultaneously knowable

Question

You build a cross-sectional value factor "as of" each fiscal quarter-end, using every company's Q1 EPS for that quarter. Company A files its 10-Q eleven days after quarter-end; Company B, in a different industry, files six weeks later. Why is grouping strictly by fiscal-period-end -- rather than by filing date -- a point-in-time problem, even though every number used truly belongs to "Q1"?

Think first, then tap
hardBacktest Mechanics

Walk-forward validation vs a single train/test split

Question

You tune a lookback window and a threshold for a signal using an 8-year sample split 70/30 into train and test. It looks great out of sample. Your PM asks you to redo it with walk-forward validation before it goes live. Why isn't the single split good enough, and what does walk-forward buy you?

Think first, then tap
coreBacktest Mechanics

Sizing trades off compounding NAV vs a fixed initial notional

Question

Two vectorized backtests of the same signal and same weights differ only in one design choice: Backtest A recomputes dollar position sizes each day off the CURRENT, compounding portfolio NAV; Backtest B sizes every day's positions off the FIXED initial capital, and just lets P&L accumulate in a separate cash-like account. Over a five-year backtest with a strong uptrend, why do these two report meaningfully different Sharpe ratios for the identical signal?

Think first, then tap
warmupCalendars & Alignment

Custom weekmask: markets with a Sunday-Thursday trading week

Question

You're building a master calendar that includes Saudi Arabia's Tadawul exchange, which trades Sunday through Thursday, not Monday through Friday like US markets. If you reindex Tadawul prices onto a standard pd.bdate_range, what breaks, and how do you build a calendar that actually matches?

Think first, then tap
warmupPoint-in-Time

Backtesting an alt-data signal further back than your desk ever had live access to it

Question

A satellite-imagery vendor sells you a signal with a backfilled history starting in 2015, but your firm didn't actually subscribe until 2021. You backtest the signal from 2015 and get a great Sharpe. What's the point-in-time problem here, separate from any row-level lookahead bias inside the data itself?

Think first, then tap
hardStatistics

Effective number of independent bets: correcting breadth in the Fundamental Law

Question

You're told the Fundamental Law of Active Management says IR ~ IC * sqrt(breadth), and your universe has 500 names, so you plug in breadth=500. Your realized IR is far below what that predicts even though your measured IC matches your estimate. What's the likely error in that breadth number, and how do you fix it?

Think first, then tap
coreBacktest Mechanics

Does it survive costs?

Question

Your strategy turns over 40 percent a day two-sided and costs are 5 bps per dollar traded. Gross Sharpe is 1.2 on 10 percent annualized vol. Walk me through whether it survives.

Think first, then tap
hardPerformance Analytics

Rolling correlation to a common factor: catching a market-neutral book quietly picking up exposure

Question

A market-neutral book is constructed to be beta-neutral at construction time (net beta ~0 on rebalance day), but over the following weeks between rebalances, the PM suspects it's drifting into a de facto momentum or value bet without anyone changing the intended factor tilts. How would you use a rolling correlation to actually catch this happening, rather than just re-checking beta on rebalance days?

Think first, then tap
coreBacktest Mechanics

Overnight vs intraday return decomposition

Question

You have a mean-reversion signal that looks solid on close-to-close returns, but you suspect its edge is concentrated in just the first few minutes after the open rather than spread across the trading day. How do you decompose a daily close-to-close return into its overnight and intraday components, and why does knowing the split change how you would actually trade the signal?

Think first, then tap
warmupData Assembly

to_numeric(errors='coerce') vs astype for a dirty numeric column

Question

A vendor's "shares_outstanding" column arrives as strings, and a few rows contain garbage like "N/A" or comma-formatted numbers like "1,234,000". You need it as float64. Why does df["shares_outstanding"].astype(float) blow up, and what's the safer way to coerce it?

Think first, then tap
hardStatistics

ADF test for stationarity before trusting a pairs-trade hedge ratio

Question

You've regressed stock A's price on stock B's price to get a hedge ratio for a pairs trade, and the spread (A minus beta times B) looks mean-reverting on a chart. Before you trust that and size the trade, what test should you run, and what exactly does a low p-value tell you that eyeballing the chart doesn't?

Think first, then tap
hardFeature Construction

Residual momentum: orthogonalizing price momentum against beta before using it as a standalone feature

Question

Your desk's 12-1 month momentum factor has been showing up as mostly a bet on high-beta names during risk-on months. How would you build a momentum feature that isn't just relabeled beta exposure, and what's the mechanism?

Think first, then tap
warmupData Assembly

Exploding a nested fills column with explode()

Question

A vendor's trade blotter has one row per parent order, but each order carries a column "fills" holding a Python list of (price, quantity) tuples for its partial executions -- some orders have one fill, others have a dozen. You need one row per individual fill for slippage analysis. What is the tool, and what should you check before and after?

Think first, then tap
hardCalendars & Alignment

DST and intraday alignment

Question

You align minute bars from New York and London to study lead-lag around the US open. Twice a year your alignment breaks by an hour for a few weeks. What is happening, and what is the robust design?

Think first, then tap
warmupPerformance Analytics

Tail ratio: a percentile-based alternative to skew for return asymmetry

Question

Your tearsheet reports skewness to describe whether a strategy's returns are asymmetric, but a single extreme day, a one-off flash crash print, swings the skewness number from positive to negative. A teammate suggests reporting the tail ratio instead. What is it, and why is it more robust to that one outlier?

Think first, then tap
hardCleaning & Corp Actions

A bonus issue (scrip issue) uses the opposite ratio convention from a stock split, and applying split logic inverts the adjustment

Question

You're ingesting corporate actions for an Indian-listed stock and see a "bonus issue 1:1" event. Your adjustment pipeline only knows how to parse split ratios in "new:old" form (a "2:1 split" means 2 new shares for every 1 old share). You feed "1:1" straight into the split handler and the adjustment factor comes out as 1.0 -- no adjustment at all -- even though the company doubled its share count. What's wrong, and what should the adjustment factor actually be?

Think first, then tap
warmupFeature Construction

rolling().apply(raw=False): the convenience that quietly kills vectorized speed

Question

You write a rolling feature with df["price"].rolling(20).apply(lambda s: s.iloc[-1] / s.iloc[0] - 1) to get a 20-day return, and it's noticeably slower than you'd expect for a one-line pandas operation. What's the hidden cost, and how do you fix it?

Think first, then tap
coreCalendars & Alignment

Merging a date-keyed fundamentals table against a tz-aware intraday index: a silent zero-match join

Question

Your fundamentals table has a column reported_date built from plain python datetime.date objects, one row per company per quarter. Your intraday price panel has a tz-aware pd.Timestamp index in US/Eastern. You merge the two on a normalized date key from each side and get zero matches, even though you can see overlapping dates with your own eyes in both frames. What's actually going wrong, and how do you fix it?

Think first, then tap
warmupPerformance Analytics

Decomposing an international portfolio's return into local-currency return and FX translation effect, instead of reporting one blended USD number

Question

A US-dollar-based fund's Japanese equity sleeve returns 8% in yen terms this year, but the yen weakened 10% against the dollar over the same period. What does the tearsheet's single USD return number for that sleeve hide, and how do you split it apart?

Think first, then tap
hardCalendars & Alignment

US and UK clocks change on different Sundays -- a hardcoded offset pair breaks for exactly one week a year

Question

You align US equity intraday data (quoted in America/New_York) with UK equity intraday data (quoted in Europe/London) by converting both to UTC using fixed constants: NY is UTC-5, London is UTC+0. Most of the year the alignment looks right. But every March and November, for about one week, trades that should line up minute-for-minute are off by an hour. What's happening, and what's the fix?

Think first, then tap
warmupPerformance Analytics

Time under water: drawdown duration vs drawdown depth

Question

Two strategies both have a max drawdown of exactly 15%. Strategy A recovers to a new equity high within 3 months every time it draws down. Strategy B, on its worst drawdown, took 22 months to recover. Max drawdown alone treats these identically. What statistic captures the difference, and how do you compute it from an equity curve?

Think first, then tap
coreData Assembly

Copy-on-Write: pandas 2.x changes view vs copy rules

Question

You upgrade a research pipeline to a pandas version with Copy-on-Write enabled by default. A function that used to mutate a slice and have that silently NOT touch the caller's frame still behaves the same way -- but a different old pattern, one that relied on a returned slice sharing memory with its source so a mutation would propagate back, now quietly stops working. What does Copy-on-Write actually change, and what discipline does it reward?

Think first, then tap
hardStatistics

Combining multiple independent backtests' Sharpe estimates with a random-effects meta-analysis instead of simple averaging

Question

You've run the same strategy idea on five independent, non-overlapping historical regimes (different market periods) and gotten Sharpe estimates of 1.8, 0.4, 2.1, 0.9, and 1.5, each with its own standard error from the regime's length. Your boss wants one combined estimate with a confidence interval. Why is a plain average across the five numbers the wrong tool here?

Think first, then tap
warmupPerformance Analytics

Hit rate as a misleading standalone performance metric

Question

A strategy has a 65% hit rate -- 65% of trades are profitable -- but a portfolio manager is skeptical it's actually a good strategy. Why might a high hit rate not translate to good risk-adjusted returns, and what else do you need to look at?

Think first, then tap
hardPerformance Analytics

A strategy with a 30% win rate can be strongly profitable, and one with a 70% win rate can lose money -- hit rate alone tells you almost nothing

Question

A trend-following strategy wins only 32% of its trades but has run profitably for years. A separate mean-reversion strategy wins 68% of its trades but has been bleeding money. Your PM is confused because "more than half the trades win." Walk through why hit rate is the wrong single number here, and what you'd compute instead.

Think first, then tap
coreBacktest Mechanics

A stock splits while your backtest holds a position

Question

Your backtest tracks weight-space returns (target weight times daily return, as in the standard vectorized P&L), using unadjusted-looking daily returns that are actually already computed from split-adjusted prices upstream -- so the return series itself is clean, per the earlier back-adjustment cards. A junior researcher asks: does anything special need to happen in the P&L engine itself on a split's ex-date, given the return series is already adjusted? What is the one thing that is easy to get wrong even with clean returns?

Think first, then tap
coreFeature Construction

Forward-filling a monthly fundamental feature into a daily panel inflates your effective sample size

Question

You forward-fill a monthly-reported fundamental (say, a valuation ratio from quarterly filings) across every trading day so each daily row has a non-null feature value, then run a daily cross-sectional regression of returns on this feature over a year of data, treating it as roughly 252 times the universe size in independent observations. What's wrong with that count, and what does it imply for how you interpret the regression's significance?

Think first, then tap
corePerformance Analytics

Implied full-Kelly leverage from a backtested Sharpe ratio, and why it's an upper bound

Question

A strategy backtests to an annualized Sharpe of 1.5. Someone on the desk says "that means full Kelly sizing would put on about 1.5x leverage." Where does that number come from, and why should you treat it as an optimistic ceiling rather than a sizing recommendation?

Think first, then tap
#1 of 1044