From d6653f18d417b98d90a703f3a7bfdb19a3337d3c Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 17 Oct 2023 13:20:45 +0200 Subject: [PATCH 1/3] fix: fixed trades.py --- trades.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trades.py b/trades.py index 4018f7d0..053984c1 100644 --- a/trades.py +++ b/trades.py @@ -162,12 +162,12 @@ def __repr__(self) -> str: return self.name @staticmethod - def argparse(s): - """Performs string conversion to Attribute.""" + def argparse(s: str) -> "MarketAttribute": + """Performs string conversion to MarketAttribute.""" try: return MarketAttribute[s.upper()] except KeyError: - return s + return MarketAttribute(s) STATS_TABLE_COLS = list(MarketState) + ["TOTAL"] @@ -355,11 +355,13 @@ def _compute_totals(table: dict[Any, dict[Any, Any]]) -> None: table[row]["TOTAL"] = total for col in STATS_TABLE_COLS: + # Omen deducts the fee from collateral_amount (INVESTMENT) to compute outcomes_tokens_traded (EARNINGS). + # Therefore, we do not need to deduct the fees again here to compute NET_EARNINGS. table[MarketAttribute.NET_EARNINGS][col] = ( table[MarketAttribute.EARNINGS][col] - - table[MarketAttribute.FEES][col] - table[MarketAttribute.INVESTMENT][col] ) + # ROI is recomputed here for all columns, including TOTAL. table[MarketAttribute.ROI][col] = _compute_roi( table[MarketAttribute.INVESTMENT][col], table[MarketAttribute.NET_EARNINGS][col], From 9d19729924b3fb95d7f60040c51562c1a8468cd1 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 17 Oct 2023 14:59:30 +0200 Subject: [PATCH 2/3] fix: fixed exception --- trades.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trades.py b/trades.py index 053984c1..11e0e664 100644 --- a/trades.py +++ b/trades.py @@ -167,7 +167,7 @@ def argparse(s: str) -> "MarketAttribute": try: return MarketAttribute[s.upper()] except KeyError: - return MarketAttribute(s) + raise ValueError(f"Invalid MarketAttribute: {s}") STATS_TABLE_COLS = list(MarketState) + ["TOTAL"] From b9034d8cb2d8ab64166c5fbf838e9f738c03701d Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 17 Oct 2023 15:03:47 +0200 Subject: [PATCH 3/3] fix: added from --- trades.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trades.py b/trades.py index 11e0e664..9d090353 100644 --- a/trades.py +++ b/trades.py @@ -166,8 +166,8 @@ def argparse(s: str) -> "MarketAttribute": """Performs string conversion to MarketAttribute.""" try: return MarketAttribute[s.upper()] - except KeyError: - raise ValueError(f"Invalid MarketAttribute: {s}") + except KeyError as e: + raise ValueError(f"Invalid MarketAttribute: {s}") from e STATS_TABLE_COLS = list(MarketState) + ["TOTAL"]