Pre-merge main conflicts
This commit is contained in:
@@ -20,9 +20,8 @@ COINBASE_API_SECRET=
|
||||
# https://www.cryptocompare.com/cryptopian/api-keys
|
||||
CRYPTOCOMPARE_API_KEY=
|
||||
|
||||
# Binance API per Market Agent
|
||||
# Ottenibili da: https://www.binance.com/en/my/settings/api-management
|
||||
# Supporta sia API autenticate che pubbliche (PublicBinance)
|
||||
# https://www.binance.com/en/my/settings/api-management
|
||||
# Non necessario per operazioni in sola lettura
|
||||
BINANCE_API_KEY=
|
||||
BINANCE_API_SECRET=
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ from dotenv import load_dotenv
|
||||
from app.markets import (
|
||||
CoinBaseWrapper,
|
||||
CryptoCompareWrapper,
|
||||
BinanceWrapper,
|
||||
PublicBinanceAgent,
|
||||
BinanceWrapper,
|
||||
YFinanceWrapper,
|
||||
BaseWrapper
|
||||
)
|
||||
@@ -241,13 +240,6 @@ def initialize_providers() -> Dict[str, BaseWrapper]:
|
||||
providers = {}
|
||||
env_vars = check_environment_variables()
|
||||
|
||||
# PublicBinanceAgent (sempre disponibile)
|
||||
try:
|
||||
providers["PublicBinance"] = PublicBinanceAgent()
|
||||
print("✅ PublicBinanceAgent inizializzato con successo")
|
||||
except Exception as e:
|
||||
print(f"❌ Errore nell'inizializzazione di PublicBinanceAgent: {e}")
|
||||
|
||||
# CryptoCompareWrapper
|
||||
if env_vars["CRYPTOCOMPARE_API_KEY"]:
|
||||
try:
|
||||
@@ -269,14 +261,11 @@ def initialize_providers() -> Dict[str, BaseWrapper]:
|
||||
print("⚠️ CoinBaseWrapper saltato: credenziali Coinbase non complete")
|
||||
|
||||
# BinanceWrapper
|
||||
if env_vars["BINANCE_API_KEY"] and env_vars["BINANCE_API_SECRET"]:
|
||||
try:
|
||||
providers["Binance"] = BinanceWrapper()
|
||||
print("✅ BinanceWrapper inizializzato con successo")
|
||||
except Exception as e:
|
||||
print(f"❌ Errore nell'inizializzazione di BinanceWrapper: {e}")
|
||||
else:
|
||||
print("⚠️ BinanceWrapper saltato: credenziali Binance non complete")
|
||||
try:
|
||||
providers["Binance"] = BinanceWrapper()
|
||||
print("✅ BinanceWrapper inizializzato con successo")
|
||||
except Exception as e:
|
||||
print(f"❌ Errore nell'inizializzazione di BinanceWrapper: {e}")
|
||||
|
||||
# YFinanceWrapper (sempre disponibile - dati azionari e crypto gratuiti)
|
||||
try:
|
||||
@@ -284,7 +273,6 @@ def initialize_providers() -> Dict[str, BaseWrapper]:
|
||||
print("✅ YFinanceWrapper inizializzato con successo")
|
||||
except Exception as e:
|
||||
print(f"❌ Errore nell'inizializzazione di YFinanceWrapper: {e}")
|
||||
|
||||
return providers
|
||||
|
||||
def print_summary(results: List[Dict[str, Any]]):
|
||||
|
||||
@@ -3,16 +3,47 @@ from pydantic import BaseModel
|
||||
|
||||
class BaseWrapper:
|
||||
"""
|
||||
Interfaccia per i wrapper delle API di mercato.
|
||||
Implementa i metodi di base che ogni wrapper deve avere.
|
||||
Base class for market API wrappers.
|
||||
All market API wrappers should inherit from this class and implement the methods.
|
||||
"""
|
||||
|
||||
def get_product(self, asset_id: str) -> 'ProductInfo':
|
||||
"""
|
||||
Get product information for a specific asset ID.
|
||||
Args:
|
||||
asset_id (str): The asset ID to retrieve information for.
|
||||
Returns:
|
||||
ProductInfo: An object containing product information.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_products(self, asset_ids: list[str]) -> list['ProductInfo']:
|
||||
"""
|
||||
Get product information for multiple asset IDs.
|
||||
Args:
|
||||
asset_ids (list[str]): The list of asset IDs to retrieve information for.
|
||||
Returns:
|
||||
list[ProductInfo]: A list of objects containing product information.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_all_products(self) -> list['ProductInfo']:
|
||||
"""
|
||||
Get product information for all available assets.
|
||||
Returns:
|
||||
list[ProductInfo]: A list of objects containing product information.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_historical_prices(self, asset_id: str = "BTC", limit: int = 100) -> list['Price']:
|
||||
"""
|
||||
Get historical price data for a specific asset ID.
|
||||
Args:
|
||||
asset_id (str): The asset ID to retrieve price data for.
|
||||
limit (int): The maximum number of price data points to return.
|
||||
Returns:
|
||||
list[Price]: A list of Price objects.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
class ProductInfo(BaseModel):
|
||||
|
||||
@@ -23,10 +23,7 @@ class BinanceWrapper(BaseWrapper):
|
||||
|
||||
def __init__(self, currency: str = "USDT"):
|
||||
api_key = os.getenv("BINANCE_API_KEY")
|
||||
assert api_key is None, "API key is required"
|
||||
|
||||
api_secret = os.getenv("BINANCE_API_SECRET")
|
||||
assert api_secret is None, "API secret is required"
|
||||
|
||||
self.currency = currency
|
||||
self.client = Client(api_key=api_key, api_secret=api_secret)
|
||||
|
||||
@@ -23,6 +23,8 @@ def pytest_configure(config:pytest.Config):
|
||||
("social", "marks tests that use social media"),
|
||||
("limited", "marks tests that have limited execution due to API constraints"),
|
||||
("wrapper", "marks tests for wrapper handler"),
|
||||
("tools", "marks tests for tools"),
|
||||
("aggregator", "marks tests for market data aggregator"),
|
||||
]
|
||||
for marker in markers:
|
||||
line = f"{marker[0]}: {marker[1]}"
|
||||
|
||||
@@ -4,6 +4,8 @@ from app.agents.market_agent import MarketToolkit
|
||||
from app.markets import MarketAPIsTool
|
||||
|
||||
@pytest.mark.limited # usa molte api calls e non voglio esaurire le chiavi api
|
||||
@pytest.mark.tools
|
||||
@pytest.mark.api
|
||||
class TestMarketAPIsTool:
|
||||
def test_wrapper_initialization(self):
|
||||
market_wrapper = MarketAPIsTool("USD")
|
||||
@@ -1,10 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from app.utils.market_data_aggregator import MarketDataAggregator
|
||||
from app.utils.aggregated_models import AggregatedProductInfo
|
||||
from app.markets.base import ProductInfo, Price
|
||||
|
||||
@pytest.mark.aggregator
|
||||
@pytest.mark.limited
|
||||
@pytest.mark.market
|
||||
@pytest.mark.api
|
||||
class TestMarketDataAggregator:
|
||||
|
||||
def test_initialization(self):
|
||||
@@ -84,7 +86,3 @@ class TestMarketDataAggregator:
|
||||
assert len(aggregated._metadata.sources_used) > 0
|
||||
assert aggregated._metadata.aggregation_timestamp != ""
|
||||
# La confidence può essere 0.0 se ci sono fonti "unknown"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__])
|
||||
6
uv.lock
generated
6
uv.lock
generated
@@ -867,12 +867,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/69/b547032297c7e63ba2af494edba695d781af8a0c6e89e4d06cf848b21d80/multidict-6.6.4-py3-none-any.whl", hash = "sha256:27d8f8e125c07cb954e54d75d04905a9bba8a439c1d84aca94949d4d03d8601c", size = 12313, upload-time = "2025-08-11T12:08:46.891Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multitasking"
|
||||
version = "0.0.12"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/17/0d/74f0293dfd7dcc3837746d0138cbedd60b31701ecc75caec7d3f281feba0/multitasking-0.0.12.tar.gz", hash = "sha256:2fba2fa8ed8c4b85e227c5dd7dc41c7d658de3b6f247927316175a57349b84d1", size = 19984, upload-time = "2025-07-20T21:27:51.636Z" }
|
||||
|
||||
[[package]]
|
||||
name = "newsapi-python"
|
||||
version = "0.2.7"
|
||||
|
||||
Reference in New Issue
Block a user