Ml4t Build Bars logo

Ml4t Build Bars

Organization
ml4t
ml4t-build-bars

Aggregate tick data into time, volume, and dollar bars. Use when resampling raw tick data into regular or information-driven bars.

Overview

Publisherml4t
Repositoryskills
Skill nameml4t-build-bars
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 Build Bars 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/build-bars
  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/build-bars .claude/skills/ml4t-build-bars
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ml4t Build Bars 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 Build Bars 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 Build Bars 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.

Build Bars

Time bars sample by the clock, producing bars with wildly different information content - a 5-minute bar during the open contains 100x more trades than one at 2pm.

The Problem

Standard time bars (1-min, 5-min, daily) sample at fixed intervals regardless of market activity. During high-volume periods, a single bar compresses thousands of trades; during quiet periods, a bar may contain just a handful. This creates heteroscedastic returns that violate the i.i.d. assumptions of most ML models. Volume and dollar bars sample by activity instead, producing bars with roughly equal information content and returns closer to normality.

The Pattern

WRONG

python
import polars as pl

# Only using time bars - uneven information per bar
trades = pl.read_parquet("trades.parquet")
bars_5min = (
    trades.group_by_dynamic("timestamp", every="5m")
    .agg(
        open=pl.col("price").first(),
        close=pl.col("price").last(),
        volume=pl.col("size").sum(),
    )
)
# Bar at 9:30 has 5000 trades, bar at 14:00 has 50 trades

CORRECT

python
import numpy as np
import polars as pl

def bar_index(dollar_vol: np.ndarray, threshold: float) -> np.ndarray:
    """Bar id per trade: accumulate, close on the crossing, then RESET.

    Bucketing by the running total (cum_dollar // threshold) never resets, so
    an overshooting bar steals from the next: four $800 trades against a
    $1,000 threshold give $1,600, $800, $800, not two $1,600 bars."""
    idx = np.empty(len(dollar_vol), dtype=np.int64)
    bar, run = 0, 0.0
    for i, value in enumerate(dollar_vol):
        idx[i] = bar
        run += value
        if run >= threshold:
            bar, run = bar + 1, 0.0
    return idx

def build_dollar_bars(trades: pl.DataFrame, threshold: float) -> pl.DataFrame:
    """Build dollar bars: each bar contains ~threshold dollars traded."""
    trades = trades.sort("timestamp").with_columns(dollar_vol=pl.col("price") * pl.col("size"))
    return (
        trades
        .with_columns(bar_idx=bar_index(trades["dollar_vol"].to_numpy(), threshold))
        .group_by("bar_idx")
        .agg(
            timestamp=pl.col("timestamp").first(),
            open=pl.col("price").first(),
            high=pl.col("price").max(),
            low=pl.col("price").min(),
            close=pl.col("price").last(),
            volume=pl.col("size").sum(),
            dollar_volume=pl.col("dollar_vol").sum(),
            n_trades=pl.len(),
        )
        .sort("bar_idx")
    )

bars = build_dollar_bars(trades, threshold=1_000_000)  # $1M per bar

Choosing the Threshold

Calibrate the threshold as total dollar volume divided by the desired bar count.

Bar Type Comparison

TypeSamples OnInformation Per BarReturns Distribution
TimeClock intervalUnevenFat-tailed, heteroscedastic
TickN tradesMore uniformCloser to normal
VolumeN sharesUniform for single stockGood for single-name
Dollar$N tradedMost uniformClosest to normal

Guardrails

  • Dollar bars require tick-level trade data (timestamp, price, size) - cannot build from OHLCV
  • Thresholds are symbol-specific: $1M/bar for AAPL vs $50K/bar for a small-cap
  • Volume and dollar bars are not directly comparable across symbols - normalize returns
  • Overnight gaps should be handled (exclude or flag the first bar of each session)

Production Implementation

ml4t-engineer provides vectorized tick, volume, dollar, imbalance, and run-bar samplers:

python
from ml4t.engineer.bars import DollarBarSampler

bars = DollarBarSampler(dollars_per_bar=1_000_000).sample(trades.rename({"size": "volume"}))

Package-level names use vectorized implementations; compatibility implementations retain the Original suffix. Volume and imbalance samplers require a signed side column. Instantiate a concrete sampler with its class-specific threshold keyword, not the abstract BarSampler.

Checklist

  • Tick data available with timestamp, price, and size columns
  • Threshold calibrated to produce reasonable bar count (~same as time bars)
  • Bars include OHLCV, dollar volume, and trade count
  • Returns closer to normal verified (Jarque-Bera test or QQ plot)

Frequently asked questions

What does the Ml4t Build Bars AI skill do?

Aggregate tick data into time, volume, and dollar bars. Use when resampling raw tick data into regular or information-driven bars.

Why use Ml4t Build Bars on TypingMind?

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

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

Which AI models can use Ml4t Build Bars?

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 Build Bars?

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

Is the Ml4t Build Bars 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 👇