diff --git a/components/finnhub/actions/get-insider-transactions/get-insider-transactions.mjs b/components/finnhub/actions/get-insider-transactions/get-insider-transactions.mjs new file mode 100644 index 0000000000000..790afe572d9f0 --- /dev/null +++ b/components/finnhub/actions/get-insider-transactions/get-insider-transactions.mjs @@ -0,0 +1,47 @@ +import app from "../../finnhub.app.mjs"; + +export default { + key: "finnhub-get-insider-transactions", + name: "Get Insider Transactions", + description: "Get a list os insider transactions from a specified time period. [See the documentation](https://finnhub.io/docs/api/insider-transactions)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + symbol: { + propDefinition: [ + app, + "symbol", + ], + }, + from: { + propDefinition: [ + app, + "from", + ], + }, + to: { + propDefinition: [ + app, + "to", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getInsiderTransactions({ + $, + params: { + symbol: this.symbol, + from: this.from, + to: this.to, + }, + }); + $.export("$summary", "Successfully retrieved " + response.data.length + " transactions"); + return response; + }, +}; diff --git a/components/finnhub/actions/get-market-news/get-market-news.mjs b/components/finnhub/actions/get-market-news/get-market-news.mjs new file mode 100644 index 0000000000000..58627ba4f877b --- /dev/null +++ b/components/finnhub/actions/get-market-news/get-market-news.mjs @@ -0,0 +1,33 @@ +import app from "../../finnhub.app.mjs"; + +export default { + key: "finnhub-get-market-news", + name: "Get Market News", + description: "Get a list of the latest market news. [See the documentation](https://finnhub.io/docs/api/market-news)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + category: { + propDefinition: [ + app, + "category", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getMarketNews({ + $, + data: { + category: this.category, + }, + }); + $.export("$summary", "Successfully retrieved " + response.length + " market news"); + return response; + }, +}; diff --git a/components/finnhub/actions/get-recommentadion-trends/get-recommentadion-trends.mjs b/components/finnhub/actions/get-recommentadion-trends/get-recommentadion-trends.mjs new file mode 100644 index 0000000000000..05520ff9540e1 --- /dev/null +++ b/components/finnhub/actions/get-recommentadion-trends/get-recommentadion-trends.mjs @@ -0,0 +1,33 @@ +import app from "../../finnhub.app.mjs"; + +export default { + key: "finnhub-get-recommentadion-trends", + name: "Get Recommentadion Trends", + description: "Get latest analyst recommendation trends for a company. [See the documentation](https://finnhub.io/docs/api/recommendation-trends)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + symbol: { + propDefinition: [ + app, + "symbol", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getRecommentadionTrends({ + $, + params: { + symbol: this.symbol, + }, + }); + $.export("$summary", "Successfully retrieved " + response.length + " recommendation trends"); + return response; + }, +}; diff --git a/components/finnhub/actions/get-symbols/get-symbols.mjs b/components/finnhub/actions/get-symbols/get-symbols.mjs new file mode 100644 index 0000000000000..1efc2aaa44122 --- /dev/null +++ b/components/finnhub/actions/get-symbols/get-symbols.mjs @@ -0,0 +1,47 @@ +import app from "../../finnhub.app.mjs"; + +export default { + key: "finnhub-get-symbols", + name: "Get Symbols", + description: "Get a list of supported stock symbols. [See the documentation](https://finnhub.io/docs/api/stock-symbols)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + exchange: { + propDefinition: [ + app, + "exchange", + ], + }, + currency: { + propDefinition: [ + app, + "currency", + ], + }, + mic: { + propDefinition: [ + app, + "mic", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getSymbols({ + $, + params: { + exchange: this.exchange, + currency: this.currency, + mic: this.mic, + }, + }); + $.export("$summary", "Successfully retrieved " + response.length + " symbols"); + return response; + }, +}; diff --git a/components/finnhub/common/constants.mjs b/components/finnhub/common/constants.mjs new file mode 100644 index 0000000000000..86481b1834d2e --- /dev/null +++ b/components/finnhub/common/constants.mjs @@ -0,0 +1,323 @@ +export default { + NEWS_CATEGORIES: [ + "general", + "forex", + "crypto", + "merger", + ], + EXCHANGES: [ + { + label: "ADU DHABI SECURITIES EXCHANGE", + value: "AD", + }, + { + label: "NYSE EURONEXT - EURONEXT AMSTERDAM", + value: "AS", + }, + { + label: "ATHENS EXCHANGE S.A. CASH MARKET", + value: "AT", + }, + { + label: "ASX - ALL MARKETS", + value: "AX", + }, + { + label: "BOLSA DE COMERCIO DE BUENOS AIRES", + value: "BA", + }, + { + label: "BOLSA DE VALORES DE COLOMBIA", + value: "BC", + }, + { + label: "BUDAPEST STOCK EXCHANGE", + value: "BD", + }, + { + label: "BOERSE BERLIN", + value: "BE", + }, + { + label: "BAHRAIN BOURSE", + value: "BH", + }, + { + label: "STOCK EXCHANGE OF THAILAND", + value: "BK", + }, + { + label: "BSE LTD", + value: "BO", + }, + { + label: "NYSE EURONEXT - EURONEXT BRUSSELS", + value: "BR", + }, + { + label: "Egyptian Stock Exchange", + value: "CA", + }, + { + label: "CANADIAN NATIONAL STOCK EXCHANGE", + value: "CN", + }, + { + label: "OMX NORDIC EXCHANGE COPENHAGEN A/S", + value: "CO", + }, + { + label: "CARACAS STOCK EXCHANGE", + value: "CR", + }, + { + label: "CASABLANCA STOCK EXCHANGE", + value: "CS", + }, + { + label: "DUBAI FINANCIAL MARKET", + value: "DB", + }, + { + label: "XETRA", + value: "DE", + }, + { + label: "BOERSE DUESSELDORF", + value: "DU", + }, + { + label: "DEUTSCHE BOERSE AG", + value: "F", + }, + { + label: "NASDAQ OMX HELSINKI LTD", + value: "HE", + }, + { + label: "HONG KONG EXCHANGES AND CLEARING LTD", + value: "HK", + }, + { + label: "HANSEATISCHE WERTPAPIERBOERSE HAMBURG", + value: "HM", + }, + { + label: "NASDAQ OMX ICELAND", + value: "IC", + }, + { + label: "IRISH STOCK EXCHANGE - ALL MARKET", + value: "IR", + }, + { + label: "BORSA ISTANBUL", + value: "IS", + }, + { + label: "INDONESIA STOCK EXCHANGE", + value: "JK", + }, + { + label: "JOHANNESBURG STOCK EXCHANGE", + value: "JO", + }, + { + label: "BURSA MALAYSIA", + value: "KL", + }, + { + label: "KOREA EXCHANGE (KOSDAQ)", + value: "KQ", + }, + { + label: "KOREA EXCHANGE (STOCK MARKET)", + value: "KS", + }, + { + label: "Kuwait Stock Exchange", + value: "KW", + }, + { + label: "LONDON STOCK EXCHANGE", + value: "L", + }, + { + label: "NYSE EURONEXT - EURONEXT LISBON", + value: "LS", + }, + { + label: "BOLSA DE MADRID", + value: "MC", + }, + { + label: "MOSCOW EXCHANGE", + value: "ME", + }, + { + label: "Italian Stock Exchange", + value: "MI", + }, + { + label: "MALTA STOCK EXCHANGE", + value: "MT", + }, + { + label: "BOERSE MUENCHEN", + value: "MU", + }, + { + label: "BOLSA MEXICANA DE VALORES (MEXICAN STOCK EXCHANGE)", + value: "MX", + }, + { + label: "AEQUITAS NEO EXCHANGE", + value: "NE", + }, + { + label: "Nigerian Stock Exchange", + value: "NL", + }, + { + label: "NATIONAL STOCK EXCHANGE OF INDIA", + value: "NS", + }, + { + label: "NEW ZEALAND EXCHANGE LTD", + value: "NZ", + }, + { + label: "OSLO BORS ASA", + value: "OL", + }, + { + label: "Muscat Stock Exchange", + value: "OM", + }, + { + label: "NYSE EURONEXT - MARCHE LIBRE PARIS", + value: "PA", + }, + { + label: "Philippine Stock Exchange", + value: "PM", + }, + { + label: "PRAGUE STOCK EXCHANGE", + value: "PR", + }, + { + label: "QATAR EXCHANGE", + value: "QA", + }, + { + label: "BUCHAREST STOCK EXCHANGE", + value: "RO", + }, + { + label: "NASDAQ OMX RIGA", + value: "RG", + }, + { + label: "Brazil Bolsa - Sao Paolo", + value: "SA", + }, + { + label: "BOERSE STUTTGART", + value: "SG", + }, + { + label: "SINGAPORE EXCHANGE", + value: "SI", + }, + { + label: "SANTIAGO STOCK EXCHANGE", + value: "SN", + }, + { + label: "SAUDI STOCK EXCHANGE", + value: "SR", + }, + { + label: "SHANGHAI STOCK EXCHANGE", + value: "SS", + }, + { + label: "NASDAQ OMX NORDIC STOCKHOLM", + value: "ST", + }, + { + label: "SWISS EXCHANGE", + value: "SW", + }, + { + label: "SHENZHEN STOCK EXCHANGE", + value: "SZ", + }, + { + label: "TOKYO STOCK EXCHANGE-TOKYO PRO MARKET", + value: "T", + }, + { + label: "TEL AVIV STOCK EXCHANGE", + value: "TA", + }, + { + label: "NASDAQ OMX TALLINN", + value: "TL", + }, + { + label: "TORONTO STOCK EXCHANGE", + value: "TO", + }, + { + label: "TAIWAN STOCK EXCHANGE", + value: "TW", + }, + { + label: "TPEx", + value: "TWO", + }, + { + label: "US exchanges (NYSE, Nasdaq)", + value: "US", + }, + { + label: "TSX VENTURE EXCHANGE - NEX", + value: "V", + }, + { + label: "Vienna Stock Exchange", + value: "VI", + }, + { + label: "Vietnam exchanges including HOSE, HNX and UPCOM", + value: "VN", + }, + { + label: "NASDAQ OMX VILNIUS", + value: "VS", + }, + { + label: "WARSAW STOCK EXCHANGE/EQUITIES/MAIN MARKET", + value: "WA", + }, + { + label: "Hanover Stock Exchange", + value: "HA", + }, + { + label: "DEUTSCHE BOERSE Stoxx", + value: "SX", + }, + { + label: "DEUTSCHE BOERSE TradeGate", + value: "TG", + }, + { + label: "BOERSE_FRANKFURT_ZERTIFIKATE", + value: "SC", + }, + ], + +}; diff --git a/components/finnhub/finnhub.app.mjs b/components/finnhub/finnhub.app.mjs index 565608f53e08a..c57356578e4db 100644 --- a/components/finnhub/finnhub.app.mjs +++ b/components/finnhub/finnhub.app.mjs @@ -1,11 +1,97 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "finnhub", - propDefinitions: {}, + propDefinitions: { + symbol: { + type: "string", + label: "Symbol", + description: "Symbol of the company, i.e.: `AAPL`", + }, + from: { + type: "string", + label: "From", + description: "Initial date to get insider transactions from, i.e.: `2020-03-15`", + optional: true, + }, + to: { + type: "string", + label: "To", + description: "Initial date to get insider transactions from, i.e.: `2020-03-15`", + optional: true, + }, + category: { + type: "string", + label: "Category", + description: "News category", + options: constants.NEWS_CATEGORIES, + }, + exchange: { + type: "string", + label: "Exchange", + description: "Exchange you want to get the list of symbols from", + options: constants.EXCHANGES, + }, + currency: { + type: "string", + label: "Currency", + description: "Filter by currency, i.e.: `USD`", + optional: true, + }, + mic: { + type: "string", + label: "MIC", + description: "Filter by MIC code, i.e.: `XNGS`", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://finnhub.io/api/v1"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "X-Finnhub-Token": `${this.$auth.api_key}`, + ...headers, + }, + }); + }, + + async getMarketNews(args = {}) { + return this._makeRequest({ + path: "/news", + ...args, + }); + }, + async getInsiderTransactions(args = {}) { + return this._makeRequest({ + path: "/stock/insider-transactions", + ...args, + }); + }, + async getRecommentadionTrends(args = {}) { + return this._makeRequest({ + path: "/stock/recommendation", + ...args, + }); + }, + async getSymbols(args = {}) { + return this._makeRequest({ + path: "/stock/symbol", + ...args, + }); }, + }, -}; \ No newline at end of file +}; diff --git a/components/finnhub/package.json b/components/finnhub/package.json index bc24c1f73b78c..ae72490e406fe 100644 --- a/components/finnhub/package.json +++ b/components/finnhub/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/finnhub", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Finnhub Components", "main": "finnhub.app.mjs", "keywords": [