From the
options-buyer-system-v2skill — the lesson that fixed chronic CE/PE confusion in V1. If tumne bhi "ek model se sab kuch" try kiya hai aur fail hue ho, ye padho.
V1 ki galti (root cause)
Ek XGBoost model se ek fuzzy sawal pucha: "CE ya PE?" — raw premium data se. Premium ek transformed signal hai (underlying move × delta × gamma × IV × theta × spread × strike distance × liquidity). Model ne noise utna hi seekha jitna signal. Direction puchne ke bajaye, humne premium ko direction padhne ki koshish ki — galat tha.
Evidence (V1 logs se)
- Balanced accuracy months tak 51-61% atki (hyperparams kabhi tune nahi hue,
lr=0.02, depth=3defaults). - Partition bug ne
iv_change_1dpoora zero kar diya silently (single-row group shift). - Rollup flag ne 15m bars 1 row/day compress kar diye — 760× data loss (387 sequences instead of 295K+).
- Live paper: 31.6% win, −₹90.3k PnL, confidence sirf 55-64%.
V2 principle: split the question
underlying mechanics → side, range, ETA, invalidation
option chain scanner → contract worth paying for?
XGBoost (many heads) → thin calibrated learner on clean mechanics
Underlying side decide karta hai; option contract execution eligibility. CE/PE premium validate kiya jata hai, seekha nahi. V1 mei ye dono mix the.
Many shallow heads, not one deep model
Alag narrow heads:
underlying_up/down_touch_(15/30/60)m-
ce_1p3x / ce_1p5x / ce_2p0xaurpe_1p3x / pe_1p5x / pe_2p0x(alag CE/PE) no_trade_quality
Ye ek change V1 ke CE/PE confusion ko khatam karta hai. Meta-label: "mechanics ne side pick kiya, ab kya humein ye trade lena hai?" — ye ek sawal confusion hata deta hai.
Shallow regularized grid
lr 0.015-0.035 | n_est 800-2000 (early stop) | max_depth 2-3
min_child_weight 12-40 | gamma 0.1-2.0 | subsample 0.65-0.90
colsample 0.55-0.85 | reg_alpha 0.5-3.0 | reg_lambda 6-20
scale_pos_weight = min(neg/pos, 8.0)
V1 ke intraday head mei 1280 mei sirf 8 features non-zero gain the. Shallow + regularized jawab hai.
Truth-quality tiering
truth_weight = 1.00 PAIR_FULL + fresh
= 0.70 PAIR_PARTIAL + fresh contract
= 0.40 LTP_ONLY
= 0.20 MIXED_PAIR
= 0.00 stale / timeout / broken
Rows at 0.00 training se exclude, never down-weight-keep.
Null-safe contract
Har feature ka explicit null policy: forward_fill_within_session, zero_is_valid_default, require_and_drop_row, median_impute_with_flag. fillna(0.0) blind use BANNED (V1 ka iv_change_1d bug yahin se aaya).
Overfit gate (hard promotion)
overfit_gap = train_metric − test_metric. > 0.15 → BLOCK. Har head, har retrain pe log.
Label design (sharp heads)
- Triple-barrier:
y_up_touch/y_down_touch/y_no_touch, k∈(0.5/0.75/1.0) ATR, horizon∈(15/30/60/120)m. - Option buyer barriers:
y_1p3x, y_1p5x, y_2p0x+mae_before_1p5x+minutes_to_1p5x. Alag CE/PE. - AFT time-to-hit (censored survival).
- Meta-label: mechanics picks side, model answers "take trade?".
Real results (honest)
V2 abhi research stage hai. Direction skill real hai (top-decile 60.5% accuracy) par fixed-SL backtest PF 0.53 (losing). Kyun? Microstructure beats prediction — 0.6/1.8 ATR SL/TP pe price SL touch kar leta hai TP reverse hone se pehle. Lesson: directional edge alone enough nahi.
Comparison V1 vs V2
| Aspect | V1 | V2 |
|---|---|---|
| Model | 1 deep | many shallow |
| CE/PE | confused | separate heads |
| Nulls | silent fill | explicit policy |
| Validation | k-fold | purged+embargo |
| Promotion | manual | automatic gate |
| Hyperparams | default | tuned (Optuna) |
FAQ
Q: Kyun alag CE/PE heads? Premium transformed hai, dono side alag dynamics.
Q: Shallow kyun? Deep overfit karta hai 1280 features mei.
Q: PF 0.53 matlab? System abhi losing hai, hidden nahi.
Q: Live trade? Nahin, paper/research only.
Common mistakes (V1 se)
- Fuzzy single question ("CE ya PE?").
- Blind fillna(0).
- Rollup flag ignore (760× loss).
- Default hyperparams.
- Promotion bina gap check.
What I learned
V1 ka sabse bada error: direction aur execution ek model mei mix kar diya. V2 ne split kiya — underlying side decide karta hai, contract eligibility alag. Plus null-safety aur gate ne silent bugs rok diye.
Research only. Not investment advice.
Deep dive: feature families (real contract)
12 families, 117 columns:
- Price Action (25): rvol, ATR(14), effort, close_loc, wick_bias, range HH/LL, accept/retest/failed-auction.
- Microstructure (12): close quality, inside-bar, velocity, trend, pressure.
- Order Flow (10): harmony, efficiency ratio, absorption up/down, aggressive/passive.
- Operator (4): expand/absorb signals.
- S/R + Breakout (6): sr_score [0-100], break_prob [5-95], bull/bear power.
- Time (2): hour_sin, hour_cos.
- Lag (6): prev_return_1/3/5, prev_vol_1/3/5.
- Multi-Timeframe (4): h1 close vs SMA, range ratio, vol ratio, h1 trend.
- Volatility Regime (3): vol_regime, contraction, expansion.
- Side Score (12): alignment, active side, CE/PE scores, gate states.
- Options (3): pc_vol_ratio, pc_oi_ratio, total_premium.
- Operator Anchor (12): anchor scores, accept zones, liquidity levels.
Feature importance well-distributed thi — koi single feature 25% se upar nahi. Top: prev_return_5 (21.3%), range_low (15.1%), atr (15.1%).
Real bug autopsy (V1)
- 25-bar label shift: index mismatch ne labels 25 bars shift kar diya. PnL −42% se −6.26% gaya fix ke baad.
- Ensemble meta-model mismatch: dimension error ne ensemble mara (val F1=0). Disabled.
- "Walk-forward" jo nahi tha: pipeline "walk-forward" print karti thi par single fixed split use karti thi.
- max_hold mismatch: labels 6 bars, backtest 8 — silent inconsistency.
Why shallow + regularized
V1 ke intraday head mei Optuna n_estimators=1080-1620 hardcoded production mei bhej diya — live prediction 10s gateway cap se timeout. V2 mei early-stop + timeout budget check. Plus depth 2-3, reg_lambda 6-20 — 1280 mei sirf 8 features non-zero gain the, regularizer ne noise prune kiya.
The promotion gate in code
overfit_gap = train_metric - test_metric
if overfit_gap > 0.15:
print("BLOCK promotion:", overfit_gap)
return
# else promote to shadow (paper) for >=1 session
V1 mei ye manual tha, V2 mei automatic har head pe.
Honest verdict
V2 cleaner architecture hai, par abhi bhi research. Directional edge real hai (60.5% top-decile) par microstructure usse eat kar leta hai PF 0.53 pe. Next: SL 1.0 ATR widen, trailing stops, ensemble re-enable, online learning, full options surface.
Research only. Not investment advice.
My V2 build workflow
- Label builder: triple-barrier + option-buyer barrier + AFT + meta-label, per-feature null-count report jo threshold breach pe fail karta hai.
- Feature builder: mechanics-first contract, sample-weighted (truth_weight × contract_weight × recency), clip [0.05, 3.00].
- Trainer: purged/embargoed CV, Optuna on buyer-relevant score, disjoint calibration.
- Replay report: chosen-side 1.5x/2.0x hit rate, MAE, time-to-hit, wrong-side rate — vs production baseline.
- Shadow (paper only): min 1 full live session before promotion talk.
- Promotion: only if replay AND shadow beat baseline. Evidence file paths log karo.
Why this matters for you
Agar tum apna options model bana rahe ho, V1 ki galtiyon se bacho: ek model mat banao, nulls silent mat karo, shallow rakho, gate lagao. Direction ≠ Profit — V1 ka sabse bada lesson.
FAQ extended
Q: Meta-label kyun? Mechanics side decide karta hai, model sirf "take trade?" batata hai — confusion khatam.
Q: Truth-weight 0 rows exclude kyun? Stale data model ko mislead karta hai, down-weight bhi galat.
Q: AFT labels? Censored survival — un-touched event ko exact time na do.
Q: Scale_pos_weight cap 8? Extreme imbalance calibration kharab karta hai.
Closing
Options-Buyer V2 ek lessons-learned rebuild hai. V1 ke saare bugs (null corruption, overfit, CE/PE confusion, single-model) address kiye gaye. Abhi PF 0.53 hai par architecture honest hai. Time + data se improve hoga.
Research only. Not investment advice. SEBI compliance separate topic.
Summary
V1 fail hua kyunki ek model ne direction aur execution dono seekhne ki koshish ki. V2 ne split kiya: underlying side decide karta hai, contract eligibility alag, aur multiple shallow heads CE/PE confusion khatam karte hain. Null-safety + overfit gate ne silent bugs rok diye. Architecture abhi losing hai (PF 0.53) par honest hai.
Research only. Not investment advice.
Action plan
Agar tumhare paas V1 jaisa model hai jo fail ho raha:
- Ek model ki jagah multiple heads banao (CE alag, PE alag).
- Underlying mechanics ko side decide karne do, premium sirf validate karo.
- Har feature ka null policy likho,
fillna(0)hatao. - Purged CV + overfit gate lagao.
- PF 1.0 se upar lane ke liye exit logic fix karo (SL widen, trailing).
Ye 5 steps V1 ke 31.6% win ko fix karne ki foundation hain.
Research only. Not investment advice.
Next article mei hum dekhenge signal gate design — kaise NO_TRADE bolna system ko bachata hai 90% false trades se. Wo V2 architecture ka final piece hai.
Research only. Not investment advice. SEBI compliance separate topic.
Agar tumhare model mei bhi CE/PE confusion hai, architecture rebuild karo V2 jaise. Ek model enough nahi hai complex options dynamics ke liye.
The blueprint is open — build your own V2, dont repeat V1 mistakes.
More From Shakti Tiwari
- 🌐 Websites: shaktitiwari.github.io/shakti-tiwari-nse · OptionTradingWithAI.in
- 📚 Books: Build Your Own AI (Amazon) · Option Trading with AI (Amazon)
- 💬 Community: Discord · X · about.me
- 💻 Code: GitHub/shaktitiwari
- 🏛️ Entity: Wikidata Q140689249
Top comments (0)