software-factory
MAmattpocock/skills337k4,978 new stars in the last 7 days
Detect IBD-style Distribution Days for QQQ/SPY (close down at least 0.2% on higher volume), track 25-session expiration and 5% invalidation, count d5/d15/d25 clusters, classify market risk (NORMAL/CAUTION/HIGH/SEVERE), and emit TQQQ/QQQ exposure recommendations. Use after market close, before TQQQ exposure changes, or as input to FTD/market-state frameworks. Does not execute trades.
QQQ is a Nasdaq-100 ETF proxy, not the Nasdaq Composite (^IXIC). SPY is an ETF proxy, not ^GSPC. DD counts use the named symbol's own price and volume; ETF counts are not official index counts. Select explicit symbols with --symbols; missing data must not trigger substitution or a mixed series. The risk classes and TQQQ policy are this tool's separate heuristics, not a calibrated FTD success probability (calibration remains #676).
Detect IBD-style Distribution Days for major market ETFs (QQQ as Nasdaq proxy, SPY as S&P 500 proxy) and produce a daily market deterioration signal plus a TQQQ/QQQ exposure recommendation. Designed for post-market review.
Invoke this skill:
Do NOT use this skill to:
--api-key, set config.data.api_key, or set the FMP_API_KEY environment variable, in that priority order.PyYAML>=6.0 and requests>=2.31.0 (see requirements.txt).--as-of YYYY-MM-DD for backtesting against a historical session.--config for a readable UTF-8 YAML mapping. Empty/null documents use defaults. Configuration read/parse errors and invalid top-level, data, strategy_context or indexes shapes return exit 1 on stderr before provider access; correct the file/path and retry. YAML error diagnostics do not echo file contents.--api-key, config.data.api_key, or FMP_API_KEY env var (in that priority order).A Distribution Day is detected when:
volume_reference: "previous_full_session" and volume_reference_date.A Distribution Day is removed from the active count when either:
Today's DD is never invalidated immediately because there are no post-DD sessions to evaluate the 5% gain against.
d5_count / d15_count / d25_count count active records with age_sessions <= N.| Risk | Trigger |
|---|---|
| NORMAL | d25 <= 2 |
| CAUTION | d25 >= 3 |
| HIGH | d25 >= 5 OR d15 >= 3 OR d5 >= 2 |
| SEVERE | d25 >= 6 OR d15 >= 4 OR (market_below_21ema_or_50ma AND d25 >= 5) |
When both QQQ and SPY are loaded, QQQ-weighted overall logic applies (TQQQ-aware): a single SEVERE escalates to SEVERE; QQQ HIGH escalates to overall HIGH; QQQ NORMAL + SPY HIGH still escalates to HIGH (broad-market spillover).
| Risk | Action | Target Exposure | Trailing Stop |
|---|---|---|---|
| NORMAL | HOLD_OR_FOLLOW_BASE_STRATEGY | 100% | base |
| CAUTION | AVOID_NEW_ADDS | 75% | min(base, 7%) |
| HIGH | REDUCE_EXPOSURE | 50% | min(base, 5%) |
| SEVERE | CLOSE_TQQQ_OR_HEDGE | 25% | min(base, 3%) |
QQQ uses a less aggressive policy (HIGH=75%, SEVERE=50%) since it lacks 3x leverage.
get_historical_prices).prepare_effective_history so effective_history[0] is the evaluation session.high_since, invalidation event, and status.d5 / d15 / d25 active records.market_below_21ema_or_50ma (None if data insufficient).--output-dir with API keys redacted.Saved to reports/ (or --output-dir):
ibd_distribution_day_monitor_YYYY-MM-DD_HHMMSS.jsonibd_distribution_day_monitor_YYYY-MM-DD_HHMMSS.mdJSON is UTF-8 with ensure_ascii=False (Japanese explanations preserved). Sensitive keys (api_key, fmp_api_key, token, etc.) are redacted automatically.
config/default.yaml is changed deliberately.audit.symbols_unavailable (reason: plan_gated) and in the Markdown audit block. A plan restriction is not a market result.python3 skills/ibd-distribution-day-monitor/scripts/ibd_monitor.py \
--symbols QQQ,SPY \
--lookback-days 80 \
--instrument TQQQ \
--current-exposure 100 \
--base-trailing-stop 10 \
--output-dir reports/
FMP API key required. The call volume of a daily QQQ + SPY run is small, but on the free plan QQQ history can be refused (HTTP 402/403) while SPY works. The run then reports the symbol as plan-gated instead of a clean market read, and a paid plan may be needed (see docs/en/getting-started.md#fmp-plans).
ftd-detector: Bottom confirmation via Follow-Through Days (counterpart of this top-side signal).market-top-detector: Composite 0-100 top probability score using O'Neil distribution + other components.position-sizer: Convert risk-management recommendations into share counts.Accept finite positive numeric closes (including numeric strings). Treat missing/null, boolean, nonnumeric, non-finite, zero and negative closes as unavailable. Retain their dated session slots: never join sessions across a price gap for DD detection, age counting or moving averages. Audit skipped calculations by date. EMA requires valid closes throughout its input history; SMA requires a valid latest-period window. Unavailable or overflowed MA comparisons and the combined filter are null, not bearish signals.
Historical --as-of reports audit only the effective history; future close defects do not affect historical exposure decisions. Overflowed price returns or DD invalidation thresholds are null with audit evidence; an unavailable threshold cannot invalidate a DD. Counts/risk from incomplete prices are observations, not evidence of safety. If either effective index has invalid closes or non-finite derived price arithmetic, block exposure increases (AVOID_NEW_ADDS, target capped at current exposure); preserve policy reductions and trailing stops. See invalid_close_data, non_finite_price_arithmetic, non_finite_moving_average and incomplete_price_evidence_no_adds in the audit. Repair/re-fetch the affected dates before using the report to increase exposure. This close-price guard does not validate every volume/high field or certify market-data completeness.
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
DIDietrichGebert/ponytail203k4,904 new stars in the last 7 days