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

freechange

v0.0.190

Published

Code and data to perform historical currency exchange.

Downloads

808

Readme

Freechange is a javascript module and data to perform historical currency exchange.

| View on npm | Try on Runkit | Website | |- |- |- |

Installation and usage

npm install freechange

This will include a few meg of historical json, so be warned we are very data heavy. See below for options to reduce this size.

var freechange = require("freechange")

console.log( freechange.by_date(100,"GBP","USD","2010") )
console.log( freechange.by_date(100,"GBP","USD","2010-01") )
console.log( freechange.by_date(100,"GBP","USD","2010-01-01") )

This will exchange 100 GBP to USD multiple times, using slightly different dates.

Remember, we have a focus on historical data so this call may give different results when used with a date less than a year old, depending on when you installed the package and when we last updated the package with newer data. This happens as new data is collected overtime.

Currencies are expressed as their ISO 4217 codes.

We currently have historical exchange rates for 190 currencies with varying degrees of support and resolution.

You can view this list by visiting https://xriss.github.io/freechange-charts/ and selecting from USD to your currency of choice.

The monthly chart represents good coverage so if that is missing then we do not support that currency very well.

Options

So to recap, times in the past are good and stable, times in the future are not.
If you mostly care about today's exchange rates, you should be using an API rather than this historical data dump.

When you provide a date, it will trigger one of three modes as described below - depending on if it is a full date, a month or a year only.

Year provided

We will use yearly averages for the given year or closest year if it is out of the range of data.

Month provided

We will use monthly averages for the given month or switch to yearly average if the date is out of the range of our monthly data.

Day provided

We will use daily numbers for the given day or switch to monthly and then yearly average if the date is out of the range of our data.

This function will return a number if it is successful or undefined if it is not; eg. we could not find the currency you requested.

If you want to reduce the amount of memory used by data, you can reduce the maximum resolution from day to month or year by changing to one of the following requires. This allows you to explicitly choose the resolutions available to reduce accuracy and more importantly, data size.

var freechange = require("freechange/day")
var freechange = require("freechange/month")
var freechange = require("freechange/year")

Sources

When it comes to sourcing the data we use ( in order of preference ) numbers from the following sources. You can find the latest data we grabbed in the JSON directory along with generated usd_to_xxx exchange rates for days, months and years.

| Name | Range | Source | JSON | |- |- |- |- | | IMF | Daily | https://www.imf.org/external/np/fin/data/param_rms_mth.aspx | https://github.com/xriss/freechange/blob/master/json/imf.json | | FRED | Daily | https://fred.stlouisfed.org/categories/94 | https://github.com/xriss/freechange/blob/master/json/fred.json | | CodeforIATI | Daily | https://raw.githubusercontent.com/codeforIATI/imf-exchangerates/gh-pages/imf_exchangerates.csv | https://github.com/xriss/freechange/blob/master/json/cfiati.json | | OECD | Monthly | https://data.oecd.org/conversion/exchange-rates.htm | https://github.com/xriss/freechange/blob/master/json/oecd.json | | MYBUTT | Yearly | https://github.com/xriss/freechange/blob/master/mybutt/year.csv | This folder contains handmade CSV for when every other source fails. |

Data Downloads

All of these sources are combined into the following output JSON files which contain data you could use directly outside of this module.
CSV files are also built at the same time as the JSON files and will contain the same data.

|Name |JSON |CSV | |- |- |- | | USD to XXX by Day | https://github.com/xriss/freechange/blob/master/json/usd_to_xxx_by_day.json | https://github.com/xriss/freechange/blob/master/csv/usd_to_xxx_by_day.csv | | USD to XXX by Month | https://github.com/xriss/freechange/blob/master/json/usd_to_xxx_by_month.json | https://github.com/xriss/freechange/blob/master/csv/usd_to_xxx_by_month.csv | | USD to XXX by Year | https://github.com/xriss/freechange/blob/master/json/usd_to_xxx_by_year.json | https://github.com/xriss/freechange/blob/master/csv/usd_to_xxx_by_year.csv |