TipRanks Integration
Relevant source files
The following files were used as context for generating this wiki page:
The TipRanks integration provides the technical analysis terminal with third-party financial analyst data, including price targets, stock scores, analyst ratings (Buy/Hold/Sell), and news sentiment analysis. This feature allows users to view professional market consensus directly alongside technical charts to inform their trading strategies.
The integration is divided into a backend service that scrapes and aggregates data from the TipRanks API and a frontend component that visualizes this data using advanced charting libraries.
Sources: backend/src/modules/tipranks/tipranks.service.ts, frontend/src/pages/chart/components/TipRanksInfo.tsx
Backend Architecture
The backend implementation resides in the TipRanksModule, which consists of a service and a resolver (invoked via GraphQL). The service is responsible for performing HTTP requests to the TipRanks public API endpoints to retrieve stock-specific metadata and sentiment analysis.
Data Acquisition Logic
The TipRanksService utilizes two primary TipRanks API endpoints:
- Stock Data: Retrieves consensus price targets, stock scores, and rating distributions.
- News Sentiment: Retrieves bullish/bearish percentages and specific news counts from the last week.
Service Implementation Detail
The backend service must provide specific headers, including a User-Agent and a session cookie, to successfully query the news sentiment endpoint.
Sources: backend/src/modules/tipranks/tipranks.service.ts:14-22
Data Models
The system uses a standardized TipRanksInfo structure shared between the backend types and the GraphQL schema to represent the professional analysis data.
| Field | Type | Description |
|---|---|---|
priceTarget | Float | The average consensus price target for the stock. |
priceTargetHigh | Float | The highest analyst price target. |
priceTargetLow | Float | The lowest analyst price target. |
stockScore | Float | A proprietary TipRanks score from 1 to 10. |
ratingBuy | Float | Number of analysts with a "Buy" recommendation. |
ratingHold | Float | Number of analysts with a "Hold" recommendation. |
ratingSell | Float | Number of analysts with a "Sell" recommendation. |
newsSentimentBullishPercent | Float | Percentage of news articles with bullish sentiment. |
newsSentimentBearishPercent | Float | Percentage of news articles with bearish sentiment. |
lastWeekBuyNews | Float | Count of buy-related news items in the last week. |
Sources: frontend/src/graphql.ts:161-174, frontend/graphql.schema.json:710-854
Frontend Visualization
The TipRanks component in the frontend handles the display of this data. It uses @antv/g2plot to render "Bullet" charts for visual comparisons of ratings and sentiments.
Visualization Components
- Price Predictions: A text-based row showing Low, Average, and High price targets.
- Stock Score Chart: A bullet chart mapping the
stockScoreagainst ranges [3, 7, 10] colored red, yellow, and green. - Analyst Ratings Chart: A visual breakdown of Sell, Hold, and Buy counts.
- News Sentiment Chart: A percentage-based bar showing the balance between Bearish and Bullish news.
GraphQL Integration
The frontend retrieves data using the useTipRanksInfoQuery hook, which is configured with fetchPolicy: "no-cache" to ensure the most recent analyst data is always displayed when the component is loaded.
const { data, error, loading } = useTipRanksInfoQuery({
fetchPolicy: "no-cache",
variables: {
ticker,
},
});
Sources: frontend/src/pages/chart/components/TipRanksInfo.tsx:25-30, frontend/src/graphql.ts:474-486
Conclusion
The TipRanks Integration acts as a bridge between technical analysis and fundamental analyst sentiment. By combining automated data scraping in the backend with dynamic G2Plot visualizations in the frontend, the project provides a comprehensive view of a security's professional market standing.