Backtest Database Schema For Point In Time Queries logo

Backtest Database Schema For Point In Time Queries

Community
HimanshuJ16
backtest-database-schema-for-point-in-time-queries

Use when designing the storage layer for backtest data, so as-of queries are native: two independent time axes let a query ask what was known on a date rather than what the table holds today. The join engine itself is point-in-time-database-for-ml-training-data.

Overview

PublisherHimanshuJ16
RepositoryAlgo-Trading-Skills
Skill namebacktest-database-schema-for-point-in-time-queries
Stars
50
Forks
7
Bundled files
5
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by HimanshuJ16 on GitHub. Read the source before you install it.

Installation

Install the Backtest Database Schema For Point In Time Queries AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-database-schema-for-point-in-time-queries
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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/backtest-database-schema-for-point-in-time-queries .claude/skills/backtest-database-schema-for-point-in-time-queries
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Backtest Database Schema For Point In Time Queries in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Backtest Database Schema For Point In Time Queries on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Backtest Database Schema For Point In Time Queries is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

When to Use

Invoke this skill when building data infrastructure for backtesting. Standard database tables return the latest value for a query, silently introducing lookahead bias. A point-in-time (PIT) schema stores records on two independent time axes, so queries like "what was the P/E ratio of AAPL as known on 2023-01-15?" return only data available at that historical moment.

The two axes follow the SQL:2011 temporal vocabulary:

AxisColumnMeaning
Knowledge timeknown_atWhen the value became externally known (vendor publication / filing release). Not the DB insert time.
Valid (application) timevalid_fromWhen the value came into effect in the real world (e.g. fiscal period end).

When NOT to Use

  • Market price bars already carry their own event timestamp and are not restated; a PIT knowledge axis adds cost without benefit. Use ordinary time-series storage.
  • Live trading reads of current state — as-of machinery is for reconstructing the past. Query the latest row directly.
  • Four sibling skills cover adjacent ground; pick by what you are building:
    • designing the schema and as-of query layer itself → this skill;
    • joining fundamentals on SEC filing dates → point-in-time-fundamentals-data-joins;
    • assembling an ML feature/label training matrix → point-in-time-database-for-ml-training-data;
    • tracking index membership over time → point-in-time-index-constituent-tracking.

Prerequisites

  • Database or data store with temporal versioning capability.
  • Historical fundamental/reference data with publication timestamps.
  • A single documented timestamp convention (see references/standards.md) agreed across every ingesting vendor feed.

Workflow

  1. Design PIT Schema: Add known_at (knowledge time) and valid_from (valid time) to every fact table, plus a revision counter so simultaneous corrections resolve deterministically. Make the table append-only.
  2. Normalize Every Timestamp On Ingest: Store one canonical representation — UTC, zero-padded, fixed-width ISO 8601. Reject anything else at the boundary rather than storing it and comparing later.
  3. Query with As-Of Semantics: Filter known_at <= as_of and valid_from <= as_of. Filtering only on the knowledge axis still returns values that had been announced but were not yet in effect.
  4. Decide the Same-Day Rule Explicitly: If a record's known_at has date granularity only, you cannot know whether it landed before or after the close. Treat it as known at end of day — so it is not tradable that same day — or store the real intraday timestamp.
  5. Validate No Future Leakage: Audit that a naive "latest row wins" query and the PIT query return the same value; where they differ, the naive path is the bug.
  6. Index for Performance: Create a composite index on (symbol, field, known_at). Equality predicates must lead so the range predicate on known_at can bound the scan; omitting field leaves it as a post-filter.

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

Common Pitfalls

  • Using created_at Instead of known_at: Database insertion time != when data was publicly available. A backfill loaded today would make every historical row look known today.
  • Restated Earnings Without Versioning: Overwriting Q1 earnings with restated figures without preserving the original destroys the only record of what you could actually have traded on.
  • Comparing Timestamps As Strings: Lexicographic comparison is chronologically correct only when every value shares an identical UTC offset representation and fractional-second precision (RFC 3339 §5.1). 2023-02-01T09:00:00-05:00 string-compares as earlier than 2023-02-01T12:00:00Z but is actually two hours later — a silent leak.
  • Unpadded or Mixed-Format Dates: A single 2023-9-01 sorts after 2023-10-01, so the row becomes invisible to every as-of query that should have returned it. Validate the format on write, not on read.
  • Filtering Only the Knowledge Axis: Guidance announced in January for a period ending in June is known in February but not yet in effect; returning it as February's value is a bitemporal modelling error.
  • Treating a Publication Date as Midnight: An earnings release timestamped only 2023-06-01 is usually after the close. Assuming start-of-day makes it tradable a full session early.

Verification

  • Run python -m unittest discover -s skills/backtest-database-schema-for-point-in-time-queries/scripts — 100% pass rate.
  • Insert an original figure and a later restatement sharing one valid_from; assert an as-of query before the restatement returns the original value, and after it returns the restated one.
  • Assert that a record whose known_at carries a UTC offset is excluded when its UTC instant falls after the as-of cutoff, even though raw string comparison would admit it.

Related Skills

  • point-in-time-fundamentals-data-joins
  • point-in-time-database-for-ml-training-data
  • point-in-time-index-constituent-tracking
  • backtest-look-ahead-in-universe-selection
  • backtest-determinism-and-reproducibility

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Backtest Database Schema For Point In Time Queries AI skill do?

Use when designing the storage layer for backtest data, so as-of queries are native: two independent time axes let a query ask what was known on a date rather than what the table holds today. The join engine itself is point-in-time-database-for-ml-training-data.

Why use Backtest Database Schema For Point In Time Queries on TypingMind?

Because you install it once and use it with any model. Backtest Database Schema For Point In Time Queries is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Backtest Database Schema For Point In Time Queries in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-database-schema-for-point-in-time-queries. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Backtest Database Schema For Point In Time Queries?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Backtest Database Schema For Point In Time Queries?

As many as you like. As long as a model supports skills, you can use Backtest Database Schema For Point In Time Queries with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Backtest Database Schema For Point In Time Queries AI skill free?

Yes. It is published on GitHub by HimanshuJ16 under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇