Submodules
manifoldpy.api module
API bindings
- class manifoldpy.api.APIWrapper(key: str)
Bases:
object- add_liquidity(market_id: str, amount: float) Response
Add liquidity to a market
- Parameters
market_id – The market to add liquidity to.
amount – The amount of liquidity to add.
- cancel_bet(bet_id: str) Response
Cancel a bet. [API reference](https://docs.manifold.markets/api#post-v0betcancelid)
- Parameters
bet_id – The bet id.
- create_market(outcomeType: Literal['BINARY', 'FREE_RESPONSE', 'PSEUDO_NUMERIC', 'MULTIPLE_CHOICE', 'NUMERIC', 'MULTI_NUMERIC', 'QUADRATIC_FUNDING', 'STONK', 'POLL', 'BOUNTIED_QUESTION', 'DATE'], question: str, description: str, closeTime: int, initialProb: Optional[int] = None, min: Optional[float] = None, max: Optional[float] = None, groupId: Optional[str] = None, visibility: Optional[Literal['public', 'unlisted']] = None, isLogScale: Optional[bool] = None, initialValue: Optional[float] = None, answers: Optional[List[str]] = None) Response
Create a new market [API reference](https://docs.manifold.markets/api#post-v0market)
- Parameters
outcomeType – The kind of market.
question – Short description of the market.
description – Additional details about the market.
closeTime – When the market closes (milliseconds since epoch).
initialProb – The initial probability for the market. Must be between 1 and 99. Used for BINARY markets.
min – Minimum value the market can resolve to. Used for PSEUDO_NUMERIC markets.
max – Maximum value the market can resolve to. Used for PSEUDO_NUMERIC markets.
groupId – The ID of the group the market belongs to, if any.
visibility – The visibility of the market. Must be ‘public’ or ‘unlisted’
isLogScale – If True, the scale between min and max uses exponential increments. Used for PSEUDO_NUMERIC markets.
initialValue – The initial value of the market. Used for PSEUDO_NUMERIC markets.
answers – The possible answers for the market. Used for MULTIPLE_CHOICE markets.
- property headers: Dict[str, str]
- key: str
- make_bet(amount: float, contractId: str, outcome: str, limitProb: Optional[float] = None) Response
Make a bet. [API reference](https://docs.manifold.markets/api#post-v0bet)
- Parameters
amount – The amount to bet
contractId – The market id.
outcome – The outcome to bet on. YES or NO for binary markets
limitProb – A limit probability for the bet. If spending the full amount would push the market past this probability, then only enough to push the market to this probability will be bought. Any additional funds will be left often as a bet that can later be matched by an opposing offer.
- make_comment(contractId: str, content: str) Response
Post a comment. [API reference](https://docs.manifold.markets/api#post-v0comment)
- Parameters
contractId – The market id.
content – The comment to post, formatted as a markdown string.
- me() Response
Return the authenticated user
- resolve_market(market_id: str, outcome: str, probabilityInt: Optional[int] = None, resolutions: Optional[List[Any]] = None, value: Optional[Any] = None) Response
Resolve an existing market. [API reference](https://docs.manifold.markets/api#post-v0marketmarketidresolve)
- Parameters
market_id – The id of the market to resolve.
outcome – The outcome to resolve with.
probabilityInt – The probability to resolve with (if outcome is MKT)
resolutions – An array of responses and weights for each response (for resolving free responses with multiple outcomes)
value – The value the market resolves to (for numeric markets)
Sell shares in a particular market
- Parameters
market_id – The market to sell shares in
outcome – The kind of shares to sell. Must be YES or NO.
- class manifoldpy.api.Answer
Bases:
objectAn answer to a free response market
- class manifoldpy.api.Bet(contractId: str, createdTime: int, shares: float, amount: int, probAfter: float, probBefore: float, id: str, outcome: str, answerId: str, challengeSlug: Optional[str] = None, isLiquidityProvision: Optional[bool] = None, isCancelled: Optional[bool] = None, orderAmount: Optional[float] = None, fills: Optional[float] = None, isFilled: Optional[bool] = None, limitProb: Optional[float] = None, dpmShares: Optional[float] = None, fees: Optional[dict] = None, sale: Optional[dict] = None, isSold: Optional[bool] = None, loanAmount: Optional[float] = None, isRedemption: Optional[bool] = None, isAnte: Optional[bool] = None, userId: Optional[str] = None)
Bases:
objectA single bet
- amount: int
- answerId: str
- challengeSlug: Optional[str]
- contractId: str
- createdTime: int
- fees: Optional[dict]
- fills: Optional[float]
- id: str
- isAnte: Optional[bool]
- isCancelled: Optional[bool]
- isFilled: Optional[bool]
- isLiquidityProvision: Optional[bool]
- isRedemption: Optional[bool]
- isSold: Optional[bool]
- limitProb: Optional[float]
- loanAmount: Optional[float]
- orderAmount: Optional[float]
- outcome: str
- probAfter: float
- probBefore: float
- sale: Optional[dict]
- userId: Optional[str]
- class manifoldpy.api.Comment(id: str, commentId: str, contractId: str, contractQuestion: str, userUsername: str, userAvatarUrl: str, userId: str, createdTime: int, userName: str, content: str, commentType: str, contractSlug: str, visibility: bool, isApi: bool, betId: Optional[str] = None, betAmount: Optional[float] = None, betOutcome: Optional[Any] = None, replyToCommentId: Optional[str] = None, likes: Optional[int] = None, commentorPositionProb: Optional[float] = None, commentorPositionOutcome: Optional[Any] = None, commentorPositionShares: Optional[float] = None, commentorPositionAnswerId: Optional[str] = None, commenterPositionProb: Optional[float] = None, commenterPositionOutcome: Optional[Any] = None, commenterPositionShares: Optional[float] = None, answerOutcome: Optional[str] = None, hiderId: Optional[str] = None, hidden: Optional[bool] = None, hiddenTime: Optional[int] = None, bettorName: Optional[str] = None, bettorUsername: Optional[str] = None, editedTime: Optional[int] = None, betAnswerId: Optional[str] = None, bountyAwarded: Optional[bool] = None, betReplyAmountsByOutcome: Optional[Dict[str, int]] = None, *, isRepost: Optional[bool] = None, betToken: Optional[str] = None, bets: Optional[list[str]] = None, bettorId: Optional[str] = None, betOrderAmount: Optional[float] = None, betLimitProb: Optional[float] = None)
Bases:
objectA comment on a market
- answerOutcome: Optional[str]
- betAmount: Optional[float]
- betAnswerId: Optional[str]
- betId: Optional[str]
- betLimitProb: Optional[float]
- betOrderAmount: Optional[float]
- betOutcome: Optional[Any]
- betReplyAmountsByOutcome: Optional[Dict[str, int]]
- betToken: Optional[str]
- bets: Optional[list[str]]
- bettorId: Optional[str]
- bettorName: Optional[str]
- bettorUsername: Optional[str]
- bountyAwarded: Optional[bool]
- commentId: str
- commentType: str
- commenterPositionOutcome: Optional[Any]
- commenterPositionProb: Optional[float]
- commentorPositionAnswerId: Optional[str]
- commentorPositionOutcome: Optional[Any]
- commentorPositionProb: Optional[float]
- content: str
- contractId: str
- contractQuestion: str
- contractSlug: str
- createdTime: int
- editedTime: Optional[int]
- hiderId: Optional[str]
- id: str
- isApi: bool
- isRepost: Optional[bool]
- likes: Optional[int]
- replyToCommentId: Optional[str]
- userAvatarUrl: str
- userId: str
- userName: str
- userUsername: str
- visibility: bool
- class manifoldpy.api.ContractMetric(contractId: str, from_dict: dict, hasNoShares: bool, hasShares: bool, hasYesShares: bool, invested: float, loan: float, maxSharesOutcome: Optional[str], payout: float, profit: float, profitPercent: float, totalShares: dict, userId: str, userUsername: str, userName: str, userAvatarUrl: str, lastBetTime: float)
Bases:
object- contractId: str
- from_dict: dict
- classmethod from_json(json_dict: dict) ContractMetric
- invested: float
- lastBetTime: float
- loan: float
- payout: float
- profit: float
- profitPercent: float
- userAvatarUrl: str
- userId: str
- userName: str
- userUsername: str
- class manifoldpy.api.Group(mostRecentActivityTime: int, aboutPostId: str, creatorId: str, mostRecentContractAddedTime: int, anyoneCanJoin: bool, name: str, totalMembers: int, createdTime: int, about: str, slug: str, id: str, totalContracts: Any, cachedLeaderboard: Dict[str, Any], pinnedItems: List[Any])
Bases:
object“A Manifold group Note that tags count as groups.
- about: str
- aboutPostId: str
- anyoneCanJoin: bool
- cachedLeaderboard: Dict[str, Any]
- createdTime: int
- creatorId: str
- id: str
- mostRecentActivityTime: int
- mostRecentContractAddedTime: int
- name: str
- pinnedItems: List[Any]
- slug: str
- totalContracts: Any
- totalMembers: int
- class manifoldpy.api.Market(id: str, creatorUsername: str, creatorName: str, createdTime: int, question: str, url: str, slug: str, pool: Dict[str, float], volume: float, volume24Hours: float, outcomeType: Literal['BINARY', 'FREE_RESPONSE', 'PSEUDO_NUMERIC', 'MULTIPLE_CHOICE', 'NUMERIC', 'MULTI_NUMERIC', 'QUADRATIC_FUNDING', 'STONK', 'POLL', 'BOUNTIED_QUESTION', 'DATE'], mechanism: str, isResolved: bool, lastUpdatedTime: int, closeTime: int, creatorId: str, creatorAvatarUrl: str, uniqueBettorCount: int, probability: float, answers: Optional[Any] = None, *, resolutionProbability: Optional[float] = None, resolverId: Optional[str] = None, p: Optional[float] = None, totalLiquidity: Optional[float] = None, resolution: Optional[str] = None, resolutionTime: Optional[int] = None, lastBetTime: Optional[float] = None, lastCommentTime: Optional[int] = None, min: Optional[int] = None, max: Optional[int] = None, isLogScale: Optional[bool] = None, textDescription: Optional[str] = None, description: Optional[dict] = None, bets: Optional[List[Bet]] = None, comments: Optional[List[Comment]] = None, marketTier: Optional[str] = None, visibility: Optional[str] = None, token: Optional[str] = None, siblingContractId: Optional[str] = None, deleted: Optional[bool] = None)
Bases:
objectA market
- answers: Optional[Any]
- closeTime: int
- createdTime: int
- creatorAvatarUrl: str
- creatorId: str
- creatorName: str
- creatorUsername: str
- deleted: Optional[bool]
- description: Optional[dict]
- final_probability() float
Get the final probability of this market
- get_updates() Tuple[ndarray, ndarray]
Get all updates to this market.
- Returns
The time of each update, and the probabilities after each update.
- Return type
Tuple[np.ndarray, np.ndarray]
- id: str
- isLogScale: Optional[bool]
- isResolved: bool
- lastBetTime: Optional[float]
- lastCommentTime: Optional[int]
- lastUpdatedTime: int
- marketTier: Optional[str]
- max: Optional[int]
- mechanism: str
- min: Optional[int]
- num_traders() int
- outcomeType: Literal['BINARY', 'FREE_RESPONSE', 'PSEUDO_NUMERIC', 'MULTIPLE_CHOICE', 'NUMERIC', 'MULTI_NUMERIC', 'QUADRATIC_FUNDING', 'STONK', 'POLL', 'BOUNTIED_QUESTION', 'DATE']
- p: Optional[float]
- pool: Dict[str, float]
- probability: float
- probability_history() Tuple[ndarray, ndarray]
- question: str
- resolution: Optional[str]
- resolutionProbability: Optional[float]
- resolutionTime: Optional[int]
- resolverId: Optional[str]
- siblingContractId: Optional[str]
- slug: str
- start_probability() float
Get the starting probability of the market
- textDescription: Optional[str]
- token: Optional[str]
- totalLiquidity: Optional[float]
- uniqueBettorCount: int
- url: str
- visibility: Optional[str]
- volume: float
- volume24Hours: float
- class manifoldpy.api.User(id: str, createdTime: int, name: str, username: str, url: str, avatarUrl: str, balance: float, totalDeposits: float, profitCached: Dict[str, Optional[float]], creatorVolumeCached: Dict[str, float], bio: Optional[str] = None, twitterHandle: Optional[str] = None, discordHandle: Optional[str] = None, bannerUrl: Optional[str] = None, website: Optional[str] = None)
Bases:
objectA manifold user
- avatarUrl: str
- balance: float
- bannerUrl: Optional[str]
- bio: Optional[str]
- createdTime: int
- creatorVolumeCached: Dict[str, float]
- discordHandle: Optional[str]
- id: str
- name: str
- profitCached: Dict[str, Optional[float]]
- totalDeposits: float
- twitterHandle: Optional[str]
- url: str
- username: str
- website: Optional[str]
- manifoldpy.api.add_liquidity(key: str, *args, **kwargs)
- manifoldpy.api.cancel_bet(key: str, *args, **kwargs)
- manifoldpy.api.create_market(key: str, *args, **kwargs)
- manifoldpy.api.get_bets(userId: Optional[str] = None, username: Optional[str] = None, marketId: Optional[str] = None, marketSlug: Optional[str] = None, limit: Optional[int] = 1000, before: Optional[str] = None) List[Bet]
Get bets, optionally associated with a user or market. Retrieves at most 1000 bets. [API reference](https://docs.manifold.markets/api#get-v0bets)
- Parameters
userId – ID of user to get bets for.
username – Username of user to get bets for.
marketId – The market to get bets for.
marketSlug – Slug of the market to get bets for
limit – Number of bets to return. Maximum 1000.
before – ID of a bet to fetch bets before.
as_json – If true, return the raw json instead of a list of Bet objects.
- manifoldpy.api.get_comments(marketId: Optional[str] = None, marketSlug: Optional[str] = None) List[Comment]
Get comments, optionally for a market.
- Parameters
marketId – Id of the market to get comments for.
marketSlug – Slug of the market to get comments for.
- manifoldpy.api.get_full_market(market_id: str) Market
Get a single full market. Will include bets and comments
- Parameters
market_id – ID of the market to fetch.
- manifoldpy.api.get_market(market_id: str) Market
Get a single market. Will not include bets or comments.
- Parameters
market_id – ID of the market to get.
- manifoldpy.api.get_market_positions(market_id: str, order: Optional[Literal['shares', 'profit']] = None, top: Optional[int] = None, bottom: Optional[int] = None, userId: Optional[str] = None) List[ContractMetric]
Get the positions on a single market.
- Parameters
market_id – ID of the market to get.
order – The ordering for results. Can be either “profit” or “shares”.
top – The number of top positions (ordered by order) to return.
bottom – The number of bottom positions (ordered by order) to return.
userId – The user ID to query by. Default: null. If provided, only the position for this user will be returned.
- manifoldpy.api.get_markets(limit: int = 1000, before: Optional[str] = None) List[Market]
Get a list of markets (not including comments or bets). [API reference](https://docs.manifold.markets/api#get-v0markets)
- Parameters
limit – Number of markets to fetch. Max 1000.
before – ID of a market to fetch markets before.
- manifoldpy.api.get_slug(slug: str) Market
Get a market by its slug. [API reference](https://docs.manifold.markets/api#get-v0slugmarketslug)
- manifoldpy.api.get_user_by_id(user_id: str) User
Get the data for one user from their username [API reference](https://docs.manifold.markets/api#get-v0userby-idid)
- Parameters
user_id – The user’s ID.
- manifoldpy.api.get_user_by_name(username: str) User
Get the data for one user from their username [API reference](https://docs.manifold.markets/api#get-v0userusername)
- Parameters
username – The user’s username.
- manifoldpy.api.get_users(limit: int = 1000, before: Optional[str] = None) List[User]
Get users up to a limit. [API reference](https://docs.manifold.markets/api#get-v0users)
- Parameters
limit – The maximum number of users to get.
before – The ID of a user to get users before.
- Returns
A list of users.
- manifoldpy.api.make_bet(key: str, *args, **kwargs)
- manifoldpy.api.me(key: str, *args, **kwargs)
- manifoldpy.api.resolve_market(key: str, *args, **kwargs)
- manifoldpy.api.search_markets(terms: List[str]) List[Market]
Search markets by terms. Returns at most 100 markets. :param terms: A list of search terms. Must not contain spaces.
- manifoldpy.api.use_api(f)
Automatically create an API Wrapper and use it
- manifoldpy.api.weak_structure(json: dict, cls: Type[T]) T
- manifoldpy.api.weak_unstructure(obj: Any) Dict[str, Any]
Convert an attrs class to a dict.