Skip to main content

Overview

Omen (also known as Presagio) is a decentralized prediction market platform on Gnosis Chain. The Omen market API provides access to binary and categorical prediction markets with full on-chain trading capabilities.

MarketType Enum

from prediction_market_agent_tooling.markets.markets import MarketType

market_type = MarketType.OMEN

Market Class

OmenAgentMarket

The OmenAgentMarket class extends AgentMarket and provides Omen-specific functionality.
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket

Core Methods

Get Markets

Retrieve available prediction markets from Omen.
markets = OmenAgentMarket.get_markets(
    limit=15,
    filter_by=FilterBy.OPEN,
    sort_by=SortBy.CLOSING_SOONEST
)
limit
int
Maximum number of markets to retrieve
filter_by
FilterBy
Filter markets by status (OPEN, RESOLVED, etc.)
sort_by
SortBy
Sort order (CLOSING_SOONEST, NEWEST, HIGHEST_LIQUIDITY, etc.)
markets
list[OmenAgentMarket]
List of market objects matching the query criteria

Get Binary Market

Retrieve a specific binary market by ID.
market = OmenAgentMarket.get_binary_market(
    id="0x0020d13c89140b47e10db54cbd53852b90bc1391"
)
id
str
required
Market address (checksummed Ethereum address)
market
OmenAgentMarket
Market object containing question, probabilities, and trading information

Buy Tokens

Purchase outcome tokens for a market.
market.buy_tokens(
    outcome="Yes",
    amount=USD(2.5)
)
outcome
str
required
Outcome to bet on (“Yes” or “No” for binary markets)
amount
USD
required
Amount to spend on tokens in USD

Sell Tokens

Sell outcome tokens from a market position.
market.sell_tokens(
    outcome="Yes",
    amount=OutcomeToken(5.0)
)
outcome
str
required
Outcome tokens to sell
amount
OutcomeToken
required
Number of outcome tokens to sell

Get Token Balance

Check token balance for a specific outcome.
balance = market.get_token_balance(
    user_id=api_keys.bet_from_address,
    outcome="Yes"
)
user_id
str
required
User’s Ethereum address
outcome
str
required
Outcome to check balance for
balance
OutcomeToken
Number of outcome tokens held

Get Positions

Retrieve all user positions across markets.
positions = OmenAgentMarket.get_positions(
    user_id=api_keys.bet_from_address,
    liquid_only=True,
    larger_than=OutcomeToken(1e-4)
)
user_id
str
required
User’s Ethereum address
liquid_only
bool
Only return positions in open markets
larger_than
OutcomeToken
Minimum position size to include
positions
list[Position]
List of user positions with market details and token amounts

Get Trade Balance

Get available trading balance.
balance = OmenAgentMarket.get_trade_balance(api_keys)
api_keys
APIKeys
required
API keys containing wallet address
balance
USD
Available balance for trading in USD

Market Data Model

Market Properties

id
str
Market address (Ethereum checksummed address)
question
str
Market question text
description
str | None
Additional market description or resolution criteria
outcomes
list[str]
Available outcomes (e.g., [“Yes”, “No”] for binary markets)
p_yes
Probability
Current probability of “Yes” outcome (0.0 to 1.0)
current_p_yes
Probability
Alias for p_yes
current_p_no
Probability
Current probability of “No” outcome (1 - p_yes)
volume
USD | None
Total trading volume
close_time
DatetimeUTC | None
When the market closes for trading
created_time
DatetimeUTC | None
When the market was created
url
str
Direct link to the market on Omen
is_open
bool
Whether the market is currently open for trading
resolution
str | None
Final resolution outcome (if resolved)

Omen-Specific Features

Market Creation

Create new prediction markets on Omen.
from prediction_market_agent_tooling.markets.omen.omen import omen_create_market_tx
from prediction_market_agent_tooling.markets.omen.data_models import (
    OMEN_TRUE_OUTCOME,
    OMEN_FALSE_OUTCOME,
)

created_market = omen_create_market_tx(
    api_keys=api_keys,
    initial_funds=USD(10),
    fee_perc=0.02,
    question="Will Bitcoin reach $100k by end of 2025?",
    closing_time=datetime(2025, 12, 31),
    category="Cryptocurrency",
    language="en",
    outcomes=[OMEN_TRUE_OUTCOME, OMEN_FALSE_OUTCOME],
    auto_deposit=True,
    collateral_token_address=collateral_token
)

Outcomes Constants

from prediction_market_agent_tooling.markets.omen.data_models import (
    OMEN_TRUE_OUTCOME,  # "Yes"
    OMEN_FALSE_OUTCOME,  # "No"
)

Subgraph Handler

Access raw Omen market data via GraphQL.
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
    OmenSubgraphHandler,
)

handler = OmenSubgraphHandler()
markets = handler.get_omen_markets(
    limit=100,
    creator=creator_address,
    resolved=False
)

Real-World Examples

Arbitrage Agent

The arbitrage agent finds correlated markets and places mirror bets.
from prediction_market_agent.agents.arbitrage_agent.deploy import (
    DeployableArbitrageAgent,
)

class DeployableArbitrageAgent(DeployableTraderAgent):
    total_trade_amount = USD(0.1)
    bet_on_n_markets_per_run = 5

    def run(self, market_type: MarketType) -> None:
        if market_type != MarketType.OMEN:
            raise RuntimeError("Can arbitrage only on Omen")
        super().run(market_type=market_type)

Microchain Agent

The microchain agent uses function calling to trade on Omen markets.
from prediction_market_agent.agents.microchain_agent.market_functions import (
    GetMarkets,
    BuyYes,
    BuyNo,
    GetBalance,
)

# Get available markets
get_markets = GetMarkets(market_type=MarketType.OMEN, keys=api_keys)
markets = get_markets()

# Buy tokens
buy_yes = BuyYes(market_type=MarketType.OMEN, keys=api_keys)
result = buy_yes(market_id=market_id, amount_usd=2.5)

Replication Agent

The replication agent copies markets from other platforms to Omen.
from prediction_market_agent.agents.replicate_to_omen_agent.omen_replicate import (
    omen_replicate_from_tx,
)

created_addresses = omen_replicate_from_tx(
    api_keys=api_keys,
    market_type=MarketType.POLYMARKET,
    n_to_replicate=5,
    initial_funds=USD(10),
    collateral_token_address=collateral_token,
    replicated_market_table_handler=handler,
    auto_deposit=True
)

Network Details

  • Blockchain: Gnosis Chain (formerly xDai)
  • Native Token: xDai (stablecoin pegged to USD)
  • Collateral Tokens: xDai, sDAI, and other ERC-20 tokens
  • Website: https://omen.eth.limo
  • Subgraph: Omen uses The Graph protocol for market data

Error Handling

try:
    market = OmenAgentMarket.get_binary_market(id=market_id)
    market.buy_tokens(outcome="Yes", amount=USD(5))
except Exception as e:
    logger.error(f"Failed to execute trade: {e}")

See Also

Build docs developers (and LLMs) love