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-rust

v0.2.2

Published

High-performance quantitative finance library with Rust FFI bindings for Bun

Readme

@ebowwa/quant-rust

High-performance quantitative finance library with Rust FFI bindings for Bun.

This package provides blazing-fast quantitative finance computations powered by Rust, accessible through a clean TypeScript API using Bun's FFI capabilities.

Features

  • Prediction Markets: Kelly criterion, AMM calculations, LMSR pricing, arbitrage detection
  • Technical Indicators: SMA, EMA, RSI, MACD, Bollinger Bands, ATR, and more
  • Risk Management: VaR, CVaR, Sharpe ratio, Sortino ratio, drawdown analysis
  • Statistical Functions: Mean, variance, standard deviation, correlation

Installation

bun add @ebowwa/quant-rust

Requirements

  • Bun >= 1.0.0
  • Prebuilt binaries are included for:
    • macOS (Apple Silicon/arm64)
    • macOS (Intel/x64)
    • Linux (x64)
    • Windows (x64)

If no prebuilt binary is available for your platform, the library will fall back to the development build in target/release/.

Usage

import {
  kellyCriterion,
  detectArbitrage,
  convertOdds,
  mean,
  sma,
  ema,
  rsi,
  macd,
  calculateVar,
  calculateSharpeRatio,
} from "@ebowwa/quant-rust";

// Kelly criterion for position sizing
const kelly = kellyCriterion(0.6, 0.5, 1000);
console.log(kelly.kelly_fraction); // 0.2
console.log(kelly.full_bet_size); // 200

// Detect arbitrage in prediction markets
const arb = detectArbitrage(0.45, 0.45);
console.log(arb.has_arbitrage); // true (0.45 + 0.45 = 0.9 < 1)
console.log(arb.profit_per_share); // 0.1 (10 cents per share)

// Convert between odds formats
const odds = convertOdds(0.5, "probability");
console.log(odds.decimal_odds); // 2.0
console.log(odds.american_odds); // 100

// Statistical functions
const avg = mean([1, 2, 3, 4, 5]);
console.log(avg); // 3

// Technical indicators
const smaResult = sma([1, 2, 3, 4, 5], 3);
console.log(smaResult); // [2, 3, 4]

const rsiResult = rsi([10, 11, 12, 11, 10, 9, 8, 9, 10, 11, 12, 13, 14, 15, 16], 14);
console.log(rsiResult); // [71.43...]

// Risk metrics
const returns = [0.01, 0.02, -0.01, 0.03, -0.02, 0.01, 0.02, 0.01, -0.01, 0.02];
const varResult = calculateVar(returns, 0.95);
console.log(varResult.var); // Value at Risk at 95% confidence

const sharpe = calculateSharpeRatio(returns, 0.04, 252);
console.log(sharpe.annualized_sharpe); // Annualized Sharpe ratio

API Reference

Prediction Market Functions

kellyCriterion(yourProbability, marketPrice, bankroll)

Calculate optimal position sizing using the Kelly criterion.

detectArbitrage(yesPrice, noPrice)

Detect arbitrage opportunities in binary prediction markets.

convertOdds(value, fromType)

Convert between probability, decimal odds, and American odds.

ammCalculateCost(poolYes, poolNo, buyYes, shares)

Calculate cost to buy shares from a constant-product AMM.

lmsrPrice(yesShares, noShares, b)

Calculate LMSR prices for a prediction market.

Statistical Functions

mean(data)

Calculate the arithmetic mean.

stdDev(data)

Calculate the standard deviation.

variance(data)

Calculate the variance.

correlation(x, y)

Calculate Pearson correlation coefficient.

Technical Indicators

sma(prices, period)

Simple Moving Average.

ema(prices, period)

Exponential Moving Average.

rsi(prices, period)

Relative Strength Index.

macd(prices, fastPeriod, slowPeriod, signalPeriod)

MACD (Moving Average Convergence Divergence).

Risk Management

calculateVar(returns, confidenceLevel)

Value at Risk calculation.

calculateDrawdown(equityCurve)

Drawdown analysis.

calculateSharpeRatio(returns, riskFreeRate, periodsPerYear)

Sharpe ratio calculation.

calculateSortinoRatio(returns, riskFreeRate, periodsPerYear)

Sortino ratio (downside deviation only).

Building from Source

If you need to build the native library from source:

# Navigate to the package directory
cd node_modules/@ebowwa/quant-rust

# Build the Rust library
cargo build --release

License

MIT

Repository

https://github.com/ebowwa/codespaces/tree/main/packages/src/quant-rust