Skip to content

Instantly share code, notes, and snippets.

@chrisjbillington
Created April 3, 2023 10:08
Show Gist options
  • Save chrisjbillington/cc4e74659f1f65c7cdf09676e61ee330 to your computer and use it in GitHub Desktop.
Save chrisjbillington/cc4e74659f1f65c7cdf09676e61ee330 to your computer and use it in GitHub Desktop.
import numpy as np
from manifoldpy import api
MARKET_ID = "NRLwgQYqCLk5zTasmxOn"
market = api.get_market(MARKET_ID)
t0 = market.createdTime
tclose = market.closeTime
bets = api.get_all_bets(marketId=MARKET_ID)[::-1]
t = np.array([t0] + [bet.createdTime for bet in bets] + [tclose])
p = 100 * np.array([0.5] + [bet.probAfter for bet in bets])
# rounding:
within_two_of_edges = (p < 2) | (p > 98)
p[within_two_of_edges] = np.round(p[within_two_of_edges], 1)
p[~within_two_of_edges] = np.round(p[~within_two_of_edges], 0)
avg = (p * np.diff(t)).sum() / (t[-1] - t[0])
print(f"Market average is: {avg:.3f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment