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

currency-market

v0.4.2

Published

A synchronous implementation of a limit order based currency market

Downloads

48

Readme

currency-market

A synchronous implementation of a limit order based currency market

Features

  • Supports an arbitrary list of currencies
  • Synchronously executes trades as orders are added
  • Emits events when changes are made to the market

Installation

npm install currency-market

API

All functions complete synchronously and throw errors if they fail. Events are made available for monitoring changes in the market.

var CurrencyMarket = require('currency-market');

// instantiate a market
var currencyMarket = new CurrencyMarket({
  currencies: [
    'EUR',
    'USD',
    'BTC'
  ]
});

// register for events
currencyMarket.on('account', function(account) {
  console.log(account);
});
currencyMarket.on('deposit', function(deposit) {
  console.log(deposit);
});
currencyMarket.on('withdrawal', function(withdrawal) {
  console.log(withdrawal);
});
currencyMarket.on('order', function(order) {
  console.log(order);
});
currencyMarket.on('cancellation', function(order) {
  console.log(order);
});
currencyMarket.on('trade', function(trade) {
  console.log(trade);
});

// add accounts
currencyMarket.register({
  id: 'Peter'
});
currencyMarket.register({
  id: 'Paul'
});

// make deposits
currencyMarket.deposit({
  account: 'Peter',
  currency: 'EUR',
  amount: '5000'
});
currencyMarket.deposit({
  account: 'Paul',
  currency: 'BTC',
  amount: '5000'
});

// make withdrawals
currencyMarket.withdraw({
  account: 'Peter',
  currency: 'EUR',
  amount: '1000'
});
currencyMarket.withdraw({
  account: 'Paul',
  currency: 'BTC',
  amount: '1000'
});

// submit orders
currencyMarket.submit({
  id: '1',
  timestamp: '1366758222',
  account: 'Peter',
  bidCurrency: 'BTC',
  offerCurrency: 'EUR',
  bidPrice: '2',
  bidAmount: '500'
});
currencyMarket.submit({
  id: '2',
  timestamp: '1366758245',
  account: 'Peter',
  bidCurrency: 'BTC',
  offerCurrency: 'EUR',
  bidPrice: '1',
  bidAmount: '2000'
});
currencyMarket.submit({
  id: '3',
  timestamp: '1366758256',
  account: 'Paul',
  bidCurrency: 'EUR',
  offerCurrency: 'BTC',
  offerPrice: '2',
  offerAmount: '250'
});
currencyMarket.submit({
  id: '4',
  timestamp: '1366758268',
  account: 'Paul',
  bidCurrency: 'EUR',
  offerCurrency: 'BTC',
  offerPrice: '3',
  offerAmount: '3000'
});

// cancel an order
currencyMarket.cancel({
  id: '1',
  timestamp: '1366758222',
  account: 'Peter',
  bidCurrency: 'BTC',
  offerCurrency: 'EUR',
  bidPrice: '2',
  bidAmount: '250'
});

// list all the active orders (keyed by id)
console.log(currencyMarket.orders);

// list all the active accounts (keyed by id)
console.log(currencyMarket.accounts);

// list all the active order books 
console.log(currencyMarket.books);

// Get the top of an order book
console.log(currencyMarket.books['EUR']['BTC'].highest);
console.log(currencyMarket.books['BTC']['EUR'].highest);

Roadmap

  • Instant orders (execute or cancel)
  • Pluggable rounding policies
  • Pluggable commission schemes

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

The CoffeeScript source is located in the src/ directory and tests in the test/ directory. Do not edit the contents of the lib/ directory as this is compiled from the CoffeeScript source.

Before commiting run npm test to perform a clean compile of the source and run the tests. This ensures that everything commited is up to date and tested and allows people to npm install directly from the git repository (useful for integrating development branches, etc).

License

Copyright (c) 2013 Peter Halliday
Licensed under the MIT license.