ManifoldMarketManager.util
Contains utility functions.
- class ManifoldMarketManager.util.DictDeserializable[source]
Bases:
object
A port of PyManifold’s DictDeserializable that does not check against the signature.
- ManifoldMarketManager.util.dynamic_import(fname: str, mname: str, __all__: MutableSequence[str], exempt: Collection[str]) None [source]
Dynamically import submodules and add them to the export list.
- ManifoldMarketManager.util.explain_abstract(time_rules: Iterable[Rule[Any]], value_rules: Iterable[Rule[Any]], **kwargs: Any) str [source]
Explain how the market will resolve and decide to resolve.
- ManifoldMarketManager.util.fibonacci(start: int = 1) Iterable[int] [source]
Iterate over the fibonacci numbers.
- ManifoldMarketManager.util.get_client(account: Optional[Account] = None) ManifoldClient [source]
Return a (possibly non-unique) Manifold client.
- ManifoldMarketManager.util.hash_to_randrange(buff: bytes, *args: int, **kwargs: int) int [source]
Generate a ‘random’ number by hashing a buffer.
- ManifoldMarketManager.util.market_to_answer_map(market: Market | APIMarket, exclude: Collection[int] = (), *filters: Callable[[int, float], bool]) dict[int, float] [source]
Given a market, grab its current list of answers and put it in a standardized format, applying given filters.
Parameters
- marketMarket | PyManifold.lib.Market
The market wrapper for which we want the current answer pool.
- excludeCollection[int], optional
Some collection of ids to exclude. Preferrably a set() or range(). by default ()
- filters*Callable[[int, float], bool]
A collection of functions which will be fed the answer ID and probability. If any return True, that answer is excluded. By default ()
Returns
- Mapping[int, float]
A mapping of integer ids to probabilities in [0…1]. Note that Manifold expects ids as strings, but they are returned as integers for ease of processing. Note also that this mapping is NOT normalized.
Raises
- RuntimeError
If a non-supported market is fed
- ManifoldMarketManager.util.normalize_mapping(answers: Mapping[T, float]) dict[T, float] [source]
Take a mapping of answers and normalize it such that the sum of their weights is 1.
- ManifoldMarketManager.util.require_env(*env: str) Callable[[Callable[..., T]], Callable[..., T]] [source]
Enforce the presence of environment variables that may be necessary for a function to properly run.