File size: 26,904 Bytes
330cbe3
 
 
 
 
 
 
 
 
 
 
e91be24
330cbe3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e91be24
330cbe3
 
 
 
 
 
e91be24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330cbe3
 
3bc6a67
330cbe3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3bc6a67
 
 
 
 
 
 
 
 
 
330cbe3
 
3bc6a67
330cbe3
3bc6a67
 
330cbe3
3bc6a67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330cbe3
 
 
 
 
 
 
3bc6a67
 
 
330cbe3
 
3bc6a67
 
 
330cbe3
 
3bc6a67
 
 
330cbe3
 
3bc6a67
330cbe3
 
 
 
 
3bc6a67
330cbe3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3bc6a67
330cbe3
3bc6a67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330cbe3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/cyberosa/.pyenv/versions/3.12.2/envs/hf_dashboards/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import gradio as gr\n",
    "import plotly.express as px\n",
    "import plotly.graph_objects as go\n",
    "from plotly.subplots import make_subplots\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "div_data = pd.read_parquet(\"../data/closed_markets_div.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>currentAnswer</th>\n",
       "      <th>id</th>\n",
       "      <th>openingTimestamp</th>\n",
       "      <th>market_creator</th>\n",
       "      <th>opening_datetime</th>\n",
       "      <th>first_outcome_prob</th>\n",
       "      <th>second_outcome_prob</th>\n",
       "      <th>kl_divergence</th>\n",
       "      <th>off_by_perc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>yes</td>\n",
       "      <td>0x5cae41dcc8a30d76a31b126c6f3b358b8d0131ca</td>\n",
       "      <td>1731542400</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-11-14 01:00:00</td>\n",
       "      <td>0.3679</td>\n",
       "      <td>0.6321</td>\n",
       "      <td>0.999944</td>\n",
       "      <td>63.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>yes</td>\n",
       "      <td>0xf8442bd26cd80d8447bb6203ededc44a77cd2a12</td>\n",
       "      <td>1731542400</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-11-14 01:00:00</td>\n",
       "      <td>0.3368</td>\n",
       "      <td>0.6632</td>\n",
       "      <td>1.088266</td>\n",
       "      <td>66.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>yes</td>\n",
       "      <td>0xde3a4b0d527013165b1b6b8aae051d223f8b770e</td>\n",
       "      <td>1731542400</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-11-14 01:00:00</td>\n",
       "      <td>0.4468</td>\n",
       "      <td>0.5532</td>\n",
       "      <td>0.805644</td>\n",
       "      <td>55.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>yes</td>\n",
       "      <td>0xccadef7757659ce271b209d647c2a51fabd88c77</td>\n",
       "      <td>1731542400</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-11-14 01:00:00</td>\n",
       "      <td>0.6804</td>\n",
       "      <td>0.3196</td>\n",
       "      <td>0.385074</td>\n",
       "      <td>31.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>no</td>\n",
       "      <td>0x78d0fc5884e74d87b0529e40da2b9490db60e731</td>\n",
       "      <td>1731628800</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-11-15 01:00:00</td>\n",
       "      <td>0.2358</td>\n",
       "      <td>0.7642</td>\n",
       "      <td>0.268926</td>\n",
       "      <td>23.58</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  currentAnswer                                          id openingTimestamp  \\\n",
       "0           yes  0x5cae41dcc8a30d76a31b126c6f3b358b8d0131ca       1731542400   \n",
       "1           yes  0xf8442bd26cd80d8447bb6203ededc44a77cd2a12       1731542400   \n",
       "2           yes  0xde3a4b0d527013165b1b6b8aae051d223f8b770e       1731542400   \n",
       "3           yes  0xccadef7757659ce271b209d647c2a51fabd88c77       1731542400   \n",
       "4            no  0x78d0fc5884e74d87b0529e40da2b9490db60e731       1731628800   \n",
       "\n",
       "  market_creator    opening_datetime  first_outcome_prob  second_outcome_prob  \\\n",
       "0     quickstart 2024-11-14 01:00:00              0.3679               0.6321   \n",
       "1     quickstart 2024-11-14 01:00:00              0.3368               0.6632   \n",
       "2     quickstart 2024-11-14 01:00:00              0.4468               0.5532   \n",
       "3     quickstart 2024-11-14 01:00:00              0.6804               0.3196   \n",
       "4     quickstart 2024-11-15 01:00:00              0.2358               0.7642   \n",
       "\n",
       "   kl_divergence  off_by_perc  \n",
       "0       0.999944        63.21  \n",
       "1       1.088266        66.32  \n",
       "2       0.805644        55.32  \n",
       "3       0.385074        31.96  \n",
       "4       0.268926        23.58  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "div_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2024-12-28 01:00:00')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "max(div_data.opening_datetime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>currentAnswer</th>\n",
       "      <th>id</th>\n",
       "      <th>openingTimestamp</th>\n",
       "      <th>market_creator</th>\n",
       "      <th>opening_datetime</th>\n",
       "      <th>first_outcome_prob</th>\n",
       "      <th>second_outcome_prob</th>\n",
       "      <th>kl_divergence</th>\n",
       "      <th>off_by_perc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>yes</td>\n",
       "      <td>0x5feab3ad41a2575461b06c5e911d67d3616ee17e</td>\n",
       "      <td>1723420800</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-08-12 02:00:00</td>\n",
       "      <td>0.9034</td>\n",
       "      <td>0.0966</td>\n",
       "      <td>0.101590</td>\n",
       "      <td>9.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>yes</td>\n",
       "      <td>0x99a7e8be86a78cf2096a15887e9add122ff113d2</td>\n",
       "      <td>1723593600</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-08-14 02:00:00</td>\n",
       "      <td>0.9050</td>\n",
       "      <td>0.0950</td>\n",
       "      <td>0.099820</td>\n",
       "      <td>9.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194</th>\n",
       "      <td>no</td>\n",
       "      <td>0x34acf849dd645b559ddbf09059df39a1d9b10f18</td>\n",
       "      <td>1723939200</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-08-18 02:00:00</td>\n",
       "      <td>0.0893</td>\n",
       "      <td>0.9107</td>\n",
       "      <td>0.093542</td>\n",
       "      <td>8.93</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    currentAnswer                                          id  \\\n",
       "120           yes  0x5feab3ad41a2575461b06c5e911d67d3616ee17e   \n",
       "148           yes  0x99a7e8be86a78cf2096a15887e9add122ff113d2   \n",
       "194            no  0x34acf849dd645b559ddbf09059df39a1d9b10f18   \n",
       "\n",
       "    openingTimestamp market_creator    opening_datetime  first_outcome_prob  \\\n",
       "120       1723420800     quickstart 2024-08-12 02:00:00              0.9034   \n",
       "148       1723593600     quickstart 2024-08-14 02:00:00              0.9050   \n",
       "194       1723939200     quickstart 2024-08-18 02:00:00              0.0893   \n",
       "\n",
       "     second_outcome_prob  kl_divergence  off_by_perc  \n",
       "120               0.0966       0.101590         9.66  \n",
       "148               0.0950       0.099820         9.50  \n",
       "194               0.9107       0.093542         8.93  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "div_data.loc[div_data[\"off_by_perc\"]<=10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>currentAnswer</th>\n",
       "      <th>id</th>\n",
       "      <th>openingTimestamp</th>\n",
       "      <th>market_creator</th>\n",
       "      <th>opening_datetime</th>\n",
       "      <th>first_outcome_prob</th>\n",
       "      <th>second_outcome_prob</th>\n",
       "      <th>kl_divergence</th>\n",
       "      <th>off_by_perc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>no</td>\n",
       "      <td>0x927beda324bfd4514a7b64ab5594451fdaf4796e</td>\n",
       "      <td>1722816000</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-08-05 02:00:00</td>\n",
       "      <td>0.8792</td>\n",
       "      <td>0.1208</td>\n",
       "      <td>2.113619</td>\n",
       "      <td>87.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>yes</td>\n",
       "      <td>0x90bb15982f2b5a5f044ad8ff49fe20daddfb8ca7</td>\n",
       "      <td>1724803200</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-08-28 02:00:00</td>\n",
       "      <td>0.1166</td>\n",
       "      <td>0.8834</td>\n",
       "      <td>2.149006</td>\n",
       "      <td>88.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>315</th>\n",
       "      <td>no</td>\n",
       "      <td>0x29462bf8c8f24772cd6da03878a4aee5c5813474</td>\n",
       "      <td>1724976000</td>\n",
       "      <td>pearl</td>\n",
       "      <td>2024-08-30 02:00:00</td>\n",
       "      <td>0.9416</td>\n",
       "      <td>0.0584</td>\n",
       "      <td>2.840439</td>\n",
       "      <td>94.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>323</th>\n",
       "      <td>yes</td>\n",
       "      <td>0x0ad9d4edb0a401ec9a5b4f2ccf7942d28c29d4e3</td>\n",
       "      <td>1724976000</td>\n",
       "      <td>quickstart</td>\n",
       "      <td>2024-08-30 02:00:00</td>\n",
       "      <td>0.0499</td>\n",
       "      <td>0.9501</td>\n",
       "      <td>2.997734</td>\n",
       "      <td>95.01</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    currentAnswer                                          id  \\\n",
       "52             no  0x927beda324bfd4514a7b64ab5594451fdaf4796e   \n",
       "293           yes  0x90bb15982f2b5a5f044ad8ff49fe20daddfb8ca7   \n",
       "315            no  0x29462bf8c8f24772cd6da03878a4aee5c5813474   \n",
       "323           yes  0x0ad9d4edb0a401ec9a5b4f2ccf7942d28c29d4e3   \n",
       "\n",
       "    openingTimestamp market_creator    opening_datetime  first_outcome_prob  \\\n",
       "52        1722816000     quickstart 2024-08-05 02:00:00              0.8792   \n",
       "293       1724803200     quickstart 2024-08-28 02:00:00              0.1166   \n",
       "315       1724976000          pearl 2024-08-30 02:00:00              0.9416   \n",
       "323       1724976000     quickstart 2024-08-30 02:00:00              0.0499   \n",
       "\n",
       "     second_outcome_prob  kl_divergence  off_by_perc  \n",
       "52                0.1208       2.113619        87.92  \n",
       "293               0.8834       2.149006        88.34  \n",
       "315               0.0584       2.840439        94.16  \n",
       "323               0.9501       2.997734        95.01  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "div_data.loc[div_data[\"kl_divergence\"]>=2.0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.20518085, 0.22002342, 1.19369249, 0.64569124, 0.42663767,\n",
       "       0.57075257, 1.01638735, 0.5982007 , 0.64454751, 0.26958024,\n",
       "       0.83517168, 0.29249363, 1.09481949, 0.22991644, 0.45381537,\n",
       "       0.83263916, 0.87299181, 0.77522529, 0.12908415, 0.84653149,\n",
       "       0.23736926, 0.66281198, 0.5982007 , 1.76960666, 0.52087596,\n",
       "       0.40481532, 0.82485167, 0.1710256 , 0.31937916, 0.35796149,\n",
       "       0.28621648, 0.16960278, 0.65488847, 0.34150488, 0.57057563,\n",
       "       1.38509508, 0.34220866, 1.03310549, 0.68438567, 1.48943512,\n",
       "       0.61971086, 1.15708922, 0.58429278, 0.14560397, 1.24931891,\n",
       "       1.24514208, 1.10352433, 0.25000101, 0.93547355, 0.42801751,\n",
       "       0.13570518, 0.64454751, 2.11361899, 1.06740436, 0.49823851,\n",
       "       0.51835389, 0.3749844 , 0.23521613, 0.49495227, 0.32739357,\n",
       "       1.11596193, 0.23041996, 1.30453006, 0.36744704, 0.84257569,\n",
       "       0.36614825, 0.66281198, 1.20130969, 0.37483891, 1.72484876,\n",
       "       1.16539332, 0.21245092, 0.8672625 , 0.20998056, 0.57412047,\n",
       "       0.16972127, 0.17482969, 0.47449369, 1.12639467, 0.13536164,\n",
       "       0.19820707, 0.52627773, 0.43463649, 0.30693285, 0.49823851,\n",
       "       0.22639884, 0.48288626, 1.52970294, 0.29008496, 0.16936585,\n",
       "       0.37950501, 0.63017238, 0.15221921, 0.34814004, 0.36326806,\n",
       "       0.43866001, 0.43866001, 0.16063835, 0.15864409, 0.3844867 ,\n",
       "       1.82386952, 0.14768827, 0.16322506, 0.23610215, 1.42628337,\n",
       "       0.34686607, 0.53273046, 0.22189433, 0.60147999, 0.70218793,\n",
       "       0.4001791 , 0.2612349 , 1.19964883, 0.74254753, 0.31910394,\n",
       "       0.72918895, 1.37357559, 0.36759146, 0.25592504, 0.90981177,\n",
       "       0.10158986, 0.12715179, 0.21418381, 0.301781  , 0.35069287,\n",
       "       0.33799339, 0.46092497, 0.25967788, 0.22840738, 0.6361999 ,\n",
       "       0.53939658, 0.74633701, 0.331425  , 0.40466543, 1.10292156,\n",
       "       0.25993721, 0.31649315, 0.93216608, 1.71813733, 0.81283202,\n",
       "       0.57839094, 0.28634963, 0.3478568 , 0.23610215, 0.67197295,\n",
       "       0.86014672, 0.65411879, 1.21334997, 0.09982034, 0.17173776,\n",
       "       0.43866001, 0.23319389, 0.97577538, 0.83378951, 0.46187674,\n",
       "       0.59438841, 0.67354065, 0.97259657, 0.50385001, 0.41218765,\n",
       "       1.43338597, 0.76485803, 0.2527011 , 0.1321609 , 0.61046181,\n",
       "       1.03930618, 0.49249467, 0.16146067, 0.11160218, 0.16075578,\n",
       "       0.38816561, 0.56721962, 0.81916402, 0.91854327, 1.7406862 ,\n",
       "       0.77870507, 0.83863549, 1.10745124, 0.99047563, 0.20874767,\n",
       "       0.11428915, 0.56229437, 0.82599309, 1.40120497, 0.33561261,\n",
       "       0.15829258, 0.49823851, 0.5982007 , 1.98050159, 0.8703618 ,\n",
       "       0.24270871, 0.92533148, 0.55216859, 0.3315643 , 0.09354174,\n",
       "       0.15012546, 0.39408016, 1.767262  , 1.08975166, 0.52661631,\n",
       "       0.78372856, 0.66884489, 0.53017835, 0.5186898 , 0.17173776,\n",
       "       0.64207391, 1.39958226, 0.6806259 , 0.28236291, 0.31800383,\n",
       "       0.30218676, 0.57075257, 0.5021963 , 0.26709544, 0.47997316,\n",
       "       1.88190302, 0.21306947, 0.92130327, 0.76528786, 0.40077612,\n",
       "       0.79540141, 0.80855803, 0.29773241, 1.00430261, 1.23580753,\n",
       "       0.81170552, 0.9673209 , 0.60990958, 0.448477  , 0.38639805,\n",
       "       0.52746326, 0.76206863, 0.53802554, 0.22727708, 0.19128158,\n",
       "       0.42205191, 0.29356602, 1.1017171 , 0.59131287, 0.73334437,\n",
       "       1.02443289, 1.41510544, 1.57939379, 0.32185952, 0.58770667,\n",
       "       1.27511083, 1.04782412, 0.17316362, 0.22602269, 0.3400988 ,\n",
       "       0.46124212, 0.78350962, 0.7001718 , 0.42113728, 0.38038233,\n",
       "       1.75446368, 0.82393947, 0.34052042, 0.21294573, 0.1468772 ,\n",
       "       0.28581715, 1.75388582, 0.42205191, 1.09123953, 0.15911297,\n",
       "       0.13673652, 0.67963883, 0.16652695, 0.26905661, 0.5352891 ,\n",
       "       0.17876788, 0.73147229, 0.37483891, 1.67825223, 0.43834994,\n",
       "       0.37062899, 0.31580724, 0.43695578, 0.8672625 , 0.14306238,\n",
       "       0.58788667, 0.60972557, 1.37753286, 0.12069979, 0.13845779,\n",
       "       0.93700377, 0.34743208, 0.12658415, 0.23610215, 0.14421685,\n",
       "       0.56352341, 1.29681935, 0.18248157, 2.14900601, 0.45728486,\n",
       "       0.47658524, 1.09213332, 0.30924625, 0.22064667, 0.14294701,\n",
       "       0.47401165, 0.42587192, 0.76614807, 0.36456312, 0.14629826,\n",
       "       0.80140077, 1.50103204, 0.13478933, 0.75077629, 0.36831384,\n",
       "       0.19759764, 0.39363536, 0.4807815 , 0.34814004, 0.3831656 ,\n",
       "       2.84043939, 0.55112692, 0.20028188, 0.94674994, 0.50236155,\n",
       "       0.3738211 , 0.25000101, 1.25141388, 2.99773428, 0.84793139,\n",
       "       0.16759059, 0.13433171, 0.42510675, 0.69314718, 0.69555007,\n",
       "       0.53290083, 0.46092497, 0.53734073, 0.31320503, 0.67393296,\n",
       "       1.59652169, 0.58950815, 0.22991644, 0.69615169, 1.20932041,\n",
       "       0.17709524, 0.16877374, 0.71764481, 0.2342045 , 0.34206786,\n",
       "       1.6419611 , 0.5519949 , 0.46314719, 0.32365473, 0.16463882,\n",
       "       0.43371027, 0.43417327, 0.1782897 , 0.71192234, 0.37833644,\n",
       "       0.32158362, 0.34347671, 0.18608864, 0.95815494, 0.57075257,\n",
       "       1.28989387, 0.22765371, 0.81238127, 0.38404614, 0.47658524,\n",
       "       0.30734071, 1.81584726, 0.98029606, 0.69314718, 0.66689481,\n",
       "       1.0782216 , 0.20028188, 0.65277329, 0.28701563, 0.69314718,\n",
       "       0.69314718, 0.69314718, 0.69314718, 0.2826282 , 0.3569607 ,\n",
       "       0.18693217, 0.93700377, 0.66009933, 0.33561261, 1.35595916,\n",
       "       0.5808905 , 0.52915933, 0.95295472, 0.3093825 , 0.46601161,\n",
       "       0.57128359, 1.32463498, 0.69314718, 0.69314718, 0.72815279,\n",
       "       0.69314718, 1.51458238, 0.53631439, 0.94623461, 0.7870184 ,\n",
       "       0.95815494, 0.79053953, 0.36701392, 0.35140315, 0.94494744,\n",
       "       0.32379296, 0.69314718, 0.84350506, 0.35738948, 0.62735944,\n",
       "       0.69314718, 0.69314718, 0.62418098, 0.69314718, 0.69314718,\n",
       "       0.60330648, 0.69314718, 1.29062061, 1.15740734, 0.60239282,\n",
       "       0.57252374, 0.95139991, 0.85896567, 0.83263916, 0.69314718,\n",
       "       0.52746326, 0.75395932, 0.57057563, 1.38949949, 0.69314718,\n",
       "       0.98349948, 0.25721753, 1.67450991, 0.23117572, 0.27878841,\n",
       "       0.69314718, 0.69314718, 0.69314718, 0.78679874, 0.34488755,\n",
       "       0.37033931, 0.27984619, 0.29383429, 0.91180083, 0.69314718,\n",
       "       0.69314718, 0.6953496 , 0.67924428, 0.69314718, 0.69314718,\n",
       "       0.6909496 , 0.43479094, 0.69314718, 0.69314718, 0.58536959,\n",
       "       0.8187104 , 0.6953496 , 0.83263916, 0.66904011, 0.69314718,\n",
       "       0.69314718, 0.43155244, 0.85496048, 0.69314718, 0.69314718,\n",
       "       0.69314718, 0.6953496 , 0.37994357, 0.67688021, 0.65027928,\n",
       "       0.63468961, 0.90362133, 0.69314718, 0.90312775, 0.41143288,\n",
       "       0.69314718, 0.91804226, 0.93521874, 0.45744285, 0.69314718,\n",
       "       0.38243241, 0.36528332, 0.69314718, 0.69314718, 0.69314718,\n",
       "       0.69314718, 0.69314718, 0.75502258, 0.69314718, 0.34644177,\n",
       "       0.43216849, 1.2265593 , 0.69314718, 1.30195321, 0.67119001,\n",
       "       0.35524739, 0.69314718, 0.67119001, 0.44613086, 0.71559731,\n",
       "       0.69314718, 0.76314055, 0.26565969, 0.69314718, 0.57075257,\n",
       "       0.86132917, 0.57075257, 0.55025969, 1.25421402, 0.35610368,\n",
       "       0.69314718, 0.69314718, 0.39245017, 0.69314718, 0.54731673,\n",
       "       0.25128586, 1.50688132, 0.31512179, 0.29948478, 0.37687765,\n",
       "       0.4764242 , 0.69314718, 0.95659203, 0.31704223, 0.15712176,\n",
       "       0.18693217, 0.14629826, 0.69314718, 0.29437106, 0.4405225 ,\n",
       "       0.73022619, 1.55211285, 0.2010152 , 0.16699954, 0.8603831 ,\n",
       "       1.83320666, 0.95633178, 0.83471074, 0.26513811, 0.69314718,\n",
       "       1.07704651, 0.5163408 , 0.35197174, 0.69314718, 0.83263916,\n",
       "       0.30979136, 0.92861638, 0.69314718, 0.69314718, 0.27338477,\n",
       "       0.69314718, 0.69314718, 0.69314718, 0.82211756, 0.69314718,\n",
       "       0.69735603, 0.29557984, 0.81215597, 0.36571569, 0.69314718,\n",
       "       1.24132859, 0.69314718, 0.21815601, 0.30584604, 0.28861584,\n",
       "       0.31717954, 0.55216859, 0.29894526, 0.69314718, 0.69856181,\n",
       "       0.69314718, 1.38909829, 0.35496213, 0.69314718, 0.27680808,\n",
       "       0.69314718, 0.69314718, 0.69314718, 0.67119001, 0.69314718,\n",
       "       0.27931716, 0.69314718, 0.69314718, 0.57075257, 0.69314718,\n",
       "       0.49298571, 0.2182804 , 1.05096564, 0.65932563, 1.03704693,\n",
       "       0.57075257, 0.49036962, 0.53597251, 0.4764242 , 0.73459437,\n",
       "       0.50005055, 0.4764242 , 0.69314718, 0.64588199, 0.37965117,\n",
       "       0.5608916 , 0.69314718, 0.68617157, 1.30822283, 0.93547355,\n",
       "       0.69314718, 0.97021907, 0.65027928, 1.09871229, 0.25077172,\n",
       "       0.69314718, 0.69314718, 0.92558378, 0.69314718, 0.57110655,\n",
       "       0.69314718, 0.69314718, 0.69314718, 0.83263916, 0.69314718,\n",
       "       0.69314718, 0.53682743, 0.69314718, 1.33370191, 1.13072234,\n",
       "       0.28090509, 0.72278199, 0.71559731, 0.69314718, 0.86988436,\n",
       "       0.69314718, 0.61766872, 0.33017212, 0.69314718, 0.69314718,\n",
       "       0.69314718])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "div_data.kl_divergence.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_markets = closed_markets.copy(deep=True)\n",
    "    all_markets[\"market_creator\"] = \"all\"\n",
    "\n",
    "    # merging both dataframes\n",
    "    final_markets = pd.concat([div_data, all_markets], ignore_index=True)\n",
    "    final_markets = final_markets.sort_values(by=\"opening_datetime\", ascending=True)\n",
    "\n",
    "    # Create the main figure and axis\n",
    "    fig, ax1 = plt.subplots(figsize=(10, 6))\n",
    "\n",
    "    # Create the boxplot using seaborn\n",
    "    sns.boxplot(\n",
    "        data=closed_markets,\n",
    "        x=\"month_year_week\",\n",
    "        y=\"kl_divergence\",\n",
    "        ax=ax1,\n",
    "        hue=\"market_creator\",\n",
    "        order=[\"pearl\", \"quickstart\", \"all\"],\n",
    "    )\n",
    "\n",
    "    # Set labels and title for the main axis\n",
    "    ax1.set_xlabel(\"Week\")\n",
    "    ax1.set_ylabel(\"KL Divergence\")\n",
    "    ax1.set_title(\"KL Divergence Boxplot with Off-by Percentage\")\n",
    "\n",
    "    # Create a secondary y-axis\n",
    "    ax2 = ax1.twinx()\n",
    "\n",
    "    # Plot the off_by_perc values on the secondary y-axis\n",
    "    for i, week in enumerate(closed_markets[\"month_year_week\"].unique()):\n",
    "        off_by_perc = closed_markets[closed_markets[\"month_year_week\"] == week][\n",
    "            \"off_by_perc\"\n",
    "        ]\n",
    "        ax2.scatter([i] * len(off_by_perc), off_by_perc, color=\"red\", alpha=0.01)\n",
    "\n",
    "    # Set label for the secondary y-axis\n",
    "    ax2.set_ylabel(\"Off-by Percentage\")\n",
    "\n",
    "    # Adjust the layout and display the plot\n",
    "    plt.tight_layout()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "hf_dashboards",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}