Skip to content

Commit

Permalink
Add get_open_and_resolved_markets function (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Feb 26, 2024
1 parent e7d4b79 commit d50c88e
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions prediction_market_agent_tooling/monitor/monitor_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import pytz
import streamlit as st

from prediction_market_agent_tooling.benchmark.utils import get_manifold_markets_dated
from prediction_market_agent_tooling.benchmark.utils import (
Market,
get_manifold_markets_dated,
)
from prediction_market_agent_tooling.markets.markets import MarketType
from prediction_market_agent_tooling.monitor.markets.manifold import (
DeployedManifoldAgent,
Expand Down Expand Up @@ -34,6 +37,36 @@ def get_deployed_agents(
raise ValueError(f"Unknown market type: {market_type}")


def get_open_and_resolved_markets(
start_time: datetime,
market_type: MarketType,
) -> tuple[list[Market], list[Market]]:
open_markets: list[Market]
resolved_markets: list[Market]

if market_type == MarketType.MANIFOLD:
open_markets = get_manifold_markets_dated(
oldest_date=start_time, filter_="open"
)
resolved_markets = [
m
for m in get_manifold_markets_dated(
oldest_date=start_time, filter_="resolved"
)
if not m.has_unsuccessful_resolution
]

elif market_type == MarketType.OMEN:
# TODO: Add Omen market support: https://github.com/gnosis/prediction-market-agent-tooling/issues/56
open_markets = []
resolved_markets = []

else:
raise ValueError(f"Unknown market type: {market_type}")

return open_markets, resolved_markets


def monitor_app() -> None:
settings = MonitorSettings()
start_time = datetime.combine(
Expand All @@ -52,12 +85,9 @@ def monitor_app() -> None:
)

st.subheader("Market resolution")
open_markets = get_manifold_markets_dated(oldest_date=start_time, filter_="open")
resolved_markets = [
m
for m in get_manifold_markets_dated(oldest_date=start_time, filter_="resolved")
if not m.has_unsuccessful_resolution
]
open_markets, resolved_markets = get_open_and_resolved_markets(
start_time, market_type
)
monitor_market(open_markets=open_markets, resolved_markets=resolved_markets)

with st.spinner("Loading agents..."):
Expand Down

0 comments on commit d50c88e

Please sign in to comment.