package polymarket
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
OCaml client library for the Polymarket prediction market API
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.2.0.tar.gz
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276
doc/src/polymarket.rate_limiter/gcra.ml.html
Source file gcra.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41(** Generic Cell Rate Algorithm (GCRA) for rate limiting. *) type t = { mutable tat : float; (** Theoretical Arrival Time *) emission_interval : float; (** Time between requests at sustained rate *) burst_allowance : float; (** Maximum burst allowance in seconds *) } let create (config : Types.limit_config) = let emission_interval = config.window_seconds /. float_of_int config.requests in let burst_allowance = config.window_seconds in { tat = 0.0; emission_interval; burst_allowance } let check t ~now = let allow_at = t.tat -. t.burst_allowance in if now >= allow_at then Ok () else let retry_after = allow_at -. now in Error retry_after let update t ~now = let new_tat = Float.max now t.tat +. t.emission_interval in t.tat <- new_tat let check_and_update t ~now = match check t ~now with | Error _ as e -> e | Ok () -> update t ~now; Ok () let reset t = t.tat <- 0.0 let time_until_ready t ~now = let allow_at = t.tat -. t.burst_allowance in Float.max 0.0 (allow_at -. now) let emission_interval t = t.emission_interval let burst_allowance t = t.burst_allowance
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>