https://github.com/bcongdon/pymanifold
Python API client for Manifold Markets
https://github.com/bcongdon/pymanifold
Last synced: 9 months ago
JSON representation
Python API client for Manifold Markets
- Host: GitHub
- URL: https://github.com/bcongdon/pymanifold
- Owner: bcongdon
- License: mit
- Created: 2022-06-15T14:59:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-18T00:13:26.000Z (about 3 years ago)
- Last Synced: 2025-03-29T00:12:00.090Z (10 months ago)
- Language: Python
- Size: 1.39 MB
- Stars: 15
- Watchers: 4
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyManifold
Python API client for [Manifold Markets](https://manifold.markets).
This is still a work in progress.
## Usage
```python
from pymanifold import ManifoldClient
# List markets
client = ManifoldClient()
markets = client.list_markets()
# Get market by slug
slug = "will-bitcoins-price-fall-below-25k"
market = client.get_market_by_slug("will-bitcoins-price-fall-below-25k")
# Get market by id
id = "rIR6mWqaO9xKLifr6cLL"
market = client.get_market_by_id(id)
# Create a bet
betId = client.create_bet(contractId="BxFQCoaaxBqRcnzJb1mV", amount=1, outcome="NO")
# Create a market
client = ManifoldClient(api_key=API_KEY)
market = client.create_binary_market(
question="Testing Binary Market creation through API",
initialProb=99,
description="Going to resolves as N/A",
tags=["fun"],
closeTime=4102444800000,
)
# Find optimal Kelly bet
from pymanifold.utils import kelly_calc
market = client.get_market_by_slug("for-this-study-published-in-nature")
utils.kelly_calc(
market = market
subjective_probability = 0.8
balance = 800
initial_market_probability = 0.5
)
```
## TODO
- [ ] Publish a version of this package to PyPI
- [ ] Add instructions for running tests that require an API key (e.g. setting the `MANIFOLD_API_KEY` environment variable)
- [ ] Generalize `kelly_bet` to correlated markets
## Running Tests
```sh
$ poetry run pytest
```