from dotenv import load_dotenv from swarms import Agent import requests import json import os from datetime import datetime
load_dotenv()
============================================
SYSTEM PROMPTS
============================================
EQUITY_ANALYST_PROMPT = """ You are the Equity Analyst in Bedrock AI.
Analyze:
- Stock performance
- Valuation (P/E, P/B, EPS trends)
- Market sentiment
- Institutional interest
- Growth outlook
Provide:
- Equity Summary
- Valuation Assessment
- Risk Factors
- Equity Score (0-100) """
CRYPTO_ANALYST_PROMPT = """ You are the Crypto Analyst in Bedrock AI.
Analyze:
- Token fundamentals
- Market cap vs FDV
- Liquidity and volume
- On-chain activity
- Narrative strength
Provide:
- Crypto Overview
- Token Strength
- Risk Analysis
- Crypto Score (0-100) """
REAL_ESTATE_PROMPT = """ You are the Real Estate Analyst in Bedrock AI.
Analyze:
- Property market trends
- Yield potential
- Location strength
- Interest rate impact
- Rental demand
Provide:
- Market Overview
- Yield Potential
- Risk Factors
- Real Estate Score (0-100) """
PRIVATE_EQUITY_PROMPT = """ You are the Private Equity Analyst in Bedrock AI.
Analyze:
- Company growth stage
- Revenue multiples
- Exit potential
- Market dominance
- Long-term value creation
Provide:
- PE Opportunity Summary
- Growth Potential
- Liquidity Risk
- PE Score (0-100) """
RISK_MANAGER_PROMPT = """ You are the Risk Manager in Bedrock AI.
Analyze:
- Portfolio risk exposure
- Correlation across assets
- Macro risks
- Liquidity risks
- Downside scenarios
Provide:
- Risk Summary
- Portfolio Exposure
- Hedging Suggestions
- Risk Score (0-100, inverted risk = higher is safer) """
WEALTH_DIRECTOR_PROMPT = """ You are the Wealth Director of Bedrock AI.
Synthesize all analyst reports into a unified portfolio strategy.
Output format:
BEDROCK AI WEALTH REPORT
Portfolio Health:
[EXCELLENT / STABLE / VOLATILE / HIGH RISK]
Composite Wealth Score:
[X]/100
Asset Allocation Strategy:
- Stocks: X%
- Crypto: X%
- Real Estate: X%
- Private Equity: X%
- Cash/Stable Assets: X%
Key Opportunities
- ...
Key Risks
- ...
Strategic Recommendation
[ACCUMULATE / HOLD / REBALANCE / DE-RISK] """
============================================
AGENT FACTORY
============================================
def create_bedrock_agents(model_name="gpt-4o-mini"):
config = {
"model_name": model_name,
"max_loops": 1,
"temperature": 0.6,
"verbose": True,
"streaming_on": False,
"autosave": False,
"max_tokens": 4000,
}
return {
"equity": Agent(
agent_name="Equity-Analyst",
agent_description="Analyzes public equities and stock markets",
system_prompt=EQUITY_ANALYST_PROMPT,
**config
),
"crypto": Agent(
agent_name="Crypto-Analyst",
agent_description="Analyzes crypto assets and tokens",
system_prompt=CRYPTO_ANALYST_PROMPT,
**config
),
"realestate": Agent(
agent_name="Real-Estate-Analyst",
agent_description="Analyzes property and housing markets",
system_prompt=REAL_ESTATE_PROMPT,
**config
),
"privateequity": Agent(
agent_name="Private-Equity-Analyst",
agent_description="Analyzes private market investments",
system_prompt=PRIVATE_EQUITY_PROMPT,
**config
),
"risk": Agent(
agent_name="Risk-Manager",
agent_description="Manages portfolio risk and exposure",
system_prompt=RISK_MANAGER_PROMPT,
**config
),
"director": Agent(
agent_name="Wealth-Director",
agent_description="Synthesizes all investment intelligence",
system_prompt=WEALTH_DIRECTOR_PROMPT,
**config
),
}
============================================
BEDROCK ENGINE
============================================
class BedrockAI:
def __init__(self, model_name="gpt-4o-mini"):
self.agents = create_bedrock_agents(model_name)
def analyze_portfolio(self, context: str):
query = f"""
Analyze this portfolio / investment context:
{context}
Generate full multi-asset wealth intelligence. """
equity = self.agents["equity"].run(query)
crypto = self.agents["crypto"].run(query)
realestate = self.agents["realestate"].run(query)
privateequity = self.agents["privateequity"].run(query)
risk = self.agents["risk"].run(query)
synthesis = f"""
=== EQUITY === {equity}
=== CRYPTO === {crypto}
=== REAL ESTATE === {realestate}
=== PRIVATE EQUITY === {privateequity}
=== RISK === {risk} """
final = self.agents["director"].run(synthesis)
return {
"equity": equity,
"crypto": crypto,
"realestate": realestate,
"privateequity": privateequity,
"risk": risk,
"final": final
}
============================================
EXAMPLE RUN
============================================
if name == "main":
system = BedrockAI()
context = input("Enter portfolio or investment context: ")
result = system.analyze_portfolio(context)
print("\n" + "="*60)
print("🏦 BEDROCK AI WEALTH REPORT")
print("="*60)
print(result["final"])
