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 🙏

© 2024 – Pkg Stats / Ryan Hefner

marketeer

v0.4.17

Published

Market monitor

Downloads

18

Readme

Marketeer

Augur market monitor/cache.

Installation

$ npm install marketeer

Usage

var marketeer = require("marketeer");

marketeer.scan fetches up-to-date data for all Augur markets from the Ethereum blockchain, and stores it in levelDB:

var config = {
    http: "rpc_server url",          //specify at least 1 of http, ws, or ipc
    ws: "websocket server url",
    ipc: "path to geth.ipc",
    db: "./path_to_db",              //will be created automatically if doesn't exist already
    limit: null,                     //How many markets to fetch (null for all)
    filtering: true,                 //Listen for new markets, price changes, etc? (only used with watch)
    scan: true,                      //Scan blockchain for markets on startup?
}
marketeer.scan(config, function (err, numUpdates) {
    if (err) throw err;
    console.log("Oh happy day!", numUpdates, "markets have been updated!");
    // fun times here
});

marketeer.watch creates a persistent blockchain listener.

marketeer.watch(config, function (err, numUpdates, data) {
    if (err) throw err;
    console.log("Oh happy day!", numUpdates, "markets have been updated!");
    // fun times here
});

marketeer.unwatch stops watching the blockchain, removes the filters, and closes the database connection.

APIs

//returns marketInfo for a single market
marketeer.getMarketInfo(id, function (err, market){ ... });
//returns a strem of all basic market info for all markets in a branch
marketeer.getMarketsInfo(options, function (err, stream){ ... });

You can consume the contents of the stream by doing:

stream.on('data', (data) => {
    console.log(data);
}).on('end', () => {
    console.log("finished");
});  

The options parameter allows you to limit the results of the stream. It should be in the format

var options = { blockId: ['eq', 4],
                volume: ['gt', 100]}

The key is the field you'd like to filter on, the first item in the array is the filter operation (eq, lt, lte, gt, gte), and the second value in the array is the value you are comparing against.

//retuns full market data for an array of market ids
marketeer.batchGetMarketInfo(ids, function (err, markets) { ... });
var options = {
    toBlock: blockNumber
    fromBlock: blockNumber
}
//returns price history for a single market
//options is an optional param. w/o it, returns price history for all blocks
marketeer.getMarketPriceHistory(id, options, function (err, history) { ... });
var options = {
    toBlock: blockNumber
    fromBlock: blockNumber
}
//returns trade history for a single user
//options is an optional param. w/o it, returns trade history for all blocks
marketeer.getAccountTrades(id, options, function (err, trades) { ... });

Tests

These tests require two geth testnet accounts funded with cash and testnet ether, as they simulate trading back and forth to test marketeer's listeners.

$ npm test