| 
 | 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 | +};  | 
0 commit comments