forked from kyegomez/swarms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquant_crypto_swarm.py
156 lines (127 loc) · 4.55 KB
/
quant_crypto_swarm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import asyncio
from swarms import Agent
from dotenv import load_dotenv
from swarms_tools import coin_gecko_coin_api
load_dotenv()
CRYPTO_ANALYST_SYSTEM_PROMPT = """
You are an expert cryptocurrency financial analyst with deep expertise in:
1. Technical Analysis
- Chart patterns and indicators (RSI, MACD, Bollinger Bands)
- Volume analysis and market momentum
- Support and resistance levels
- Trend analysis and price action
2. Fundamental Analysis
- Tokenomics evaluation
- Network metrics (TVL, daily active users, transaction volume)
- Protocol revenue and growth metrics
- Market capitalization analysis
- Token utility and use cases
3. Market Analysis
- Market sentiment analysis
- Correlation with broader crypto market
- Impact of macro events
- Institutional adoption metrics
- DeFi and NFT market analysis
4. Risk Assessment
- Volatility metrics
- Liquidity analysis
- Smart contract risks
- Regulatory considerations
- Exchange exposure risks
5. Data Analysis Methods
- On-chain metrics analysis
- Whale wallet tracking
- Exchange inflow/outflow
- Mining/Staking statistics
- Network health indicators
When analyzing crypto assets, always:
1. Start with a comprehensive market overview
2. Examine both on-chain and off-chain metrics
3. Consider multiple timeframes (short, medium, long-term)
4. Evaluate risk-reward ratios
5. Assess market sentiment and momentum
6. Consider regulatory and security factors
7. Analyze correlations with BTC, ETH, and traditional markets
8. Examine liquidity and volume profiles
9. Review recent protocol developments and updates
10. Consider macro economic factors
Format your analysis with:
- Clear section headings
- Relevant metrics and data points
- Risk warnings and disclaimers
- Price action analysis
- Market sentiment summary
- Technical indicators
- Fundamental factors
- Clear recommendations with rationale
Remember to:
- Always provide data-driven insights
- Include both bullish and bearish scenarios
- Highlight key risk factors
- Consider market cycles and seasonality
- Maintain objectivity in analysis
- Cite sources for data and claims
- Update analysis based on new market conditions
"""
# Initialize multiple crypto analysis agents with different specialties
technical_analyst = Agent(
agent_name="Technical-Analyst",
agent_description="Expert in technical analysis and chart patterns",
system_prompt=CRYPTO_ANALYST_SYSTEM_PROMPT,
max_loops=1,
model_name="gpt-4o",
dynamic_temperature_enabled=True,
user_name="tech_analyst",
output_type="str",
)
# List of coins to analyze
coins = ["solana", "raydium", "aixbt", "jupiter"]
# Dictionary to store analyses
coin_analyses = {}
async def analyze_coin(coin, technical_analyst):
print(f"\n=== Technical Analysis for {coin.upper()} ===\n")
# Fetch market data
gecko_data = coin_gecko_coin_api(coin)
# Get technical analysis
analysis = await technical_analyst.arun(
f"""Analyze {coin}'s technical indicators and price action using this data:
CoinGecko Data: {gecko_data}
Focus on:
- Chart patterns and trends
- Support/resistance levels
- Momentum indicators
- Price targets and risk levels
- Overall technical strength rating (1-10)
End with a clear technical strength score out of 10.
"""
)
return coin, analysis
async def main():
# Create tasks for concurrent execution
tasks = [analyze_coin(coin, technical_analyst) for coin in coins]
# Execute all analyses concurrently
results = await asyncio.gather(*tasks)
# Store results in coin_analyses
for coin, analysis in results:
coin_analyses[coin] = analysis
# Have technical analyst compare and recommend best investment
consensus = await technical_analyst.arun(
f"""Based on your technical analysis of these coins:
Solana Analysis:
{coin_analyses['solana']}
Raydium Analysis:
{coin_analyses['raydium']}
Jupiter Analysis:
{coin_analyses['jupiter']}
AIXBT Analysis:
{coin_analyses['aixbt']}
Please:
1. Rank the coins from strongest to weakest technical setup
2. Identify which coin has the best risk/reward ratio
3. Make a clear recommendation on which coin is the best investment opportunity and why
4. Note any key risks or concerns with the recommended coin
"""
)
return consensus
# Run the async main function
consensus = asyncio.run(main())