New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@d3fc/d3fc-financial-feed

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@d3fc/d3fc-financial-feed - npm Package Compare versions

Comparing version 5.0.7 to 6.0.0

141

build/d3fc-financial-feed.js

@@ -73,144 +73,3 @@ (function (global, factory) {

// https://www.quandl.com/docs/api#datasets
var quandl = function () {
function defaultColumnNameMap(colName) {
return colName[0].toLowerCase() + colName.substr(1);
}
var database = 'YAHOO';
var dataset = 'GOOG';
var apiKey = null;
var start = null;
var end = null;
var rows = null;
var descending = false;
var collapse = null;
var columnNameMap = defaultColumnNameMap;
var quandl = function quandl() {
var params = [];
if (apiKey != null) {
params.push('api_key=' + apiKey);
}
if (start != null) {
params.push('start_date=' + start.toISOString().substring(0, 10));
}
if (end != null) {
params.push('end_date=' + end.toISOString().substring(0, 10));
}
if (rows != null) {
params.push('rows=' + rows);
}
if (!descending) {
params.push('order=asc');
}
if (collapse != null) {
params.push('collapse=' + collapse);
}
var url = 'https://www.quandl.com/api/v3/datasets/' + database + '/' + dataset + '/data.json?' + params.join('&');
return d3Fetch.json(url).then(function (data) {
var datasetData = data.dataset_data;
var nameMapping = columnNameMap || function (n) {
return n;
};
var colNames = datasetData.column_names.map(function (n, i) {
return [i, nameMapping(n)];
}).filter(function (v) {
return v[1];
});
return datasetData.data.map(function (d) {
var output = {};
colNames.forEach(function (v) {
output[v[1]] = v[0] === 0 ? new Date(d[v[0]]) : d[v[0]];
});
return output;
});
});
};
// Unique Database Code (e.g. WIKI)
quandl.database = function (x) {
if (!arguments.length) {
return database;
}
database = x;
return quandl;
};
// Unique Dataset Code (e.g. AAPL)
quandl.dataset = function (x) {
if (!arguments.length) {
return dataset;
}
dataset = x;
return quandl;
};
// Set To Use API Key In Request (needed for premium set or high frequency requests)
quandl.apiKey = function (x) {
if (!arguments.length) {
return apiKey;
}
apiKey = x;
return quandl;
};
// Start Date of Data Series
quandl.start = function (x) {
if (!arguments.length) {
return start;
}
start = x;
return quandl;
};
// End Date of Data Series
quandl.end = function (x) {
if (!arguments.length) {
return end;
}
end = x;
return quandl;
};
// Limit Number of Rows
quandl.rows = function (x) {
if (!arguments.length) {
return rows;
}
rows = x;
return quandl;
};
// Return Results In Descending Order (true) or Ascending (false)
quandl.descending = function (x) {
if (!arguments.length) {
return descending;
}
descending = x;
return quandl;
};
// Periodicity of Data (daily | weekly | monthly | quarterly | annual)
quandl.collapse = function (x) {
if (!arguments.length) {
return collapse;
}
collapse = x;
return quandl;
};
// Function Used to Normalise the Quandl Column Name To Field Name, Return Null To Skip Field
quandl.columnNameMap = function (x) {
if (!arguments.length) {
return columnNameMap;
}
columnNameMap = x;
return quandl;
};
// Expose default column name map
quandl.defaultColumnNameMap = defaultColumnNameMap;
return quandl;
};
exports.feedGdax = gdax;
exports.feedQuandl = quandl;

@@ -217,0 +76,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

2

build/d3fc-financial-feed.min.js

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-fetch")):"function"==typeof define&&define.amd?define(["exports","d3-fetch"],t):t(n.fc=n.fc||{},n.d3)}(this,function(n,t){"use strict";var e=function(){var n="BTC-USD",e=null,u=null,r=null,o=function(){var o=[];null!=e&&o.push("start="+e.toISOString()),null!=u&&o.push("end="+u.toISOString()),null!=r&&o.push("granularity="+r);var l="https://api.gdax.com/products/"+n+"/candles?"+o.join("&");return t.json(l).then(function(n){return n.map(function(n){return{date:new Date(1e3*n[0]),open:n[3],high:n[2],low:n[1],close:n[4],volume:n[5]}})})};return o.product=function(t){return arguments.length?(n=t,o):n},o.start=function(n){return arguments.length?(e=n,o):e},o.end=function(n){return arguments.length?(u=n,o):u},o.granularity=function(n){return arguments.length?(r=n,o):r},o},u=function(){function n(n){return n[0].toLowerCase()+n.substr(1)}var e="YAHOO",u="GOOG",r=null,o=null,l=null,a=null,i=!1,c=null,s=n,f=function(){var n=[];null!=r&&n.push("api_key="+r),null!=o&&n.push("start_date="+o.toISOString().substring(0,10)),null!=l&&n.push("end_date="+l.toISOString().substring(0,10)),null!=a&&n.push("rows="+a),i||n.push("order=asc"),null!=c&&n.push("collapse="+c);var f="https://www.quandl.com/api/v3/datasets/"+e+"/"+u+"/data.json?"+n.join("&");return t.json(f).then(function(n){var t=n.dataset_data,e=s||function(n){return n},u=t.column_names.map(function(n,t){return[t,e(n)]}).filter(function(n){return n[1]});return t.data.map(function(n){var t={};return u.forEach(function(e){t[e[1]]=0===e[0]?new Date(n[e[0]]):n[e[0]]}),t})})};return f.database=function(n){return arguments.length?(e=n,f):e},f.dataset=function(n){return arguments.length?(u=n,f):u},f.apiKey=function(n){return arguments.length?(r=n,f):r},f.start=function(n){return arguments.length?(o=n,f):o},f.end=function(n){return arguments.length?(l=n,f):l},f.rows=function(n){return arguments.length?(a=n,f):a},f.descending=function(n){return arguments.length?(i=n,f):i},f.collapse=function(n){return arguments.length?(c=n,f):c},f.columnNameMap=function(n){return arguments.length?(s=n,f):s},f.defaultColumnNameMap=n,f};n.feedGdax=e,n.feedQuandl=u,Object.defineProperty(n,"__esModule",{value:!0})});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-fetch")):"function"==typeof define&&define.amd?define(["exports","d3-fetch"],t):t(n.fc=n.fc||{},n.d3)}(this,function(n,t){"use strict";var e=function(){var n="BTC-USD",e=null,u=null,r=null,o=function(){var o=[];null!=e&&o.push("start="+e.toISOString()),null!=u&&o.push("end="+u.toISOString()),null!=r&&o.push("granularity="+r);var i="https://api.gdax.com/products/"+n+"/candles?"+o.join("&");return t.json(i).then(function(n){return n.map(function(n){return{date:new Date(1e3*n[0]),open:n[3],high:n[2],low:n[1],close:n[4],volume:n[5]}})})};return o.product=function(t){return arguments.length?(n=t,o):n},o.start=function(n){return arguments.length?(e=n,o):e},o.end=function(n){return arguments.length?(u=n,o):u},o.granularity=function(n){return arguments.length?(r=n,o):r},o};n.feedGdax=e,Object.defineProperty(n,"__esModule",{value:!0})});

@@ -6,2 +6,18 @@ # Change Log

<a name="6.0.0"></a>
# [6.0.0](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-financial-feed@5.0.7...@d3fc/d3fc-financial-feed@6.0.0) (2019-01-21)
### Bug Fixes
* remove Quandl feed ([8e8a605](https://github.com/d3fc/d3fc/commit/8e8a605))
### BREAKING CHANGES
* removing Quandl feed as no longer supported
<a name="5.0.7"></a>

@@ -8,0 +24,0 @@ ## [5.0.7](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-financial-feed@5.0.6...@d3fc/d3fc-financial-feed@5.0.7) (2019-01-15)

declare namespace fc_financial_feed {
export function Gdax(): Gdax;
export function Quandl(): Quandl;

@@ -27,26 +26,2 @@ interface GdaxDatum {

}
interface Quandl {
database(): string;
database(x: string): Quandl;
dataset(): string;
dataset(x: string): Quandl;
apiKey(): string;
apiKey(x: string): Quandl;
start(): Date;
start(x: Date): Quandl;
end(): Date;
end(x: Date): Quandl;
rows(): number;
rows(x: number): Quandl;
descending(): boolean;
descending(x: boolean): Quandl;
collapse(): string;
collapse(x: string): Quandl;
columnNameMap(): (name: string) => string;
columnNameMap(mapFunction: (name: string) => string): Quandl;
defaultColumnNameMap: (name: string) => string;
(): Promise<any[]>;
}
}

@@ -53,0 +28,0 @@

export { default as feedGdax } from './src/gdax';
export { default as feedQuandl } from './src/quandl';
{
"name": "@d3fc/d3fc-financial-feed",
"version": "5.0.7",
"description": "An API for fetching financial time-series data from different sources including Quandl and GDAX",
"version": "6.0.0",
"description": "An API for fetching financial time-series data from different sources including GDAX",
"license": "MIT",

@@ -11,3 +11,2 @@ "keywords": [

"data",
"quandl",
"coinbase",

@@ -14,0 +13,0 @@ "gdax"

# d3fc-financial-feed
An API for fetching financial time-series data from different sources including Quandl and GDAX.
An API for fetching financial time-series data from different sources including GDAX.

@@ -16,3 +16,2 @@ [Main d3fc package](https://github.com/d3fc/d3fc)

* [GDAX](#gdax)
* [Quandl](#quandl)

@@ -75,99 +74,1 @@ ### GDAX

### Quandl
``` javascript
import { feedQuandl } from 'd3fc-financial-feed';
const quandl = feedQuandl()
.database('WIKI')
.dataset('AAPL')
.rows(10)
.descending(true)
.collapse('weekly');
quandl()
.then(data => { console.log(data); });
// [
// {
// date: 2016-05-15T00:00:00.000Z,
// open: 93.33,
// high: 93.57,
// low: 92.11,
// close: 93.39,
// volume: 33217012,
// 'ex-Dividend': 0,
// 'split Ratio': 1,
// 'adj. Open': 93.33,
// 'adj. High': 93.57,
// 'adj. Low': 92.11,
// 'adj. Close': 93.39,
// 'adj. Volume': 33217012
// },
// ...
// ]
```
https://www.quandl.com/docs/api#datasets
<a name="feedQuandl" href="#feedQuandl">#</a> fc.**feedQuandl**()
Constructs a new quandl feed.
<a name="feedQuandl_" href="#feedQuandl_">#</a> *feedQuandl*()
Makes a request to the Quandl API, returns a `Promise` which resolves with data.
Data returned from the API is mapped to an array of objects with properties for all non-null names mapped by *feedQuandl*.columnNameMap, with date column values converted to `Date` instances.
<a name="feedQuandl_database" href="#feedQuandl_database">#</a> *feedQuandl*.**database**([*value*])
If *value* is specified, sets the unique database code to the specified string and returns this feed instance.
If *value* is not specified, returns the current database code, which defaults to `"YAHOO"`.
<a name="feedQuandl_dataset" href="#feedQuandl_dataset">#</a> *feedQuandl*.**dataset**([*value*])
If *value* is specified, sets the unique dataset code to the specified string and returns this feed instance.
If *value* is not specified, returns the current dataset code, which defaults to `"GOOG"`.
<a name="feedQuandl_apiKey" href="#feedQuandl_apiKey">#</a> *feedQuandl*.**apiKey**([*value*])
If *value* is specified, sets the API key to the specified string and returns this feed instance.
This is required for premium set or high frequency requests.
If *value* is not specified, returns the current API key, which defaults to null.
<a name="feedQuandl_start" href="#feedQuandl_start">#</a> *feedQuandl*.**start**([*value*])
If *value* is specified, sets the start date to the specified `Date` object and returns this feed instance.
If *value* is not specified, returns the current start date, which defaults to null.
<a name="feedQuandl_end" href="#feedQuandl_end">#</a> *feedQuandl*.**end**([*value*])
If *value* is specified, sets the end date to the specified `Date` object and returns this feed instance.
If *value* is not specified, returns the current end date, which defaults to null.
<a name="feedQuandl_rows" href="#feedQuandl_rows">#</a> *feedQuandl*.**rows**([*value*])
If *value* is specified, sets the row limit to the specified number and returns this feed instance.
If *value* is not specified, returns the current row limit, which defaults to null.
<a name="feedQuandl_descending" href="#feedQuandl_descending">#</a> *feedQuandl*.**descending**([*value*])
If *value* is specified, sets the ordering of the data (descending if `true`, ascending if `false`) and returns this feed instance.
If *value* is not specified, returns the current ordering value, which defaults to false.
<a name="feedQuandl_collapse" href="#feedQuandl_collapse">#</a> *feedQuandl*.**collapse**([*value*])
If *value* is specified, sets the periodicity of the data ("none", "daily" | "weekly" | "monthly" | "quarterly" | "annual") and returns this feed instance.
If *value* is not specified, returns the current periodicity, which defaults to null.
<a name="feedQuandl_columnNameMap" href="#feedQuandl_columnNameMap">#</a> *feedQuandl*.**columnNameMap**([*value*])
If *value* is specified, sets the function used to map Quandl column names to property names and returns this feed instance.
If *value* is not specified, returns the current column name map, which defaults to *feedQuandl*.defaultColumnNameMap.
If the supplied function returns null for a column, then that column will be omitted from the output data.
Setting *value* to null will preserve the original column names.
<a name="feedQuandl_defaultColumnNameMap" href="#feedQuandl_defaultColumnNameMap">#</a> *feedQuandl*.**defaultColumnNameMap**
Returns the default column name mapping function. This function returns the supplied column name with a lower case first letter (e.g. it maps "Close" to "close").

@@ -16,6 +16,4 @@ import jsdom from 'jsdom';

const gdaxFeed = win.fc.feedGdax();
const quandlFeed = win.fc.feedQuandl();
expect(gdaxFeed).toBeDefined();
expect(quandlFeed).toBeDefined();
done();

@@ -22,0 +20,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc