On 15 Sep 2026 the twenty session realised volatility of the Nifty was 7.3% a year. Across the 300 sessions in the NSE file that ends that day, the same measure ran from 5.2% to 29.5%. A model fitted inside one of those regimes has learned that regime, and nothing in its score says so. Machine learning works well where data carries a lot of signal. Market data carries little, comes as one history and keeps changing, so most of the work sits in the method around the model. This module is about that method. It is education: it names no strategy, promises no result and makes no call on any contract.

3By the end you can

  1. Build a label and a validation split that respect overlap, with purging and an embargo.
  2. Work out the effective sample, the noise in a hit rate and the chance a lucky variant passes.
  3. Turn a model probability into a size with ruin in view, inside the Indian algo framework.
A blue wireframe surface on navy, a lit path descending its slope to the lowest point

The idea, plainly

Why is market data hard for machine learning?

Four facts do the damage, and a good algorithm cannot remove any of them.

  • Small signal. Daily returns are mostly noise, so a model can fit noise and look skilful.
  • One history. The past cannot be re-run, so each idea is tested on the same data again and again.
  • A moving process. Volatility, correlations, lot sizes, tax rates and settlement rules change.
  • Overlapping labels. A label that looks ahead several days shares most of its days with its neighbours, so the sample is smaller than the row count.

The regime moves: twenty session volatility ran from 5.2% to 29.5%

Nifty twenty session realised volatility from 1 Jul 2025 to 15 Sep 2026, with a low stretch and a high stretchNifty 20 day realised vol: from 10.1% at 1 Jul 2025 to 7.3% at 15 Sep 2026, high 29.5% at 8 Apr 2026, low 5.2% at 1 Sep 2026.5%10%15%20%25%30%Jul 2025OctJan 2026AprJul7.3%
Percent a year, close to close over twenty sessions. A model fitted on the low stretch has never seen the high one, and the reverse. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.

A fit that is good inside one stretch can be poor in the next, and a single train and test split cannot tell the two cases apart. That is why the checks below are about how the data is cut, not about which model is used.

What does a careful pipeline look like?

Each stage can fail without any error message, and a later stage cannot repair an earlier one. The map is a method, not a result.

A model passes seven checks before its score is worth reading

Seven stages of a careful machine learning pipeline for market data: point in time data, features, labels, sample weights, purged validation, a trial ledger, and size with costs and rulesDiagram with 7 boxes. Point in time data to Features; Features to Labels; Labels to Sample weights; Sample weights to Purged validation; Purged validation to Trial ledger; Trial ledger to Size, costs, rules.Point in time datadated, never revisedFeaturesknown at decision timeLabelswhat a trade could earnSample weightsundo the overlapPurged validationpurge and embargoTrial ledgercount every variantSize, costs, rulesafter charges, inside theframework
A method map, with no market figures. The ledger and the cost stage are the ones most often skipped. Source: RupeeCase method map, no market data. As of 17 Oct 2026.
  • Data: each value as it was known on its date, not as later revised.
  • Features: only what was known when the trade would have been placed.
  • Labels: what a trade could earn after costs, not an arbitrary next day sign.
  • Ledger: a count of every variant tried, kept even for the ones that failed.

How should a label be built?

A fixed horizon label asks whether the price is higher in a set number of days. A triple barrier label is closer to a trade. It sets a profit barrier, a loss barrier and a time barrier, each scaled to recent volatility, and records which was touched first. Barriers wide in quiet markets and narrow in noisy ones keep the label comparable across regimes.

Meta-labelling splits the job. A simple rule decides the side of a trade, and a second model decides whether to take it and how large. The second model sees fewer, more selective rows, which is where overfitting waits.

Why does overlap shrink the sample?

Label each day with the return of the next three. Today's label and the next day's label share two of their three days, so they are not independent rows. Counting them as independent overstates the evidence by about the horizon, and a fit on overlapping rows looks sharper than the data supports.

The maths: effective sample size

Uniqueness of a label =
average of 1 over the
number of labels sharing
each of its days
Effective N = sum of
uniqueness over all labels

With a horizon of h days and one label a day, each interior label shares its days with up to h minus one neighbours on each side, and its average uniqueness is close to one over h. The effective sample size is then about N over h. Sample weights equal to uniqueness give each stretch of time a fair say, and a weight can also scale with the size of the return, so large moves do not swamp the fit. The standard error of a hit rate p over N independent rows is the root of p times (1 minus p) over N, which at p of one half is one half over the root of N.

The term this section turns on: Effective sample size

The term this section turns on: Effective sample sizeThe term this section turns on: Effective sample size. Effective sample size: The number of independent rows a sample is worth once overlapping labels are accounted for. With a label horizon of h days and one row a day it is about N over h.Effective sample sizeThe number of independent rows a sample isworth once overlapping labels are accountedfor. With a label horizon of h days and...
From the module glossary; every term is in the Learn glossary too. Source: Module 19.14, Financial machine learning done carefully.

What do purging and an embargo do?

Ordinary k fold validation shuffles rows into folds. With overlapping labels, a training row just before a test fold has a label window that reaches into it, so the model has seen part of its own answer. Purging deletes training rows whose label windows overlap the test period. An embargo also skips a short stretch after the test fold, because serial correlation lets information leak forward.

  • Purge: drop training rows whose window crosses into the test fold.
  • Embargo: drop a further slice, often a small share of the sample, after it.
  • Walk forward testing, in module A29, never trains on the future by construction, but gives one path only.
The maths: combinatorial purged paths

Split the sample into N groups
Test k groups at a time
Splits = N choose k
Paths = splits times k over N

Each group appears in the test set in a share k over N of the splits, so the test results can be stitched into several full length paths instead of one. With six groups and two tested at a time that is 15 splits and 5 paths. A strategy then has a spread of results to read, not one number. Purging and an embargo apply to every split.

How many tries did it take?

Every variant tried on the same history is a draw from the same noise. The honest question is not whether a model scored well but how many were tried to find it. The bars show the chance that at least one of n useless variants clears two standard errors above a coin flip by luck, each with a 2.3% chance on its own.

Twenty tries on one history clear a lucky bar more than a third of the time

Chance that at least one of n useless variants clears two standard errors by luck: 2.3 percent for one, 10.9 for five, 20.6 for ten, 36.9 for twenty and 68.4 for fifty1 variant 2.3%; 5 variants 10.9%; 10 variants 20.6%; 20 variants 36.9%; 50 variants 68.4%.Chance that at least one useless variant clears the bar by luck1 variant2.3%5 variants10.9%10 variants20.6%20 variants36.9%50 variants68.4%
Arithmetic of one minus the chance of no hit, with each variant independent and useless. Real variants are correlated, so the true figure is smaller but still grows with every try. Not market data. Source: RupeeCase arithmetic, not market data. As of 17 Oct 2026.

This is why the ledger matters. Module E16 turns the count of trials into a deflated Sharpe ratio. Until the count is known, a good score is a number without a denominator.

Which features leak?

  • Revised data. A figure restated later was not available on its date.
  • Look ahead in code. A rolling window centred on the day, or a scaler fitted on the whole sample, uses the future.
  • Survivorship. An index list as it stands today leaves out the names that dropped out.
  • Corporate actions. A split or a bonus looks like a crash. The realised correlation file used in this course leaves out any name with a one day move above a quarter in a window, for that reason.
  • Rule changes. Lot sizes, STT and settlement methods differ by date, and a model fitted across them mixes two products.

The relationship between stocks moves too. The twenty session realised correlation among the fifty Nifty names, on a fixed weight set, ran from 0.04 to 0.60 between 24 Sep 2025 and 15 Sep 2026, and stood at 0.10 on the last day.

The link between the names moves: correlation ran from 0.04 to 0.60

Realised correlation of the Nifty 50 names over twenty sessions from 24 Sep 2025 to 15 Sep 2026, moving between a low and a high levelnifty-realised-corr: from 0.162 at 24 Sep 2025 to 0.098 at 15 Sep 2026, high 0.602 at 8 Apr 2026, low 0.035 at 1 Sep 2026.0.10.20.30.40.50.6Oct 2025Jan 2026AprJul0.1
Realised correlation implied by the Nifty's variance and the weighted volatilities of its fifty names, twenty session window, weights of 10 Jun 2026 held fixed. A feature built on it inherits this drift. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.

Which features matter, and how would anyone know?

Importance scores from a fitted model mislead when features are correlated: the score of one is split or stolen by its neighbours. Two checks help. Shuffle one feature at a time in a purged test fold and see how much the score falls, which is permutation importance. And test whether the features carry information in a fresh period, not only in the one used to rank them.

  • A feature that ranks high in training and low in a later period was fitting that period.
  • A cluster of related features is better judged as one group than one by one.
  • Fewer, simpler features are easier to audit and cheaper to retest.

How does a probability become a size?

A classifier outputs a probability, and a position size turns it into rupees. The Kelly fraction of an edge is the size that grows an account fastest if the edge is known exactly, and it is not known exactly. Sizes near or above it ruin accounts that have a real edge. The model below takes a rule that wins 52% of trades with equal wins and losses, so Kelly is 4% of the account.

Model, not market data

The same edge ruins few paths at a small size and most paths at twice Kelly

Model, not market data. Share of simulated paths that lose half the account over 250 trades for a rule that wins 52 percent of trades with equal wins and losses: none at 1 percent risk, about 1 at 2, about 19 at 4 and about 57 at 8Risk 1% a trade 0.0%; Risk 2% a trade 0.9%; Risk 4% a trade 18.9%; Risk 8% a trade 56.9%.Paths that hit the ruin level, percent of 2,000Risk 1% a trade0.0%Risk 2% a trade0.9%Risk 4% a trade18.9%Risk 8% a trade56.9%
A model of one assumed rule, not a strategy and not market data. Only the risk per trade changes between the bars, from one to eight percent; the two percent named in the inputs is the base case, the second bar. Inputs: win rate 52%, average win 1.00 times the average loss, 2% of the account risked on each trade, ruin at a 50% loss of the starting account, 250 trades, 2,000 simulated paths, seed 1. Source: RupeeCase model, seeded simulation. As of 17 Oct 2026.
Read one more paragraph, 48 words

At 4% of the account per trade, the size equal to Kelly, 19% of paths still lose half. At 8%, twice Kelly, 57% do. A model that scores well is not a size. Fractions of Kelly, set from a fixed risk budget, sit in module A31.

What happens after it goes live?

A model keeps being tested after launch, because the world it was fitted on keeps moving. A written plan for that, fixed before the first order, is part of the method.

  • Drift checks. Compare the live spread of features and of outcomes with the spread in training, on a schedule.
  • Stop rules. A drawdown or a run of misses that pauses the program, set in advance and not by feel.
  • Retraining. Each refit is a new variant. It goes in the ledger with its date and its data window.

What do the Indian rules add?

  • A program that sends orders through a broker's API is an algo order under SEBI's framework, whatever the model inside it (module A27).
  • Giving the model's signals or the algo to others is a different route, with its own registration and claims rules.
  • Past performance may be shown only as verified figures by firms permitted to do so. A chart of a backtest is not that.
  • SEBI's Aug 2026 study found 87.7% of individual F&O traders lost money in FY26. Costs and size decide many outcomes before any model does.
The RupeeCase terminal on sample data: Model history or your portfolio: which numbers am I looking at?
Watch in the terminal: which numbers am I looking at? A short tutorial on sample data.

Worked example: a three day label on the sessions in the file

The NSE file behind the volatility chart has 300 Nifty closes. Take a label that looks three sessions ahead and one row a day, and read what the sample can support.

  1. Rows. 300 closes give one row a day, before the last three rows lose their label.
  2. Overlap. Neighbouring labels share two of three days, so the effective sample is about 300 over three: 100 independent rows.
  3. Noise. The standard error of a hit rate over 100 independent rows is one half over ten: 5.0%.
  4. A bar. Two standard errors above a coin flip is a hit rate of 60%, before any cost, to be seen as unusual on this sample.
  5. Purge and embargo. With a three session label, drop 2 rows before a test fold, and an embargo of one percent of the sample is 3 rows after it.
  6. Trials. If ten variants were tried, the chance that one clears the bar by luck is 21%. If twenty, it is 37%.
Read one more paragraph, 59 words

The same arithmetic shows the limit of the exercise. A hit rate in the high fifties on this sample is within the noise, and a model with a hundred features has far more freedom than a hundred rows can pin down. More history and a smaller set of ideas are the cures. Neither is a feature of the model.

The common mistake

The claim: The model scored 70% accuracy on the test set, so it has an edge. A score says little until three things are known: how many variants were tried, whether the test rows overlapped the training rows, and what the trades earn after STT, charges and slippage. A hit rate does not give a payoff either, since a rule can win most trades and still lose money. Read a score as a hypothesis, test it on a later period it never touched, with costs charged, and quote the number of trials with it. The short answer is on the machine learning question page.

Two terms to hold on to from 19.14

Two terms to hold on to from 19.14Two terms to hold on to from 19.14. Triple barrier label: A label that records which of three barriers a trade touches first: a profit barrier, a loss barrier or a time limit, each scaled to recent volatility. Meta-labelling: A second model that decides whether to take the trade a simple rule proposes, and how large to make it. The rule sets the side, the model sets the take or skip and the size.Triple barrier labelA label that records which of three barriers atrade touches first: a profit barrier, a lossbarrier or a time limit, each scaled to...Meta-labellingA second model that decides whether to takethe trade a simple rule proposes, and howlarge to make it. The rule sets the side,...
From the module glossary. Source: Module 19.14, Financial machine learning done carefully.

Key takeaways

  • Market data has little signal, one history and changing rules.
  • Overlapping labels shrink a sample to about N over the horizon.
  • Purge training rows that overlap the test fold, then embargo what follows.
  • Count every variant tried: twenty tries clear a lucky bar often.
  • A probability is not a size. Kelly is a limit, not a target.
  • Test later data with costs charged, and quote the trial count.

Where this section sits in module 19.14

Where this section sits in module 19.14Where this section sits in module 19.14. 1. The idea, plainly 2. Worked example: a three day label on the sessions in the file 3. The common mistake 4. Key takeaways01The idea, plainly02Worked example: a three day labelon the sessions in the file03The common mistake04Key takeaways
Sections 1 to 4 of 4; the highlighted one is next. Source: Module 19.14, Financial machine learning done carefully.

Before you trade. Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. Read the SEBI study