Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {
SORT_HISTORICAL_OPTIONS,
SORT_OPTIONS, TIMEFRAME_OPTIONS,
} from "../../common/constants.mjs";
import polygon from "../../polygon.app.mjs";

export default {
key: "polygon-get-company-financials",
name: "Get Company Financials",
description: "Retrieves financial details for a specific company by stock ticker. [See the documentation](https://polygon.io/docs/stocks/get_v3_reference_financials).",
version: "0.0.1",
type: "action",
props: {
polygon,
stockTicker: {
propDefinition: [
polygon,
"stockTicker",
],
},
filingDate: {
type: "string",
label: "Filing Date",
description: `Query by the date when the filing with financials data was filed in **YYYY-MM-DD** format.
\nBest used when querying over date ranges to find financials based on filings that happen in a time period.
\nExamples:
\nTo get financials based on filings that have happened after January 1, 2009 use the query param filing_date.gte=2009-01-01
\nTo get financials based on filings that happened in the year 2009 use the query params filing_date.gte=2009-01-01&filing_date.lt=2010-01-01`,
optional: true,
},
periodOfReportDate: {
type: "string",
label: "Period Of Report Date",
description: "The period of report for the filing with financials data in **YYYY-MM-DD** format.",
optional: true,
},
timeframe: {
type: "string",
label: "Timeframe",
description: "Query by timeframe. Annual financials originate from 10-K filings, and quarterly financials originate from 10-Q filings. Note: Most companies do not file quarterly reports for Q4 and instead include those financials in their annual report, so some companies my not return quarterly financials for Q4",
options: TIMEFRAME_OPTIONS,
optional: true,
},
order: {
type: "string",
label: "Order",
description: "Order results based on the `Sort` field.",
options: SORT_OPTIONS,
optional: true,
},
limit: {
type: "integer",
label: "Limit",
description: "Limit the number of results returned.",
optional: true,
min: 1,
max: 100,
default: 10,
},
sort: {
type: "string",
label: "Sort",
description: "Sort field used for ordering",
options: SORT_HISTORICAL_OPTIONS,
optional: true,
},
},
async run({ $ }) {
const financialDetails = await this.polygon.getFinancialDetails({
$,
params: {
stockTicker: this.stockTicker,
filingDate: this.filingDate,
periodOfReportDate: this.periodOfReportDate,
timeframe: this.timeframe,
order: this.order,
limit: this.limit,
sort: this.sort,
},
});
$.export("$summary", `Successfully retrieved financial details for ${this.stockTicker}`);
return financialDetails;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {
SORT_OPTIONS,
TIMESPAN_OPTIONS,
} from "../../common/constants.mjs";
import polygon from "../../polygon.app.mjs";

export default {
key: "polygon-get-historical-prices",
name: "Get Historical Prices",
description: "Fetches historical price data for a specified stock ticker within a date range. [See the documentation](https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to)",
version: "0.0.1",
type: "action",
props: {
polygon,
stockTicker: {
propDefinition: [
polygon,
"stockTicker",
],
},
multiplier: {
type: "integer",
label: "Multiplier",
description: "The size of the timespan multiplier.",
default: 1,
},
timespan: {
type: "string",
label: "Timespan",
description: "The size of the time window.",
options: TIMESPAN_OPTIONS,
},
from: {
type: "string",
label: "From Date",
description: "The start of the aggregate time window. Either a date with the format **YYYY-MM-DD** or a millisecond timestamp.",
},
to: {
type: "string",
label: "To Date",
description: "The end of the aggregate time window. Either a date with the format **YYYY-MM-DD** or a millisecond timestamp.",
},
adjusted: {
propDefinition: [
polygon,
"adjusted",
],
optional: true,
},
sort: {
type: "string",
label: "Sort",
description: "Sort the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return results in descending order (newest at the top).",
options: SORT_OPTIONS,
optional: true,
},
limit: {
type: "integer",
label: "Limit",
description: "Limits the number of base aggregates queried to create the aggregate results. Max 50000 and Default 5000. Read more about how limit is used to calculate aggregate results in our article on [Aggregate Data API Improvements](https://polygon.io/blog/aggs-api-updates).",
optional: true,
min: 1,
max: 5000,
defalt: 5000,
},
},
async run({ $ }) {
const response = await this.polygon.getHistoricalPriceData({
$,
stockTicker: this.stockTicker,
multiplier: this.multiplier,
timespan: this.timespan,
from: this.from,
to: this.to,
params: {
adjusted: this.adjusted,
sort: this.sort,
limit: this.limit,
},
});
$.export("$summary", `Fetched historical prices for ${this.stockTicker} from ${this.from} to ${this.to}.`);
return response;
},
};
51 changes: 51 additions & 0 deletions components/polygon/actions/get-stock-price/get-stock-price.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import polygon from "../../polygon.app.mjs";

export default {
key: "polygon-get-stock-price",
name: "Get Stock Price",
description: "Get the open, close and afterhours prices of a stock symbol on a certain date. [See the documentation](https://polygon.io/docs/stocks/get_v1_open-close__stocksticker___date)",
version: "0.0.1",
type: "action",
props: {
polygon,
stockTicker: {
propDefinition: [
polygon,
"stockTicker",
],
},
date: {
type: "string",
label: "Date",
description: "The date of the requested open/close in the format YYYY-MM-DD.",
},
adjusted: {
propDefinition: [
polygon,
"adjusted",
],
optional: true,
},
},
async run({ $ }) {
try {

const response = await this.polygon.getCurrentPrice({
$,
date: this.date,
stockTicker: this.stockTicker,
params: {
adjusted: this.adjusted,
},
});

$.export("$summary", `Successfully fetched the price of ${this.stockTicker}`);
return response;
} catch ({ response }) {
if (response.status === 404) {
$.export("$summary", `No data found for ${this.stockTicker}`);
return {};
}
}
},
};
26 changes: 26 additions & 0 deletions components/polygon/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const TIMESPAN_OPTIONS = [
"second",
"minute",
"hour",
"day",
"week",
"month",
"quarter",
"year",
];

export const TIMEFRAME_OPTIONS = [
"annual",
"quarterly",
"ttm",
];

export const SORT_OPTIONS = [
"asc",
"desc",
];

export const SORT_HISTORICAL_OPTIONS = [
"filing_date",
"period_of_report_date",
];
7 changes: 7 additions & 0 deletions components/polygon/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const parseNextPage = (nextUrl = null) => {
if (nextUrl) {
const url = new URL(nextUrl);
nextUrl = url.searchParams.get("cursor");
}
return nextUrl;
};
18 changes: 18 additions & 0 deletions components/polygon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@pipedream/polygon",
"version": "0.1.0",
"description": "Pipedream Polygon Components",
"main": "polygon.app.mjs",
"keywords": [
"pipedream",
"polygon"
],
"homepage": "https://pipedream.com/apps/polygon",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
Loading
Loading