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

@solncebro/strategy-player-sdk

v1.8.0

Published

Stable contract between strategy-player backtest engine and external strategy repositories. Source-of-truth for TradingEnv types and runtime behavior.

Readme

strategy-player-sdk

Stable contract between strategy-player backtest engine and external strategy repositories.

Single source of truth for TradingEnv types and runtime behavior. Same code path runs in backtest and in live trading. Strategies depend only on this SDK.

Install

yarn add git+ssh://[email protected]:solncebro/strategy-player-sdk.git#v1.8.0

For local development (when working on this SDK):

yarn add file:../strategy-player-sdk

Quick start

// my-strategy/src/index.ts
import { defineStrategy } from "@solncebro/strategy-player-sdk";

export default defineStrategy({
  name: "My Strategy",
  version: "1.0",
  params: {
    fastPeriod: 9,
    slowPeriod: 21,
    positionSize: 100,
  },
  init(env) {
    /* one-time setup before the first bar */
  },
  onBar(bar, maValues, env) {
    const fastPeriod = env.getParam("fastPeriod", 9);
    const slowPeriod = env.getParam("slowPeriod", 21);

    const history = env.getHistory(slowPeriod);
    if (history.length < slowPeriod) return;

    /* ... your trading logic ... */
  },
  onOrderFill(filledOrder, env) {
    /* react to limit/stop fills */
  },
  onEnd(env) {
    /* cleanup at the end of the run */
  },
});

Compile your strategy with tsc (or via esbuild bundling, which the player does at upload time), then upload through the strategy-player UI or pass the entry path to the backtest API.

Public surface

  • TradingEnv — the interface every strategy interacts with. Methods for opening/closing positions, placing limit orders, reading history and aux series, configuring stop loss, emitting events, and querying parameters. See src/types.ts.
  • Strategy — the contract your default export must satisfy.
  • defineStrategy<TParams>(spec) — type-safe declarative helper. Narrows env.getParam("key", default) to the parameter's actual type.
  • Bar, MaValues, Position, FilledOrder, PendingOrder, Trade, EquityPoint, BacktestEvent, BacktestColumnSpec, BacktestTooltip and other domain types.
  • Strategy.backtestColumns — optional extra columns for the backtest trades table; values via env.setPositionDisplay()Trade.display.
  • API_VERSION — the SDK version your bundle was built against.

Subpath exports

| Import path | Use for | |---|---| | @solncebro/strategy-player-sdk | Strategy code (types + defineStrategy) | | @solncebro/strategy-player-sdk/runtime | Backtest runner (player only — StrategyRuntimeContext) | | @solncebro/strategy-player-sdk/testing | Unit tests for strategies (MockTradingEnv) |

Behavior specification

Read behavior.md for the canonical runtime semantics — fill priority, commission split, funding signs, sandbox limits, time invariants, nullability rules. The contract is the types plus this document.

Examples

See examples/:

Testing your strategy

import { describe, it, expect } from "vitest";
import { MockTradingEnv } from "@solncebro/strategy-player-sdk/testing";
import strategy from "./my-strategy";

describe("my strategy", () => {
  it("opens long on golden cross", () => {
    const mock = new MockTradingEnv(strategy);
    mock.feedBars([
      /* ... synthetic bars + maValues ... */
    ]);

    expect(mock.getOpenPositionList()).toHaveLength(1);
    expect(mock.getOpenPositionList()[0].side).toBe("long");
  });
});

Versioning

Current release is v1.8.0. Future v1.x releases add optional methods/fields only — never break or remove. Breaking changes ship as v2.0.0 with a migration guide. See CHANGELOG.md.