forked from drbeep/yahoo_datafeed
-
Notifications
You must be signed in to change notification settings - Fork 77
/
symbols_database.js
213 lines (193 loc) · 13.1 KB
/
symbols_database.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
This file is a node.js module intended for use in different UDF datafeeds.
*/
// This list should contain all the symbols available through your datafeed.
// The current version is extremely incomplete (as it's just a sample): Quandl has much more of them.
"use strict";
var logos = require("./logos");
/* global exports */
var symbols = [{"name":"A","description":"Agilent Technologies Inc.","exchange":"NYSE","type":"stock"},
{"name":"AA","description":"Alcoa Inc.","exchange":"NYSE","type":"stock"},
{"name":"AAL","description":"American Airlines Group Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AAPL","description":"Apple Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ABBV","description":"AbbVie Inc.","exchange":"NYSE","type":"stock"},
{"name":"ABT","description":"Abbott Laboratories","exchange":"NYSE","type":"stock"},
{"name":"ACHN","description":"Achillion Pharmaceuticals, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ACI","description":"Arch Coal Inc.","exchange":"NYSE","type":"stock"},
{"name":"ACN","description":"Accenture plc","exchange":"NYSE","type":"stock"},
{"name":"ADBE","description":"Adobe Systems Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ADSK","description":"Autodesk, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AEO","description":"American Eagle Outfitters, Inc.","exchange":"NYSE","type":"stock"},
{"name":"AGNC","description":"American Capital Agency Corp.","exchange":"NasdaqNM","type":"stock"},
{"name":"AIG","description":"American International Group, Inc.","exchange":"NYSE","type":"stock"},
{"name":"AKAM","description":"Akamai Technologies, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ALXN","description":"Alexion Pharmaceuticals, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AMAT","description":"Applied Materials, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AMD","description":"Advanced Micro Devices, Inc.","exchange":"NYSE","type":"stock"},
{"name":"AMGN","description":"Amgen Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AMZN","description":"Amazon.com Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ANF","description":"Abercrombie & Fitch Co.","exchange":"NYSE","type":"stock"},
{"name":"ANR","description":"Alpha Natural Resources, Inc.","exchange":"NYSE","type":"stock"},
{"name":"APA","description":"Apache Corp.","exchange":"NYSE","type":"stock"},
{"name":"APC","description":"Anadarko Petroleum Corporation","exchange":"NYSE","type":"stock"},
{"name":"ARC","description":"ARC Document Solutions, Inc.","exchange":"NYSE","type":"stock"},
{"name":"ARIA","description":"Ariad Pharmaceuticals Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ARNA","description":"Arena Pharmaceuticals, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ARR","description":"ARMOUR Residential REIT, Inc.","exchange":"NYSE","type":"stock"},
{"name":"AUXL","description":"Auxilium Pharmaceuticals Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AVGO","description":"Avago Technologies Limited","exchange":"NasdaqNM","type":"stock"},
{"name":"AVNR","description":"Avanir Pharmaceuticals, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AWAY","description":"HomeAway, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"AXP","description":"American Express Company","exchange":"NYSE","type":"stock"},
{"name":"AZO","description":"AutoZone, Inc.","exchange":"NYSE","type":"stock"},
{"name":"BA","description":"The Boeing Company","exchange":"NYSE","type":"stock"},
{"name":"BAC","description":"Bank of America Corporation","exchange":"NYSE","type":"stock"},
{"name":"BAX","description":"Baxter International Inc.","exchange":"NYSE","type":"stock"},
{"name":"BBBY","description":"Bed Bath & Beyond Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"BBT","description":"BB&T Corporation","exchange":"NYSE","type":"stock"},
{"name":"BBY","description":"Best Buy Co., Inc.","exchange":"NYSE","type":"stock"},
{"name":"BIDU","description":"Baidu, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"BIIB","description":"Biogen Idec Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"BK","description":"The Bank of New York Mellon Corporation","exchange":"NYSE","type":"stock"},
{"name":"BLK","description":"BlackRock, Inc.","exchange":"NYSE","type":"stock"},
{"name":"BMY","description":"Bristol-Myers Squibb Company","exchange":"NYSE","type":"stock"},
{"name":"BP","description":"BP plc","exchange":"NYSE","type":"stock"},
{"name":"BRCD","description":"Brocade Communications Systems, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"BRCM","description":"Broadcom Corp.","exchange":"NasdaqNM","type":"stock"},
{"name":"BTU","description":"Peabody Energy Corp.","exchange":"NYSE","type":"stock"},
{"name":"C","description":"Citigroup Inc.","exchange":"NYSE","type":"stock"},
{"name":"CHK","description":"Chesapeake Energy Corporation","exchange":"NYSE","type":"stock"},
{"name":"CNP","description":"CenterPoint Energy, Inc.","exchange":"NYSE","type":"stock"},
{"name":"CSCO","description":"Cisco Systems, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"D","description":"Dominion Resources, Inc.","exchange":"NYSE","type":"stock"},
{"name":"DAL","description":"Delta Air Lines Inc.","exchange":"NYSE","type":"stock"},
{"name":"DBD","description":"Diebold, Incorporated","exchange":"NYSE","type":"stock"},
{"name":"DD","description":"E. I. du Pont de Nemours and Company","exchange":"NYSE","type":"stock"},
{"name":"DDD","description":"3D Systems Corp.","exchange":"NYSE","type":"stock"},
{"name":"DE","description":"Deere & Company","exchange":"NYSE","type":"stock"},
{"name":"DECK","description":"Deckers Outdoor Corp.","exchange":"NYSE","type":"stock"},
{"name":"DEI","description":"Douglas Emmett Inc","exchange":"NYSE","type":"stock"},
{"name":"DHI","description":"DR Horton Inc.","exchange":"NYSE","type":"stock"},
{"name":"DIS","description":"The Walt Disney Company","exchange":"NYSE","type":"stock"},
{"name":"DLTR","description":"Dollar Tree, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"DNDN","description":"Dendreon Corp.","exchange":"NasdaqNM","type":"stock"},
{"name":"DO","description":"Diamond Offshore Drilling, Inc.","exchange":"NYSE","type":"stock"},
{"name":"DOV","description":"Dover Corporation","exchange":"NYSE","type":"stock"},
{"name":"DOW","description":"The Dow Chemical Company","exchange":"NYSE","type":"stock"},
{"name":"DRI","description":"Darden Restaurants, Inc.","exchange":"NYSE","type":"stock"},
{"name":"DV","description":"DeVry Education Group Inc.","exchange":"NYSE","type":"stock"},
{"name":"DVN","description":"Devon Energy Corporation","exchange":"NYSE","type":"stock"},
{"name":"EA","description":"Electronic Arts Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"EBAY","description":"eBay Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"EBIX","description":"Ebix Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ECYT","description":"Endocyte, Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"ED","description":"Consolidated Edison, Inc.","exchange":"NYSE","type":"stock"},
{"name":"EMC","description":"EMC Corporation","exchange":"NYSE","type":"stock"},
{"name":"ENT","description":"Global Eagle Entertainment Inc.","exchange":"NCM","type":"stock"},
{"name":"ESI","description":"ITT Educational Services Inc.","exchange":"NYSE","type":"stock"},
{"name":"ESRX","description":"Express Scripts Holding Company","exchange":"NasdaqNM","type":"stock"},
{"name":"ETFC","description":"E*TRADE Financial Corporation","exchange":"NasdaqNM","type":"stock"},
{"name":"EXC","description":"Exelon Corporation","exchange":"NYSE","type":"stock"},
{"name":"EXPE","description":"Expedia Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"F","description":"Ford Motor Co.","exchange":"NYSE","type":"stock"},
{"name":"FCEL","description":"FuelCell Energy Inc.","exchange":"NGM","type":"stock"},
{"name":"GALE","description":"Galena Biopharma, Inc.","exchange":"NCM","type":"stock"},
{"name":"GD","description":"General Dynamics Corp.","exchange":"NYSE","type":"stock"},
{"name":"GE","description":"General Electric Company","exchange":"NYSE","type":"stock"},
{"name":"GTAT","description":"GT Advanced Technologies Inc.","exchange":"NasdaqNM","type":"stock"},
{"name":"HD","description":"The Home Depot, Inc.","exchange":"NYSE","type":"stock"},
{"name":"IBM","description":"International Business Machines Corporation","exchange":"NYSE","type":"stock"},
{"name":"INTC","description":"Intel Corporation","exchange":"NasdaqNM","type":"stock"},
{"name":"JPM","description":"JPMorgan Chase & Co.","exchange":"NYSE","type":"stock"},
{"name":"KERX","description":"Keryx Biopharmaceuticals Inc.","exchange":"NCM","type":"stock"},
{"name":"KO","description":"The Coca-Cola Company","exchange":"NYSE","type":"stock"},
{"name":"LLY","description":"Eli Lilly and Company","exchange":"NYSE","type":"stock"},
{"name":"LUV","description":"Southwest Airlines Co.","exchange":"NYSE","type":"stock"},
{"name":"MCD","description":"McDonald's Corp.","exchange":"NYSE","type":"stock"},
{"name":"MNST","description":"Monster Beverage Corporation","exchange":"NasdaqNM","type":"stock"},
{"name":"MO","description":"Altria Group Inc.","exchange":"NYSE","type":"stock"},
{"name":"MSFT","description":"Microsoft Corporation","exchange":"NasdaqNM","type":"stock"},
{"name":"NLY","description":"Annaly Capital Management, Inc.","exchange":"NYSE","type":"stock"},
{"name":"NUS","description":"Nu Skin Enterprises Inc.","exchange":"NYSE","type":"stock"},
{"name":"OLED","description":"Universal Display Corp.","exchange":"NasdaqNM","type":"stock"},
{"name":"PNRA","description":"Panera Bread Company","exchange":"NasdaqNM","type":"stock"},
{"name":"RAD","description":"Rite Aid Corporation","exchange":"NYSE","type":"stock"},
{"name":"SAM","description":"Boston Beer Co. Inc.","exchange":"NYSE","type":"stock"},
{"name":"SCTY","description":"SolarCity Corporation","exchange":"NasdaqNM","type":"stock"},
{"name":"SD","description":"SandRidge Energy, Inc.","exchange":"NYSE","type":"stock"},
{"name":"STZ","description":"Constellation Brands Inc.","exchange":"NYSE","type":"stock"},
{"name":"T","description":"AT&T, Inc.","exchange":"NYSE","type":"stock"},
{"name":"UA","description":"Under Armour, Inc.","exchange":"NYSE","type":"stock"},
{"name":"USB","description":"U.S. Bancorp","exchange":"NYSE","type":"stock"},
{"name":"VZ","description":"Verizon Communications Inc.","exchange":"NYSE","type":"stock"},
{"name":"WDC","description":"Western Digital Corporation","exchange":"NasdaqNM","type":"stock"},
{"name":"WFC","description":"Wells Fargo & Company","exchange":"NYSE","type":"stock"},
{"name":"WLT","description":"Walter Energy, Inc.","exchange":"NYSE","type":"stock"},
{"name":"XOM","description":"Exxon Mobil Corporation","exchange":"NYSE","type":"stock"}];
function searchResultFromDatabaseItem(item) {
const result = {
symbol: item.name,
full_name: item.name,
description: item.description,
exchange: item.exchange,
type: item.type,
};
const logoUrls = logos.getSymbolLogos(item.name);
if (logoUrls) {
result.logo_urls = logoUrls;
}
const exchangeLogo = logos.getExchangeLogoUrl(item.exchange);
if (exchangeLogo) {
result.exchange_logo = exchangeLogo;
}
return result;
}
exports.search = function (searchString, type, exchange, maxRecords) {
var MAX_SEARCH_RESULTS = !!maxRecords ? maxRecords : 50;
var results = []; // array of WeightedItem { item, weight }
var queryIsEmpty = !searchString || searchString.length === 0;
var searchStringUpperCase = searchString.toUpperCase();
for (var i = 0; i < symbols.length; ++i) {
var item = symbols[i];
if (type && type.length > 0 && item.type != type) {
continue;
}
if (exchange && exchange.length > 0 && item.exchange != exchange) {
continue;
}
var positionInName = item.name.toUpperCase().indexOf(searchStringUpperCase);
var positionInDescription = item.description.toUpperCase().indexOf(searchStringUpperCase);
if (queryIsEmpty || positionInName >= 0 || positionInDescription >= 0) {
var found = false;
for (var resultIndex = 0; resultIndex < results.length; resultIndex++) {
if (results[resultIndex].item == item) {
found = true;
break;
}
}
if (!found) {
var weight = positionInName >= 0 ? positionInName : 8000 + positionInDescription;
results.push({ item: item, weight: weight });
}
}
}
return results
.sort(function (weightedItem1, weightedItem2) { return weightedItem1.weight - weightedItem2.weight; })
.map(function (weightedItem) { return searchResultFromDatabaseItem(weightedItem.item); })
.slice(0, Math.min(results.length, MAX_SEARCH_RESULTS));
};
exports.addSymbols = function(newSymbols) {
symbols = symbols.concat(newSymbols);
};
exports.symbolInfo = function (symbolName) {
var data = symbolName.split(':');
var exchange = (data.length > 1 ? data[0] : "").toUpperCase();
var symbol = (data.length > 1 ? data[1] : symbolName).toUpperCase();
for (var i = 0; i < symbols.length; ++i) {
var item = symbols[i];
if (item.name.toUpperCase() == symbol && (exchange.length === 0 || exchange == item.exchange.toUpperCase())) {
return item;
}
}
return null;
};