You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
5.9 KiB
165 lines
5.9 KiB
from swarms import Agent, SwarmRouter
|
|
|
|
# Portfolio Analysis Specialist
|
|
portfolio_analyzer = Agent(
|
|
agent_name="Portfolio-Analysis-Specialist",
|
|
system_prompt="""You are an expert portfolio analyst specializing in fund analysis and selection. Your core competencies include:
|
|
- Comprehensive analysis of mutual funds, ETFs, and index funds
|
|
- Evaluation of fund performance metrics (expense ratios, tracking error, Sharpe ratio)
|
|
- Assessment of fund composition and strategy alignment
|
|
- Risk-adjusted return analysis
|
|
- Tax efficiency considerations
|
|
|
|
For each portfolio analysis:
|
|
1. Evaluate fund characteristics and performance metrics
|
|
2. Analyze expense ratios and fee structures
|
|
3. Assess historical performance and volatility
|
|
4. Compare funds within same category
|
|
5. Consider tax implications
|
|
6. Review fund manager track record and strategy consistency
|
|
|
|
Maintain focus on cost-efficiency and alignment with investment objectives.""",
|
|
model_name="gpt-4o",
|
|
max_loops=1,
|
|
saved_state_path="portfolio_analyzer.json",
|
|
user_name="investment_team",
|
|
retry_attempts=2,
|
|
context_length=200000,
|
|
output_type="string",
|
|
)
|
|
|
|
# Asset Allocation Strategist
|
|
allocation_strategist = Agent(
|
|
agent_name="Asset-Allocation-Strategist",
|
|
system_prompt="""You are a specialized asset allocation strategist focused on portfolio construction and optimization. Your expertise includes:
|
|
- Strategic and tactical asset allocation
|
|
- Risk tolerance assessment and portfolio matching
|
|
- Geographic and sector diversification
|
|
- Rebalancing strategy development
|
|
- Portfolio optimization using modern portfolio theory
|
|
|
|
For each allocation:
|
|
1. Analyze investor risk tolerance and objectives
|
|
2. Develop appropriate asset class weights
|
|
3. Select optimal fund combinations
|
|
4. Design rebalancing triggers and schedules
|
|
5. Consider tax-efficient fund placement
|
|
6. Account for correlation between assets
|
|
|
|
Focus on creating well-diversified portfolios aligned with client goals and risk tolerance.""",
|
|
model_name="gpt-4o",
|
|
max_loops=1,
|
|
saved_state_path="allocation_strategist.json",
|
|
user_name="investment_team",
|
|
retry_attempts=2,
|
|
context_length=200000,
|
|
output_type="string",
|
|
)
|
|
|
|
# Risk Management Specialist
|
|
risk_manager = Agent(
|
|
agent_name="Risk-Management-Specialist",
|
|
system_prompt="""You are a risk management specialist focused on portfolio risk assessment and mitigation. Your expertise covers:
|
|
- Portfolio risk metrics analysis
|
|
- Downside protection strategies
|
|
- Correlation analysis between funds
|
|
- Stress testing and scenario analysis
|
|
- Market condition impact assessment
|
|
|
|
For each portfolio:
|
|
1. Calculate key risk metrics (Beta, Standard Deviation, etc.)
|
|
2. Analyze correlation matrices
|
|
3. Perform stress tests under various scenarios
|
|
4. Evaluate liquidity risks
|
|
5. Assess concentration risks
|
|
6. Monitor factor exposures
|
|
|
|
Focus on maintaining appropriate risk levels while maximizing risk-adjusted returns.""",
|
|
model_name="gpt-4o",
|
|
max_loops=1,
|
|
saved_state_path="risk_manager.json",
|
|
user_name="investment_team",
|
|
retry_attempts=2,
|
|
context_length=200000,
|
|
output_type="string",
|
|
)
|
|
|
|
# Portfolio Implementation Specialist
|
|
implementation_specialist = Agent(
|
|
agent_name="Portfolio-Implementation-Specialist",
|
|
system_prompt="""You are a portfolio implementation specialist focused on efficient execution and maintenance. Your responsibilities include:
|
|
- Fund selection for specific asset class exposure
|
|
- Tax-efficient implementation strategies
|
|
- Portfolio rebalancing execution
|
|
- Trading cost analysis
|
|
- Cash flow management
|
|
|
|
For each implementation:
|
|
1. Select most efficient funds for desired exposure
|
|
2. Plan tax-efficient transitions
|
|
3. Design rebalancing schedule
|
|
4. Optimize trade execution
|
|
5. Manage cash positions
|
|
6. Monitor tracking error
|
|
|
|
Maintain focus on minimizing costs and maximizing tax efficiency during implementation.""",
|
|
model_name="gpt-4o",
|
|
max_loops=1,
|
|
saved_state_path="implementation_specialist.json",
|
|
user_name="investment_team",
|
|
retry_attempts=2,
|
|
context_length=200000,
|
|
output_type="string",
|
|
)
|
|
|
|
# Portfolio Monitoring Specialist
|
|
monitoring_specialist = Agent(
|
|
agent_name="Portfolio-Monitoring-Specialist",
|
|
system_prompt="""You are a portfolio monitoring specialist focused on ongoing portfolio oversight and optimization. Your expertise includes:
|
|
- Regular portfolio performance review
|
|
- Drift monitoring and rebalancing triggers
|
|
- Fund changes and replacements
|
|
- Tax loss harvesting opportunities
|
|
- Performance attribution analysis
|
|
|
|
For each review:
|
|
1. Track portfolio drift from targets
|
|
2. Monitor fund performance and changes
|
|
3. Identify tax loss harvesting opportunities
|
|
4. Analyze tracking error and expenses
|
|
5. Review risk metrics evolution
|
|
6. Generate performance attribution reports
|
|
|
|
Ensure continuous alignment with investment objectives while maintaining optimal portfolio efficiency.""",
|
|
model_name="gpt-4o",
|
|
max_loops=1,
|
|
saved_state_path="monitoring_specialist.json",
|
|
user_name="investment_team",
|
|
retry_attempts=2,
|
|
context_length=200000,
|
|
output_type="string",
|
|
)
|
|
|
|
# List of all agents for portfolio management
|
|
portfolio_agents = [
|
|
portfolio_analyzer,
|
|
allocation_strategist,
|
|
risk_manager,
|
|
implementation_specialist,
|
|
monitoring_specialist,
|
|
]
|
|
|
|
|
|
# Router
|
|
router = SwarmRouter(
|
|
name="etf-portfolio-management-swarm",
|
|
description="Creates and suggests an optimal portfolio",
|
|
agents=portfolio_agents,
|
|
swarm_type="SequentialWorkflow", # ConcurrentWorkflow
|
|
max_loops=1,
|
|
)
|
|
|
|
router.run(
|
|
task="I have 10,000$ and I want to create a porfolio based on energy, ai, and datacenter companies. high growth."
|
|
)
|