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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@socktrader/indicators

v2.0.3

Published

SockTrader indicators is a single utility package for all technical indicators, financial analysis as well as statistical utilities

Downloads

21

Readme

What is "@socktrader/indicators"?

This independent package contains various utility functions to support risk, performance, quantitative and technical analysis. @socktrader/indicators is part of the SockTrader monorepo project but can be used in any project without depending on the rest of the SockTrader project.

Quickstart

  1. Install library: npm install @socktrader/indicators
  2. Use library activeReturn([0.003], [0.04], 12)

Indicators

Technical indicators

@socktrader/indicators re-exports all indicators from technicalindicators. Check the technicalindicators docs for more API details.

Performance metrics

    const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]
    const z = [0.04, -0.022, 0.043, 0.028, -0.078, -0.011, 0.033, -0.049, 0.09, 0.087]
    
    activeReturn(x, z, 12)
    // 0.041978811047168385
    
    annualReturn(x, 12)
    // 0.2338146820656939
    
    compoundAnnualGrowthRate(x, x.length / 12)
    // 0.22938756017127182
    
    internalRateOfReturn([250000, 25000, -10000, -285000])
    // 0.024712563094781776
    
    mdietz(1200, 1000, [10, 50, 35, 20], [15, 38, 46, 79], 90)
    // 0.0804331826306382
    
    percpos(x)
    // 0.8
    
    rateOfReturn(x)
    // 0.18779277315203946
    
    timeWeightedReturn([250000, 255000, 257000, 288000, 293000, 285000], [0, 0, 25000, 0, -10000, 0])
    // 0.07564769566198049
    

Risk metrics

    const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]
    const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058]
    const z = [0.04, -0.022, 0.043, 0.028, -0.078, -0.011, 0.033, -0.049, 0.09, 0.087]
    
    adjustedSharpeRatio(x, 0.02 / 12)
    // 0.7481337144481773
    
    annualAdjustedSharpeRatio(x, 0.02, 12, Mode.geometric)
    // 3.3767236091658313
    
    annualRisk(x, 12)
    // 0.08047276972160623
    
    avgDrawdown(x)
    // 0.01150000000000001
    
    burkeRatio(x, 0, 12)
    // 14.048562698619559
    
    calmarRatio(x, 0, 12)
    // 16.70104871897814
    
    continuousDrawdown(x)
    // [0.009000000000000008, 0.014000000000000012]
    
    downsidePotential(x, 0.1 / 100)
    // 0.0024999999999999996
    
    downsideRisk(x, 0.1 / 100)
    // 0.005700877125495689
    
    drawdown(x) 
    // {
    //    'dd': [0, 0, 0, 0.00900000000000004, 0, 0, 0, 0, 0.013999999999999995, 0],
    //    'ddrecov': [0, 0, 0, 4, 0, 0, 0, 0, 9, 0],
    //    'maxdd': 0.013999999999999995,
    //    'maxddrecov': [8, 9]
    // }
    
    histcondvar(x)
    // 0.014
    
    histvar(x)
    // 0.013999999999999999
    
    informationRatio(x, y)
    // 0.09369148584852913
    
    jensenAlpha(x, y)
    // 0.01760907323602524
    
    m2sortino(x, y, 0, 0, 12)
    // 0.504144074388577
    
    martinRatio(x, 0, 12)
    // 44.42545597931942
    
    modigliani(x, y)
    // 0.040694064858387835
    
    monteCarloValueAtRisk(x, 0.95, 1, 0, 1, 10000)
    // random: 0 < x < 1
    
    omegaRatio(x)
    // 8.782608695652174
    
    painIndex(x)
    // 0.0023000000000000034
    
    painRatio(x, 0, 12)
    // 101.04495520047377
    
    parametricConditionalValueAtRisk(mean(x), std(x))
    // 0.030017825479120894
    
    parametricValueAtRisk([0, 0, 0], [1, 2, 3])
    // [1.6448536127562643, 3.2897072255125286, 4.934560838268792]
    
    sharpeRatio(x, 0.02 / 12)
    // 0.6987943426529188
    
    sortino(x, 0.02 / 12)
    // 3.0843795993743215
    
    sterlingRatio(x, 0, 12)
    // 16.70104871897812
    
    trackingError(x, z)
    // 0.06843618276256436
    
    treynorRatio(x, z, 0.01 / 12)
    // -0.09568702060685172
    
    ulcerIndex(x)
    // 0.005263078946776312
    
    upsidePotential(x, 0.1 / 100)
    // 0.0194