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

trading-strategies

v0.3.5

Published

Trading strategies to run trading bots with JavaScript / TypeScript.

Readme

Trading Strategies

Trading strategy implementations that combine technical indicators into actionable trading signals. Ideally designed for creating custom strategies and operating automated trading bots.

Motivation

The "trading-strategies" library provides a TypeScript implementation for common trading strategies. It is designed to work seamlessly with the trading-signals library, allowing developers to combine technical indicators into complete automated trading strategies.

[!CAUTION]

No strategy works all the time, so build in strict loss caps, a realistic positive price target, and the discipline to accept occasional losses. Managing risk matters more than heroically “holding a falling knife,” so focus on winning more often than you lose.

Installation

npm install trading-strategies

Usage

import {StrategySignal, StrategyAdvice} from 'trading-strategies';

Domain Knowledge

  • An exchange (such as the NYSE) is a marketplace where buyers and sellers trade assets, it matches orders by price and time, and it operates only during specific opening hours.

  • A broker (such as Alpaca or Interactive Brokers) is a service that gives traders access to the exchange and executes trades, acting as the middle layer between the trader and the market.

  • Backtesting is the process of evaluating a trading strategy by running it on historical market data to see how it would have performed.

  • Paper trading is the process of evaluating a trading strategy in real time using simulated money to mimic live trading without financial risk.

  • An order book is a real-time list of all the buy and sell orders for an asset, organized by price, showing where traders are willing to buy (bids) and sell (asks) and how much liquidity (trading volume) is available at each level.

  • The spread is the difference between the bid price buyers offer and the ask price sellers accept. A wide spread often signals low liquidity or higher uncertainty in the market, while a tighter spread suggests the opposite.

  • A long position is when a trader buys an asset because they expect its price to rise, and they plan to sell it later for a profit.

  • A short position is when a trader sells an asset they do not own by borrowing it because they expect its price to fall, and they plan to buy it back later at a lower price.

  • A market order tells the broker to buy or sell immediately at the best available current price.

  • A limit order tells the broker to buy or sell only at a specific price, so it won’t execute unless the market reaches that price.

  • A market maker adds liquidity by placing orders that sit on the order book and wait for someone to trade against them. This usually affects broker fees because brokers often reward makers with lower trading fees when placing their orders. Limit orders are usually market maker orders when they rest on the order book and wait to be filled.

  • A market taker removes liquidity by placing orders that execute immediately against those resting orders on the order book. This usually leads to higher trading fees because brokers often charge more for taking liquidity from the order book. Market orders are usually market taker orders because they execute immediately against orders already on the book.

  • Spot trading is when a trader buys or sells an asset with immediate settlement, meaning ownership of the asset is transferred right away.

  • Futures trading is when a trader buys or sells a contract that represents an agreement to trade an asset at a later date.

  • Fungible assets are assets where each unit is interchangeable with another unit of the same type, meaning they have identical value and properties and can be exchanged one for one without loss. Stocks are fungible assets because one share of a company’s common stock is interchangeable with any other share of the same class, carrying the same rights, value, and economic exposure regardless of who owns it.

  • Non-fungible assets are assets where each unit is unique and not directly interchangeable with another, meaning their value depends on specific characteristics such as rarity, condition, history, or ownership rather than a standard market price. A Pokémon trading card is a non-fungible asset because each card can differ in edition, rarity, condition, and even print run, so one card is not perfectly interchangeable with another, even if they feature the same Pokémon.

Strategy Signals

  • BUY_MARKET: Buy at current market price
  • BUY_LIMIT: Buy when price reaches specified limit
  • SELL_MARKET: Sell at current market price
  • SELL_LIMIT: Sell when price reaches specified limit
  • NONE: No action recommended

Backtesting

Always backtest your strategies with historical data before deploying them in live trading. A good strategy should:

  1. Beat Buy-and-Hold: Outperform simply holding the asset
  2. Beat Random Chance: Outperform the CoinFlipStrategy baseline
  3. Beat Broad Benchmarks: Outperform the MSCI World or S&P 500 (after costs)
  4. Work in All Markets: Perform well in bullish, bearish, and sideways markets
  5. Avoid Overfitting: Perform well on historic data and real-world data
  6. Manage Risk: Include stop-loss limits and realistic profit targets
  7. Handle Losses: Accept that no strategy wins 100% of the time

Disclaimer

The information and publications of trading-strategies do not constitute financial advice, investment advice, trading advice or any other form of advice. All results from trading-strategies are intended for information purposes only.

It is very important to do your own analysis before making any investment based on your own personal circumstances. If you need financial advice or further advice in general, it is recommended that you identify a relevantly qualified individual in your jurisdiction who can advise you accordingly.

Maintainers

Benny Neugebauer on Stack Exchange

⭐️ Become a TypeScript rockstar! ⭐️

This package was built by Benny Neugebauer. Checkout my TypeScript course to become a coding rockstar!

License

This project is MIT licensed.