Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
except KeyError as e:
raise ValueError(f"Invalid MarketAttribute: {s}") from e


STATS_TABLE_COLS = list(MarketState) + ["TOTAL"]
Expand Down Expand Up @@ -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],
Expand Down