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

@particle-academy/fancy-trading

v0.1.0

Published

Headless trading domain core for the Fancy UI suite — exact decimal money, instrument shapes across equities/futures/perpetuals/event markets, the FIX-derived order lifecycle, and position + P&L arithmetic with average-cost and FIFO. Zero runtime depend

Readme

@particle-academy/fancy-trading

Headless trading domain core for the Fancy UI suite. Zero runtime dependencies. No React, no network, no opinions about how you build a strategy.

npm install @particle-academy/fancy-trading

What it is

The plumbing a trading application needs and should not write twice:

  • Exact decimal money — integer minor units on bigint. Math.trunc(19.99 * 100) is 1998; this is not.
  • Position and P&L — average-cost, FIFO and LIFO, position flips, futures multipliers, and inverse (coin-margined) contracts whose P&L is non-linear.
  • The order lifecycle — the FIX OrdStatus / ExecType pair, a validated transition table, and cumulative-state events that survive a reconnect gap.
  • A trust-but-verify gate — agents propose, humans confirm, structurally.

What it is NOT

No strategy DSL, no prescribed workflow, no indicator library, and no advice. It shows you the shapes; what you build on them is yours.

Quick look

import { parseDecimal, formatDecimal } from "@particle-academy/fancy-trading";
import { emptyPosition, applyFill, unrealised } from "@particle-academy/fancy-trading";

const equity = { contractType: "linear" as const, multiplier: parseDecimal("1", 0), moneyExp: 2 };

let pos = emptyPosition("fifo");
pos = applyFill(pos, { side: "buy", qty: parseDecimal("100", 0), price: parseDecimal("10.00", 2), at: 1 }, equity).position;
pos = applyFill(pos, { side: "buy", qty: parseDecimal("100", 0), price: parseDecimal("20.00", 2), at: 2 }, equity).position;

const { position, realisedDelta } = applyFill(
  pos, { side: "sell", qty: parseDecimal("100", 0), price: parseDecimal("25.00", 2), at: 3 }, equity,
);

formatDecimal(realisedDelta);                              // "1500.00"  (FIFO)
formatDecimal(unrealised(position, parseDecimal("25.00", 2), equity)); // "500.00"

Switch emptyPosition("average") and the same fills realise 1000.00 with 1000.00 unrealised. Both are correct; they are different questions. That is why the basis is a required argument.

Licence

MIT.