Enhance documentation
This commit is contained in:
@@ -2,6 +2,10 @@ from coinbase.rest.types.product_types import Candle, GetProductResponse
|
||||
|
||||
|
||||
class BaseWrapper:
|
||||
"""
|
||||
Interfaccia per i wrapper delle API di mercato.
|
||||
Implementa i metodi di base che ogni wrapper deve avere.
|
||||
"""
|
||||
def get_product(self, asset_id: str) -> 'ProductInfo':
|
||||
raise NotImplementedError
|
||||
def get_products(self, asset_ids: list[str]) -> list['ProductInfo']:
|
||||
@@ -12,6 +16,10 @@ class BaseWrapper:
|
||||
raise NotImplementedError
|
||||
|
||||
class ProductInfo:
|
||||
"""
|
||||
Informazioni sul prodotto, come ottenute dalle API di mercato.
|
||||
Implementa i metodi di conversione dai dati grezzi delle API.
|
||||
"""
|
||||
id: str
|
||||
symbol: str
|
||||
price: float
|
||||
@@ -39,6 +47,10 @@ class ProductInfo:
|
||||
return product
|
||||
|
||||
class Price:
|
||||
"""
|
||||
Rappresenta i dati di prezzo per un asset, come ottenuti dalle API di mercato.
|
||||
Implementa i metodi di conversione dai dati grezzi delle API.
|
||||
"""
|
||||
high: float
|
||||
low: float
|
||||
open: float
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Versione pubblica senza autenticazione
|
||||
from binance.client import Client
|
||||
|
||||
# TODO fare l'aggancio con API in modo da poterlo usare come wrapper di mercato
|
||||
# TODO implementare i metodi di BaseWrapper
|
||||
|
||||
class PublicBinanceAgent:
|
||||
def __init__(self):
|
||||
# Client pubblico (senza credenziali)
|
||||
|
||||
@@ -2,6 +2,10 @@ from coinbase.rest import RESTClient
|
||||
from app.markets.base import ProductInfo, BaseWrapper, Price
|
||||
|
||||
class CoinBaseWrapper(BaseWrapper):
|
||||
"""
|
||||
Wrapper per le API di Coinbase.
|
||||
La documentazione delle API è disponibile qui: https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/introduction
|
||||
"""
|
||||
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"
|
||||
|
||||
@@ -4,6 +4,11 @@ from app.markets.base import ProductInfo, BaseWrapper, Price
|
||||
BASE_URL = "https://min-api.cryptocompare.com"
|
||||
|
||||
class CryptoCompareWrapper(BaseWrapper):
|
||||
"""
|
||||
Wrapper per le API pubbliche di CryptoCompare.
|
||||
La documentazione delle API è disponibile qui: https://developers.coindesk.com/documentation/legacy/Price/SingleSymbolPriceEndpoint
|
||||
!!ATTENZIONE!! sembra essere una API legacy e potrebbe essere deprecata in futuro.
|
||||
"""
|
||||
def __init__(self, api_key:str, currency:str='USD'):
|
||||
assert api_key is not None, "API key is required"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user