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.data/types.ml.html
Source file types.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307(** Data API types for Polymarket. These types correspond to the OpenAPI 3.0.3 schema defined in data-api-openapi.yaml for the Polymarket Data API (https://data-api.polymarket.com). *) open Ppx_yojson_conv_lib.Yojson_conv.Primitives (** {1 Query Parameter Enums} *) module Sort_direction = struct type t = Asc | Desc [@@deriving enum] end module Position_sort_by = struct type t = | Current | Initial | Tokens | Cashpnl | Percentpnl | Title | Resolving | Price | Avgprice [@@deriving enum] end module Filter_type = struct type t = Cash | Tokens [@@deriving enum] end module Activity_sort_by = struct type t = Timestamp | Tokens | Cash [@@deriving enum] end module Closed_position_sort_by = struct type t = Realizedpnl | Title | Price | Avgprice | Timestamp [@@deriving enum] end module Time_period = struct type t = Day | Week | Month | All [@@deriving enum] end module Leaderboard_category = struct type t = | Overall | Politics | Sports | Crypto | Culture | Mentions | Weather | Economics | Tech | Finance [@@deriving enum] end module Leaderboard_order_by = struct type t = Pnl | Vol [@@deriving enum] end (** {1 Domain Enums} *) module Side = Polymarket_common.Primitives.Side (** Re-export shared Side module from Common.Primitives *) module Activity_type = struct type t = Trade | Split | Merge | Redeem | Reward | Conversion [@@deriving enum] end (** {1 Response Types} *) type health_response = { data : string } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Health check response *) type error = Polymarket_http.Client.error (** Structured error type for all API errors *) let error_to_string = Polymarket_http.Client.error_to_string let pp_error = Polymarket_http.Client.pp_error (** {1 Domain Models} *) type position = { proxy_wallet : Polymarket_common.Primitives.Address.t; [@key "proxyWallet"] asset : string; condition_id : Polymarket_common.Primitives.Hash64.t; [@key "conditionId"] size : float; avg_price : float; [@key "avgPrice"] initial_value : float; [@key "initialValue"] current_value : float; [@key "currentValue"] cash_pnl : float; [@key "cashPnl"] percent_pnl : float; [@key "percentPnl"] total_bought : float; [@key "totalBought"] realized_pnl : float; [@key "realizedPnl"] percent_realized_pnl : float; [@key "percentRealizedPnl"] cur_price : float; [@key "curPrice"] redeemable : bool; mergeable : bool; title : string; slug : string; icon : string; event_slug : string; [@key "eventSlug"] outcome : string; outcome_index : int; [@key "outcomeIndex"] opposite_outcome : string; [@key "oppositeOutcome"] opposite_asset : string; [@key "oppositeAsset"] end_date : string; [@key "endDate"] negative_risk : bool; [@key "negativeRisk"] event_id : string; [@key "eventId"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Position in a market *) type closed_position = { proxy_wallet : Polymarket_common.Primitives.Address.t; [@key "proxyWallet"] asset : string; condition_id : Polymarket_common.Primitives.Hash64.t; [@key "conditionId"] avg_price : float; [@key "avgPrice"] total_bought : float; [@key "totalBought"] realized_pnl : float; [@key "realizedPnl"] cur_price : float; [@key "curPrice"] timestamp : int64; title : string; slug : string; icon : string; event_slug : string; [@key "eventSlug"] outcome : string; outcome_index : int; [@key "outcomeIndex"] opposite_outcome : string; [@key "oppositeOutcome"] opposite_asset : string; [@key "oppositeAsset"] end_date : string; [@key "endDate"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Closed position in a market *) type trade = { proxy_wallet : Polymarket_common.Primitives.Address.t; [@key "proxyWallet"] side : Side.t; asset : string; condition_id : Polymarket_common.Primitives.Hash64.t; [@key "conditionId"] size : float; price : float; timestamp : int64; title : string; slug : string; icon : string; event_slug : string; [@key "eventSlug"] outcome : string; outcome_index : int; [@key "outcomeIndex"] name : string; pseudonym : string; bio : string; profile_image : string; [@key "profileImage"] profile_image_optimized : string; [@key "profileImageOptimized"] transaction_hash : string; [@key "transactionHash"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Trade record *) type activity = { proxy_wallet : Polymarket_common.Primitives.Address.t; [@key "proxyWallet"] timestamp : int64; condition_id : Polymarket_common.Primitives.Hash64.t; [@key "conditionId"] activity_type : Activity_type.t; [@key "type"] size : float; usdc_size : float; [@key "usdcSize"] transaction_hash : string; [@key "transactionHash"] price : float; asset : string; side : Side.t; outcome_index : int; [@key "outcomeIndex"] title : string; slug : string; icon : string; event_slug : string; [@key "eventSlug"] outcome : string; name : string; pseudonym : string; bio : string; profile_image : string; [@key "profileImage"] profile_image_optimized : string; [@key "profileImageOptimized"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Activity record *) type holder = { proxy_wallet : Polymarket_common.Primitives.Address.t; [@key "proxyWallet"] bio : string; asset : string; pseudonym : string; amount : float; display_username_public : bool; [@key "displayUsernamePublic"] outcome_index : int; [@key "outcomeIndex"] name : string; profile_image : string; [@key "profileImage"] profile_image_optimized : string; [@key "profileImageOptimized"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Holder of a position *) type meta_holder = { token : string; holders : holder list } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Meta holder with token and list of holders *) type traded = { user : Polymarket_common.Primitives.Address.t; traded : int } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Traded record *) type revision_entry = { revision : string; timestamp : int } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Revision entry *) type revision_payload = { question_id : Polymarket_common.Primitives.Hash64.t; [@key "questionID"] revisions : revision_entry list; } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Revision payload *) type value = { user : Polymarket_common.Primitives.Address.t; value : float } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Value record *) type open_interest = { market : string; (** Can be "GLOBAL" or a condition ID hash *) value : float; } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Open interest for a market *) type market_volume = { market : Polymarket_common.Primitives.Hash64.t option; [@yojson.option] value : float option; [@yojson.option] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Market volume *) type live_volume = { total : float option; [@yojson.option] markets : market_volume list; [@default []] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Live volume *) (** Custom deserializer for live_volume that handles null markets *) let live_volume_of_yojson json = match json with | `Assoc fields -> let total = match List.assoc_opt "total" fields with | Some (`Float f) -> Some f | Some (`Int i) -> Some (float_of_int i) | Some `Null | None -> None | _ -> None in let markets = match List.assoc_opt "markets" fields with | Some `Null | None -> [] | Some (`List items) -> List.map market_volume_of_yojson items | _ -> [] in { total; markets } | _ -> failwith "live_volume_of_yojson: expected object" (** {1 Leaderboard Types} *) type leaderboard_entry = { rank : string; builder : string; volume : float; active_users : int; [@key "activeUsers"] verified : bool; builder_logo : string; [@key "builderLogo"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Leaderboard entry for builders *) type builder_volume_entry = { dt : Polymarket_common.Primitives.Timestamp.t; builder : string; builder_logo : string; [@key "builderLogo"] verified : bool; volume : float; active_users : int; [@key "activeUsers"] rank : string; } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Builder volume entry *) type trader_leaderboard_entry = { rank : string; proxy_wallet : Polymarket_common.Primitives.Address.t; [@key "proxyWallet"] user_name : string; [@key "userName"] vol : float; pnl : float; profile_image : string; [@key "profileImage"] x_username : string; [@key "xUsername"] verified_badge : bool; [@key "verifiedBadge"] } [@@yojson.allow_extra_fields] [@@deriving yojson, show, eq, yojson_fields] (** Trader leaderboard entry *)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>