Skip to content

Commit

Permalink
Merge pull request #100 from valory-xyz/fix/aea_log_config
Browse files Browse the repository at this point in the history
Update finalizing markets script
  • Loading branch information
jmoreira-valory authored Apr 5, 2024
2 parents 4bc47f6 + 3f96f80 commit f8ce708
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions scripts/list_finalizing_markets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
" isPendingArbitration\n",
" answerFinalizedTimestamp\n",
" currentAnswer\n",
" collateralVolume\n",
" }\n",
" }\n",
" \"\"\"\n",
Expand Down Expand Up @@ -145,12 +146,19 @@
"\n",
"\n",
"def _get_market_title(market: Dict[str, Any]) -> str:\n",
" question_title = \"\"\n",
" question_title = \"question_title\"\n",
" url = \"\"\n",
" if market.get(\"question\"):\n",
" question_title = market[\"question\"].get(\"title\", \"\")\n",
" return question_title\n",
" url = f'https://aiomen.eth.limo/#/{market.get(\"id\",\"\")}'\n",
" return _make_clickable(question_title, url)\n",
"\n",
"\n",
"def _get_collateral_volume(market: Dict[str, Any]) -> str:\n",
" volume = int(market.get(\"collateralVolume\", 0))\n",
" formatted_volume = f\"{volume / 10**18:.2f}\"\n",
" return formatted_volume\n",
"\n",
"def _get_current_answer(market: Dict[str, Any]) -> str:\n",
" currentAnswer = market.get(\"currentAnswer\", \"\")\n",
" if not currentAnswer:\n",
Expand Down Expand Up @@ -193,8 +201,8 @@
" output = {\"data\": {\"fixedProductMarketMakers\": all_markets}}\n",
" return output\n",
"\n",
"def _make_clickable(url: str) -> str:\n",
" return f'<a href=\"{url}\" target=\"_blank\">{url}</a>'\n",
"def _make_clickable(text: str, url: str) -> str:\n",
" return f'<a href=\"{url}\" target=\"_blank\">{text}</a>'\n",
"\n",
"def _generate_markets_df() -> pd.DataFrame:\n",
" data = _execute_fpmm_query()\n",
Expand All @@ -203,6 +211,7 @@
" rows.append(\n",
" {\n",
" \"Title\": _get_market_title(entry),\n",
" \"Volume (xDAI):\": _get_collateral_volume(entry),\n",
" \"Current answer\": _get_current_answer(entry),\n",
" \"Num answers\": _get_num_answers(entry),\n",
" \"State\": _get_market_state(entry),\n",
Expand All @@ -211,7 +220,6 @@
" \"Opening (UTC)\": _get_date(entry[\"openingTimestamp\"]),\n",
" \"Answer finalized (UTC)\": _get_date(entry[\"answerFinalizedTimestamp\"]),\n",
" \"Resolution (UTC)\": _get_date(entry[\"resolutionTimestamp\"]),\n",
" \"URL\": f'https://aiomen.eth.limo/#/{entry.get(\"id\",\"\")}',\n",
" }\n",
" )\n",
"\n",
Expand All @@ -226,21 +234,24 @@
"source": [
"from IPython.display import display, HTML\n",
"df = _generate_markets_df()\n",
"df['URL'] = df['URL'].apply(_make_clickable)\n",
"\n",
"# Select markets to display\n",
"market_states = [\n",
" #MarketState.OPEN,\n",
" MarketState.PENDING,\n",
" MarketState.FINALIZING,\n",
" #MarketState.FINALIZING,\n",
" #MarketState.ARBITRATING,\n",
" #MarketState.CLOSED,\n",
" #MarketState.UNKNOWN\n",
"]\n",
"\n",
"df.style.set_properties(subset=[\"Title\"], **{'text-align': 'right'})\n",
"\n",
"df_filtered = df[df[\"State\"].isin(market_states)]\n",
"pd.options.display.max_colwidth = 150\n",
"print(f\"Total {[str(s) for s in market_states]} markets: {len(df_filtered)}\")\n",
"html = df_filtered.to_html(escape=False, classes='sortable')\n",
"\n",
"display(HTML(df_filtered.to_html(escape=False)))\n"
]
}
Expand Down

0 comments on commit f8ce708

Please sign in to comment.