WIP: Fix Aggregazione market Product #67
Reference in New Issue
Block a user
Delete Branch "62-aggregazione-market-product-non-corretta"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Potrebbero esserci ancora delle cose da rivedere ma per ora mi sento di dire che è una roba sicura
Questo sarebbe dovuto andare nell'issue opportuno ma può anche stare qui. Verrà perfezionato nel branch 64
@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0Aggiunto metodo di aggregazione singola, serve sia per un metodo GET del tool market sia per snellire la logica del secondo metodo di aggregazione quello di aggregazione multipla.
Pull Request Overview
This PR refactors the market data aggregation system by splitting the aggregation logic into two distinct methods (
aggregate_single_assetandaggregate_multi_assets) and adds comprehensive test coverage for various edge cases. The changes improve API clarity and fix volume calculation bugs.ProductInfo.aggregate()toaggregate_multi_assets()and introducedaggregate_single_asset()for better separation of concernsproviderfield toProductInfomodel and populated it across all market data extractorsReviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 15 comments.
Show a summary per file
aggregate_single_asset()andaggregate_multi_assets()methods; fixed volume calculation logicget_product_aggregated()method and updatedget_products_aggregated()to use new aggregation approachproviderfield assignment in all market data extractors (Binance, Coinbase, CryptoCompare, YFinance)TaskTypedDict and corrected toolkit namegpt-oss:latestmodel entry💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0Italian comment in English codebase. Should be translated to 'Building map symbol -> list of ProductInfo (from all providers)'.
Italian comment in English codebase. Should be translated to 'Ensure that the provider is set'.
Italian comment in English codebase. Should be translated to 'Aggregation for each symbol using aggregate_single_asset'.
Italian comment in English codebase. Should be translated to 'Use aggregate_single_asset to aggregate each symbol'.
Italian comment in English codebase. Should be translated to 'If aggregate_single_asset fails (e.g., no USD when currencies differ), skip'.
Italian comment in English codebase. Should be translated to 'Currency check: if not all the same, filter only USD'.
Italian comment in English codebase. Should be translated to 'Different currencies: filter only USD'.
Italian comment in English codebase. Should be translated to 'Aggregation for each exchange'.
Italian comment in English codebase. Should be translated to 'Collect providers that have provided data'.
Italian comment in English codebase. Should be translated to 'Average volume calculation'.
Italian comment in English codebase. Should be translated to 'Volume-weighted price calculation (VWAP - Volume Weighted Average Price)'.
Italian comment in English codebase. Should be translated to 'If there is no volume, we do a simple average of prices'.
The type annotation indicates
dict[str, list[ProductInfo]]buttry_call_all()returnsdict[str, ProductInfo](mapping provider name to ProductInfo). This creates a type mismatch whereall_products[asset]is assigned a dict instead of a list. The variable should be typed asdict[str, dict[str, ProductInfo]]or the dict should be converted to a list.Italian comment in English codebase. Should be translated to 'Search both in name and symbol, ignoring case'.
Italian comment in English codebase. Should be translated to 'Convert the result to a list of tuples'.
Questo file, insieme ad altri, non dovrebbe essere committato in questo branch, dato che causa errori di merge con il main e non interessa nella PR
Questo file, insieme ad altri, non dovrebbe essere committato in questo branch, dato che causa errori di merge con il main e non interessa nella PR
Questo file, insieme ad altri, non dovrebbe essere committato in questo branch, dato che causa errori di merge con il main e non interessa nella PR
@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0Come mai è stata aggiunta una funzione in più? Non bastava fare tutto nella funzione precedente?
Inoltre, come mai vengono passati tutti questi tipi di dati?
@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0volume_24h: float = 0.0currency: str = ""provider: str = ""Come mai è stato aggiunto il provider direttamente nel product? Il provider è già passato come input nel dizionario e bastava dare in output una lista (o una stringa) con tutti i providers.
Questo non ha senso, come era prima già creava un dizionario dato con il nome del provider e, per ognuno, una lista di valori
La tabella non viene creata in questo modo. Ha molti altri dati interni e non solo Symbol e Name.
Il try è effettivamente inutile, dato che una eccezione può essere sollevata solo da read_csv se il file non esiste.
Ma se il file non esiste allora crea un dataframe nuovo.
L'unico caso in cui può essere utile è se il csv è corrotto. Ma ciò non può succedere dato che è seguito da git.
Rimettere come prima la creazione di quest'ultima.
Il try qui non ha molto senso, dato che non potrebbe mai sollevare una eccezione.
L'unico caso in cui potrebbe succedere è se la query è una regex non valida, ma basta aggiungere regex=False alla funzione pandas
Pensavo di averlo ripristinato, mi è sfuggito. Era una prova. Comunque prima usava la
get_productsmentre ora compone un dizionario iterando con laget_product, è la stessa cosa.@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0Come prima, dimenticanza da esperimento.
Rispondo solo a uno. Come faccio a cambiare il prompt se ne ho bisogno? Devo davvero essere così rigido? Se cambio branch per cambiarlo poi non posso comunque averlo nel mio branch su cui sto lavorando.
Non mi ricordo, non ho memoria di quella cosa
Non mi ricordo, non ho memoria di quella cosa
@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0volume_24h: float = 0.0currency: str = ""provider: str = ""Mi serviva nell'aggregate. Ma a pensarci ora quel dato era come chiave del dizionario. Vorrei giustificartelo ma adesso mi sento perso. Sono stanco e non vorrei dirti altre stronzate. Scusa, mi odierai...
Esattamente, dato che quelle modifiche sono di un altro branch devono stare su un altro branch.
D'altronde qui stai facendo la parte di aggregazione non i prompt degli agenti.
Poi, in realtà non serve che tu rimuova questa parte da questo PR, però sappi che ci sono dei merge conflict su questo file e sugli altri, dato che questo branch è vecchio rispetto al main.
Se volevi avere le modifiche che ci sono ora sul main basta che, prima di modificare qualcosa, o dopo aver committato tutto, tu faccia (sempre su questo branch):
@@ -13,43 +13,56 @@ class ProductInfo(BaseModel):price: float = 0.0volume_24h: float = 0.0currency: str = ""provider: str = ""Guarda che non odio nessuno, sono solo più pistino di Copilot.
Io chiedo solo le modifiche che sono state effettuate solo perchè le avrei fatte in un altro modo o non mi aspetto qualche cosa che è stata fatta.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.