Logo van Backtesting Alt Data Strategies With Realistic Availability Lag

Backtesting Alt Data Strategies With Realistic Availability Lag

Community
HimanshuJ16
backtesting-alt-data-strategies-with-realistic-availability-lag

Gebruik dit bij het backtesten van een alternatieve-datastrategie. Koppel elke waarneming aan de publicatiedatum, niet aan de datum van de gebeurtenis: het verschil tussen die twee is de oorzaak van onmogelijke backtestresultaten.

Add to TypingMind

Overzicht

UitgeverHimanshuJ16
RepositoryAlgo-Trading-Skills
Skillnaambacktesting-alt-data-strategies-with-realistic-availability-lag
Sterren
50
Forks
7
Meegeleverde bestanden
5
LicentieApache-2.0
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 5

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door HimanshuJ16 op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Backtesting Alt Data Strategies With Realistic Availability Lag in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtesting-alt-data-strategies-with-realistic-availability-lag
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/backtesting-alt-data-strategies-with-realistic-availability-lag .claude/skills/backtesting-alt-data-strategies-with-realistic-availability-lag
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Backtesting Alt Data Strategies With Realistic Availability Lag in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Backtesting Alt Data Strategies With Realistic Availability Lag automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Backtesting Alt Data Strategies With Realistic Availability Lag niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

When to Use

Alternative data (e.g., foot traffic, weather, credit card data) is almost never available on the day the event occurs. There is a processing, aggregation, and publication delay. Backtesting using the event_date instead of the publication_date creates massive Lookahead Bias, resulting in impossible simulated returns. Invoke this skill to wrap alternative datasets in a Point-in-Time (PIT) lag enforcer before feeding them to the backtest engine.

The two axes follow the SQL:2011 vocabulary this repository uses in backtest-database-schema-for-point-in-time-queries: valid time is event_date (when the event happened), knowledge time is the effective publication date (when the row became usable). A backtest may only read rows whose knowledge time has already passed.

When NOT to Use

  • Not a licensing or compliance control. Enforcing a lag says nothing about whether you are permitted to trade on the dataset. Material non-public information, vendor contract restrictions, and consent provenance are separate questions — see insider-trading-controls-for-alternative-data-usage and alternative-data-vendor-due-diligence-checklist.
  • Not a substitute for vendor snapshots. If the vendor overwrites history in place, no filter can recover what the file said last year. revision_key_cols only helps when the dataset already carries versioned rows. Without stored daily snapshots the backtest reads today's restated figures regardless.
  • Not an intraday engine. The knowledge-time axis is a timestamp, so intraday precision works if the vendor supplies it, but the fallback lag is whole days and availability_time is a single delivery time per dataset. Sub-daily arrival jitter is out of scope.
  • Not a data-quality check. It does not detect a vendor silently changing panel composition, coverage, or methodology mid-history, all of which distort a backtest as badly as look-ahead.
  • Not sufficient on its own. A correct lag on a universe selected with hindsight still leaks. Pair with backtest-look-ahead-in-universe-selection.

Prerequisites

  • Alternative data time-series loaded into a Pandas DataFrame.
  • A known publication_date for each record, OR a known default_lag_days taken from your vendor contract — published lags vary widely across vendors and products, so treat any figure quoted elsewhere as an illustration, not a default.
  • The backtest engine must request data as_of the current simulated trading date.
  • One timezone convention across the dataset and the as_of query; mixing naive and aware timestamps raises.
  • For restatement handling, columns that identify one logical observation (e.g. ["ticker", "event_date"]).

Workflow

  1. Initialize Enforcer: Wrap the alternative dataset in AltDataLagEnforcer. Construction validates the dataset and fails loudly rather than degrading the guarantee.
  2. Define Lags: Specify event_date_col, publication_date_col (if available), and a fallback default_lag_days. Naming a publication_date_col that is not in the frame raises — it will not quietly substitute the fallback lag. Pass publication_date_col=None to choose the fallback deliberately.
  3. Choose the Lag Calendar: default_lag_days is calendar days by default, matching the T+N convention vendors quote. Set lag_calendar="business" where the vendor's pipeline only runs on business days, and pass holidays= — business-day offsets skip weekends but not holidays.
  4. Decide the Delivery Time: A bare date lands at midnight, which asserts the file existed at 00:00. Set availability_time to the hour the vendor actually delivers, or time(23, 59, 59) for the conservative reading, so a 09:30 decision cannot read an 18:00 file.
  5. Handle Restatements: Set revision_key_cols so a query returns the version known on that date, rather than the original and every later revision together. Without it the enforcer logs a warning when duplicate event dates are present, and lag_audit()["duplicate_event_rows_without_key"] counts them.
  6. Simulate Point-in-Time: During the backtest loop, query the enforcer using get_point_in_time_data(as_of_date).
  7. Enforce Causality: The enforcer filters out any data where publication_date > as_of_date, guaranteeing the strategy cannot peek into the future.
  8. Audit the Guarantee: lag_audit() separates rows resting on a real vendor publication date from rows resting on the assumed lag. A high fallback_rows means the PIT guarantee is an assumption, not evidence. Pass include_effective_date=True to return the knowledge-time column so every admitted row is traceable.

Full procedure: see references/workflows.md. Standards reference: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Using Event Date as Trade Date: E.g., buying a retail stock on Black Friday because the "Black Friday Sales" alt-data row was exceptionally high. That data isn't published until Wednesday.
  • Ignoring Revision Bias: Data vendors often restate historical data. If the dataset does not have versioned rows (Knowledge Time vs Valid Time), the backtest is using the revised "perfect" data rather than the noisy initial estimate.
  • A Mistyped Publication Column Voiding the Guarantee: The single most dangerous failure. An enforcer that falls back to default_lag_days when the named column is absent replaces real publication dates with a guess — a real 2024-06-01 publication date became visible on 2023-11-27, six months early.
  • Returning Every Revision at Once: Without a revision key, a restated observation is returned twice — the original estimate and the revision — and any aggregation double-counts it.
  • Calendar Days Where the Vendor Means Business Days: A Friday event with a "3 day" lag becomes visible Monday under calendar counting and Wednesday under business counting. Across every weekend that is two days of look-ahead.
  • Weekend Events Under a Business Calendar: A Saturday event has no business-day pipeline start until Monday. Rolling backward to Friday before counting publishes a day early; this enforcer rolls forward.
  • Midnight Publication Timestamps: A date-only stamp read as 00:00 gives a full extra session of access to a file that may not land until the evening.
  • Publication Before the Event: A row whose publication date precedes its own event date is not a short lag — it is corrupt data claiming knowledge of an event that had not happened.
  • Negative Fallback Lags: A negative default_lag_days exposes data before its event. Rejected on construction.
  • Timezone Drift: Alt-data delivery times straddle midnight. A silent naive/aware mismatch shifts availability by a day; the enforcer raises instead.

Verification

  • Query the enforcer for as_of_date = 2023-11-25. An event that occurred on 2023-11-24 with a 3-day lag should NOT be returned.
  • Name a publication_date_col that does not exist and assert construction raises rather than falling back.
  • Feed a restated observation and assert that with revision_key_cols set, a query before the restatement returns the original value and a query after it returns the revision — exactly one row either way.
  • Assert Friday 2023-11-24 with a 3-business-day lag is invisible on Monday and visible on Wednesday 2023-11-29; assert Saturday 2023-11-25 is visible only on Thursday 2023-11-30.
  • Assert that with availability_time=time(18, 0), a 09:30 query on the publication date returns nothing.
  • Sweep a simulated backtest loop and assert max(effective_publication_date) <= as_of on every day.
  • Run python -m unittest discover -s skills/backtesting-alt-data-strategies-with-realistic-availability-lag/scripts and confirm 100% pass rate.

Related Skills

  • backtest-look-ahead-in-universe-selection
  • point-in-time-fundamentals-data-joins
  • backtest-database-schema-for-point-in-time-queries
  • alternative-data-vendor-due-diligence-checklist
  • insider-trading-controls-for-alternative-data-usage

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Backtesting Alt Data Strategies With Realistic Availability Lag?

Gebruik dit bij het backtesten van een alternatieve-datastrategie. Koppel elke waarneming aan de publicatiedatum, niet aan de datum van de gebeurtenis: het verschil tussen die twee is de oorzaak van onmogelijke backtestresultaten.

Waarom Backtesting Alt Data Strategies With Realistic Availability Lag gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Backtesting Alt Data Strategies With Realistic Availability Lag bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Backtesting Alt Data Strategies With Realistic Availability Lag in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtesting-alt-data-strategies-with-realistic-availability-lag. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Backtesting Alt Data Strategies With Realistic Availability Lag gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Backtesting Alt Data Strategies With Realistic Availability Lag gebruiken?

Zoveel als je wilt. Je kunt Backtesting Alt Data Strategies With Realistic Availability Lag gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Backtesting Alt Data Strategies With Realistic Availability Lag gratis?

Ja. Deze skill is door HimanshuJ16 op GitHub gepubliceerd onder de licentie Apache-2.0. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇