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

cortex-risk-sdk

v1.1.0

Published

TypeScript SDK for the CortexAgent Risk Engine — MSM-VaR, EVT, SVJ, Hawkes, Rough Volatility, Copula VaR, Guardian risk veto, on-chain liquidity, tick-level backtesting, and Hawkes on-chain contagion for autonomous DeFi agents on Solana.

Readme

cortex-risk-sdk

TypeScript SDK for the CortexAgent Risk Engine — 60+ typed endpoints covering MSM regime detection, EVT, SVJ, Hawkes, rough volatility, copula VaR, Guardian risk veto, on-chain liquidity, tick-level backtesting, and Hawkes on-chain contagion.

npm

Install

npm install cortex-risk-sdk

Requires Node 18+ (native fetch).

Quick Start

import { RiskEngineClient } from "cortex-risk-sdk";

const risk = new RiskEngineClient({
  baseUrl: "http://localhost:8000",
  timeout: 15_000,
  retries: 3,
  validateResponses: true,
});

// Calibrate MSM model
await risk.calibrate({ token: "SOL-USD", num_states: 5 });

// Check regime
const regime = await risk.regime("SOL-USD");
console.log(regime.regime_state, regime.regime_name);

// Guardian risk veto
const assessment = await risk.guardianAssess({
  token: "SOL-USD",
  trade_size_usd: 50_000,
  direction: "long",
});

if (assessment.approved) {
  console.log(`Approved — size $${assessment.recommended_size}`);
} else {
  console.log(`Vetoed — ${assessment.veto_reasons.join(", ")}`);
}

Modules (60+ endpoints)

| Module | Methods | Description | |--------|---------|-------------| | Core MSM | calibrate, regime, var, volatilityForecast, backtestSummary, tailProbs | Regime detection, VaR | | Regime Analytics | regimeDurations, regimeHistory, regimeStatistics, transitionAlert | Temporal regime analysis | | Model Comparison | compare, comparisonReport | 9-model benchmark | | Portfolio VaR | portfolioCalibrate, portfolioVar, marginalVar, stressVar | Multi-asset risk | | Copula VaR | copulaVar, copulaCompare, copulaDiagnostics, regimeDependentCopulaVar | Dependence modeling | | EVT | evtCalibrate, evtVar, evtDiagnostics | Tail risk (GPD) | | Hawkes | hawkesCalibrate, hawkesIntensity, hawkesClusters, hawkesVar, hawkesSimulate | Crash contagion | | Hawkes On-Chain | hawkesOnchainCalibrate, hawkesOnchainEvents, hawkesOnchainRisk | On-chain event contagion & flash crash risk | | Multifractal | hurst, spectrum, regimeHurst, fractalDiagnostics | Hurst exponent | | Rough Vol | roughCalibrate, roughForecast, roughDiagnostics, roughCompareMsm | Rough Bergomi | | SVJ | svjCalibrate, svjVar, svjJumpRisk, svjDiagnostics | Jump risk | | News | newsFeed, newsSentiment, newsSignal | Sentiment signals | | Guardian | guardianAssess | Unified risk veto | | LVaR | lvarEstimate, lvarRegimeVar, lvarImpact, lvarRegimeProfile | Liquidity-adjusted VaR | | On-Chain Liquidity | onchainDepth, realizedSpread, onchainLVaR | DEX depth, realized spread, on-chain LVaR | | Tick Data | tickAggregate, tickBacktest | Tick-level bars & multi-horizon backtesting | | Oracle (Pyth) | oracleFeeds, oracleSearch, oraclePrices, oracleHistory, oracleBuffer, oracleStatus | Pyth price feeds | | Streams | streamEvents, streamStatus | Helius on-chain event stream | | Social | socialSentiment | Social media sentiment | | Macro | macroIndicators | Fear & Greed, BTC dominance | | Portfolio Risk | portfolioPositions, updatePosition, closePosition, setPortfolioValue, portfolioDrawdown, portfolioLimits | Position & drawdown management | | Execution | executionPreflight, executeTrade, executionLog, executionStats | Trade execution pipeline | | Axiom DEX | axiomPrice, axiomPair, axiomLiquidityMetrics, axiomHolders, axiomTokenAnalysis, axiomNewTokens, axiomWsStatus, axiomWalletBalance, axiomStatus | Axiom DEX data | | Token Info | tokenInfo | Token metadata (Birdeye) | | Health | health | Service health check |

WebSocket Streaming

import { RegimeStreamClient } from "cortex-risk-sdk";

const stream = new RegimeStreamClient({
  baseUrl: "http://localhost:8000",
  token: "SOL-USD",
  onRegime: (msg) => console.log(`Regime ${msg.regime_state}`),
  onError: (err) => console.error(err),
});
stream.connect();

Resilience

Built-in via cockatiel:

  • Retry — exponential backoff (configurable retries)
  • Circuit breaker — opens after consecutive failures, half-opens after cooldown
  • Timeout — per-request timeout with AbortSignal

Validation

Optional zod runtime validation for critical responses (Guardian, VaR, Regime). Enable with validateResponses: true.

Configuration

const risk = new RiskEngineClient({
  baseUrl: "http://localhost:8000",       // Risk Engine URL
  timeout: 10_000,                        // Request timeout (ms)
  retries: 3,                             // Max retry attempts
  retryDelay: 500,                        // Retry base delay (ms)
  circuitBreakerThreshold: 5,             // Circuit breaker threshold
  circuitBreakerResetMs: 30_000,          // Circuit breaker reset (ms)
  validateResponses: false,               // Zod validation
});

License

MIT — Cortex AI