diff --git a/demos/example.py b/demos/agno_demo.py similarity index 67% rename from demos/example.py rename to demos/agno_demo.py index c1fa08c..38b29ce 100644 --- a/demos/example.py +++ b/demos/agno_demo.py @@ -1,3 +1,9 @@ +#### FOR ALL FILES OUTSIDE src/ FOLDER #### +import sys +import os +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) +########################################### + from agno.agent import Agent from agno.models.google import Gemini from agno.tools.reasoning import ReasoningTools @@ -8,9 +14,7 @@ try: reasoning_agent = Agent( model=Gemini(), - tools=[ - ReasoningTools(), - ], + tools=[ReasoningTools()], instructions="Use tables to display data.", markdown=True, ) diff --git a/demos/cdp_market_demo.py b/demos/cdp_market_demo.py deleted file mode 100644 index 307d02f..0000000 --- a/demos/cdp_market_demo.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python3 -""" -Demo script per testare il MarketAgent aggiornato con Coinbase CDP -""" - -import sys -import os -sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) - -from src.app.agents.market_agent import MarketAgent -import logging - -# Setup logging -logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' -) - -def main(): - print("πŸš€ Test MarketAgent con Coinbase CDP") - print("=" * 50) - - # Inizializza l'agent - agent = MarketAgent() - - # Verifica provider disponibili - providers = agent.get_available_providers() - print(f"πŸ“‘ Provider disponibili: {providers}") - - if not providers: - print("⚠️ Nessun provider configurato. Verifica il file .env") - print("\nPer Coinbase CDP, serve:") - print("CDP_API_KEY_NAME=your_key_name") - print("CDP_API_PRIVATE_KEY=your_private_key") - print("\nPer CryptoCompare, serve:") - print("CRYPTOCOMPARE_API_KEY=your_api_key") - return - - # Mostra capabilities di ogni provider - for provider in providers: - capabilities = agent.get_provider_capabilities(provider) - print(f"πŸ”§ {provider.upper()}: {capabilities}") - - print("\n" + "=" * 50) - - # Test ottenimento prezzo singolo - test_symbols = ["BTC", "ETH", "ADA"] - - for symbol in test_symbols: - print(f"\nπŸ’° Prezzo {symbol}:") - - # Prova ogni provider - for provider in providers: - try: - price = agent.get_asset_price(symbol, provider) - if price: - print(f" {provider}: ${price:,.2f}") - else: - print(f" {provider}: N/A") - except Exception as e: - print(f" {provider}: Errore - {e}") - - print("\n" + "=" * 50) - - # Test market overview - print("\nπŸ“Š Market Overview:") - try: - overview = agent.get_market_overview(["BTC", "ETH", "ADA", "DOT"]) - - if overview["data"]: - print(f"πŸ“‘ Fonte: {overview['source']}") - - for crypto, prices in overview["data"].items(): - if isinstance(prices, dict): - usd_price = prices.get("USD", "N/A") - eur_price = prices.get("EUR", "N/A") - - if eur_price != "N/A": - print(f" {crypto}: ${usd_price} (€{eur_price})") - else: - print(f" {crypto}: ${usd_price}") - else: - print("⚠️ Nessun dato disponibile") - - except Exception as e: - print(f"❌ Errore nel market overview: {e}") - - print("\n" + "=" * 50) - - # Test funzione analyze - print("\nπŸ” Analisi mercato:") - try: - analysis = agent.analyze("Market overview") - print(analysis) - except Exception as e: - print(f"❌ Errore nell'analisi: {e}") - - # Test specifico Coinbase CDP se disponibile - if 'coinbase' in providers: - print("\n" + "=" * 50) - print("\n🏦 Test specifico Coinbase CDP:") - - try: - # Test asset singolo - btc_info = agent.get_coinbase_asset_info("BTC") - print(f"πŸ“ˆ BTC Info: {btc_info}") - - # Test asset multipli - multi_assets = agent.get_coinbase_multiple_assets(["BTC", "ETH"]) - print(f"πŸ“Š Multi Assets: {multi_assets}") - - except Exception as e: - print(f"❌ Errore nel test Coinbase CDP: {e}") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/demos/coinbase_demo.py b/demos/coinbase_demo.py new file mode 100644 index 0000000..8b6bd41 --- /dev/null +++ b/demos/coinbase_demo.py @@ -0,0 +1,36 @@ +#### FOR ALL FILES OUTSIDE src/ FOLDER #### +import sys +import os +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) +########################################### + +from dotenv import load_dotenv +from app.markets import CoinBaseWrapper + +def main(): + print("Demo Coinbase CDP") + + print("=== Chiavi API ===") + print(f" COINBASE_API_KEY: {os.getenv('COINBASE_API_KEY') is not None}") + print(f" COINBASE_API_SECRET: {os.getenv('COINBASE_API_SECRET') is not None}") + + # Inizializza le API + coinbase = CoinBaseWrapper() + + # ottenimento prezzo attuale + print("=== Demo prezzo attuale ===") + test_symbols = ["BTC", "ETH", "ADA"] + for symbol in test_symbols: + info = coinbase.get_product(symbol) + print(f" {symbol}: ${info.price:,.2f}") + + # ottenimento prezzi storici + print("\n=== Demo prezzi storici ===") + test_symbols = ["BTC", "ETH"] + for symbol in test_symbols: + prices = coinbase.get_historical_prices(symbol) + print(f" {symbol}: {" ".join([f'${entry["price"]:,.2f}' for entry in prices[:5]])}") # mostra solo i primi 5 + +if __name__ == "__main__": + load_dotenv() + main() diff --git a/demos/cryptocompare_demo.py b/demos/cryptocompare_demo.py new file mode 100644 index 0000000..f929b87 --- /dev/null +++ b/demos/cryptocompare_demo.py @@ -0,0 +1,36 @@ +#### FOR ALL FILES OUTSIDE src/ FOLDER #### +import sys +import os +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) +########################################### + +from dotenv import load_dotenv +from app.markets.cryptocompare import CryptoCompareWrapper + +def main(): + print("Demo CryptoCompare") + + print("=== Chiavi API ===") + print(f" CRYPTOCOMPARE_API_KEY: {os.getenv('CRYPTOCOMPARE_API_KEY') is not None}") + + # Inizializza le API + cryptocompare = CryptoCompareWrapper() + + # ottenimento prezzo attuale + print("=== Demo prezzo attuale ===") + test_symbols = ["BTC", "ETH", "ADA"] + for symbol in test_symbols: + info = cryptocompare.get_product(symbol) + print(f" {symbol}: ${info.price:,.2f}") + + # ottenimento prezzi storici + print("=== Demo prezzi storici ===") + test_symbols = ["BTC", "ETH"] + for symbol in test_symbols: + prices = cryptocompare.get_historical_prices(symbol) + prices = [f'[${entry.high:,.2f}-${entry.low:,.2f}]' for entry in prices] + print(f" {symbol}: {" ".join(prices[:5])}") # mostra solo i primi 5 + +if __name__ == "__main__": + load_dotenv() + main() \ No newline at end of file diff --git a/demos/market_agent_demo.py b/demos/market_agent_demo.py deleted file mode 100644 index 1ef8f21..0000000 --- a/demos/market_agent_demo.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python3 -""" -Esempio di utilizzo del MarketAgent unificato. -Questo script mostra come utilizzare il nuovo MarketAgent che supporta -multiple fonti di dati (Coinbase e CryptoCompare). -""" - -import sys -from pathlib import Path - -# Aggiungi il path src al PYTHONPATH -src_path = Path(__file__).parent / "src" -sys.path.insert(0, str(src_path)) - -from dotenv import load_dotenv -from app.agents.market_agent import MarketAgent - -# Carica variabili d'ambiente -load_dotenv() - -def main(): - print("πŸš€ Market Agent Demo\n") - - try: - # Inizializza il market agent (auto-configura i provider disponibili) - agent = MarketAgent() - - # Mostra provider disponibili - providers = agent.get_available_providers() - print(f"πŸ“‘ Available providers: {providers}") - - if not providers: - print("❌ No providers configured. Please check your .env file.") - print("Required variables:") - print(" For Coinbase: COINBASE_API_KEY, COINBASE_SECRET, COINBASE_PASSPHRASE") - print(" For CryptoCompare: CRYPTOCOMPARE_API_KEY") - return - - # Mostra le capacitΓ  di ogni provider - print("\nπŸ”§ Provider capabilities:") - for provider in providers: - capabilities = agent.get_provider_capabilities(provider) - print(f" {provider}: {capabilities}") - - # Ottieni panoramica del mercato - print("\nπŸ“Š Market Overview:") - overview = agent.get_market_overview(["BTC", "ETH", "ADA"]) - print(f"Data source: {overview.get('source', 'Unknown')}") - - for crypto, prices in overview.get('data', {}).items(): - if isinstance(prices, dict): - usd = prices.get('USD', 'N/A') - eur = prices.get('EUR', 'N/A') - if eur != 'N/A': - print(f" {crypto}: ${usd} (€{eur})") - else: - print(f" {crypto}: ${usd}") - - # Analisi completa del mercato - print("\nπŸ“ˆ Market Analysis:") - analysis = agent.analyze("comprehensive market analysis") - print(analysis) - - # Test specifici per provider (se disponibili) - if 'cryptocompare' in providers: - print("\nπŸ”Έ CryptoCompare specific test:") - try: - btc_price = agent.get_single_crypto_price("BTC", "USD") - print(f" BTC price: ${btc_price}") - - top_coins = agent.get_top_cryptocurrencies(5) - if top_coins.get('Data'): - print(" Top 5 cryptocurrencies by market cap:") - for coin in top_coins['Data'][:3]: # Show top 3 - coin_info = coin.get('CoinInfo', {}) - display = coin.get('DISPLAY', {}).get('USD', {}) - name = coin_info.get('FullName', 'Unknown') - price = display.get('PRICE', 'N/A') - print(f" {name}: {price}") - except Exception as e: - print(f" CryptoCompare test failed: {e}") - - if 'coinbase' in providers: - print("\nπŸ”Έ Coinbase specific test:") - try: - ticker = agent.get_coinbase_ticker("BTC-USD") - price = ticker.get('price', 'N/A') - volume = ticker.get('volume_24h', 'N/A') - print(f" BTC-USD: ${price} (24h volume: {volume})") - except Exception as e: - print(f" Coinbase test failed: {e}") - - print("\nβœ… Demo completed successfully!") - - except Exception as e: - print(f"❌ Demo failed: {e}") - print("Make sure you have configured at least one provider in your .env file.") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/src/app/markets/cryptocompare.py b/src/app/markets/cryptocompare.py index 188a2c2..aa220fa 100644 --- a/src/app/markets/cryptocompare.py +++ b/src/app/markets/cryptocompare.py @@ -49,7 +49,7 @@ class CryptoCompareWrapper(BaseWrapper): def get_all_products(self) -> list[ProductInfo]: raise NotImplementedError("CryptoCompare does not support fetching all assets") - def get_historical_prices(self, asset_id: str, day_back: int = 10) -> list[dict]: + def get_historical_prices(self, asset_id: str, day_back: int = 10) -> list[Price]: assert day_back <= 30, "day_back should be less than or equal to 30" response = self.__request("/data/v2/histohour", params = { "fsym": asset_id,