Ml4t Continuous Futures logo

Ml4t Continuous Futures

Organization
ml4t
ml4t-continuous-futures

Build roll-adjusted continuous futures series without artificial price jumps. Use when backtesting futures strategies that span contract rollovers.

Overview

Publisherml4t
Repositoryskills
Skill nameml4t-continuous-futures
Stars
45
Forks
13
Bundled files
Instructions only
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.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

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

Installation

Install the Ml4t Continuous Futures 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/ml4t/skills/tree/main/data/continuous-futures
  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/ml4t/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/data/continuous-futures .claude/skills/ml4t-continuous-futures
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ml4t Continuous Futures 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 Ml4t Continuous Futures 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 Ml4t Continuous Futures 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.

Continuous Futures

Naively concatenating front-month futures contracts creates artificial price jumps at each roll, corrupting returns and every feature derived from price levels.

The Problem

Futures contracts expire. When you roll from the March contract to the June contract, the price can jump $5 overnight - not because the market moved, but because the new contract trades at a different level (contango or backwardation). Concatenating contracts without adjustment produces fake returns of 2-5% at every roll date. A momentum signal built on this series will fire on roll artifacts, not real trends. Over a year with 4-12 rolls, this distortion compounds.

The Pattern

WRONG

python
import polars as pl

# Naive concatenation - price jumps at every roll
contracts = pl.read_parquet("futures_contracts.parquet")
continuous = (
    contracts.sort("timestamp")
    .group_by("timestamp")
    .agg(pl.col("close").first())  # Just take front month
)
# 3-5% fake returns at each quarterly roll

CORRECT

python
import polars as pl
import numpy as np

def panama_canal_adjust(
    front: pl.DataFrame,                    # timestamp, close: stitched front month
    rolls: list[tuple[str, float, float]],  # (roll_date, old_close, new_close)
) -> pl.DataFrame:
    """Back-adjust prices using the Panama Canal (additive) method.

    The gap is the spread between the outgoing and incoming contract quoted on
    the SAME day, which is why both prices have to be passed in. Differencing
    adjacent rows of the stitched series instead measures the old contract's
    overnight move on top of the spread.
    """
    df = front.sort("timestamp")
    ts = df["timestamp"].to_numpy()
    adj = df["close"].to_numpy().copy().astype(np.float64)

    for roll_date, old_close, new_close in sorted(rolls, reverse=True):
        # Lift prior history so the roll nets to zero PRICE CHANGE - additive
        # adjustment does not preserve percentage returns, ratio does.
        # Subtracting the gap doubles the jump: a 5% artifact becomes 10.5%.
        adj[ts < np.datetime64(roll_date)] += new_close - old_close

    return df.with_columns(adj_close=pl.Series("adj_close", adj))

Roll Methods

MethodAdjustmentPreservesBest For
Panama (additive)Shift by price gapAbsolute price changesTrend following
Ratio (multiplicative)Multiply by price ratioPercentage returnsCross-asset comparison
Return-basedChain daily returnsReturns onlyPure return signals
No adjustmentNoneNothing usefulNever use for backtesting

Term Structure and Carry

Loading multiple contract months enables carry signals - the slope of the futures term structure.

python
# Carry = (front - back) / front
front = prices.filter(pl.col("position") == 0)
back = prices.filter(pl.col("position") == 1)

carry = front.join(back, on=["product", "timestamp"], suffix="_back").with_columns(
    carry=(pl.col("close") - pl.col("close_back")) / pl.col("close")
)
# Negative carry (contango) = cost of holding; positive (backwardation) = benefit

Guardrails

  • Never take a return off raw close of a stitched series, which jumps at every roll; per-contract raw prices are correct for term-structure work like the carry above
  • Roll dates vary by product: energy rolls monthly, equity index rolls quarterly
  • Panama adjustment changes historical price levels - do not use adjusted prices for margin calculations
  • Match the adjustment to the unit you trade: additive adj_close for absolute price changes, ratio adjustment for percentage returns, which Panama distorts early in the history
  • Carry signals require accurate term structure with at least 2 contract months

Production Implementation

ml4t-data provides futures download managers plus configurable continuous-contract builders:

python
from ml4t.data import FUTURES_REGISTRY
from ml4t.data.futures import ContinuousContractBuilder, FuturesDataManager

manager = FuturesDataManager.from_config("configs/ml4t_futures.yaml")
futures = manager.load_ohlcv("ES")
continuous = ContinuousContractBuilder().build("ES", data_source="databento")

# Access roll specifications
es_spec = FUTURES_REGISTRY["ES"]  # Multiplier, tick size, margin, exchange

Checklist

  • Roll method chosen and documented (Panama for most uses)
  • All prior history back-adjusted at each roll
  • Roll dates show no artificial jump in the series the method preserves
  • Multiple contract months available for carry signals
  • Roll dates sourced from exchange calendar, not hardcoded

Frequently asked questions

What does the Ml4t Continuous Futures AI skill do?

Build roll-adjusted continuous futures series without artificial price jumps. Use when backtesting futures strategies that span contract rollovers.

Why use Ml4t Continuous Futures on TypingMind?

Because you install it once and use it with any model. Ml4t Continuous Futures 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 Ml4t Continuous Futures in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ml4t/skills/tree/main/data/continuous-futures. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Ml4t Continuous Futures?

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 Ml4t Continuous Futures?

As many as you like. As long as a model supports skills, you can use Ml4t Continuous Futures with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ml4t Continuous Futures AI skill free?

Yes. It is published on GitHub by ml4t 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 👇