Backtest broker accumulation for IDX stocks

Broker summary history lets you backtest accumulation and distribution patterns. Because ranges are aggregated, pulling a window such as one month returns one row per broker covering the whole window - a clean input for ranking brokers against each other.

A common approach is to rank brokers by net accumulation (buy_value minus sell_value) or by the ratio of buy_value to sell_value, then test a signal - for example, buy a ticker when its top broker's net buy value exceeds a threshold, and hold it for a fixed number of days.

The sketch below pulls five tickers for one month via the batch endpoint, builds a combined DataFrame, and ranks brokers by net buy value.

import pandas as pd
import requests

API_KEY = "<YOUR_API_KEY>"
BASE_URL = "https://api.indexalpha.id"
headers = {"Authorization": f"Bearer {API_KEY}"}

payload = {
    "tickers": ["BBCA", "BBRI", "TLKM", "BMRI", "ASII"],
    "from": "2026-06-01",
    "to": "2026-06-30",
    "investor": "all",
    "market": "RG",
}
resp = requests.post(f"{BASE_URL}/stocks/broker-summary/batch", json=payload, headers=headers)
resp.raise_for_status()

frames = []
for ticker, rows in resp.json()["data"].items():
    frame = pd.DataFrame(rows)
    frame.insert(0, "ticker", ticker)
    frames.append(frame)
df = pd.concat(frames, ignore_index=True)

df["net_buy_value"] = df["buy_value"] - df["sell_value"]
top_accumulators = df.sort_values("net_buy_value", ascending=False)
print(top_accumulators[["ticker", "code", "net_buy_value"]].head(10))

Data is available from 2025-01-01. Because backtesting results depend on your own methodology, filters, and assumptions, the data alone does not imply future performance.