sentisense 0.50.0 → 0.52.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.d.mts CHANGED
@@ -668,6 +668,24 @@ type RatingDimensionKey = "crowd" | "smart_money" | "options" | "analysts" | "fu
668
668
  * the last run. The other two mean the run looked and declined to grade.
669
669
  */
670
670
  type RatingNotRatedReason = "stale" | "not_rated_today" | "insufficient_dimensions" | "insufficient_coverage_weight";
671
+ /**
672
+ * A risk condition evaluated against a rated stock. An active one deducts points from the
673
+ * score, up to 12 apiece; `percentile` itself is never touched by them.
674
+ */
675
+ type RiskCondition = "thin_coverage" | "weak_dimension" | "unprofitable" | "no_fundamentals" | "high_leverage" | "unseasoned_listing" | "small_market_cap" | "thin_liquidity" | "extended_price" | "insider_selling" | "institutional_outflow";
676
+ /**
677
+ * One graded deduction applied to a rated stock's score.
678
+ *
679
+ * A condition is graded rather than binary, so `points` is the share of the 12-point
680
+ * maximum this one actually cost. Only active conditions appear, and `penaltyPoints` is
681
+ * the sum of these.
682
+ */
683
+ interface RiskAdjustment {
684
+ /** Which condition, by the same key `riskConditions` reports. */
685
+ condition: RiskCondition;
686
+ /** Points deducted, to one decimal, up to 12 for a single condition. */
687
+ points: number;
688
+ }
671
689
  /**
672
690
  * One constituent leg behind a dimension's percentile.
673
691
  *
@@ -737,18 +755,59 @@ interface RatingBase {
737
755
  /** The standard financial disclaimer. Display it alongside the grade. */
738
756
  disclaimer: string;
739
757
  }
740
- /** A stock that has a grade for `asOf`. */
741
- interface RatedStockRating extends RatingBase {
758
+ /**
759
+ * A stock that has a grade for `asOf`.
760
+ *
761
+ * `score`, `bucketLetter`, `riskConditions`, `riskAdjustments` and `penaltyPoints` arrive
762
+ * from the next API deploy onward and are optional here because a response served before
763
+ * then omits them.
764
+ */
765
+ interface StockRating extends RatingBase {
742
766
  rated: true;
743
767
  /**
744
- * `"A"`, `"B"`, `"C"`, `"D"` or `"F"`. Served as stored, never re-derived from
745
- * `percentile`, so read it rather than computing your own bucket edges.
768
+ * The headline number, 0 to 100 with one decimal, and the number `letter` is the band
769
+ * of: `score = percentile - sum(riskAdjustments.map((a) => a.points))`, floored at 10
770
+ * when fewer than five dimensions are available and at 0 otherwise. Absent on a
771
+ * response served before this field shipped.
772
+ */
773
+ score?: number;
774
+ /**
775
+ * `"A"`, `"B"`, `"C"`, `"D"` or `"F"`: the band `score` falls in, at edges 90, 70, 30
776
+ * and 10. Served as stored, so read it rather than deriving your own edges. Deriving
777
+ * it from `percentile` disagrees with the API for every stock carrying a risk
778
+ * condition.
746
779
  */
747
780
  letter: string;
748
- /** Rank of `composite` among the day's rated stocks, 0 to 100. */
781
+ /**
782
+ * The band `percentile` alone would fall in, so a difference from `letter` is exactly
783
+ * what the risk conditions cost. Absent on a response served before this field
784
+ * shipped.
785
+ */
786
+ bucketLetter?: string;
787
+ /**
788
+ * Rank of `composite` among the day's rated stocks, 0 to 100. This stays the true rank
789
+ * of the blended signals: the risk conditions are subtracted from `score`, never here.
790
+ */
749
791
  percentile: number;
750
792
  /** The weighted blend before ranking, in [-1, +1]. */
751
793
  composite: number;
794
+ /**
795
+ * Which risk conditions were active. An empty array means none were, and the field is
796
+ * absent on a response served before it shipped.
797
+ */
798
+ riskConditions?: RiskCondition[];
799
+ /**
800
+ * The same conditions with the points each one actually cost, since a condition is
801
+ * graded rather than binary and can cost anything up to 12. Absent on a response
802
+ * served before this field shipped.
803
+ */
804
+ riskAdjustments?: RiskAdjustment[];
805
+ /**
806
+ * The sum of `riskAdjustments` points, to one decimal: how far `score` sits below
807
+ * `percentile` before the floor applies. Absent on a response served before this field
808
+ * shipped.
809
+ */
810
+ penaltyPoints?: number;
752
811
  /** How many stocks were rated that day: the rank's denominator. */
753
812
  ratedCount: number;
754
813
  /** The weights and floors in force when the row was written, e.g. `"2026.09-v1"`. */
@@ -758,7 +817,7 @@ interface RatedStockRating extends RatingBase {
758
817
  * A stock with no grade for `asOf`. A normal 200, not an error: ETFs and tickers outside
759
818
  * the swept universe answer this way, and the composition still arrives so a card can render.
760
819
  */
761
- interface UnratedStockRating extends RatingBase {
820
+ interface StockNotRated extends RatingBase {
762
821
  rated: false;
763
822
  /** Why there is no grade. */
764
823
  reason: RatingNotRatedReason;
@@ -779,7 +838,7 @@ interface UnratedStockRating extends RatingBase {
779
838
  * and it is not a recommendation about any security. Carry `disclaimer` wherever you display
780
839
  * a grade. Methodology: https://sentisense.ai/methodology/#sentisense-rating
781
840
  */
782
- type StockRating = RatedStockRating | UnratedStockRating;
841
+ type StockRatingResponse = StockRating | StockNotRated;
783
842
  type DocumentSource = "news" | "reddit" | "x" | "substack" | "youtube";
784
843
  /** Per-entity sentiment classification with resolved entity details. */
785
844
  interface SentimentEntry {
@@ -1500,7 +1559,7 @@ interface PreviewResponse<T> {
1500
1559
  /** Supported metric types for the v2 Serving Metrics API. */
1501
1560
  type MetricType = "mentions" | "sentiment" | "sentisense_score"
1502
1561
  /**
1503
- * The SentiSense Rating percentile, 0 to 100. Time series only: it has no source
1562
+ * The SentiSense Rating score, 0 to 100. Time series only: it has no source
1504
1563
  * breakdown, so `getDistribution` answers with an empty distribution for it.
1505
1564
  */
1506
1565
  | "sentisense_rating" | "social_dominance" | "creators";
@@ -3026,11 +3085,48 @@ declare class Institutional {
3026
3085
  getInstitutionDetail(slugOrCik: string): Promise<unknown>;
3027
3086
  }
3028
3087
 
3088
+ /** Public entity types the search `type` filter accepts, and that come back on a hit. */
3089
+ type EntitySearchType = "person" | "company" | "product" | "organization" | "etf" | "topic" | "country";
3090
+ /**
3091
+ * One ranked match from {@link KB.searchEntities}.
3092
+ *
3093
+ * `urlSlug` is the handle the metric endpoints address an entity by, which is the reason
3094
+ * this endpoint exists: it answers "what is the handle for the thing I typed".
3095
+ */
3096
+ interface EntitySearchResult {
3097
+ name: string;
3098
+ /** Stable handle for this entity, or `null` when it has none. */
3099
+ urlSlug: string | null;
3100
+ /** `"person"`, `"company"`, `"product"`, `"organization"`, `"etf"`, `"topic"`, `"country"`. */
3101
+ type: EntitySearchType | string | null;
3102
+ /** The listed symbol for a tradeable entity, `null` for everything else. */
3103
+ ticker: string | null;
3104
+ }
3105
+ interface SearchEntitiesOptions {
3106
+ /** Narrow to one entity type. An unrecognised value is rejected with a 400. */
3107
+ type?: EntitySearchType | string;
3108
+ /** Matches to return, 1 to 25. Omitted, the API applies its own default of 10. */
3109
+ limit?: number;
3110
+ }
3029
3111
  declare class KB {
3030
3112
  private client;
3031
3113
  constructor(client: APIClient);
3032
3114
  /** Get popular entities for search suggestions. */
3033
3115
  getPopularEntities(): Promise<KBEntity[]>;
3116
+ /**
3117
+ * Resolve a name, alias, ticker or slug to the entities we track, best match first.
3118
+ *
3119
+ * This is resolution, not enumeration: the query must be at least 2 characters and the
3120
+ * result count is capped, so it answers "which handle did the user mean" rather than
3121
+ * dumping the graph. Use it when someone typed "Tesla" and the rest of your code needs
3122
+ * `TSLA`, or when you need the `urlSlug` an entity's metric series is addressed by.
3123
+ *
3124
+ * Returns a bare array, not a `PreviewResponse` envelope, and an empty array is the
3125
+ * normal answer for a query that matches nothing.
3126
+ *
3127
+ * @param q What the user typed. At least 2 characters, or the API answers 400.
3128
+ */
3129
+ searchEntities(q: string, options?: SearchEntitiesOptions): Promise<EntitySearchResult[]>;
3034
3130
  }
3035
3131
 
3036
3132
  declare class MarketMoodResource {
@@ -3356,10 +3452,10 @@ declare class Stocks {
3356
3452
  * security. `disclaimer` carries the wording to display alongside a grade. Methodology:
3357
3453
  * https://sentisense.ai/methodology/#sentisense-rating
3358
3454
  *
3359
- * **A discriminated union on `rated`.** `if (rating.rated)` narrows to `letter`,
3360
- * `percentile`, `composite`, `ratedCount` and `methodologyVersion`; the `else` branch
3361
- * narrows to `reason`, `dimensionsPresent` and `presentDimensions`. Branch on the flag
3362
- * rather than testing a field for `undefined`.
3455
+ * **A discriminated union on `rated`.** `if (rating.rated)` narrows to `score`,
3456
+ * `letter`, `percentile`, `composite`, `ratedCount` and `methodologyVersion`; the
3457
+ * `else` branch narrows to `reason`, `dimensionsPresent` and `presentDimensions`.
3458
+ * Branch on the flag rather than testing a field for `undefined`.
3363
3459
  *
3364
3460
  * **Having no grade is a normal 200, not a 404.** ETFs and tickers outside the swept
3365
3461
  * universe answer with `rated` false, and the composition still arrives so a card can
@@ -3369,13 +3465,24 @@ declare class Stocks {
3369
3465
  *
3370
3466
  * `dimensions` always holds all six rows in a fixed order, including the ones with no
3371
3467
  * data, which arrive with `present` false and a `null` percentile. Read `present` first
3372
- * and never read a missing percentile as zero. `letter` is served as stored rather than
3373
- * derived from `percentile`, so read it instead of computing your own bucket edges.
3468
+ * and never read a missing percentile as zero.
3469
+ *
3470
+ * **`score` and `percentile` are different numbers.** `percentile` is the rank of the
3471
+ * blended signals against the day's rated set, and
3472
+ * `score = percentile - sum(riskAdjustments.map((a) => a.points))`, floored at 10 when
3473
+ * fewer than five dimensions are available and at 0 otherwise. `letter` is the band
3474
+ * `score` falls in, at edges 90, 70, 30 and 10, while `bucketLetter` is the band the
3475
+ * percentile alone would fall in, so a difference between the two letters is exactly
3476
+ * what the conditions cost. `riskConditions` names the active ones, `riskAdjustments`
3477
+ * gives the points each cost (graded, up to 12 apiece), and `penaltyPoints` is their
3478
+ * sum. `letter` is served as stored, so read it instead of computing your own bucket
3479
+ * edges. The five fields arrive from the next API deploy onward and are optional, so a
3480
+ * response served before then still parses.
3374
3481
  *
3375
- * For the daily history of a stock's percentile, ask `client.entityMetrics.getMetrics`
3376
- * for the `sentisense_rating` metric.
3482
+ * For the daily history of a stock's score, ask `client.entityMetrics.getMetrics` for
3483
+ * the `sentisense_rating` metric.
3377
3484
  */
3378
- getRating(ticker: string): Promise<StockRating>;
3485
+ getRating(ticker: string): Promise<StockRatingResponse>;
3379
3486
  }
3380
3487
 
3381
3488
  /**
@@ -3532,6 +3639,6 @@ declare class APIError extends SentiSenseError {
3532
3639
  constructor(message: string, status: number, code?: string);
3533
3640
  }
3534
3641
 
3535
- declare const VERSION = "0.50.0";
3642
+ declare const VERSION = "0.52.0";
3536
3643
 
3537
- export { type AISummary, APIError, type AnalystAction, type AnalystCall, type AnalystConsensus, type AnalystCoverage, type AnalystCoverageAnalyst, type AnalystCoverageBookEntry, type AnalystCoverageFirm, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AnalystFirmRating, type AnalystFirmTenure, type AnalystNote, type AnalystProfile, type AnalystRatingBuckets, 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 EarningsKpiHighlight, type EarningsQuarter, type EarningsSource, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfScreenerExecuteResponse, type EtfScreenerRow, type EtfSentimentAggregate, type EtfSentimentReading, type FeaturedScreen, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystCallsOptions, type GetAnalystCoverageOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEarningsSummariesOptions, type GetEtfInsiderAggregateOptions, type GetHoldersOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetOptionsHistoryOptions, type GetPoliticianActivityOptions, type GetPoliticianDirectoryOptions, type GetPoliticianMemberOptions, type GetPoliticiansOptions, type GetRecentEarningsOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type HolderNotableChanges, type IndexConstituent, type IndexHistoryPoint, type IndexHistoryResponse, type IndexListResponse, type IndexListing, type IndexSnapshot, 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 OptionsAggregate, type OptionsContext, type OptionsHistory, type OptionsHistoryWindow, type OptionsOiWalls, type OptionsOverview, type OptionsOverviewRow, type OptionsSummary, type OptionsUnusualContract, type OptionsWall, type PoliticianDetail, type PoliticianDirectory, type PoliticianDirectoryEntry, type PoliticianDirectoryResponse, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, type RatedStockRating, type RatingBase, type RatingDimension, type RatingDimensionKey, type RatingFlag, type RatingNotRatedReason, type RatingSubLeg, type RecentEarningsEntry, type ScreenerExecuteOptions, type ScreenerExecuteResponse, type ScreenerFieldCatalog, type ScreenerFieldDescriptor, type ScreenerFieldOption, type ScreenerFilter, type ScreenerPlan, type ScreenerRow, type ScreenerScreensResponse, type ScreenerSort, 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 StockRating, type StockSocialDominance, 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, type UnratedStockRating, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
3644
+ export { type AISummary, APIError, type AnalystAction, type AnalystCall, type AnalystConsensus, type AnalystCoverage, type AnalystCoverageAnalyst, type AnalystCoverageBookEntry, type AnalystCoverageFirm, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AnalystFirmRating, type AnalystFirmTenure, type AnalystNote, type AnalystProfile, type AnalystRatingBuckets, 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 EarningsKpiHighlight, type EarningsQuarter, type EarningsSource, type EntitySearchResult, type EntitySearchType, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfScreenerExecuteResponse, type EtfScreenerRow, type EtfSentimentAggregate, type EtfSentimentReading, type FeaturedScreen, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystCallsOptions, type GetAnalystCoverageOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEarningsSummariesOptions, type GetEtfInsiderAggregateOptions, type GetHoldersOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetOptionsHistoryOptions, type GetPoliticianActivityOptions, type GetPoliticianDirectoryOptions, type GetPoliticianMemberOptions, type GetPoliticiansOptions, type GetRecentEarningsOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type HolderNotableChanges, type IndexConstituent, type IndexHistoryPoint, type IndexHistoryResponse, type IndexListResponse, type IndexListing, type IndexSnapshot, 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 OptionsAggregate, type OptionsContext, type OptionsHistory, type OptionsHistoryWindow, type OptionsOiWalls, type OptionsOverview, type OptionsOverviewRow, type OptionsSummary, type OptionsUnusualContract, type OptionsWall, type PoliticianDetail, type PoliticianDirectory, type PoliticianDirectoryEntry, type PoliticianDirectoryResponse, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, type RatingBase, type RatingDimension, type RatingDimensionKey, type RatingFlag, type RatingNotRatedReason, type RatingSubLeg, type RecentEarningsEntry, type RiskAdjustment, type RiskCondition, type ScreenerExecuteOptions, type ScreenerExecuteResponse, type ScreenerFieldCatalog, type ScreenerFieldDescriptor, type ScreenerFieldOption, type ScreenerFilter, type ScreenerPlan, type ScreenerRow, type ScreenerScreensResponse, type ScreenerSort, type SearchEntitiesOptions, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockNotRated, type StockPrice, type StockProfile, type StockQuote, type StockRating, type StockRatingResponse, type StockSocialDominance, 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
@@ -668,6 +668,24 @@ type RatingDimensionKey = "crowd" | "smart_money" | "options" | "analysts" | "fu
668
668
  * the last run. The other two mean the run looked and declined to grade.
669
669
  */
670
670
  type RatingNotRatedReason = "stale" | "not_rated_today" | "insufficient_dimensions" | "insufficient_coverage_weight";
671
+ /**
672
+ * A risk condition evaluated against a rated stock. An active one deducts points from the
673
+ * score, up to 12 apiece; `percentile` itself is never touched by them.
674
+ */
675
+ type RiskCondition = "thin_coverage" | "weak_dimension" | "unprofitable" | "no_fundamentals" | "high_leverage" | "unseasoned_listing" | "small_market_cap" | "thin_liquidity" | "extended_price" | "insider_selling" | "institutional_outflow";
676
+ /**
677
+ * One graded deduction applied to a rated stock's score.
678
+ *
679
+ * A condition is graded rather than binary, so `points` is the share of the 12-point
680
+ * maximum this one actually cost. Only active conditions appear, and `penaltyPoints` is
681
+ * the sum of these.
682
+ */
683
+ interface RiskAdjustment {
684
+ /** Which condition, by the same key `riskConditions` reports. */
685
+ condition: RiskCondition;
686
+ /** Points deducted, to one decimal, up to 12 for a single condition. */
687
+ points: number;
688
+ }
671
689
  /**
672
690
  * One constituent leg behind a dimension's percentile.
673
691
  *
@@ -737,18 +755,59 @@ interface RatingBase {
737
755
  /** The standard financial disclaimer. Display it alongside the grade. */
738
756
  disclaimer: string;
739
757
  }
740
- /** A stock that has a grade for `asOf`. */
741
- interface RatedStockRating extends RatingBase {
758
+ /**
759
+ * A stock that has a grade for `asOf`.
760
+ *
761
+ * `score`, `bucketLetter`, `riskConditions`, `riskAdjustments` and `penaltyPoints` arrive
762
+ * from the next API deploy onward and are optional here because a response served before
763
+ * then omits them.
764
+ */
765
+ interface StockRating extends RatingBase {
742
766
  rated: true;
743
767
  /**
744
- * `"A"`, `"B"`, `"C"`, `"D"` or `"F"`. Served as stored, never re-derived from
745
- * `percentile`, so read it rather than computing your own bucket edges.
768
+ * The headline number, 0 to 100 with one decimal, and the number `letter` is the band
769
+ * of: `score = percentile - sum(riskAdjustments.map((a) => a.points))`, floored at 10
770
+ * when fewer than five dimensions are available and at 0 otherwise. Absent on a
771
+ * response served before this field shipped.
772
+ */
773
+ score?: number;
774
+ /**
775
+ * `"A"`, `"B"`, `"C"`, `"D"` or `"F"`: the band `score` falls in, at edges 90, 70, 30
776
+ * and 10. Served as stored, so read it rather than deriving your own edges. Deriving
777
+ * it from `percentile` disagrees with the API for every stock carrying a risk
778
+ * condition.
746
779
  */
747
780
  letter: string;
748
- /** Rank of `composite` among the day's rated stocks, 0 to 100. */
781
+ /**
782
+ * The band `percentile` alone would fall in, so a difference from `letter` is exactly
783
+ * what the risk conditions cost. Absent on a response served before this field
784
+ * shipped.
785
+ */
786
+ bucketLetter?: string;
787
+ /**
788
+ * Rank of `composite` among the day's rated stocks, 0 to 100. This stays the true rank
789
+ * of the blended signals: the risk conditions are subtracted from `score`, never here.
790
+ */
749
791
  percentile: number;
750
792
  /** The weighted blend before ranking, in [-1, +1]. */
751
793
  composite: number;
794
+ /**
795
+ * Which risk conditions were active. An empty array means none were, and the field is
796
+ * absent on a response served before it shipped.
797
+ */
798
+ riskConditions?: RiskCondition[];
799
+ /**
800
+ * The same conditions with the points each one actually cost, since a condition is
801
+ * graded rather than binary and can cost anything up to 12. Absent on a response
802
+ * served before this field shipped.
803
+ */
804
+ riskAdjustments?: RiskAdjustment[];
805
+ /**
806
+ * The sum of `riskAdjustments` points, to one decimal: how far `score` sits below
807
+ * `percentile` before the floor applies. Absent on a response served before this field
808
+ * shipped.
809
+ */
810
+ penaltyPoints?: number;
752
811
  /** How many stocks were rated that day: the rank's denominator. */
753
812
  ratedCount: number;
754
813
  /** The weights and floors in force when the row was written, e.g. `"2026.09-v1"`. */
@@ -758,7 +817,7 @@ interface RatedStockRating extends RatingBase {
758
817
  * A stock with no grade for `asOf`. A normal 200, not an error: ETFs and tickers outside
759
818
  * the swept universe answer this way, and the composition still arrives so a card can render.
760
819
  */
761
- interface UnratedStockRating extends RatingBase {
820
+ interface StockNotRated extends RatingBase {
762
821
  rated: false;
763
822
  /** Why there is no grade. */
764
823
  reason: RatingNotRatedReason;
@@ -779,7 +838,7 @@ interface UnratedStockRating extends RatingBase {
779
838
  * and it is not a recommendation about any security. Carry `disclaimer` wherever you display
780
839
  * a grade. Methodology: https://sentisense.ai/methodology/#sentisense-rating
781
840
  */
782
- type StockRating = RatedStockRating | UnratedStockRating;
841
+ type StockRatingResponse = StockRating | StockNotRated;
783
842
  type DocumentSource = "news" | "reddit" | "x" | "substack" | "youtube";
784
843
  /** Per-entity sentiment classification with resolved entity details. */
785
844
  interface SentimentEntry {
@@ -1500,7 +1559,7 @@ interface PreviewResponse<T> {
1500
1559
  /** Supported metric types for the v2 Serving Metrics API. */
1501
1560
  type MetricType = "mentions" | "sentiment" | "sentisense_score"
1502
1561
  /**
1503
- * The SentiSense Rating percentile, 0 to 100. Time series only: it has no source
1562
+ * The SentiSense Rating score, 0 to 100. Time series only: it has no source
1504
1563
  * breakdown, so `getDistribution` answers with an empty distribution for it.
1505
1564
  */
1506
1565
  | "sentisense_rating" | "social_dominance" | "creators";
@@ -3026,11 +3085,48 @@ declare class Institutional {
3026
3085
  getInstitutionDetail(slugOrCik: string): Promise<unknown>;
3027
3086
  }
3028
3087
 
3088
+ /** Public entity types the search `type` filter accepts, and that come back on a hit. */
3089
+ type EntitySearchType = "person" | "company" | "product" | "organization" | "etf" | "topic" | "country";
3090
+ /**
3091
+ * One ranked match from {@link KB.searchEntities}.
3092
+ *
3093
+ * `urlSlug` is the handle the metric endpoints address an entity by, which is the reason
3094
+ * this endpoint exists: it answers "what is the handle for the thing I typed".
3095
+ */
3096
+ interface EntitySearchResult {
3097
+ name: string;
3098
+ /** Stable handle for this entity, or `null` when it has none. */
3099
+ urlSlug: string | null;
3100
+ /** `"person"`, `"company"`, `"product"`, `"organization"`, `"etf"`, `"topic"`, `"country"`. */
3101
+ type: EntitySearchType | string | null;
3102
+ /** The listed symbol for a tradeable entity, `null` for everything else. */
3103
+ ticker: string | null;
3104
+ }
3105
+ interface SearchEntitiesOptions {
3106
+ /** Narrow to one entity type. An unrecognised value is rejected with a 400. */
3107
+ type?: EntitySearchType | string;
3108
+ /** Matches to return, 1 to 25. Omitted, the API applies its own default of 10. */
3109
+ limit?: number;
3110
+ }
3029
3111
  declare class KB {
3030
3112
  private client;
3031
3113
  constructor(client: APIClient);
3032
3114
  /** Get popular entities for search suggestions. */
3033
3115
  getPopularEntities(): Promise<KBEntity[]>;
3116
+ /**
3117
+ * Resolve a name, alias, ticker or slug to the entities we track, best match first.
3118
+ *
3119
+ * This is resolution, not enumeration: the query must be at least 2 characters and the
3120
+ * result count is capped, so it answers "which handle did the user mean" rather than
3121
+ * dumping the graph. Use it when someone typed "Tesla" and the rest of your code needs
3122
+ * `TSLA`, or when you need the `urlSlug` an entity's metric series is addressed by.
3123
+ *
3124
+ * Returns a bare array, not a `PreviewResponse` envelope, and an empty array is the
3125
+ * normal answer for a query that matches nothing.
3126
+ *
3127
+ * @param q What the user typed. At least 2 characters, or the API answers 400.
3128
+ */
3129
+ searchEntities(q: string, options?: SearchEntitiesOptions): Promise<EntitySearchResult[]>;
3034
3130
  }
3035
3131
 
3036
3132
  declare class MarketMoodResource {
@@ -3356,10 +3452,10 @@ declare class Stocks {
3356
3452
  * security. `disclaimer` carries the wording to display alongside a grade. Methodology:
3357
3453
  * https://sentisense.ai/methodology/#sentisense-rating
3358
3454
  *
3359
- * **A discriminated union on `rated`.** `if (rating.rated)` narrows to `letter`,
3360
- * `percentile`, `composite`, `ratedCount` and `methodologyVersion`; the `else` branch
3361
- * narrows to `reason`, `dimensionsPresent` and `presentDimensions`. Branch on the flag
3362
- * rather than testing a field for `undefined`.
3455
+ * **A discriminated union on `rated`.** `if (rating.rated)` narrows to `score`,
3456
+ * `letter`, `percentile`, `composite`, `ratedCount` and `methodologyVersion`; the
3457
+ * `else` branch narrows to `reason`, `dimensionsPresent` and `presentDimensions`.
3458
+ * Branch on the flag rather than testing a field for `undefined`.
3363
3459
  *
3364
3460
  * **Having no grade is a normal 200, not a 404.** ETFs and tickers outside the swept
3365
3461
  * universe answer with `rated` false, and the composition still arrives so a card can
@@ -3369,13 +3465,24 @@ declare class Stocks {
3369
3465
  *
3370
3466
  * `dimensions` always holds all six rows in a fixed order, including the ones with no
3371
3467
  * data, which arrive with `present` false and a `null` percentile. Read `present` first
3372
- * and never read a missing percentile as zero. `letter` is served as stored rather than
3373
- * derived from `percentile`, so read it instead of computing your own bucket edges.
3468
+ * and never read a missing percentile as zero.
3469
+ *
3470
+ * **`score` and `percentile` are different numbers.** `percentile` is the rank of the
3471
+ * blended signals against the day's rated set, and
3472
+ * `score = percentile - sum(riskAdjustments.map((a) => a.points))`, floored at 10 when
3473
+ * fewer than five dimensions are available and at 0 otherwise. `letter` is the band
3474
+ * `score` falls in, at edges 90, 70, 30 and 10, while `bucketLetter` is the band the
3475
+ * percentile alone would fall in, so a difference between the two letters is exactly
3476
+ * what the conditions cost. `riskConditions` names the active ones, `riskAdjustments`
3477
+ * gives the points each cost (graded, up to 12 apiece), and `penaltyPoints` is their
3478
+ * sum. `letter` is served as stored, so read it instead of computing your own bucket
3479
+ * edges. The five fields arrive from the next API deploy onward and are optional, so a
3480
+ * response served before then still parses.
3374
3481
  *
3375
- * For the daily history of a stock's percentile, ask `client.entityMetrics.getMetrics`
3376
- * for the `sentisense_rating` metric.
3482
+ * For the daily history of a stock's score, ask `client.entityMetrics.getMetrics` for
3483
+ * the `sentisense_rating` metric.
3377
3484
  */
3378
- getRating(ticker: string): Promise<StockRating>;
3485
+ getRating(ticker: string): Promise<StockRatingResponse>;
3379
3486
  }
3380
3487
 
3381
3488
  /**
@@ -3532,6 +3639,6 @@ declare class APIError extends SentiSenseError {
3532
3639
  constructor(message: string, status: number, code?: string);
3533
3640
  }
3534
3641
 
3535
- declare const VERSION = "0.50.0";
3642
+ declare const VERSION = "0.52.0";
3536
3643
 
3537
- export { type AISummary, APIError, type AnalystAction, type AnalystCall, type AnalystConsensus, type AnalystCoverage, type AnalystCoverageAnalyst, type AnalystCoverageBookEntry, type AnalystCoverageFirm, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AnalystFirmRating, type AnalystFirmTenure, type AnalystNote, type AnalystProfile, type AnalystRatingBuckets, 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 EarningsKpiHighlight, type EarningsQuarter, type EarningsSource, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfScreenerExecuteResponse, type EtfScreenerRow, type EtfSentimentAggregate, type EtfSentimentReading, type FeaturedScreen, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystCallsOptions, type GetAnalystCoverageOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEarningsSummariesOptions, type GetEtfInsiderAggregateOptions, type GetHoldersOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetOptionsHistoryOptions, type GetPoliticianActivityOptions, type GetPoliticianDirectoryOptions, type GetPoliticianMemberOptions, type GetPoliticiansOptions, type GetRecentEarningsOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type HolderNotableChanges, type IndexConstituent, type IndexHistoryPoint, type IndexHistoryResponse, type IndexListResponse, type IndexListing, type IndexSnapshot, 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 OptionsAggregate, type OptionsContext, type OptionsHistory, type OptionsHistoryWindow, type OptionsOiWalls, type OptionsOverview, type OptionsOverviewRow, type OptionsSummary, type OptionsUnusualContract, type OptionsWall, type PoliticianDetail, type PoliticianDirectory, type PoliticianDirectoryEntry, type PoliticianDirectoryResponse, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, type RatedStockRating, type RatingBase, type RatingDimension, type RatingDimensionKey, type RatingFlag, type RatingNotRatedReason, type RatingSubLeg, type RecentEarningsEntry, type ScreenerExecuteOptions, type ScreenerExecuteResponse, type ScreenerFieldCatalog, type ScreenerFieldDescriptor, type ScreenerFieldOption, type ScreenerFilter, type ScreenerPlan, type ScreenerRow, type ScreenerScreensResponse, type ScreenerSort, 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 StockRating, type StockSocialDominance, 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, type UnratedStockRating, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
3644
+ export { type AISummary, APIError, type AnalystAction, type AnalystCall, type AnalystConsensus, type AnalystCoverage, type AnalystCoverageAnalyst, type AnalystCoverageBookEntry, type AnalystCoverageFirm, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AnalystFirmRating, type AnalystFirmTenure, type AnalystNote, type AnalystProfile, type AnalystRatingBuckets, 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 EarningsKpiHighlight, type EarningsQuarter, type EarningsSource, type EntitySearchResult, type EntitySearchType, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfScreenerExecuteResponse, type EtfScreenerRow, type EtfSentimentAggregate, type EtfSentimentReading, type FeaturedScreen, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystCallsOptions, type GetAnalystCoverageOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEarningsSummariesOptions, type GetEtfInsiderAggregateOptions, type GetHoldersOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetOptionsHistoryOptions, type GetPoliticianActivityOptions, type GetPoliticianDirectoryOptions, type GetPoliticianMemberOptions, type GetPoliticiansOptions, type GetRecentEarningsOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type HolderNotableChanges, type IndexConstituent, type IndexHistoryPoint, type IndexHistoryResponse, type IndexListResponse, type IndexListing, type IndexSnapshot, 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 OptionsAggregate, type OptionsContext, type OptionsHistory, type OptionsHistoryWindow, type OptionsOiWalls, type OptionsOverview, type OptionsOverviewRow, type OptionsSummary, type OptionsUnusualContract, type OptionsWall, type PoliticianDetail, type PoliticianDirectory, type PoliticianDirectoryEntry, type PoliticianDirectoryResponse, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, type RatingBase, type RatingDimension, type RatingDimensionKey, type RatingFlag, type RatingNotRatedReason, type RatingSubLeg, type RecentEarningsEntry, type RiskAdjustment, type RiskCondition, type ScreenerExecuteOptions, type ScreenerExecuteResponse, type ScreenerFieldCatalog, type ScreenerFieldDescriptor, type ScreenerFieldOption, type ScreenerFilter, type ScreenerPlan, type ScreenerRow, type ScreenerScreensResponse, type ScreenerSort, type SearchEntitiesOptions, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockNotRated, type StockPrice, type StockProfile, type StockQuote, type StockRating, type StockRatingResponse, type StockSocialDominance, 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
@@ -676,6 +676,22 @@ var KB = class {
676
676
  async getPopularEntities() {
677
677
  return this.client.get("/api/v1/kb/entities/popular");
678
678
  }
679
+ /**
680
+ * Resolve a name, alias, ticker or slug to the entities we track, best match first.
681
+ *
682
+ * This is resolution, not enumeration: the query must be at least 2 characters and the
683
+ * result count is capped, so it answers "which handle did the user mean" rather than
684
+ * dumping the graph. Use it when someone typed "Tesla" and the rest of your code needs
685
+ * `TSLA`, or when you need the `urlSlug` an entity's metric series is addressed by.
686
+ *
687
+ * Returns a bare array, not a `PreviewResponse` envelope, and an empty array is the
688
+ * normal answer for a query that matches nothing.
689
+ *
690
+ * @param q What the user typed. At least 2 characters, or the API answers 400.
691
+ */
692
+ async searchEntities(q, options) {
693
+ return this.client.get("/api/v1/kb/entities/search", { q, ...options });
694
+ }
679
695
  };
680
696
 
681
697
  // src/resources/marketMood.ts
@@ -1080,10 +1096,10 @@ var Stocks = class {
1080
1096
  * security. `disclaimer` carries the wording to display alongside a grade. Methodology:
1081
1097
  * https://sentisense.ai/methodology/#sentisense-rating
1082
1098
  *
1083
- * **A discriminated union on `rated`.** `if (rating.rated)` narrows to `letter`,
1084
- * `percentile`, `composite`, `ratedCount` and `methodologyVersion`; the `else` branch
1085
- * narrows to `reason`, `dimensionsPresent` and `presentDimensions`. Branch on the flag
1086
- * rather than testing a field for `undefined`.
1099
+ * **A discriminated union on `rated`.** `if (rating.rated)` narrows to `score`,
1100
+ * `letter`, `percentile`, `composite`, `ratedCount` and `methodologyVersion`; the
1101
+ * `else` branch narrows to `reason`, `dimensionsPresent` and `presentDimensions`.
1102
+ * Branch on the flag rather than testing a field for `undefined`.
1087
1103
  *
1088
1104
  * **Having no grade is a normal 200, not a 404.** ETFs and tickers outside the swept
1089
1105
  * universe answer with `rated` false, and the composition still arrives so a card can
@@ -1093,11 +1109,22 @@ var Stocks = class {
1093
1109
  *
1094
1110
  * `dimensions` always holds all six rows in a fixed order, including the ones with no
1095
1111
  * data, which arrive with `present` false and a `null` percentile. Read `present` first
1096
- * and never read a missing percentile as zero. `letter` is served as stored rather than
1097
- * derived from `percentile`, so read it instead of computing your own bucket edges.
1098
- *
1099
- * For the daily history of a stock's percentile, ask `client.entityMetrics.getMetrics`
1100
- * for the `sentisense_rating` metric.
1112
+ * and never read a missing percentile as zero.
1113
+ *
1114
+ * **`score` and `percentile` are different numbers.** `percentile` is the rank of the
1115
+ * blended signals against the day's rated set, and
1116
+ * `score = percentile - sum(riskAdjustments.map((a) => a.points))`, floored at 10 when
1117
+ * fewer than five dimensions are available and at 0 otherwise. `letter` is the band
1118
+ * `score` falls in, at edges 90, 70, 30 and 10, while `bucketLetter` is the band the
1119
+ * percentile alone would fall in, so a difference between the two letters is exactly
1120
+ * what the conditions cost. `riskConditions` names the active ones, `riskAdjustments`
1121
+ * gives the points each cost (graded, up to 12 apiece), and `penaltyPoints` is their
1122
+ * sum. `letter` is served as stored, so read it instead of computing your own bucket
1123
+ * edges. The five fields arrive from the next API deploy onward and are optional, so a
1124
+ * response served before then still parses.
1125
+ *
1126
+ * For the daily history of a stock's score, ask `client.entityMetrics.getMetrics` for
1127
+ * the `sentisense_rating` metric.
1101
1128
  */
1102
1129
  async getRating(ticker) {
1103
1130
  return this.client.get(`/api/v1/rating/${encodeURIComponent(ticker.toUpperCase())}`);
@@ -1181,7 +1208,7 @@ var Trackers = class {
1181
1208
  };
1182
1209
 
1183
1210
  // src/version.ts
1184
- var VERSION = "0.50.0";
1211
+ var VERSION = "0.52.0";
1185
1212
 
1186
1213
  // src/client.ts
1187
1214
  var DEFAULT_BASE_URL = "https://app.sentisense.ai";