sentisense 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +70 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +136 -6
- package/dist/index.d.ts +136 -6
- package/dist/index.mjs +69 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -87,6 +87,61 @@ interface StockEntity {
|
|
|
87
87
|
type: string;
|
|
88
88
|
[key: string]: unknown;
|
|
89
89
|
}
|
|
90
|
+
/** Per-source tone for a stock: where the conversation is, and how it leans. */
|
|
91
|
+
interface SentimentSourceTone {
|
|
92
|
+
source: string;
|
|
93
|
+
/** "Bullish" | "Neutral" | "Bearish". */
|
|
94
|
+
direction: string;
|
|
95
|
+
/** Share of this stock's mentions coming from this source. */
|
|
96
|
+
mentionShare: number;
|
|
97
|
+
/** Exact polarity in [-1, 1]. */
|
|
98
|
+
value?: number;
|
|
99
|
+
}
|
|
100
|
+
/** A news story moving a stock's sentiment, with its own tone. */
|
|
101
|
+
interface SentimentDriver {
|
|
102
|
+
title: string;
|
|
103
|
+
/** Tone of this driver in [-1, 1]. */
|
|
104
|
+
tone: number;
|
|
105
|
+
}
|
|
106
|
+
interface StockSentiment {
|
|
107
|
+
ticker: string;
|
|
108
|
+
companyName?: string;
|
|
109
|
+
/** ISO date (YYYY-MM-DD) the data is current as of. */
|
|
110
|
+
asOf?: string;
|
|
111
|
+
/** Latest SentiSense Score: a 0-centered composite of sentiment and mentions, unbounded. */
|
|
112
|
+
sentisenseScore?: number;
|
|
113
|
+
/** 30-day average Score, the stable regime figure. */
|
|
114
|
+
sentisenseScoreAvg30d?: number;
|
|
115
|
+
sentisenseScoreDelta30d?: number;
|
|
116
|
+
/** Seven-band label of the 30-day average. */
|
|
117
|
+
scoreLabel?: string;
|
|
118
|
+
/** "Bullish" | "Neutral" | "Bearish", from the 30-day average. */
|
|
119
|
+
direction?: string;
|
|
120
|
+
/** Same three bands, from today's read. */
|
|
121
|
+
latestDirection?: string;
|
|
122
|
+
/** "UP" | "DOWN" | "FLAT". */
|
|
123
|
+
trend?: string;
|
|
124
|
+
/** Daily Score series. */
|
|
125
|
+
scoreSparkline?: number[];
|
|
126
|
+
/** Today's mention volume. */
|
|
127
|
+
mentions?: number;
|
|
128
|
+
/** 30-day average mentions per day. */
|
|
129
|
+
mentionsAvg30d?: number;
|
|
130
|
+
socialDominance?: number;
|
|
131
|
+
bySource?: SentimentSourceTone[];
|
|
132
|
+
relatedTickers?: Array<{
|
|
133
|
+
ticker: string;
|
|
134
|
+
name: string;
|
|
135
|
+
}>;
|
|
136
|
+
drivers?: SentimentDriver[];
|
|
137
|
+
/** Plain-language summary of why the Score sits where it does. */
|
|
138
|
+
narrative?: string;
|
|
139
|
+
faq?: Array<{
|
|
140
|
+
question: string;
|
|
141
|
+
answer: string;
|
|
142
|
+
}>;
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}
|
|
90
145
|
interface ChartDataPoint {
|
|
91
146
|
/** Unix timestamp in milliseconds. */
|
|
92
147
|
timestamp?: number;
|
|
@@ -112,9 +167,47 @@ interface MarketStatus {
|
|
|
112
167
|
status: string;
|
|
113
168
|
[key: string]: unknown;
|
|
114
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* One period of filed financial statement data from `stocks.getFundamentals()`.
|
|
172
|
+
*
|
|
173
|
+
* The index signature is deliberate: the response carries the full income statement, balance
|
|
174
|
+
* sheet, and cash flow line items, and more are added over time, so every field is reachable
|
|
175
|
+
* whether or not it is typed here. The cash-flow block below is typed because its sign and
|
|
176
|
+
* relationships are easy to get wrong.
|
|
177
|
+
*/
|
|
115
178
|
interface Fundamentals {
|
|
116
179
|
ticker: string;
|
|
117
180
|
timeframe: string;
|
|
181
|
+
/**
|
|
182
|
+
* The currency the filer reports in ("USD", "KRW", "EUR", ...). Statement figures are as
|
|
183
|
+
* reported in this currency and are never converted to US dollars: foreign companies listed
|
|
184
|
+
* as ADRs file in their home currency while their listed share price is in USD. Absent means
|
|
185
|
+
* the currency is unknown, not implicitly USD. For non-USD filers the API serves `peRatio`,
|
|
186
|
+
* `psRatio`, and `pbRatio` as `null` on purpose (a USD price over a home-currency per-share
|
|
187
|
+
* figure is a unit mismatch); do not recompute them client-side.
|
|
188
|
+
*/
|
|
189
|
+
reportedCurrency?: string;
|
|
190
|
+
/** Net cash from operating activities, in the reporting currency (see `reportedCurrency`). */
|
|
191
|
+
operatingCashFlow?: number | null;
|
|
192
|
+
/** Net cash from investing activities, in the reporting currency. */
|
|
193
|
+
investingCashFlow?: number | null;
|
|
194
|
+
/** Net cash from financing activities, in the reporting currency. */
|
|
195
|
+
financingCashFlow?: number | null;
|
|
196
|
+
/**
|
|
197
|
+
* Capital expenditure, in the reporting currency, signed as filed: normally NEGATIVE,
|
|
198
|
+
* because it is an outflow. Take the absolute value before treating it as a magnitude.
|
|
199
|
+
*/
|
|
200
|
+
capitalExpenditure?: number | null;
|
|
201
|
+
/**
|
|
202
|
+
* Free cash flow, in the reporting currency: `operatingCashFlow - Math.abs(capitalExpenditure)`.
|
|
203
|
+
*
|
|
204
|
+
* `null` rather than a guess when the period's capital expenditure is not available, so a
|
|
205
|
+
* screen for positive free cash flow can never match on a fabricated number. Do not
|
|
206
|
+
* substitute `operatingCashFlow + investingCashFlow`: investing cash flow also carries
|
|
207
|
+
* marketable-securities and acquisition activity, which for a company holding a large
|
|
208
|
+
* securities portfolio is wrong by billions and can flip the sign.
|
|
209
|
+
*/
|
|
210
|
+
freeCashFlow?: number | null;
|
|
118
211
|
[key: string]: unknown;
|
|
119
212
|
}
|
|
120
213
|
/**
|
|
@@ -169,7 +262,14 @@ interface AISummary {
|
|
|
169
262
|
[key: string]: unknown;
|
|
170
263
|
}
|
|
171
264
|
interface GetChartOptions {
|
|
172
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Chart range. "MAX" returns the full available history (up to ~26 years); "10Y" and "5Y"
|
|
267
|
+
* return weekly bars. Ranges of "5Y" and longer are split- and dividend-adjusted; shorter
|
|
268
|
+
* ranges are split-adjusted only.
|
|
269
|
+
*
|
|
270
|
+
* "ALL" is a legacy alias of "5Y", retained so existing code keeps compiling.
|
|
271
|
+
*/
|
|
272
|
+
timeframe?: "1D" | "5D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "10Y" | "MAX" | "ALL";
|
|
173
273
|
}
|
|
174
274
|
interface GetImagesOptions {
|
|
175
275
|
forced?: boolean;
|
|
@@ -1089,14 +1189,15 @@ declare class EntityMetrics {
|
|
|
1089
1189
|
/**
|
|
1090
1190
|
* Get time-series metric data for an entity using the v2 Serving Metrics API.
|
|
1091
1191
|
*
|
|
1092
|
-
* @param symbol Ticker symbol (e.g. "AAPL")
|
|
1192
|
+
* @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug (e.g. "Nancy-Pelosi",
|
|
1193
|
+
* case-insensitive; discover slugs via stocks.getEntities()).
|
|
1093
1194
|
* @param options Metric type and optional time range / resolution.
|
|
1094
1195
|
*/
|
|
1095
1196
|
getMetrics(symbol: string, options?: MetricsOptions): Promise<ServingMetric[]>;
|
|
1096
1197
|
/**
|
|
1097
1198
|
* Get distribution data for a metric, broken down by a dimension (default: source).
|
|
1098
1199
|
*
|
|
1099
|
-
* @param symbol Ticker symbol (e.g. "AAPL").
|
|
1200
|
+
* @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug.
|
|
1100
1201
|
* @param metricType The metric to break down (e.g. "mentions", "sentiment").
|
|
1101
1202
|
* @param options Optional dimension parameter.
|
|
1102
1203
|
*/
|
|
@@ -1492,6 +1593,18 @@ declare class Stocks {
|
|
|
1492
1593
|
getSimilar(ticker: string, options?: GetSimilarOptions): Promise<SimilarStock[]>;
|
|
1493
1594
|
/** Get company profile (CEO, sector, industry, market data). */
|
|
1494
1595
|
getProfile(ticker: string, options?: GetProfileOptions): Promise<StockProfile>;
|
|
1596
|
+
/**
|
|
1597
|
+
* Get the headline sentiment picture for a stock in one call.
|
|
1598
|
+
*
|
|
1599
|
+
* Returns the SentiSense Score with its 30-day regime, mention volume and social
|
|
1600
|
+
* dominance, per-source tone in `bySource`, plus related tickers, story drivers, a
|
|
1601
|
+
* narrative and an FAQ. Available in full on every API-key tier.
|
|
1602
|
+
*
|
|
1603
|
+
* Use `entityMetrics.getMetrics(ticker, "sentiment", ...)` instead when you need a time
|
|
1604
|
+
* series over a specific window rather than the headline read. Returns 404 for tickers
|
|
1605
|
+
* with no sentiment coverage.
|
|
1606
|
+
*/
|
|
1607
|
+
getSentiment(ticker: string): Promise<PreviewResponse<StockSentiment>>;
|
|
1495
1608
|
/** Get related KB entities (people, products, partners). */
|
|
1496
1609
|
getEntities(ticker: string): Promise<StockEntity[]>;
|
|
1497
1610
|
/** Get AI-generated stock analysis report. Requires PRO tier. */
|
|
@@ -1508,7 +1621,13 @@ declare class Stocks {
|
|
|
1508
1621
|
getChart(ticker: string, options?: GetChartOptions): Promise<ChartData>;
|
|
1509
1622
|
/** Get current market open/closed/pre-market/after-hours status. */
|
|
1510
1623
|
getMarketStatus(): Promise<MarketStatus>;
|
|
1511
|
-
/**
|
|
1624
|
+
/**
|
|
1625
|
+
* Get financial statement data for one reporting period: income statement, balance sheet,
|
|
1626
|
+
* and cash flow, including `capitalExpenditure` and `freeCashFlow`.
|
|
1627
|
+
*
|
|
1628
|
+
* Capital expenditure is signed as filed, so normally negative. See {@link Fundamentals}
|
|
1629
|
+
* for the free-cash-flow relationship and when it is `null`.
|
|
1630
|
+
*/
|
|
1512
1631
|
getFundamentals(ticker: string, options?: GetFundamentalsOptions): Promise<Fundamentals>;
|
|
1513
1632
|
/** Get available fiscal periods. The periods are in `periods`. */
|
|
1514
1633
|
getFundamentalsPeriods(ticker: string): Promise<FundamentalsPeriodsResponse>;
|
|
@@ -1632,6 +1751,17 @@ declare class AuthenticationError extends SentiSenseError {
|
|
|
1632
1751
|
declare class NotFoundError extends SentiSenseError {
|
|
1633
1752
|
constructor(message: string, code?: string);
|
|
1634
1753
|
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Thrown when a deep chart range is still being assembled.
|
|
1756
|
+
*
|
|
1757
|
+
* The API answers 202 for "10Y" and "MAX" the first time a rarely-requested stock is asked
|
|
1758
|
+
* for. It deliberately does not substitute a shorter range, so a successful response always
|
|
1759
|
+
* carries the timeframe you asked for. Retry after a few seconds.
|
|
1760
|
+
*/
|
|
1761
|
+
declare class DeepHistoryUnavailableError extends SentiSenseError {
|
|
1762
|
+
retryAfter?: number;
|
|
1763
|
+
constructor(message: string, retryAfter?: number);
|
|
1764
|
+
}
|
|
1635
1765
|
declare class RateLimitError extends SentiSenseError {
|
|
1636
1766
|
retryAfter?: number;
|
|
1637
1767
|
constructor(message: string, code?: string, retryAfter?: number);
|
|
@@ -1640,6 +1770,6 @@ declare class APIError extends SentiSenseError {
|
|
|
1640
1770
|
constructor(message: string, status: number, code?: string);
|
|
1641
1771
|
}
|
|
1642
1772
|
|
|
1643
|
-
declare const VERSION = "0.
|
|
1773
|
+
declare const VERSION = "0.33.0";
|
|
1644
1774
|
|
|
1645
|
-
export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
|
|
1775
|
+
export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, DeepHistoryUnavailableError, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,6 +87,61 @@ interface StockEntity {
|
|
|
87
87
|
type: string;
|
|
88
88
|
[key: string]: unknown;
|
|
89
89
|
}
|
|
90
|
+
/** Per-source tone for a stock: where the conversation is, and how it leans. */
|
|
91
|
+
interface SentimentSourceTone {
|
|
92
|
+
source: string;
|
|
93
|
+
/** "Bullish" | "Neutral" | "Bearish". */
|
|
94
|
+
direction: string;
|
|
95
|
+
/** Share of this stock's mentions coming from this source. */
|
|
96
|
+
mentionShare: number;
|
|
97
|
+
/** Exact polarity in [-1, 1]. */
|
|
98
|
+
value?: number;
|
|
99
|
+
}
|
|
100
|
+
/** A news story moving a stock's sentiment, with its own tone. */
|
|
101
|
+
interface SentimentDriver {
|
|
102
|
+
title: string;
|
|
103
|
+
/** Tone of this driver in [-1, 1]. */
|
|
104
|
+
tone: number;
|
|
105
|
+
}
|
|
106
|
+
interface StockSentiment {
|
|
107
|
+
ticker: string;
|
|
108
|
+
companyName?: string;
|
|
109
|
+
/** ISO date (YYYY-MM-DD) the data is current as of. */
|
|
110
|
+
asOf?: string;
|
|
111
|
+
/** Latest SentiSense Score: a 0-centered composite of sentiment and mentions, unbounded. */
|
|
112
|
+
sentisenseScore?: number;
|
|
113
|
+
/** 30-day average Score, the stable regime figure. */
|
|
114
|
+
sentisenseScoreAvg30d?: number;
|
|
115
|
+
sentisenseScoreDelta30d?: number;
|
|
116
|
+
/** Seven-band label of the 30-day average. */
|
|
117
|
+
scoreLabel?: string;
|
|
118
|
+
/** "Bullish" | "Neutral" | "Bearish", from the 30-day average. */
|
|
119
|
+
direction?: string;
|
|
120
|
+
/** Same three bands, from today's read. */
|
|
121
|
+
latestDirection?: string;
|
|
122
|
+
/** "UP" | "DOWN" | "FLAT". */
|
|
123
|
+
trend?: string;
|
|
124
|
+
/** Daily Score series. */
|
|
125
|
+
scoreSparkline?: number[];
|
|
126
|
+
/** Today's mention volume. */
|
|
127
|
+
mentions?: number;
|
|
128
|
+
/** 30-day average mentions per day. */
|
|
129
|
+
mentionsAvg30d?: number;
|
|
130
|
+
socialDominance?: number;
|
|
131
|
+
bySource?: SentimentSourceTone[];
|
|
132
|
+
relatedTickers?: Array<{
|
|
133
|
+
ticker: string;
|
|
134
|
+
name: string;
|
|
135
|
+
}>;
|
|
136
|
+
drivers?: SentimentDriver[];
|
|
137
|
+
/** Plain-language summary of why the Score sits where it does. */
|
|
138
|
+
narrative?: string;
|
|
139
|
+
faq?: Array<{
|
|
140
|
+
question: string;
|
|
141
|
+
answer: string;
|
|
142
|
+
}>;
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}
|
|
90
145
|
interface ChartDataPoint {
|
|
91
146
|
/** Unix timestamp in milliseconds. */
|
|
92
147
|
timestamp?: number;
|
|
@@ -112,9 +167,47 @@ interface MarketStatus {
|
|
|
112
167
|
status: string;
|
|
113
168
|
[key: string]: unknown;
|
|
114
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* One period of filed financial statement data from `stocks.getFundamentals()`.
|
|
172
|
+
*
|
|
173
|
+
* The index signature is deliberate: the response carries the full income statement, balance
|
|
174
|
+
* sheet, and cash flow line items, and more are added over time, so every field is reachable
|
|
175
|
+
* whether or not it is typed here. The cash-flow block below is typed because its sign and
|
|
176
|
+
* relationships are easy to get wrong.
|
|
177
|
+
*/
|
|
115
178
|
interface Fundamentals {
|
|
116
179
|
ticker: string;
|
|
117
180
|
timeframe: string;
|
|
181
|
+
/**
|
|
182
|
+
* The currency the filer reports in ("USD", "KRW", "EUR", ...). Statement figures are as
|
|
183
|
+
* reported in this currency and are never converted to US dollars: foreign companies listed
|
|
184
|
+
* as ADRs file in their home currency while their listed share price is in USD. Absent means
|
|
185
|
+
* the currency is unknown, not implicitly USD. For non-USD filers the API serves `peRatio`,
|
|
186
|
+
* `psRatio`, and `pbRatio` as `null` on purpose (a USD price over a home-currency per-share
|
|
187
|
+
* figure is a unit mismatch); do not recompute them client-side.
|
|
188
|
+
*/
|
|
189
|
+
reportedCurrency?: string;
|
|
190
|
+
/** Net cash from operating activities, in the reporting currency (see `reportedCurrency`). */
|
|
191
|
+
operatingCashFlow?: number | null;
|
|
192
|
+
/** Net cash from investing activities, in the reporting currency. */
|
|
193
|
+
investingCashFlow?: number | null;
|
|
194
|
+
/** Net cash from financing activities, in the reporting currency. */
|
|
195
|
+
financingCashFlow?: number | null;
|
|
196
|
+
/**
|
|
197
|
+
* Capital expenditure, in the reporting currency, signed as filed: normally NEGATIVE,
|
|
198
|
+
* because it is an outflow. Take the absolute value before treating it as a magnitude.
|
|
199
|
+
*/
|
|
200
|
+
capitalExpenditure?: number | null;
|
|
201
|
+
/**
|
|
202
|
+
* Free cash flow, in the reporting currency: `operatingCashFlow - Math.abs(capitalExpenditure)`.
|
|
203
|
+
*
|
|
204
|
+
* `null` rather than a guess when the period's capital expenditure is not available, so a
|
|
205
|
+
* screen for positive free cash flow can never match on a fabricated number. Do not
|
|
206
|
+
* substitute `operatingCashFlow + investingCashFlow`: investing cash flow also carries
|
|
207
|
+
* marketable-securities and acquisition activity, which for a company holding a large
|
|
208
|
+
* securities portfolio is wrong by billions and can flip the sign.
|
|
209
|
+
*/
|
|
210
|
+
freeCashFlow?: number | null;
|
|
118
211
|
[key: string]: unknown;
|
|
119
212
|
}
|
|
120
213
|
/**
|
|
@@ -169,7 +262,14 @@ interface AISummary {
|
|
|
169
262
|
[key: string]: unknown;
|
|
170
263
|
}
|
|
171
264
|
interface GetChartOptions {
|
|
172
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Chart range. "MAX" returns the full available history (up to ~26 years); "10Y" and "5Y"
|
|
267
|
+
* return weekly bars. Ranges of "5Y" and longer are split- and dividend-adjusted; shorter
|
|
268
|
+
* ranges are split-adjusted only.
|
|
269
|
+
*
|
|
270
|
+
* "ALL" is a legacy alias of "5Y", retained so existing code keeps compiling.
|
|
271
|
+
*/
|
|
272
|
+
timeframe?: "1D" | "5D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "10Y" | "MAX" | "ALL";
|
|
173
273
|
}
|
|
174
274
|
interface GetImagesOptions {
|
|
175
275
|
forced?: boolean;
|
|
@@ -1089,14 +1189,15 @@ declare class EntityMetrics {
|
|
|
1089
1189
|
/**
|
|
1090
1190
|
* Get time-series metric data for an entity using the v2 Serving Metrics API.
|
|
1091
1191
|
*
|
|
1092
|
-
* @param symbol Ticker symbol (e.g. "AAPL")
|
|
1192
|
+
* @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug (e.g. "Nancy-Pelosi",
|
|
1193
|
+
* case-insensitive; discover slugs via stocks.getEntities()).
|
|
1093
1194
|
* @param options Metric type and optional time range / resolution.
|
|
1094
1195
|
*/
|
|
1095
1196
|
getMetrics(symbol: string, options?: MetricsOptions): Promise<ServingMetric[]>;
|
|
1096
1197
|
/**
|
|
1097
1198
|
* Get distribution data for a metric, broken down by a dimension (default: source).
|
|
1098
1199
|
*
|
|
1099
|
-
* @param symbol Ticker symbol (e.g. "AAPL").
|
|
1200
|
+
* @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug.
|
|
1100
1201
|
* @param metricType The metric to break down (e.g. "mentions", "sentiment").
|
|
1101
1202
|
* @param options Optional dimension parameter.
|
|
1102
1203
|
*/
|
|
@@ -1492,6 +1593,18 @@ declare class Stocks {
|
|
|
1492
1593
|
getSimilar(ticker: string, options?: GetSimilarOptions): Promise<SimilarStock[]>;
|
|
1493
1594
|
/** Get company profile (CEO, sector, industry, market data). */
|
|
1494
1595
|
getProfile(ticker: string, options?: GetProfileOptions): Promise<StockProfile>;
|
|
1596
|
+
/**
|
|
1597
|
+
* Get the headline sentiment picture for a stock in one call.
|
|
1598
|
+
*
|
|
1599
|
+
* Returns the SentiSense Score with its 30-day regime, mention volume and social
|
|
1600
|
+
* dominance, per-source tone in `bySource`, plus related tickers, story drivers, a
|
|
1601
|
+
* narrative and an FAQ. Available in full on every API-key tier.
|
|
1602
|
+
*
|
|
1603
|
+
* Use `entityMetrics.getMetrics(ticker, "sentiment", ...)` instead when you need a time
|
|
1604
|
+
* series over a specific window rather than the headline read. Returns 404 for tickers
|
|
1605
|
+
* with no sentiment coverage.
|
|
1606
|
+
*/
|
|
1607
|
+
getSentiment(ticker: string): Promise<PreviewResponse<StockSentiment>>;
|
|
1495
1608
|
/** Get related KB entities (people, products, partners). */
|
|
1496
1609
|
getEntities(ticker: string): Promise<StockEntity[]>;
|
|
1497
1610
|
/** Get AI-generated stock analysis report. Requires PRO tier. */
|
|
@@ -1508,7 +1621,13 @@ declare class Stocks {
|
|
|
1508
1621
|
getChart(ticker: string, options?: GetChartOptions): Promise<ChartData>;
|
|
1509
1622
|
/** Get current market open/closed/pre-market/after-hours status. */
|
|
1510
1623
|
getMarketStatus(): Promise<MarketStatus>;
|
|
1511
|
-
/**
|
|
1624
|
+
/**
|
|
1625
|
+
* Get financial statement data for one reporting period: income statement, balance sheet,
|
|
1626
|
+
* and cash flow, including `capitalExpenditure` and `freeCashFlow`.
|
|
1627
|
+
*
|
|
1628
|
+
* Capital expenditure is signed as filed, so normally negative. See {@link Fundamentals}
|
|
1629
|
+
* for the free-cash-flow relationship and when it is `null`.
|
|
1630
|
+
*/
|
|
1512
1631
|
getFundamentals(ticker: string, options?: GetFundamentalsOptions): Promise<Fundamentals>;
|
|
1513
1632
|
/** Get available fiscal periods. The periods are in `periods`. */
|
|
1514
1633
|
getFundamentalsPeriods(ticker: string): Promise<FundamentalsPeriodsResponse>;
|
|
@@ -1632,6 +1751,17 @@ declare class AuthenticationError extends SentiSenseError {
|
|
|
1632
1751
|
declare class NotFoundError extends SentiSenseError {
|
|
1633
1752
|
constructor(message: string, code?: string);
|
|
1634
1753
|
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Thrown when a deep chart range is still being assembled.
|
|
1756
|
+
*
|
|
1757
|
+
* The API answers 202 for "10Y" and "MAX" the first time a rarely-requested stock is asked
|
|
1758
|
+
* for. It deliberately does not substitute a shorter range, so a successful response always
|
|
1759
|
+
* carries the timeframe you asked for. Retry after a few seconds.
|
|
1760
|
+
*/
|
|
1761
|
+
declare class DeepHistoryUnavailableError extends SentiSenseError {
|
|
1762
|
+
retryAfter?: number;
|
|
1763
|
+
constructor(message: string, retryAfter?: number);
|
|
1764
|
+
}
|
|
1635
1765
|
declare class RateLimitError extends SentiSenseError {
|
|
1636
1766
|
retryAfter?: number;
|
|
1637
1767
|
constructor(message: string, code?: string, retryAfter?: number);
|
|
@@ -1640,6 +1770,6 @@ declare class APIError extends SentiSenseError {
|
|
|
1640
1770
|
constructor(message: string, status: number, code?: string);
|
|
1641
1771
|
}
|
|
1642
1772
|
|
|
1643
|
-
declare const VERSION = "0.
|
|
1773
|
+
declare const VERSION = "0.33.0";
|
|
1644
1774
|
|
|
1645
|
-
export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
|
|
1775
|
+
export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, DeepHistoryUnavailableError, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
|
package/dist/index.mjs
CHANGED
|
@@ -19,6 +19,13 @@ var NotFoundError = class extends SentiSenseError {
|
|
|
19
19
|
this.name = "NotFoundError";
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
var DeepHistoryUnavailableError = class extends SentiSenseError {
|
|
23
|
+
constructor(message, retryAfter) {
|
|
24
|
+
super(message, 202);
|
|
25
|
+
this.name = "DeepHistoryUnavailableError";
|
|
26
|
+
this.retryAfter = retryAfter;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
22
29
|
var RateLimitError = class extends SentiSenseError {
|
|
23
30
|
constructor(message, code, retryAfter) {
|
|
24
31
|
super(message, 429, code);
|
|
@@ -152,7 +159,8 @@ var EntityMetrics = class {
|
|
|
152
159
|
/**
|
|
153
160
|
* Get time-series metric data for an entity using the v2 Serving Metrics API.
|
|
154
161
|
*
|
|
155
|
-
* @param symbol Ticker symbol (e.g. "AAPL")
|
|
162
|
+
* @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug (e.g. "Nancy-Pelosi",
|
|
163
|
+
* case-insensitive; discover slugs via stocks.getEntities()).
|
|
156
164
|
* @param options Metric type and optional time range / resolution.
|
|
157
165
|
*/
|
|
158
166
|
async getMetrics(symbol, options = {}) {
|
|
@@ -169,7 +177,7 @@ var EntityMetrics = class {
|
|
|
169
177
|
/**
|
|
170
178
|
* Get distribution data for a metric, broken down by a dimension (default: source).
|
|
171
179
|
*
|
|
172
|
-
* @param symbol Ticker symbol (e.g. "AAPL").
|
|
180
|
+
* @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug.
|
|
173
181
|
* @param metricType The metric to break down (e.g. "mentions", "sentiment").
|
|
174
182
|
* @param options Optional dimension parameter.
|
|
175
183
|
*/
|
|
@@ -564,6 +572,22 @@ var Stocks = class {
|
|
|
564
572
|
async getProfile(ticker, options) {
|
|
565
573
|
return this.client.get(`/api/v1/stocks/${encodeURIComponent(ticker)}/profile`, options);
|
|
566
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Get the headline sentiment picture for a stock in one call.
|
|
577
|
+
*
|
|
578
|
+
* Returns the SentiSense Score with its 30-day regime, mention volume and social
|
|
579
|
+
* dominance, per-source tone in `bySource`, plus related tickers, story drivers, a
|
|
580
|
+
* narrative and an FAQ. Available in full on every API-key tier.
|
|
581
|
+
*
|
|
582
|
+
* Use `entityMetrics.getMetrics(ticker, "sentiment", ...)` instead when you need a time
|
|
583
|
+
* series over a specific window rather than the headline read. Returns 404 for tickers
|
|
584
|
+
* with no sentiment coverage.
|
|
585
|
+
*/
|
|
586
|
+
async getSentiment(ticker) {
|
|
587
|
+
return this.client.get(
|
|
588
|
+
`/api/v1/stocks/${encodeURIComponent(ticker)}/sentiment`
|
|
589
|
+
);
|
|
590
|
+
}
|
|
567
591
|
/** Get related KB entities (people, products, partners). */
|
|
568
592
|
async getEntities(ticker) {
|
|
569
593
|
return this.client.get(`/api/v1/stocks/${encodeURIComponent(ticker)}/entities`);
|
|
@@ -597,7 +621,13 @@ var Stocks = class {
|
|
|
597
621
|
async getMarketStatus() {
|
|
598
622
|
return this.client.get("/api/v1/stocks/market-status");
|
|
599
623
|
}
|
|
600
|
-
/**
|
|
624
|
+
/**
|
|
625
|
+
* Get financial statement data for one reporting period: income statement, balance sheet,
|
|
626
|
+
* and cash flow, including `capitalExpenditure` and `freeCashFlow`.
|
|
627
|
+
*
|
|
628
|
+
* Capital expenditure is signed as filed, so normally negative. See {@link Fundamentals}
|
|
629
|
+
* for the free-cash-flow relationship and when it is `null`.
|
|
630
|
+
*/
|
|
601
631
|
async getFundamentals(ticker, options) {
|
|
602
632
|
return this.client.get("/api/v1/stocks/fundamentals", { ticker, ...options });
|
|
603
633
|
}
|
|
@@ -699,7 +729,7 @@ var Trackers = class {
|
|
|
699
729
|
};
|
|
700
730
|
|
|
701
731
|
// src/version.ts
|
|
702
|
-
var VERSION = "0.
|
|
732
|
+
var VERSION = "0.33.0";
|
|
703
733
|
|
|
704
734
|
// src/client.ts
|
|
705
735
|
var DEFAULT_BASE_URL = "https://app.sentisense.ai";
|
|
@@ -707,6 +737,16 @@ var DEFAULT_TIMEOUT = 3e4;
|
|
|
707
737
|
var DEFAULT_MAX_RETRIES = 3;
|
|
708
738
|
var BASE_DELAY_MS = 1e3;
|
|
709
739
|
var MAX_DELAY_MS = 6e4;
|
|
740
|
+
var DEEP_HISTORY_FALLBACK_WAIT_S = 3;
|
|
741
|
+
var MAX_DEEP_HISTORY_WAIT_S = 30;
|
|
742
|
+
var MAX_RATE_LIMIT_WAIT_S = 120;
|
|
743
|
+
var RATE_LIMIT_FALLBACK_WAIT_S = 60;
|
|
744
|
+
function retryAfterSeconds(raw, defaultS, maxWaitS) {
|
|
745
|
+
if (!raw) return defaultS;
|
|
746
|
+
const parsed = Number(raw);
|
|
747
|
+
if (!Number.isFinite(parsed)) return defaultS;
|
|
748
|
+
return Math.min(Math.max(0.5, parsed), maxWaitS);
|
|
749
|
+
}
|
|
710
750
|
function sleep(ms) {
|
|
711
751
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
712
752
|
}
|
|
@@ -757,12 +797,34 @@ var SentiSense = class {
|
|
|
757
797
|
headers,
|
|
758
798
|
signal: controller.signal
|
|
759
799
|
});
|
|
800
|
+
if (response.status === 202) {
|
|
801
|
+
const waitSeconds = retryAfterSeconds(
|
|
802
|
+
response.headers.get("Retry-After"),
|
|
803
|
+
DEEP_HISTORY_FALLBACK_WAIT_S,
|
|
804
|
+
MAX_DEEP_HISTORY_WAIT_S
|
|
805
|
+
);
|
|
806
|
+
try {
|
|
807
|
+
await response.body?.cancel();
|
|
808
|
+
} catch {
|
|
809
|
+
}
|
|
810
|
+
if (attempt < this.maxRetries) {
|
|
811
|
+
delayMs = waitSeconds * 1e3;
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
throw new DeepHistoryUnavailableError(
|
|
815
|
+
"Deep history is still being assembled. Retry in a few seconds.",
|
|
816
|
+
waitSeconds
|
|
817
|
+
);
|
|
818
|
+
}
|
|
760
819
|
if (!response.ok) {
|
|
761
820
|
const isRetryable = response.status === 429 || response.status >= 500;
|
|
762
821
|
if (isRetryable && attempt < this.maxRetries) {
|
|
763
822
|
if (response.status === 429) {
|
|
764
|
-
|
|
765
|
-
|
|
823
|
+
delayMs = retryAfterSeconds(
|
|
824
|
+
response.headers.get("Retry-After"),
|
|
825
|
+
RATE_LIMIT_FALLBACK_WAIT_S,
|
|
826
|
+
MAX_RATE_LIMIT_WAIT_S
|
|
827
|
+
) * 1e3;
|
|
766
828
|
} else {
|
|
767
829
|
delayMs = Math.min(BASE_DELAY_MS * Math.pow(2, attempt), MAX_DELAY_MS) + Math.random() * 1e3;
|
|
768
830
|
}
|
|
@@ -864,6 +926,7 @@ var SentiSense = class {
|
|
|
864
926
|
export {
|
|
865
927
|
APIError,
|
|
866
928
|
AuthenticationError,
|
|
929
|
+
DeepHistoryUnavailableError,
|
|
867
930
|
NotFoundError,
|
|
868
931
|
RateLimitError,
|
|
869
932
|
SentiSense,
|