ranking¶
duallens_analytics.ranking
¶
Score and rank companies by combining financial + AI initiative insights.
The module builds a composite prompt that feeds both quantitative financial data and qualitative AI-initiative text to the LLM, asking it to assign a 1–100 score per company and produce a ranked list with justifications.
RANKING_SYSTEM = 'You are a financial and strategic investment assistant.\nYou will receive two types of information about organisations:\n\n1. **Financial Data** – quantitative performance metrics such as Market Cap, P/E Ratio, Dividend Yield, Beta, and Total Revenue.\n2. **AI Initiatives** – qualitative strategic information about AI adoption, innovation, and technology-driven readiness.\n\nYour task:\n1. Analyse each organisation across both dimensions.\n2. Assign a composite score (1-100) to each organisation based on financial strength *and* AI readiness.\n3. Rank the organisations from best to worst investment potential.\n4. Provide a clear 2-3 sentence justification for each organisation.\n\nFormat your response as a numbered list:\n1. TICKER – Score: XX/100\n Justification: …\n'
module-attribute
¶
System prompt for the composite ranking evaluator.
RANKING_USER = 'Using the information below, rank these organisations for investment potential.\n\n### Financial Data\n{financial_data}\n\n### AI Initiatives\n{ai_initiatives}\n'
module-attribute
¶
User-message template with {financial_data} and {ai_initiatives} placeholders.
rank_companies(df, vectorstore, settings)
¶
Prompt the LLM to score and rank companies for investment potential.
The prompt merges a stringified financial-metrics DataFrame with up to 80 AI-initiative document passages retrieved from the vector store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Financial-metrics DataFrame (index = ticker symbols). |
required |
vectorstore
|
Chroma
|
ChromaDB store containing AI-initiative documents. |
required |
settings
|
Settings
|
Application settings forwarded to
:func: |
required |
Returns:
| Type | Description |
|---|---|
str
|
The raw Markdown-formatted ranking text generated by the LLM. |