From de0ed03454d28a8d79af58657ff940444d4b5815 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Thu, 6 Feb 2025 11:26:40 -0500 Subject: [PATCH] example cleanup --- .../majority_voting_example.py | 0 .../model_router_example.py | 0 .../together_deepseek_agent.py | 0 .../hierarchical_swarm_example.py | 0 quant_crypto_swarm.py | 156 ++++++++++++++++++ trader_swarm.py | 0 6 files changed, 156 insertions(+) rename majority_voting_example.py => examples/majority_voting_example.py (100%) rename model_router_example.py => examples/model_router_example.py (100%) rename together_deepseek_agent.py => examples/together_deepseek_agent.py (100%) rename hierarchical_swarm_example.py => hs_examples/hierarchical_swarm_example.py (100%) create mode 100644 quant_crypto_swarm.py delete mode 100644 trader_swarm.py diff --git a/majority_voting_example.py b/examples/majority_voting_example.py similarity index 100% rename from majority_voting_example.py rename to examples/majority_voting_example.py diff --git a/model_router_example.py b/examples/model_router_example.py similarity index 100% rename from model_router_example.py rename to examples/model_router_example.py diff --git a/together_deepseek_agent.py b/examples/together_deepseek_agent.py similarity index 100% rename from together_deepseek_agent.py rename to examples/together_deepseek_agent.py diff --git a/hierarchical_swarm_example.py b/hs_examples/hierarchical_swarm_example.py similarity index 100% rename from hierarchical_swarm_example.py rename to hs_examples/hierarchical_swarm_example.py diff --git a/quant_crypto_swarm.py b/quant_crypto_swarm.py new file mode 100644 index 00000000..f12a1ee3 --- /dev/null +++ b/quant_crypto_swarm.py @@ -0,0 +1,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()) diff --git a/trader_swarm.py b/trader_swarm.py deleted file mode 100644 index e69de29b..00000000