Skip to content

Commit 787abff

Browse files
New Components - polygon (#15558)
* polygon init * [Components] polygon #15141 Sources - New Market Trade - New Market News - New Stock Price Summary Actions - Get Stock Price - Get Historical Prices - Get Company * pnpm update * Update components/polygon/actions/get-historical-prices/get-historical-prices.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * some adjusts * fix source summary * pnpm update --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent b79cea0 commit 787abff

File tree

20 files changed

+664
-20
lines changed

20 files changed

+664
-20
lines changed

components/bitbucket_data_center/bitbucket_data_center.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/brillium/brillium.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/frontify/frontify.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/membership_io/membership_io.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import {
2+
SORT_HISTORICAL_OPTIONS,
3+
SORT_OPTIONS, TIMEFRAME_OPTIONS,
4+
} from "../../common/constants.mjs";
5+
import polygon from "../../polygon.app.mjs";
6+
7+
export default {
8+
key: "polygon-get-company-financials",
9+
name: "Get Company Financials",
10+
description: "Retrieves financial details for a specific company by stock ticker. [See the documentation](https://polygon.io/docs/stocks/get_vx_reference_financials).",
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
polygon,
15+
stockTicker: {
16+
propDefinition: [
17+
polygon,
18+
"stockTicker",
19+
],
20+
},
21+
filingDate: {
22+
type: "string",
23+
label: "Filing Date",
24+
description: "Query by the date when the filing with financials data was filed in **YYYY-MM-DD** format.",
25+
optional: true,
26+
},
27+
periodOfReportDate: {
28+
type: "string",
29+
label: "Period Of Report Date",
30+
description: "The period of report for the filing with financials data in **YYYY-MM-DD** format.",
31+
optional: true,
32+
},
33+
timeframe: {
34+
type: "string",
35+
label: "Timeframe",
36+
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",
37+
options: TIMEFRAME_OPTIONS,
38+
optional: true,
39+
},
40+
order: {
41+
type: "string",
42+
label: "Order",
43+
description: "Order results based on the `Sort` field.",
44+
options: SORT_OPTIONS,
45+
optional: true,
46+
},
47+
limit: {
48+
type: "integer",
49+
label: "Limit",
50+
description: "Limit the number of results returned.",
51+
optional: true,
52+
min: 1,
53+
max: 100,
54+
default: 10,
55+
},
56+
sort: {
57+
type: "string",
58+
label: "Sort",
59+
description: "Sort field used for ordering",
60+
options: SORT_HISTORICAL_OPTIONS,
61+
optional: true,
62+
},
63+
},
64+
async run({ $ }) {
65+
const financialDetails = await this.polygon.getFinancialDetails({
66+
$,
67+
params: {
68+
ticker: this.stockTicker,
69+
filing_date: this.filingDate,
70+
period_of_report_date: this.periodOfReportDate,
71+
timeframe: this.timeframe,
72+
order: this.order,
73+
limit: this.limit,
74+
sort: this.sort,
75+
},
76+
});
77+
$.export("$summary", `Successfully retrieved financial details for ${this.stockTicker}`);
78+
return financialDetails;
79+
},
80+
};
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {
2+
SORT_OPTIONS,
3+
TIMESPAN_OPTIONS,
4+
} from "../../common/constants.mjs";
5+
import polygon from "../../polygon.app.mjs";
6+
7+
export default {
8+
key: "polygon-get-historical-prices",
9+
name: "Get Historical Prices",
10+
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)",
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
polygon,
15+
stockTicker: {
16+
propDefinition: [
17+
polygon,
18+
"stockTicker",
19+
],
20+
},
21+
multiplier: {
22+
type: "integer",
23+
label: "Multiplier",
24+
description: "The size of the timespan multiplier.",
25+
default: 1,
26+
},
27+
timespan: {
28+
type: "string",
29+
label: "Timespan",
30+
description: "The size of the time window.",
31+
options: TIMESPAN_OPTIONS,
32+
},
33+
from: {
34+
type: "string",
35+
label: "From Date",
36+
description: "The start of the aggregate time window. Either a date with the format **YYYY-MM-DD** or a millisecond timestamp.",
37+
},
38+
to: {
39+
type: "string",
40+
label: "To Date",
41+
description: "The end of the aggregate time window. Either a date with the format **YYYY-MM-DD** or a millisecond timestamp.",
42+
},
43+
adjusted: {
44+
propDefinition: [
45+
polygon,
46+
"adjusted",
47+
],
48+
optional: true,
49+
},
50+
sort: {
51+
type: "string",
52+
label: "Sort",
53+
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).",
54+
options: SORT_OPTIONS,
55+
optional: true,
56+
},
57+
limit: {
58+
type: "integer",
59+
label: "Limit",
60+
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).",
61+
optional: true,
62+
min: 1,
63+
max: 50000,
64+
default: 5000,
65+
},
66+
},
67+
async run({ $ }) {
68+
const response = await this.polygon.getHistoricalPriceData({
69+
$,
70+
stockTicker: this.stockTicker,
71+
multiplier: this.multiplier,
72+
timespan: this.timespan,
73+
from: this.from,
74+
to: this.to,
75+
params: {
76+
adjusted: this.adjusted,
77+
sort: this.sort,
78+
limit: this.limit,
79+
},
80+
});
81+
$.export("$summary", `Fetched historical prices for ${this.stockTicker} from ${this.from} to ${this.to}.`);
82+
return response;
83+
},
84+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import polygon from "../../polygon.app.mjs";
2+
3+
export default {
4+
key: "polygon-get-stock-price",
5+
name: "Get Stock Price",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
polygon,
11+
stockTicker: {
12+
propDefinition: [
13+
polygon,
14+
"stockTicker",
15+
],
16+
},
17+
date: {
18+
type: "string",
19+
label: "Date",
20+
description: "The date of the requested open/close in the format YYYY-MM-DD.",
21+
},
22+
adjusted: {
23+
propDefinition: [
24+
polygon,
25+
"adjusted",
26+
],
27+
optional: true,
28+
},
29+
},
30+
async run({ $ }) {
31+
try {
32+
33+
const response = await this.polygon.getCurrentPrice({
34+
$,
35+
date: this.date,
36+
stockTicker: this.stockTicker,
37+
params: {
38+
adjusted: this.adjusted,
39+
},
40+
});
41+
42+
$.export("$summary", `Successfully fetched the price of ${this.stockTicker}`);
43+
return response;
44+
} catch ({ response }) {
45+
if (response.status === 404) {
46+
$.export("$summary", `No data found for ${this.stockTicker}`);
47+
return {};
48+
}
49+
}
50+
},
51+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const TIMESPAN_OPTIONS = [
2+
"second",
3+
"minute",
4+
"hour",
5+
"day",
6+
"week",
7+
"month",
8+
"quarter",
9+
"year",
10+
];
11+
12+
export const TIMEFRAME_OPTIONS = [
13+
"annual",
14+
"quarterly",
15+
"ttm",
16+
];
17+
18+
export const SORT_OPTIONS = [
19+
"asc",
20+
"desc",
21+
];
22+
23+
export const SORT_HISTORICAL_OPTIONS = [
24+
"filing_date",
25+
"period_of_report_date",
26+
];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const parseNextPage = (nextUrl = null) => {
2+
if (nextUrl) {
3+
const url = new URL(nextUrl);
4+
nextUrl = url.searchParams.get("cursor");
5+
}
6+
return nextUrl;
7+
};

components/polygon/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/polygon",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Pipedream polygon Components",
55
"main": "polygon.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.0"
16+
"@pipedream/platform": "^3.0.3"
1717
}
1818
}

0 commit comments

Comments
 (0)