npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ebowwa/quant

v0.1.0

Published

Quantitative trading tools and formulas - technical indicators, risk management, pattern detection, and statistical functions for AI trading systems

Readme

@ebowwa/quant

Multi-market quantitative trading tools and formulas for AI trading systems.

Features

Multi-Market Support

  • Prediction Markets - Binary outcomes, AMM math, Kelly criterion
  • Traditional Markets - Stocks, crypto, forex technical analysis
  • Derivatives - Options, futures, perpetuals risk management

Modules

prediction - Prediction Market Tools

import { kellyCriterion, ammBuyCost, detectArbitrage } from '@ebowwa/quant/prediction';

// Kelly sizing for binary bets
const kelly = kellyCriterion(0.65, 0.55, 1000); // Your prob, market price, bankroll
console.log(kelly.kellyFraction); // Optimal fraction to bet

// AMM cost calculation (constant product)
const cost = ammBuyCost({ poolYes: 1000, poolNo: 1000, k: 1000000 }, 'yes', 100);

// Detect arbitrage
const arb = detectArbitrage(0.48, 0.48); // YES + NO < 1 = arb opportunity

indicators - Technical Indicators

import { sma, ema, rsi, macd, bollingerBands, atr } from '@ebowwa/quant/indicators';

const prices = [100, 102, 101, 103, 105, 104, 106];

// Moving averages
const sma20 = sma(prices, 20);
const ema12 = ema(prices, 12);

// RSI
const rsi14 = rsi(prices, 14);

// MACD
const { macd: macdLine, signal, histogram } = macd(prices, 12, 26, 9);

// Bollinger Bands
const { upper, middle, lower } = bollingerBands(prices, 20, 2);

risk - Risk Management

import {
  sharpeRatio, sortinoRatio, calculateDrawdown,
  calculateVaR, fixedFractionalSize
} from '@ebowwa/quant/risk';

// Position sizing
const size = fixedFractionalSize(10000, 0.02, 100, 95); // 2% risk

// Risk metrics
const sharpe = sharpeRatio(returns, 0.04, 252);
const { maxDrawdown } = calculateDrawdown(equityCurve);
const { var95, expectedShortfall95 } = calculateVaR(returns);

stats - Statistical Functions

import {
  pearsonCorrelation, linearRegression,
  distributionStats, autocorrelation
} from '@ebowwa/quant/stats';

// Distribution analysis
const stats = distributionStats(returns);
console.log(stats.skewness, stats.kurtosis);

// Correlation
const corr = pearsonCorrelation(assetReturns, marketReturns);

// Linear regression
const { slope, intercept, r2 } = linearRegression(x, y);

// Time series
const acf = autocorrelation(prices, 20);

patterns - Pattern Detection

import {
  findSupportResistance, detectDoubleTop,
  detectHeadAndShoulders, detectTriangles
} from '@ebowwa/quant/patterns';

// Support/Resistance levels
const levels = findSupportResistance(high, low);

// Pattern detection
const doubleTops = detectDoubleTop(high, low);
const headShoulders = detectHeadAndShoulders(high, low);
const triangles = detectTriangles(high, low);

Installation

bun add @ebowwa/quant

API Reference

Prediction Markets

| Function | Description | |----------|-------------| | kellyCriterion(yourProb, marketPrice, bankroll) | Calculate optimal bet size | | ammBuyCost(state, outcome, shares) | Cost to buy shares from AMM | | ammSharesReceived(state, outcome, cost) | Shares received for cost | | detectArbitrage(yesPrice, noPrice) | Find arb opportunities | | brierScore(predictions) | Measure forecast accuracy | | calculateCalibration(predictions) | Calibration analysis |

Technical Indicators

| Function | Description | |----------|-------------| | sma(data, period) | Simple Moving Average | | ema(data, period) | Exponential Moving Average | | rsi(data, period) | Relative Strength Index | | macd(data, fast, slow, signal) | MACD indicator | | bollingerBands(data, period, stdDev) | Bollinger Bands | | atr(high, low, close, period) | Average True Range | | adx(high, low, close, period) | Average Directional Index | | ichimoku(high, low, close) | Ichimoku Cloud |

Risk Management

| Function | Description | |----------|-------------| | sharpeRatio(returns, rf, periods) | Sharpe ratio | | sortinoRatio(returns, rf, periods) | Sortino ratio | | calculateDrawdown(equityCurve) | Max drawdown analysis | | calculateVaR(returns) | Value at Risk | | portfolioVolatility(weights, covMatrix) | Portfolio volatility | | beta(assetReturns, marketReturns) | Beta coefficient |

Statistics

| Function | Description | |----------|-------------| | distributionStats(data) | Full distribution analysis | | pearsonCorrelation(x, y) | Pearson correlation | | linearRegression(x, y) | Simple linear regression | | autocorrelation(data, maxLag) | ACF | | rollingStats(data, period) | Rolling statistics |

Types

The package includes comprehensive TypeScript types for all market types:

  • MarketType - 'prediction' | 'equity' | 'crypto' | 'forex' | 'derivative'
  • OHLCV - Standard candlestick data
  • PredictionQuote - Prediction market quote
  • AMMState - AMM pool state
  • KellyResult - Kelly criterion output
  • TradingSignal - Trading signal with confidence
  • PatternMatch - Detected pattern with confidence

Future: MCP Interface

This package is designed to be wrapped by an MCP server for AI trading systems:

// Future MCP tool example
{
  name: "calculate_kelly",
  description: "Calculate optimal position size using Kelly criterion",
  inputSchema: {
    type: "object",
    properties: {
      yourProbability: { type: "number" },
      marketPrice: { type: "number" },
      bankroll: { type: "number" }
    }
  }
}

License

MIT