Skip to main content

MCP-native technical analysis runtime — 8 core indicators, 2 composite signals, and the unique Polymarket Sentiment Divergence (PSD).

Project description

Sigil

MCP-native technical analysis runtime — 8 core indicators, 2 composite signals, and the unique Polymarket Sentiment Divergence (PSD).

pip install sigil-ta
sigil demo rsi

Sigil is a TA library that's also a Claude / Cursor / Cline tool server. Every indicator is exposed via the Model Context Protocol — point your AI agent at sigil-mcp, ask "what's the RSI of BTC right now?", and it answers with live data.

Why this exists

I built this because I needed three things in one toolkit:

  1. Indicators that aren't a pile of opinionated TA-Lib glue. Pure Python core, zero runtime deps, deterministic outputs.
  2. A way to compose signals our way, not LuxAlgo's way. Two of our composite signals (ReversionScore, MomentumComposite) and one unique signal (PolymarketSentimentDivergence) you won't find anywhere else.
  3. MCP-native runtime so any AI agent can query live signals. No glue code. No subprocess wrappers. Install, configure once, ask in natural language.

What's in v0.1

8 core indicators (pure stdlib)

Indicator Description
sma(closes, period) Simple Moving Average
ema(closes, period) Exponential Moving Average
rsi(closes, period=14) Wilder's Relative Strength Index
macd(closes, 12, 26, 9) MACD with signal & histogram
bollinger_bands(closes, 20, 2.0) BB upper/middle/lower
atr(series, 14) Wilder's Average True Range
supertrend(series, 10, 3.0) Supertrend with line + direction
stochastic(series, 14, 3) %K and %D

2 composite signals (our naming, our weighting)

Signal Components Use case
reversion_score RSI deviation + BB position + ATR-normalized deviation Mean-reversion entries
momentum_composite RSI + MACD histogram + Supertrend direction Trend-following

Both score on [-1, +1] — directly usable as a backtest signal.

1 unique signal: polymarket_sentiment_divergence (PSD)

Measures divergence between an underlying asset's price action and the resolved sentiment from a related Polymarket prediction market. When the chart says "going up" but the market consensus says "probably won't happen", one of them is wrong — that's signal, and that's what PSD captures.

Why PSD is uncopyable: Pure-TA libraries (LuxAlgo, ta, pandas-ta, ta-lib) do not have access to prediction-market sentiment. Sigil integrates Polymarket via sigil.data.polymarket so the sentiment channel is built in.

Data fetchers (zero deps, stdlib only)

  • fetch_binance_ohlcv(symbol, interval, limit) → live OHLCV
  • fetch_polymarket_price_history(token_id, ...) → PM probability time series

Backtest harness

from sigil.backtest import backtest_signal

result = backtest_signal(
    series=ohlcv_series,
    signal=reversion_scores,
    entry_threshold=0.5,
    exit_threshold=0.0,
    fee_per_side_pct=0.001,  # 10 bps each side
)
print(result.summary())
# Backtest: 24 trades, WR 66.7% (16/24), total_pnl_pct -2.84%, avg_per_trade -0.12%, avg_bars_held 14.0

MCP server

pip install sigil-ta[mcp]
sigil-mcp                # stdio (Claude Desktop / Cursor / Cline)
sigil-mcp --transport http --port 8765   # HTTP transport

14 tools exposed. Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "sigil": {
      "command": "sigil-mcp"
    }
  }
}

Then ask Claude things like:

  • "Fetch the last 200 hours of BTCUSDT and compute the RSI."
  • "Run a Supertrend backtest on ETHUSDT with default params."
  • "What's the Bollinger Bands upper band for SOLUSDT right now?"

Streamlit dashboard

pip install sigil-ta[dashboard]
sigil-dashboard

Pick a symbol, an interval, an indicator. See the candles + indicator + (for composite signals) a backtest panel underneath. Designed for signals.protodex.io deployment but runs locally too.

Install options

# Core (pure stdlib, no deps)
pip install sigil-ta

# With MCP server
pip install sigil-ta[mcp]

# With Streamlit dashboard
pip install sigil-ta[dashboard]

# Everything
pip install sigil-ta[all]

CLI quickstart

$ sigil list                  # list indicators
$ sigil demo rsi              # synthetic-data smoke test
RSI(14) last 5: [89.96, 91.16, 92.12, 92.89, 93.5]

$ sigil demo reversion
ReversionScore last 5: [-0.933, -0.941, -0.947, -0.953, -0.952]

Python API

from sigil import indicators, signals
from sigil.core import OHLCVSeries
from sigil.data import fetch_binance_ohlcv

# Fetch live data
series = fetch_binance_ohlcv("BTCUSDT", "1h", limit=500)
closes = series.closes

# Indicators
rsi = indicators.rsi(closes, 14)
macd = indicators.macd(closes)
bb = indicators.bollinger_bands(closes)
print(f"RSI = {rsi[-1]:.2f}, BB middle = ${bb.middle[-1]:,.2f}")

# Composite signals
rev = signals.reversion_score(series)
mom = signals.momentum_composite(series)
print(f"ReversionScore = {rev[-1]:+.3f}, MomentumComposite = {mom[-1]:+.3f}")

PSD example

from sigil import signals
from sigil.data import fetch_binance_ohlcv, fetch_polymarket_price_history

# 1. Fetch BTC 1h closes
series = fetch_binance_ohlcv("BTCUSDT", "1h", limit=500)
asset_closes = series.closes

# 2. Fetch Polymarket "Will BTC be above $X by Y" probability history (same length, aligned)
pm_rows = fetch_polymarket_price_history(token_id="...", fidelity=60)
pm_probs = [r["price"] for r in pm_rows[-500:]]

# 3. Compute PSD
result = signals.polymarket_sentiment_divergence(
    asset_closes, pm_probs, smoothing_window=5,
)
print(f"Latest PSD score: {result.score[-1]:+.3f}")
# Score > 0 = bullish divergence (price down, sentiment up)
# Score < 0 = bearish divergence (price up, sentiment down)

Design choices

Pure stdlib core. No numpy, pandas, scipy required. Every indicator is plain Python doing arithmetic. This makes the package install in milliseconds, run on cold-start serverless, and never break from a third-party version bump. (pandas/streamlit/plotly/mcp are optional extras.)

Indicators return list[float | None] same length as input. None during warm-up. No magic resampling. No silent NaN propagation. What you put in, you get back, aligned.

Composite signals score on [-1, +1]. Clip-and-combine math, no exotic weights. If you don't like the weights, there are 100 lines of code to read in signals/reversion.py — fork it.

Backtest is FOK-style. Decisions on bar i, trade fills at bar i+1 open. No look-ahead. Realistic-by-default fees (10 bps per side).

Test coverage is the contract. Every indicator has property tests (constant input behaves correctly, monotone-up RSI = 100, etc.). 47 tests at v0.1.

Tested

47 tests. Run them:

git clone https://github.com/LuciferForge/sigil
cd sigil
pip install -e ".[dev,mcp]"
pytest -v

Sample output:

tests/test_backtest.py .......                                           [ 14%]
tests/test_core.py .....                                                 [ 25%]
tests/test_indicators.py .....................                           [ 70%]
tests/test_mcp.py .....                                                  [ 80%]
tests/test_signals.py .........                                          [100%]
============================== 47 passed in 3.18s ==============================

What's coming (roadmap)

  • v0.2 — More indicators: ADX, Ichimoku, OBV, VWAP, Heikin-Ashi
  • v0.3 — Walk-forward backtest with parameter sweeps
  • v0.4 — Multi-timeframe signal fusion (15m + 1h + 4h alignment)
  • v0.5 — Live signal alerting (Discord/Telegram/Slack)
  • v0.6 — Public ground-truth ledger at signals.protodex.io

License

MIT.

About the author

Built by LuciferForge, running a public-audited Polymarket trading bot (302 closed trades, 79.8% WR). I needed an MCP-native TA stack for my own bot work and built one from scratch rather than wrapping an existing library. Other projects:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sigil_ta-0.1.0.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sigil_ta-0.1.0-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file sigil_ta-0.1.0.tar.gz.

File metadata

  • Download URL: sigil_ta-0.1.0.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for sigil_ta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb6f7175ce7331c62d01723f44753158833f5d7a54440daea480a81b563d5128
MD5 1e6339b835048478660da91ccba2db9b
BLAKE2b-256 76230446916e8c6a2d77a1733cab48fddd4d308903dc63860073dfeaf7aac84b

See more details on using hashes here.

File details

Details for the file sigil_ta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sigil_ta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for sigil_ta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00e1dd3859748981f460a30c65902a118093a25659d87d917a2bc3c3e55aba18
MD5 caf71238081add8361786194aa57e3de
BLAKE2b-256 9640a0035e4072bb6345deafbadde550a7dfc7f5744741291b37443f97a9f377

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page