0.4.17 • Published 8 years ago

marketeer v0.4.17

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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
0.4.17

8 years ago

0.4.16

8 years ago

0.4.15

8 years ago

0.4.14

8 years ago

0.4.13

8 years ago

0.4.12

8 years ago

0.4.11

8 years ago

0.4.10

8 years ago

0.4.9

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.11

8 years ago

0.3.10

8 years ago

0.3.9

8 years ago

0.3.8

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.0

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago