This guide explains how to run the Kiploks Open Core engine on your machine: the deterministic analyze() pipeline, the kiploks CLI, and optional conformance checks. Scope is this repository and published packages only.
If you only need the first successful analyze() call:
mkdir my-kiploks-run && cd my-kiploks-run
npm init -y
npm install @kiploks/engine-core @kiploks/engine-contracts
node -e "const { analyze } = require('@kiploks/engine-core'); console.log(analyze({strategyId:'demo',trades:[{profit:1.2},{profit:-0.4}]},{seed:42,decimals:8}).summary)"Then continue with Option 1 or Option 2 sections for CLI/conformance/upload.
You can work in two ways:
- Clone from Git - full source, best for contributors and for running
test-conformanceand the full engine test suite. - Install from npm - intended for integrators (CI or custom glue code) once packages are published; smaller footprint, fewer dev commands.
- Node.js 20.x or newer (LTS recommended). Check with
node -v. - npm 9+ (comes with Node). Check with
npm -v. - A shell where you can run
bash-style commands (macOS, Linux, or Windows with Git Bash or WSL).
Optional:
- Git, if you clone the repository.
- tsx may be a dev dependency when developing this repo; the npm-only path assumes published
dist/artifacts inside packages (notsxrequired for end users after publish).
Use this when you want the complete engine source, golden vectors, and scripts that match CI.
Clone the engine repository (public Open Core root):
git clone https://github.com/kiploks/engine.git
cd engineFrom the repository root (where the root package.json lives):
npm ciUse npm install only if you do not rely on a lockfile (not recommended for reproducible builds).
Consumers and local scripts typically expect compiled dist/ for @kiploks/engine-contracts and @kiploks/engine-core:
npm run buildCreate a file input.json with a minimal AnalyzeInput shape:
{
"strategyId": "demo",
"trades": [{ "profit": 10.5 }, { "profit": -2.2 }]
}Run analysis (machine-readable output):
npx tsx cli/src/index.ts analyze ./input.json --jsonOr after npm link / local install of the CLI package, use the kiploks binary.
On Windows, use the same paths; prefer forward slashes or quoted paths if your directory names contain spaces.
This runs Vitest for this workspace, plus boundary and npm bundle safety checks:
npm run engine:validateOr via the CLI helper (must be run from the engine repository root so it can find vitest.config.ts and engine:validate):
npm run engine:test-conformanceIf you have a Kiploks integration API key and a standalone result payload:
export KIPLOKS_API_BASE=https://kiploks.com
export KIPLOKS_API_KEY=your_integration_key
npx tsx cli/src/index.ts upload ./result.json --cloud --dry-runRemove --dry-run only when you intend to POST for real. See cli/README.md for --local-analyze and parity options.
Use this when official packages are published to the npm registry under scopes such as @kiploks/engine-cli, @kiploks/engine-core, and @kiploks/engine-contracts. Publishing and public registry names are part of your release process; until then, prefer Option 1.
Pin the same semver line for all @kiploks/engine-* packages you install.
mkdir my-kiploks-run && cd my-kiploks-run
npm init -yPin versions to the same release line (example versions only):
npm install @kiploks/engine-cli@^0.2.0 @kiploks/engine-core@^0.2.0 @kiploks/engine-contracts@^0.2.0If the CLI declares peerDependencies, install those versions as shown by npm install warnings.
After publish, the kiploks binary should be available via npx:
npx kiploks analyze ./input.json --jsonOr add an npm script in your package.json:
{
"scripts": {
"analyze": "kiploks analyze ./input.json --json"
}
}kiploks test-conformanceis designed to discover a checkout whose root hasvitest.config.tsorvitest.engine.config.tsand theengine:validatenpm script. It will not replace a full clone for running the golden vector suite if you only installed packages from the registry.- To verify published bits as a consumer, rely on the version you installed and optional upstream CI badges or release notes. To run the full suite locally, use Option 1 (clone).
import { analyze } from "@kiploks/engine-core";
import type { AnalyzeInput } from "@kiploks/engine-contracts";
const input: AnalyzeInput = {
strategyId: "demo",
trades: [{ profit: 1 }],
};
const out = analyze(input, { seed: 42, decimals: 8 });
console.log(out.summary, out.metadata);Ensure moduleResolution and target in tsconfig.json match your Node version. Use the package main/types fields (typically dist/) from the published tarball.
- Input types are defined in
@kiploks/engine-contracts(AnalyzeInput,AnalyzeConfig,AnalyzeOutput). - Outputs include reproducibility fields:
inputHash,configHash,engineVersion,formulaVersion,riskAnalysisVersion,contractVersion,seed,decimals. - Use
@kiploks/engine-coreas the public, semver-stable API (root import from the published package).
A full analysis report (TestResultData) with every block (WFA, turnover, benchmark, verdict, and so on) is assembled by hosting-side pipelines that consume unified payloads. Most of the underlying math still lives in @kiploks/engine-core; the CLI analyze path is a smaller, reproducible surface. Details of how a host wires I/O and assembly are outside this repository.
See also packages/test-vectors/CONFORMANCE.md for how golden JSON vectors are maintained.
| Issue | What to try |
|---|---|
Cannot find module '@kiploks/engine-core' |
Run npm install from the directory that contains your package.json; ensure workspaces are not required for a standalone project. |
Workspace cannot resolve @kiploks/engine-* |
Ensure npm run build was run in this repo so dist/ exists, or pin published versions from npm. |
| CLI not found after npm install | Use npx kiploks or ./node_modules/.bin/kiploks. |
test-conformance says it cannot find monorepo root |
Run it from the git clone root (Option 1), or use npm run engine:validate there. |
| Wrong numbers vs cloud | Align engine package version with the server; compare metadata hashes and engineVersion in the API response. |
Engine packages follow the license shipped in the repository or npm tarball (see root LICENSE or package metadata). Using the CLI against the hosted API is subject to the product terms and your API key scope.