Refactor Predictor and market data handling

- Added Predictor class with input preparation and instructions for financial strategy generation.
- Removed PredictorAgent class and integrated its functionality into the new Predictor module.
- Created a base market API wrapper and specific implementations for Coinbase and CryptoCompare.
- Introduced PublicBinanceAgent for fetching public prices from Binance.
- Refactored ToolAgent to utilize the new Predictor and market API wrappers for improved data handling and predictions.
- Updated models to streamline the selection of available LLM providers.
- Removed deprecated signer classes for Coinbase and CryptoCompare.
This commit is contained in:
2025-09-26 03:43:31 +02:00
parent 48502fc6c7
commit 148bff7cfd
18 changed files with 362 additions and 2324 deletions

View File

@@ -0,0 +1,35 @@
from coinbase.rest import RESTClient
from app.markets.base import ProductInfo, BaseWrapper, Price
class CoinBaseWrapper(BaseWrapper):
def __init__(self, api_key:str, api_private_key:str, currency: str = "USD"):
assert api_key is not None, "API key is required"
assert api_private_key is not None, "API private key is required"
self.currency = currency
self.client: RESTClient = RESTClient(
api_key=api_key,
api_secret=api_private_key
)
def __format(self, asset_id: str) -> str:
return asset_id if '-' in asset_id else f"{asset_id}-{self.currency}"
def get_product(self, asset_id: str) -> ProductInfo:
asset_id = self.__format(asset_id)
asset = self.client.get_product(asset_id)
return ProductInfo.from_coinbase(asset)
def get_products(self, asset_ids: list[str]) -> list[ProductInfo]:
all_asset_ids = [self.__format(asset_id) for asset_id in asset_ids]
assets = self.client.get_products(all_asset_ids)
return [ProductInfo.from_coinbase(asset) for asset in assets.products]
def get_all_products(self) -> list[ProductInfo]:
assets = self.client.get_products()
return [ProductInfo.from_coinbase(asset) for asset in assets.products]
def get_historical_prices(self, asset_id: str = "BTC") -> list[Price]:
asset_id = self.__format(asset_id)
data = self.client.get_candles(product_id=asset_id)
return [Price.from_coinbase(candle) for candle in data.candles]