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

crypto-trade-parser

v0.2.0

Published

Easy trade history parser for several exchanges' CSV exports

Readme

crypto-trade-parser

Easy trade history parser for several exchanges' CSV exports. It uses Fast-csv lib to serialize the csv file and custom mappers to unify the trade entry format.

Installation

npm install crypto-trade-parser

Usage

All main methods from Fast-csv were translated into:

  • fromStream(stream, csvOptions)
  • fromPath(pathString, csvOptions)
  • fromString(string, csvOptions)

csvOptions is the Fast-csv lib's option, refer to its documentation.

Default options:

{
  headers: true,
  strictColumnHandling: true,
  ignoreEmpty: true
}

To keep a unified interface, all operations were promisefied.

data-invalid events will reject the promise and its content will be passed over for error handling purposes.

No data event is pushed, being suppressed until end event, which will resolve all content as a list of entries.

Example

var exchange = 'poloniex';
var parser = new Parser(exchange);
parser.fromPath('./myFile.csv').then((list)=>{
    console.log("Parsing is complete, there are " + list.length + " entries".)
}).catch((failedRow)=>{
    console.error("Validation failed on:", failedRow);
});

Output

The execution product is a list of entries representing the trade. As information availability differ on exchanges, some fields may be unavailable, so do check for existence or inspect the code. (@Todo: table with propersties per exchange).

A entry has the following format:

{
  "exchange": "poloniex",
  "bookID": "1074456646",
  "rate": 1.064,
  "date": "2016-11-04T09:58:54.000Z"
  "fee": {
    "percentage": 0.15,
    "absolute": {
      "ETC": 0.000015009398496241134,
      "BTC": 0.000015970000000000567
    }
  },
  "sold": {
    "currency": "ETC",
    "valueGross": 0.01000911
  },
  "bought": {
    "currency": "BTC",
    "valueNet": 0.01063372
  }
}
  • exchange: [string] the exchange name/source.
  • bookID: [string] is the order number/ID on the exchange's book. No transformation is applied.
  • rate: [float] is the rate used/multiplied on the sold currency to result on the bought currency.
  • date: [moment.utc] is the datetime in UTC timezone with the best precision ofered from the source.
  • fee: [Object] has the properties related to the fee
    • percentage: [float] is the rate applied over Gross values to find total fee
    • absolute: [Object] has the [float] values of calculated fee. The keys for this object are infered from the CSV file.
  • sold: [Object]
    • exchange: [string] currency being sold.
    • valueGross: [float] Total/Gross value being liquidated from funds on the operation.
  • bought: [Object]
    • exchange: [string] currency being bought.
    • valueNet: [float] Total/Net value being added to funds on the operation.