Skip to content

Commit

Permalink
Release 11.2.0 (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
msuperina authored Nov 8, 2018
1 parent 306c43f commit 8b768a6
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 116 deletions.
2 changes: 1 addition & 1 deletion docs/TEST_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Hover off means to move mouse cursor off an element.

### Searching
| Action |Result |
|---|---|---|
|---|---|
| View empty search field | Should contain text "Enter stock name or symbol" |
| Enter "A" character into search field | Should remove the "Enter stock name or symbol" text and replace with the entered search term. The search results field should display "loading search results". Search results which match criteria should be displayed|
| Entering "A" character into search field and hovering on search results | A scroll bar should become visible down the left side of the search results to allow scrolling down the long list. Dragging it should scroll down the list. The stock hovered over should receive dark grey highlighting. |
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "StockFlux",
"description": "Hosts BitFlux as an OpenFin application.",
"version": "11.1.0",
"version": "11.2.0",
"private": true,
"license": "GPL-3.0",
"repository": {
Expand Down Expand Up @@ -76,7 +76,7 @@
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"BitFlux": "github:scottlogic/BitFlux#1.6.1",
"BitFlux": "github:scottlogic/BitFlux#1.6.2",
"babel-polyfill": "^6.3.14",
"classnames": "^2.2.3",
"d3fc": "^5.3.0",
Expand Down
6 changes: 3 additions & 3 deletions src/child/components/favourite/Favourite.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Favourite extends Component {

const price = !isNaN(+stockData.price) ? (+stockData.price).toFixed(2) : null;
const delta = !isNaN(+stockData.delta) ? (+stockData.delta).toFixed(2) : null;
const percentage = !isNaN(+stockData.percentage) ? Math.abs((+stockData.percentage)).toFixed(2) : null;
const percentage = !isNaN(+stockData.percentage) ? (+stockData.percentage).toFixed(2) : null;
const name = stockData.name ? truncate(stockData.name) : '';

const confirmationBindings = {
Expand Down Expand Up @@ -180,9 +180,9 @@ class Favourite extends Component {
<div className="details">
{price && <div className="price">{price}</div>}
{delta && <div className="delta">{delta}</div>}
{percentage && <div className="percentage">
{percentage !== null && <div className="percentage">
<img src={percentage > 0 ? arrowUp : arrowDown} className="stock-arrow" draggable="false" />
{percentage}%
{Math.abs(percentage)}%
</div>}
</div>
</div>
Expand Down
29 changes: 27 additions & 2 deletions src/child/containers/showcase/Showcase.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import React, { Component, PropTypes } from 'react';
import { apiKey as quandlServiceApiKey } from '../../services/QuandlService';
import { apiKey as quandlServiceApiKey, dataset as quandlServiceDataset } from '../../services/QuandlService';
import configService from '../../../shared/ConfigService';

const columnNameMap = {
Open: 'unadjustedOpen',
High: 'unadjustedHigh',
Low: 'unadjustedLow',
Close: 'unadjustedClose',
Volume: 'unadjustedVolume',
Adj_Open: 'open',
Adj_High: 'high',
Adj_Low: 'low',
Adj_Close: 'close',
Adj_Volume: 'volume'
};

function mapColumnNames(colName) {
let mappedName = columnNameMap[colName];
if (!mappedName) {
mappedName = colName[0].toLowerCase() + colName.substr(1);
}
return mappedName;
}

class Showcase extends Component {

componentDidMount() {

this.chart = bitflux.app().quandlApiKey(quandlServiceApiKey());
this.chart = bitflux
.app()
.quandlDatabase(quandlServiceDataset())
.quandlColumnNameMap(mapColumnNames)
.quandlApiKey(quandlServiceApiKey());

this.chart.periodsOfDataToFetch(configService.getBitfluxStockAmount());
this.chart.proportionOfDataToDisplayByDefault(configService.getInitialBitfluxProportion());
Expand Down
20 changes: 9 additions & 11 deletions src/child/services/QuandlService.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const HIGH_INDEX = 9;
const LOW_INDEX = 10;
const CLOSE_INDEX = 11;
const VOLUME_INDEX = 12;
const QUANDL_URL = 'https://www.quandl.com/api/v3/';
const QUANDL_WIKI = 'datasets/WIKI/';
const BASE_URL = 'https://www.quandl.com/api/v3';
const DATASETS_URL = `${BASE_URL}/datasets`;
const DATASET = 'EOD';

// limit concurrency to ensure that we don't have any concurrent Quandl requests
// see: https://blog.quandl.com/change-quandl-api-limits
Expand Down Expand Up @@ -99,11 +100,10 @@ function validateResponse(response) {
});
}


// Exported functions
export function search(query, usefallback = false) {
const apiKeyParam = (usefallback ? '' : API_KEY_VALUE);
return throttle(() => fetch(`${QUANDL_URL}datasets.json?${apiKeyParam}&query=${query}&database_code=WIKI`, {
return throttle(() => fetch(`${DATASETS_URL}.json?${apiKeyParam}&query=${query}&database_code=${DATASET}`, {
method: 'GET',
cache: true
}))
Expand All @@ -118,17 +118,11 @@ export function search(query, usefallback = false) {
});
}

// Queries Quandl for the specific stock code
export function getStockMetadata(code) {
return throttle(() => fetch(`${QUANDL_URL}${QUANDL_WIKI}${code}/metadata.json?${API_KEY_VALUE}`))
.then(validateResponse);
}

export function getStockData(code, usefallback = false) {
const startDate = period().format('YYYY-MM-DD');
const apiKeyParam = (usefallback ? '' : API_KEY_VALUE);

return throttle(() => fetch(`${QUANDL_URL}${QUANDL_WIKI}${code}.json?${apiKeyParam}&start_date=${startDate}`, {
return throttle(() => fetch(`${DATASETS_URL}/${DATASET}/${code}.json?${apiKeyParam}&start_date=${startDate}`, {
method: 'GET',
cache: true
}))
Expand All @@ -139,3 +133,7 @@ export function getStockData(code, usefallback = false) {
export function apiKey() {
return API_KEY;
}

export function dataset() {
return DATASET;
}
32 changes: 16 additions & 16 deletions test/fixture/quandlMetadataResponse.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"dataset": {
"id": 9775718,
"id": 42624632,
"dataset_code": "GOOG",
"database_code": "WIKI",
"name": "Alphabet Inc (GOOG) Prices, Dividends, Splits and Trading Volume",
"description": "End of day open, high, low, close and volume, dividends and splits, and split/dividend adjusted open, high, low close and volume for Google Inc. (GOOG). Ex-Dividend is non-zero on ex-dividend dates. Split Ratio is 1 on non-split dates. Adjusted prices are calculated per CRSP (www.crsp.com/products/documentation/crsp-calculations)\n\nThis data is in the public domain. You may copy, distribute, disseminate or include the data in other products for commercial and/or noncommercial purposes.\n\nThis data is part of Quandl's Wiki initiative to get financial data permanently into the public domain. Quandl relies on users like you to flag errors and provide data where data is wrong or missing. Get involved: [email protected]\n",
"refreshed_at": "2016-05-31T21:47:50.929Z",
"newest_available_date": "2016-05-31",
"database_code": "EOD",
"name": "Alphabet Inc. (GOOG) Stock Prices, Dividends and Splits",
"description": "\u003cp\u003e\u003cb\u003eTicker\u003c/b\u003e: GOOG\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eExchange\u003c/b\u003e: NASDAQ\u003c/p\u003e\n\u003cp\u003ePrices, dividends, splits for Alphabet Inc. (GOOG).\n\n\u003cp\u003eColumns:\u003c/p\u003e\n\u003cp\u003eOpen, High, Low, Close, Volume are \u003cb\u003eunadjusted\u003c/b\u003e.\u003c/p\u003e\n\u003cp\u003eDividend shows the \u003cb\u003eunadjusted\u003c/b\u003e dividend on any ex-dividend date else 0.0.\u003c/p\u003e\n\u003cp\u003eSplit shows any split that occurred on a the given DATE else 1.0\u003c/p\u003e\n\u003cp\u003eAdjusted values are adjusted for dividends and splits using the \u003ca href='http://www.crsp.com/products/documentation/crsp-calculations'\u003eCRSP methodology\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eUpdates of this dataset occur at 5pm ET. Subsequent corrections from the exchange are applied at 9pm ET.\u003c/p\u003e\n\u003cp\u003eData is sourced from NASDAQ, NYSE and AMEX via \u003ca href='http://www.quotemedia.com'\u003eQuotemedia\u003c/a\u003e.\u003c/p\u003e\n\n",
"refreshed_at": "2018-11-03T01:22:19.311Z",
"newest_available_date": "2018-11-02",
"oldest_available_date": "2014-03-27",
"column_names": [
"Date",
Expand All @@ -15,17 +15,17 @@
"Low",
"Close",
"Volume",
"Ex-Dividend",
"Split Ratio",
"Adj. Open",
"Adj. High",
"Adj. Low",
"Adj. Close",
"Adj. Volume"
"Dividend",
"Split",
"Adj_Open",
"Adj_High",
"Adj_Low",
"Adj_Close",
"Adj_Volume"
],
"frequency": "daily",
"type": "Time Series",
"premium": false,
"database_id": 4922
"premium": true,
"database_id": 12910
}
}
}
62 changes: 31 additions & 31 deletions test/fixture/quandlSearchResponse.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"datasets": [
{
"id": 9775718,
"id": 42624632,
"dataset_code": "GOOG",
"database_code": "WIKI",
"name": "Alphabet Inc (GOOG) Prices, Dividends, Splits and Trading Volume",
"description": "End of day open, high, low, close and volume, dividends and splits, and split/dividend adjusted open, high, low close and volume for Google Inc. (GOOG). Ex-Dividend is non-zero on ex-dividend dates. Split Ratio is 1 on non-split dates. Adjusted prices are calculated per CRSP (www.crsp.com/products/documentation/crsp-calculations)\n\nThis data is in the public domain. You may copy, distribute, disseminate or include the data in other products for commercial and/or noncommercial purposes.\n\nThis data is part of Quandl's Wiki initiative to get financial data permanently into the public domain. Quandl relies on users like you to flag errors and provide data where data is wrong or missing. Get involved: [email protected]\n",
"refreshed_at": "2016-05-31T21:47:50.929Z",
"newest_available_date": "2016-05-31",
"database_code": "EOD",
"name": "Alphabet Inc. (GOOG) Stock Prices, Dividends and Splits",
"description": "\u003cp\u003e\u003cb\u003eTicker\u003c/b\u003e: GOOG\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eExchange\u003c/b\u003e: NASDAQ\u003c/p\u003e\n\u003cp\u003ePrices, dividends, splits for Alphabet Inc. (GOOG).\n\n\u003cp\u003eColumns:\u003c/p\u003e\n\u003cp\u003eOpen, High, Low, Close, Volume are \u003cb\u003eunadjusted\u003c/b\u003e.\u003c/p\u003e\n\u003cp\u003eDividend shows the \u003cb\u003eunadjusted\u003c/b\u003e dividend on any ex-dividend date else 0.0.\u003c/p\u003e\n\u003cp\u003eSplit shows any split that occurred on a the given DATE else 1.0\u003c/p\u003e\n\u003cp\u003eAdjusted values are adjusted for dividends and splits using the \u003ca href='http://www.crsp.com/products/documentation/crsp-calculations'\u003eCRSP methodology\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eUpdates of this dataset occur at 5pm ET. Subsequent corrections from the exchange are applied at 9pm ET.\u003c/p\u003e\n\u003cp\u003eData is sourced from NASDAQ, NYSE and AMEX via \u003ca href='http://www.quotemedia.com'\u003eQuotemedia\u003c/a\u003e.\u003c/p\u003e\n\n",
"refreshed_at": "2018-11-03T01:22:19.311Z",
"newest_available_date": "2018-11-02",
"oldest_available_date": "2014-03-27",
"column_names": [
"Date",
Expand All @@ -16,27 +16,27 @@
"Low",
"Close",
"Volume",
"Ex-Dividend",
"Split Ratio",
"Adj. Open",
"Adj. High",
"Adj. Low",
"Adj. Close",
"Adj. Volume"
"Dividend",
"Split",
"Adj_Open",
"Adj_High",
"Adj_Low",
"Adj_Close",
"Adj_Volume"
],
"frequency": "daily",
"type": "Time Series",
"premium": false,
"database_id": 4922
"premium": true,
"database_id": 12910
},
{
"id": 11304017,
"id": 42632267,
"dataset_code": "GOOGL",
"database_code": "WIKI",
"name": "Alphabet Inc (GOOGL) Prices, Dividends, Splits and Trading Volume",
"description": "This dataset has no description.",
"refreshed_at": "2016-05-31T21:47:50.933Z",
"newest_available_date": "2016-05-31",
"database_code": "EOD",
"name": "Alphabet Inc. (GOOGL) Stock Prices, Dividends and Splits",
"description": "\u003cp\u003e\u003cb\u003eTicker\u003c/b\u003e: GOOGL\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eExchange\u003c/b\u003e: NASDAQ\u003c/p\u003e\n\u003cp\u003ePrices, dividends, splits for Alphabet Inc. (GOOGL).\n\n\u003cp\u003eColumns:\u003c/p\u003e\n\u003cp\u003eOpen, High, Low, Close, Volume are \u003cb\u003eunadjusted\u003c/b\u003e.\u003c/p\u003e\n\u003cp\u003eDividend shows the \u003cb\u003eunadjusted\u003c/b\u003e dividend on any ex-dividend date else 0.0.\u003c/p\u003e\n\u003cp\u003eSplit shows any split that occurred on a the given DATE else 1.0\u003c/p\u003e\n\u003cp\u003eAdjusted values are adjusted for dividends and splits using the \u003ca href='http://www.crsp.com/products/documentation/crsp-calculations'\u003eCRSP methodology\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eUpdates of this dataset occur at 5pm ET. Subsequent corrections from the exchange are applied at 9pm ET.\u003c/p\u003e\n\u003cp\u003eData is sourced from NASDAQ, NYSE and AMEX via \u003ca href='http://www.quotemedia.com'\u003eQuotemedia\u003c/a\u003e.\u003c/p\u003e\n\n",
"refreshed_at": "2018-11-03T01:22:19.751Z",
"newest_available_date": "2018-11-02",
"oldest_available_date": "2004-08-19",
"column_names": [
"Date",
Expand All @@ -45,18 +45,18 @@
"Low",
"Close",
"Volume",
"Ex-Dividend",
"Split Ratio",
"Adj. Open",
"Adj. High",
"Adj. Low",
"Adj. Close",
"Adj. Volume"
"Dividend",
"Split",
"Adj_Open",
"Adj_High",
"Adj_Low",
"Adj_Close",
"Adj_Volume"
],
"frequency": "daily",
"type": "Time Series",
"premium": false,
"database_id": 4922
"premium": true,
"database_id": 12910
}
],
"meta": {
Expand All @@ -70,4 +70,4 @@
"current_first_item": 1,
"current_last_item": 2
}
}
}
30 changes: 15 additions & 15 deletions test/fixture/quandlStockDataResponse.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"dataset": {
"id": 9775718,
"id": 42624632,
"dataset_code": "GOOG",
"database_code": "WIKI",
"name": "Alphabet Inc (GOOG) Prices, Dividends, Splits and Trading Volume",
"description": "End of day open, high, low, close and volume, dividends and splits, and split/dividend adjusted open, high, low close and volume for Google Inc. (GOOG). Ex-Dividend is non-zero on ex-dividend dates. Split Ratio is 1 on non-split dates. Adjusted prices are calculated per CRSP (www.crsp.com/products/documentation/crsp-calculations)\n\nThis data is in the public domain. You may copy, distribute, disseminate or include the data in other products for commercial and/or noncommercial purposes.\n\nThis data is part of Quandl's Wiki initiative to get financial data permanently into the public domain. Quandl relies on users like you to flag errors and provide data where data is wrong or missing. Get involved: [email protected]\n",
"database_code": "EOD",
"name": "Alphabet Inc. (GOOG) Stock Prices, Dividends and Splits",
"description": "\u003cp\u003e\u003cb\u003eTicker\u003c/b\u003e: GOOG\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eExchange\u003c/b\u003e: NASDAQ\u003c/p\u003e\n\u003cp\u003ePrices, dividends, splits for Alphabet Inc. (GOOG).\n\n\u003cp\u003eColumns:\u003c/p\u003e\n\u003cp\u003eOpen, High, Low, Close, Volume are \u003cb\u003eunadjusted\u003c/b\u003e.\u003c/p\u003e\n\u003cp\u003eDividend shows the \u003cb\u003eunadjusted\u003c/b\u003e dividend on any ex-dividend date else 0.0.\u003c/p\u003e\n\u003cp\u003eSplit shows any split that occurred on a the given DATE else 1.0\u003c/p\u003e\n\u003cp\u003eAdjusted values are adjusted for dividends and splits using the \u003ca href='http://www.crsp.com/products/documentation/crsp-calculations'\u003eCRSP methodology\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eUpdates of this dataset occur at 5pm ET. Subsequent corrections from the exchange are applied at 9pm ET.\u003c/p\u003e\n\u003cp\u003eData is sourced from NASDAQ, NYSE and AMEX via \u003ca href='http://www.quotemedia.com'\u003eQuotemedia\u003c/a\u003e.\u003c/p\u003e\n\n",
"refreshed_at": "2016-05-31 21:47:50 UTC",
"newest_available_date": "2016-05-31",
"oldest_available_date": "2014-03-27",
Expand All @@ -15,17 +15,17 @@
"Low",
"Close",
"Volume",
"Ex-Dividend",
"Split Ratio",
"Adj. Open",
"Adj. High",
"Adj. Low",
"Adj. Close",
"Adj. Volume"
"Dividend",
"Split",
"Adj_Open",
"Adj_High",
"Adj_Low",
"Adj_Close",
"Adj_Volume"
],
"frequency": "daily",
"type": "Time Series",
"premium": false,
"premium": true,
"limit": null,
"transform": null,
"column_index": null,
Expand Down Expand Up @@ -8119,7 +8119,7 @@
]
],
"collapse": null,
"order": "desc",
"database_id": 4922
"order": null,
"database_id": 12910
}
}
}
20 changes: 10 additions & 10 deletions test/helper/fakeQuandlServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ module.exports = (apiKey = '') => {
const routes = {};

// search
routes[`/api/v3/datasets.json?${apiKeyParam}&query=GOOG&database_code=WIKI`] = [200, quandlSearchResponse];
routes['/api/v3/datasets.json?&query=GOOG&database_code=WIKI'] = [200, quandlSearchResponse];
routes[`/api/v3/datasets.json?${apiKeyParam}&query=BAD&database_code=WIKI`] = [404, quandlBadResponse];
routes['/api/v3/datasets.json?&query=BAD&database_code=WIKI'] = [404, quandlBadResponse];
routes[`/api/v3/datasets.json?${apiKeyParam}&query=GOOG&database_code=EOD`] = [200, quandlSearchResponse];
routes['/api/v3/datasets.json?&query=GOOG&database_code=EOD'] = [200, quandlSearchResponse];
routes[`/api/v3/datasets.json?${apiKeyParam}&query=BAD&database_code=EOD`] = [404, quandlBadResponse];
routes['/api/v3/datasets.json?&query=BAD&database_code=EOD'] = [404, quandlBadResponse];

// metadata
routes[`/api/v3/datasets/WIKI/GOOG/metadata.json?${apiKeyParam}`] = [200, googMetadataResponse];
routes[`/api/v3/datasets/WIKI/BAD/metadata.json?${apiKeyParam}`] = [404, quandlBadResponse];
routes[`/api/v3/datasets/EOD/GOOG/metadata.json?${apiKeyParam}`] = [200, googMetadataResponse];
routes[`/api/v3/datasets/EOD/BAD/metadata.json?${apiKeyParam}`] = [404, quandlBadResponse];

// stock data
routes[`/api/v3/datasets/WIKI/GOOG.json?${apiKeyParam}&start_date=2016-05-04`] = [200, googStockdataResponse];
routes['/api/v3/datasets/WIKI/GOOG.json?&start_date=2016-05-04'] = [200, googStockdataResponse];
routes['/api/v3/datasets/WIKI/BAD.json?&start_date=2016-05-04'] = [404, quandlBadResponse];
routes[`/api/v3/datasets/WIKI/BAD.json?${apiKeyParam}&start_date=2016-05-04`] = [404, quandlBadResponse];
routes[`/api/v3/datasets/EOD/GOOG.json?${apiKeyParam}&start_date=2016-05-04`] = [200, googStockdataResponse];
routes['/api/v3/datasets/EOD/GOOG.json?&start_date=2016-05-04'] = [200, googStockdataResponse];
routes['/api/v3/datasets/EOD/BAD.json?&start_date=2016-05-04'] = [404, quandlBadResponse];
routes[`/api/v3/datasets/EOD/BAD.json?${apiKeyParam}&start_date=2016-05-04`] = [404, quandlBadResponse];

return nock('https://www.quandl.com')
.persist()
Expand Down
4 changes: 2 additions & 2 deletions test/specs/child/actions/searchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ describe('child/actions/search', () => {
const term = 'GOOG';
const result1 = {
code: 'GOOG',
name: 'Alphabet Inc (GOOG) Prices, Dividends, Splits and Trading Volume'
name: 'Alphabet Inc. (GOOG) Stock Prices, Dividends and Splits'
};
const result2 = {
code: 'GOOGL',
name: 'Alphabet Inc (GOOGL) Prices, Dividends, Splits and Trading Volume'
name: 'Alphabet Inc. (GOOGL) Stock Prices, Dividends and Splits'
};
const results = [result1, result2];
const expectedActions = [
Expand Down
Loading

0 comments on commit 8b768a6

Please sign in to comment.