# quandl-eod-helper

> Fetch, extract and parse time-series stock data from the Quandl API

Latest version **1.2.5** (published 2017-09-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install quandl-eod-helper
pnpm add quandl-eod-helper
yarn add quandl-eod-helper
bun add quandl-eod-helper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2017-09-11 |
| First published | 2017-09-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ian Halverson |
| Maintainers | idhalverson |
| Keywords | quandl, eod, helper, stocks, parser, fetch |

## Links

- npm: https://www.npmjs.com/package/quandl-eod-helper
- Repository: https://github.com/IDHalverson/quandl-eod-helper
- Issues: https://github.com/IDHalverson/quandl-eod-helper/issues
- npm.io page: https://npm.io/package/quandl-eod-helper

## Dependencies (3)

- [dotenv](https://npm.io/package/dotenv.md) ^4.0.0
- [moment](https://npm.io/package/moment.md) ^2.18.1
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^2.2.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.2.5 (latest) — 2017-09-11
- 1.2.4 — 2017-09-11
- 1.2.3 — 2017-09-11
- 1.2.2 — 2017-09-10
- 1.2.1 — 2017-09-10
- 1.2.0 — 2017-09-10
- 1.0.1 — 2017-09-10
- 1.0.0 — 2017-09-10

## README

# Quandl EOD Helper

See it on [NPM](https://www.npmjs.com/package/quandl-eod-helper)

Fetch, extract and parse time-series stock data from the [Quandl](https://www.quandl.com/) API (only `database_code` EOD supported). This package also fills the data
such that weekends and holidays will be populated with the stock price data from
the last day from which data is available. Future
versions may support different schemas, file types, and/or database_codes.

Consult the Quandl time-series [API Docs](https://docs.quandl.com/docs/time-series)
 for information on the API.

Output Format (full example is shown at bottom of README):
```
{
  dataTypes: [...],
  tickers: [ticker1, ticker2, ...],
  dates: [date1, date2, ...],
  pricesByTicker: {
    ticker1: {
      date1: price,
      date2: price
    }
    ticker2: {
      date1: price,
      date2: price
    }
  }
  pricesByDate: {
    date1: {
      ticker1: price,
      ticker2: price
    }
    date2: {
      ticker1: price,
      ticker2: price
    }
  }
}
```

# Installation

Install via NPM
```
npm install --save quandl-eod-helper
```

**quandl-eod-helper has the following npm dependencies:**

`isomorphic-fetch`, `dot-env`, `moment`

# Setup and Configuration

**Place your Quandl api key in a `.env` file.**

root/.env
```
QUANDL_API_KEY=YOUR_KEY
```

**Require the module, and instantiate a new `Eod` instance.**

```
const quandlEodHelper = require('quandl-eod-helper')
const Eod = new quandlEodHelper()
```

**Configure the `Eod` instance to your preferences.**

All configurations are optional and will provide minimal default values; however,
the helper will throw an error if you attempt to parse (using Eod.data()) without
either passing in properly formatted data or fetching first.

```
const year = '2016'
const tickers = ['AAPL', 'MSFT']
const eodData = {} //<--very optional
```
`year` as 'yyyy' string format
`tickers` as an array of tickers... check the Quandl Docs for available options.
`eodData` is an option to input your own API response data if you do not want to use
this module's native 'fetch' method. Ensure it's in the same JSON format that Quandl returns.

```
Eod.config({ year, tickers })
const Eod = new quandleEodHelper({ year, tickers })
```
...example of configuration using **either** the constructor or the `config()` method.
Note: we are not passing in the optional eodData parameter.


You can also configure parameters one at a time...

```
Eod.setYear(year)
Eod.setTickers(tickers)
Eod.setEodData(eodData)
```

# Usage

**Fetch the data from Quandl.**

When fetching, data is stored within the `Eod` instance. Fetching returns a promise, which resolves the raw JSON data from Quandl.
```
Eod.fetch()
.then((data) => {
  console.log(data) //raw JSON response
  })
```

**Your parsed data should now be available for use, using the `Eod.data()` method!**

Note: If you configured your own Quandl API data, you can use Eod.data() now (skip the previous 'fetch' step) to just parse that data.

Example response from our configurations:
```
const data = Eod.data()
console.log(data)
```
result:
```
{
  dataTypes: [
    "tickers",
    "dates",
    "pricesByTicker",
    "pricesByDate"
    ],
  tickers: [
    "AAPL",
    "MSFT"
    ],
  dates: [
    "2016-01-01",
    "2016-01-02",
    "2016-01-03",
    etc...
    ],
  pricesByTicker: {
    AAPL: {
      2016-01-01: 105.35,
      2016-01-02: 102.71,
      2016-01-03: 100.7,
      etc...
      },
    MSFT: {
      2016-01-01: 54.8,
      2016-01-02: 55.05,
      2016-01-03: 54.05,
      etc...
    }
  },
  pricesByDate: {
    2016-01-01: {
      AAPL: 105.35,
      MSFT: 54.8,
      },
    2016-01-02: {
      AAPL: 102.71,
      MSFT: 55.05
      },
    2016-01-03: {
      AAPL: 100.7,
      MSFT: 54.05
      },
    etc...
  }
}
```

### License

Copyright 2017 idhalverson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/quandl-eod-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
