Skip to main content

Python tools for working with Manifold Markets

Project description

manifoldpy

CircleCI Documentation Status PyPI version codecov

Tools for analyzing Manifold Markets data. Currently has bindings for their API, and code for computing various accuracy metrics (Brier score, log score, calibration).

Full Documentation.

Calibration

This is the most recent calibration graph for Manifold Markets. Markets with less than 4 unique traders are excluded. The calibration is generated from the probability halfway between market open and market close.

Midmarket calibration

Installation

The package is on PyPI as manifoldpy. It can be installed with:

pip install manifoldpy

However, you may want to install the most up-to-date version from github instead if you encounter any issues:

pip install --upgrade https://github.com/vluzko/manifoldpy/tarball/main

Basic Usage

Get a list containing every market:

from manifoldpy import api
markets = api.get_all_markets()

Manifold also has a POST API that lets you make/resolve/bet on markets. This requires you to have an API key (which you can generate on your Manifold profile page). Here's an example for making a bet on a binary market:

from manifoldpy import api
# Amount to spend
amount = 100
# The ID of the market to bet on
contract_id = "8Lt9ZTHCPCK58gtn0Y8n"
# The outcome you want to bet on.
outcome = "YES"
api.make_bet(YOUR_API_KEY, amount, contract_id, outcome)

If you want to avoid passing the key every time, you can instead create an APIWrapper and use that:

from manifoldpy import api
wrapper = api.APIWrapper(YOUR_API_KEY)
amount = 100
contract_id = "8Lt9ZTHCPCK58gtn0Y8n"
outcome = "YES"
wrapper.make_bet(amount, contract_id, outcome)

Get a market's history of probabilities:

from manifoldpy import api
market = api.get_market("market_id")
times, probabilities = market.probability_history()

Generate a basic calibration graph:

from manifoldpy import api, calibration
full_markets = api.get_full_markets()
binary = [
    m for m in full_markets if isinstance(m, api.BinaryMarket) and m.isResolved
]
df, histories = calibration.build_dataframe(binary)

yes_markets = df[df["resolution"] == "YES"]
no_markets = df[df["resolution"] == "NO"]

# Calibration at start
yes_probs = yes_markets["start"]
no_probs = no_markets["start"]
calibration = calibration.market_set_accuracy(yes_probs, no_probs)

There are additional examples for analyzing market calibration in the scripts/ directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manifoldpy-1.1.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

manifoldpy-1.1.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file manifoldpy-1.1.2.tar.gz.

File metadata

  • Download URL: manifoldpy-1.1.2.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for manifoldpy-1.1.2.tar.gz
Algorithm Hash digest
SHA256 1d97d1c63a8c32fe9ecc0a43d18ea3292c44d864acab6c3e9ddd766a92185f4c
MD5 8c59623a8c68866b4aaa4c5b54afeaa9
BLAKE2b-256 8d20fd448781cb7766e0f8b84936575c8f36fd2b2511c472f57f2dd35927d8cd

See more details on using hashes here.

File details

Details for the file manifoldpy-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: manifoldpy-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for manifoldpy-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c47e4b06cbde5c6c5653352d00fd9d5bc2033e30f7fc46d302fee442c0195588
MD5 26e81455b512b827075873dabde5bb07
BLAKE2b-256 80735c5f2d371bc2451cea9f9721787f6a06bee6ef833b2e9752acf6faf381c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page