|
| 1 | +# Company Overview Agent |
| 2 | + |
| 3 | + |
| 4 | +[](https://github.com/fetchai/uAgent-Examples/tree/main/1-uagents/finance/company-overview-agent) |
| 5 | +[](https://agentverse.ai/agents/details/agent1qggzwfa032ddngqkrsgn9d3qwp4a7dh34q9cnpy9np7vzzvp8ws5u0rq5d8/profile) |
| 6 | + |
| 7 | +This agent uses the Alphavantage Finance API to provide company overview of a given company name. |
| 8 | + |
| 9 | +## Example input |
| 10 | + |
| 11 | +```python |
| 12 | +CompanyOverviewRequest( |
| 13 | + ticker: "AMZN" |
| 14 | +) |
| 15 | +``` |
| 16 | + |
| 17 | +## Example output |
| 18 | + |
| 19 | +```python |
| 20 | +CompanyOverviewResponse( |
| 21 | + overview={ |
| 22 | + "Symbol": "AMZN", |
| 23 | + "AssetType": "Common Stock", |
| 24 | + "Name": "Amazon.com Inc", |
| 25 | + "Description": "Amazon.com, Inc. is an American multinational technology company which focuses on e-commerce, cloud computing, digital streaming, and artificial intelligence. It is one of the Big Five companies in the U.S. information technology industry, along with Google, Apple, Microsoft, and Facebook. The company has been referred to as one of the most influential economic and cultural forces in the world, as well as the world's most valuable brand.", |
| 26 | + "CIK": "1018724", |
| 27 | + "Exchange": "NASDAQ", |
| 28 | + "Currency": "USD", |
| 29 | + "Country": "USA", |
| 30 | + "Sector": "TRADE & SERVICES", |
| 31 | + "Industry": "RETAIL-CATALOG & MAIL-ORDER HOUSES", |
| 32 | + "Address": "410 TERRY AVENUE NORTH, SEATTLE, WA, US", |
| 33 | + "OfficialSite": "https://www.aboutamazon.com", |
| 34 | + "FiscalYearEnd": "December", |
| 35 | + "LatestQuarter": "2024-06-30", |
| 36 | + "MarketCapitalization": "1957324390000", |
| 37 | + "EBITDA": "104049000000", |
| 38 | + "PERatio": "44.51", |
| 39 | + "PEGRatio": "1.771", |
| 40 | + "BookValue": "22.54", |
| 41 | + "DividendPerShare": "None", |
| 42 | + "DividendYield": "None", |
| 43 | + "EPS": "4.19", |
| 44 | + "RevenuePerShareTTM": "58.22", |
| 45 | + "ProfitMargin": "0.0735", |
| 46 | + "OperatingMarginTTM": "0.0992", |
| 47 | + "ReturnOnAssetsTTM": "0.0658", |
| 48 | + "ReturnOnEquityTTM": "0.219", |
| 49 | + "RevenueTTM": "604333998000", |
| 50 | + "GrossProfitTTM": "225152000000", |
| 51 | + "DilutedEPSTTM": "4.19", |
| 52 | + "QuarterlyEarningsGrowthYOY": "0.938", |
| 53 | + "QuarterlyRevenueGrowthYOY": "0.101", |
| 54 | + "AnalystTargetPrice": "218.35", |
| 55 | + "AnalystRatingStrongBuy": "17", |
| 56 | + "AnalystRatingBuy": "44", |
| 57 | + "AnalystRatingHold": "2", |
| 58 | + "AnalystRatingSell": "0", |
| 59 | + "AnalystRatingStrongSell": "0", |
| 60 | + "TrailingPE": "44.51", |
| 61 | + "ForwardPE": "31.55", |
| 62 | + "PriceToSalesRatioTTM": "3.239", |
| 63 | + "PriceToBookRatio": "8.28", |
| 64 | + "EVToRevenue": "3.311", |
| 65 | + "EVToEBITDA": "18.79", |
| 66 | + "Beta": "1.146", |
| 67 | + "52WeekHigh": "201.2", |
| 68 | + "52WeekLow": "118.35", |
| 69 | + "50DayMovingAverage": "179.94", |
| 70 | + "200DayMovingAverage": "173.92", |
| 71 | + "SharesOutstanding": "10495600000", |
| 72 | + "DividendDate": "None", |
| 73 | + "ExDividendDate": "None" |
| 74 | + } |
| 75 | +) |
| 76 | +``` |
| 77 | + |
| 78 | +## Usage Example |
| 79 | + |
| 80 | +Copy and paste the following code into a new [Blank agent](https://agentverse.ai/agents/create/getting-started/blank-agent) for an example of how to interact with this agent. |
| 81 | + |
| 82 | +```python |
| 83 | +from typing import Dict |
| 84 | +from uagents import Agent, Context, Model |
| 85 | + |
| 86 | + |
| 87 | +class CompanyOverviewRequest(Model): |
| 88 | + ticker: str |
| 89 | + |
| 90 | + |
| 91 | +class CompanyOverviewResponse(Model): |
| 92 | + overview: Dict[str, str] |
| 93 | + |
| 94 | + |
| 95 | +agent = Agent() |
| 96 | + |
| 97 | + |
| 98 | +AI_AGENT_ADDRESS = "{{ .Agent.Address }}" |
| 99 | + |
| 100 | +ticker = "AMZN" |
| 101 | + |
| 102 | + |
| 103 | +@agent.on_event("startup") |
| 104 | +async def send_message(ctx: Context): |
| 105 | + await ctx.send(AI_AGENT_ADDRESS, CompanyOverviewRequest(ticker=ticker)) |
| 106 | + ctx.logger.info(f"Sent prompt to AI agent: {ticker}") |
| 107 | + |
| 108 | + |
| 109 | +@agent.on_message(CompanyOverviewResponse) |
| 110 | +async def handle_response(ctx: Context, sender: str, msg: CompanyOverviewResponse): |
| 111 | + ctx.logger.info(f"Received response from {sender}:") |
| 112 | + ctx.logger.info(msg.overview) |
| 113 | + |
| 114 | + |
| 115 | +if __name__ == "__main__": |
| 116 | + agent.run() |
| 117 | +``` |
| 118 | + |
| 119 | +### Local Agent |
| 120 | + |
| 121 | +1. Install the necessary packages: |
| 122 | + |
| 123 | + ```bash |
| 124 | + pip install uagents |
| 125 | + ``` |
| 126 | + |
| 127 | +2. To interact with this agent from a local agent instead, replace `agent = Agent()` in the above with: |
| 128 | + |
| 129 | + ```python |
| 130 | + agent = Agent( |
| 131 | + name="user", |
| 132 | + endpoint="http://localhost:8001/submit", |
| 133 | + ) |
| 134 | + ``` |
| 135 | + |
| 136 | +3. Run the agent: |
| 137 | + ```bash |
| 138 | + python agent.py |
| 139 | + ``` |
0 commit comments