cyberosa
commited on
Commit
Β·
a0ba53d
1
Parent(s):
cd2003a
updating scripts and weekly data
Browse files- app.py +6 -10
- data/closed_markets_div.parquet +2 -2
- data/daily_info.parquet +2 -2
- data/unknown_daily_traders.parquet +2 -2
- data/unknown_traders.parquet +2 -2
- data/weekly_mech_calls.parquet +2 -2
- notebooks/unknown_traders.ipynb +303 -0
- scripts/closed_markets_divergence.py +3 -3
- scripts/metrics.py +3 -9
- scripts/num_mech_calls.py +17 -14
app.py
CHANGED
@@ -285,19 +285,15 @@ with demo:
|
|
285 |
outputs=trader_u_markets_plot,
|
286 |
)
|
287 |
with gr.TabItem("π
Daily metrics"):
|
288 |
-
current_week_trades = get_current_week_data(trades_df=traders_data)
|
289 |
live_trades_current_week = get_current_week_data(trades_df=daily_info)
|
290 |
-
if len(
|
291 |
-
|
292 |
-
compute_daily_metrics_by_market_creator(
|
|
|
|
|
293 |
)
|
294 |
else:
|
295 |
-
|
296 |
-
daily_prof_metrics_by_market_creator = pd.DataFrame()
|
297 |
-
live_metrics_by_market_creator = compute_daily_metrics_by_market_creator(
|
298 |
-
live_trades_current_week, trader_filter=None, live_metrics=True
|
299 |
-
)
|
300 |
-
|
301 |
with gr.Row():
|
302 |
gr.Markdown("# Daily live metrics for all trades")
|
303 |
with gr.Row():
|
|
|
285 |
outputs=trader_u_markets_plot,
|
286 |
)
|
287 |
with gr.TabItem("π
Daily metrics"):
|
|
|
288 |
live_trades_current_week = get_current_week_data(trades_df=daily_info)
|
289 |
+
if len(live_trades_current_week) > 0:
|
290 |
+
live_metrics_by_market_creator = (
|
291 |
+
compute_daily_metrics_by_market_creator(
|
292 |
+
live_trades_current_week, trader_filter=None, live_metrics=True
|
293 |
+
)
|
294 |
)
|
295 |
else:
|
296 |
+
live_metrics_by_market_creator = pd.DataFrame()
|
|
|
|
|
|
|
|
|
|
|
297 |
with gr.Row():
|
298 |
gr.Markdown("# Daily live metrics for all trades")
|
299 |
with gr.Row():
|
data/closed_markets_div.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3eced4105a55dfb65e767f6ca4dd876a9d5ff0f0247b8ca613f5cad5fe00d7e7
|
3 |
+
size 56966
|
data/daily_info.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d9f224f954dd108e164b12763dd628e05a5f17a94fd2422d9853f60f470a690d
|
3 |
+
size 697569
|
data/unknown_daily_traders.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:45f38b60d39b31a089052b97cddd6fe27bf94b64f62b1eeab5947881fa590665
|
3 |
+
size 38656
|
data/unknown_traders.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0164ef5ecaf966a5dcc677d96bba860c344f43cf53e237b6687b797502bd5e36
|
3 |
+
size 184719
|
data/weekly_mech_calls.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06cafb7b09261c509c443fce63f245203341c691eeda2e4ade1d2d1b69335818
|
3 |
+
size 55489
|
notebooks/unknown_traders.ipynb
ADDED
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"import matplotlib.pyplot as plt\n",
|
11 |
+
"import seaborn as sns\n",
|
12 |
+
"import gc"
|
13 |
+
]
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"cell_type": "code",
|
17 |
+
"execution_count": 2,
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [],
|
20 |
+
"source": [
|
21 |
+
"unknown_traders = pd.read_parquet(\"../data/unknown_traders.parquet\")"
|
22 |
+
]
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"cell_type": "code",
|
26 |
+
"execution_count": 3,
|
27 |
+
"metadata": {},
|
28 |
+
"outputs": [
|
29 |
+
{
|
30 |
+
"data": {
|
31 |
+
"text/html": [
|
32 |
+
"<div>\n",
|
33 |
+
"<style scoped>\n",
|
34 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
35 |
+
" vertical-align: middle;\n",
|
36 |
+
" }\n",
|
37 |
+
"\n",
|
38 |
+
" .dataframe tbody tr th {\n",
|
39 |
+
" vertical-align: top;\n",
|
40 |
+
" }\n",
|
41 |
+
"\n",
|
42 |
+
" .dataframe thead th {\n",
|
43 |
+
" text-align: right;\n",
|
44 |
+
" }\n",
|
45 |
+
"</style>\n",
|
46 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
47 |
+
" <thead>\n",
|
48 |
+
" <tr style=\"text-align: right;\">\n",
|
49 |
+
" <th></th>\n",
|
50 |
+
" <th>trader_address</th>\n",
|
51 |
+
" <th>market_creator</th>\n",
|
52 |
+
" <th>trade_id</th>\n",
|
53 |
+
" <th>creation_timestamp</th>\n",
|
54 |
+
" <th>title</th>\n",
|
55 |
+
" <th>market_status</th>\n",
|
56 |
+
" <th>collateral_amount</th>\n",
|
57 |
+
" <th>outcome_index</th>\n",
|
58 |
+
" <th>trade_fee_amount</th>\n",
|
59 |
+
" <th>outcomes_tokens_traded</th>\n",
|
60 |
+
" <th>...</th>\n",
|
61 |
+
" <th>is_invalid</th>\n",
|
62 |
+
" <th>winning_trade</th>\n",
|
63 |
+
" <th>earnings</th>\n",
|
64 |
+
" <th>redeemed</th>\n",
|
65 |
+
" <th>redeemed_amount</th>\n",
|
66 |
+
" <th>num_mech_calls</th>\n",
|
67 |
+
" <th>mech_fee_amount</th>\n",
|
68 |
+
" <th>net_earnings</th>\n",
|
69 |
+
" <th>roi</th>\n",
|
70 |
+
" <th>staking</th>\n",
|
71 |
+
" </tr>\n",
|
72 |
+
" </thead>\n",
|
73 |
+
" <tbody>\n",
|
74 |
+
" <tr>\n",
|
75 |
+
" <th>0</th>\n",
|
76 |
+
" <td>0x23522318aebb55b55879b60fb3ad4682abc6cc2f</td>\n",
|
77 |
+
" <td>quickstart</td>\n",
|
78 |
+
" <td>0xeeaadfc4d0ef3f3bb1c430bc96657ed01a52e3e20x23...</td>\n",
|
79 |
+
" <td>2024-12-23 12:36:05+00:00</td>\n",
|
80 |
+
" <td>Will any additional Amazon facilities join the...</td>\n",
|
81 |
+
" <td>CLOSED</td>\n",
|
82 |
+
" <td>0.401540</td>\n",
|
83 |
+
" <td>0</td>\n",
|
84 |
+
" <td>0.004015</td>\n",
|
85 |
+
" <td>0.939802</td>\n",
|
86 |
+
" <td>...</td>\n",
|
87 |
+
" <td>False</td>\n",
|
88 |
+
" <td>True</td>\n",
|
89 |
+
" <td>0.939802</td>\n",
|
90 |
+
" <td>True</td>\n",
|
91 |
+
" <td>0.939802</td>\n",
|
92 |
+
" <td>0</td>\n",
|
93 |
+
" <td>0.0</td>\n",
|
94 |
+
" <td>0.534247</td>\n",
|
95 |
+
" <td>1.317323</td>\n",
|
96 |
+
" <td>non_Olas</td>\n",
|
97 |
+
" </tr>\n",
|
98 |
+
" <tr>\n",
|
99 |
+
" <th>1</th>\n",
|
100 |
+
" <td>0x8c4abc95e0091bf3bffe723d2b3c958edf642549</td>\n",
|
101 |
+
" <td>quickstart</td>\n",
|
102 |
+
" <td>0x6df8ac2c78c8a801d6b6f30e19d3c193daf54f1e0x8c...</td>\n",
|
103 |
+
" <td>2024-12-24 07:22:50+00:00</td>\n",
|
104 |
+
" <td>Will the World Health Organization issue an of...</td>\n",
|
105 |
+
" <td>CLOSED</td>\n",
|
106 |
+
" <td>0.298503</td>\n",
|
107 |
+
" <td>0</td>\n",
|
108 |
+
" <td>0.002985</td>\n",
|
109 |
+
" <td>0.624681</td>\n",
|
110 |
+
" <td>...</td>\n",
|
111 |
+
" <td>False</td>\n",
|
112 |
+
" <td>True</td>\n",
|
113 |
+
" <td>0.624681</td>\n",
|
114 |
+
" <td>True</td>\n",
|
115 |
+
" <td>0.624681</td>\n",
|
116 |
+
" <td>0</td>\n",
|
117 |
+
" <td>0.0</td>\n",
|
118 |
+
" <td>0.323193</td>\n",
|
119 |
+
" <td>1.071994</td>\n",
|
120 |
+
" <td>non_Olas</td>\n",
|
121 |
+
" </tr>\n",
|
122 |
+
" <tr>\n",
|
123 |
+
" <th>2</th>\n",
|
124 |
+
" <td>0xb3ead49f4797662511816d2798f774dee3603185</td>\n",
|
125 |
+
" <td>quickstart</td>\n",
|
126 |
+
" <td>0x4cb63dbf490e1f8f7c10d1e62be7ae6bbbb6d0790xb3...</td>\n",
|
127 |
+
" <td>2024-12-23 12:50:40+00:00</td>\n",
|
128 |
+
" <td>Will Dominion Energy announce any additional p...</td>\n",
|
129 |
+
" <td>CLOSED</td>\n",
|
130 |
+
" <td>0.423050</td>\n",
|
131 |
+
" <td>1</td>\n",
|
132 |
+
" <td>0.004230</td>\n",
|
133 |
+
" <td>0.687175</td>\n",
|
134 |
+
" <td>...</td>\n",
|
135 |
+
" <td>False</td>\n",
|
136 |
+
" <td>False</td>\n",
|
137 |
+
" <td>0.000000</td>\n",
|
138 |
+
" <td>False</td>\n",
|
139 |
+
" <td>0.000000</td>\n",
|
140 |
+
" <td>0</td>\n",
|
141 |
+
" <td>0.0</td>\n",
|
142 |
+
" <td>-0.427280</td>\n",
|
143 |
+
" <td>-1.000000</td>\n",
|
144 |
+
" <td>non_Olas</td>\n",
|
145 |
+
" </tr>\n",
|
146 |
+
" <tr>\n",
|
147 |
+
" <th>3</th>\n",
|
148 |
+
" <td>0x2dd9f5678484c1f59f97ed334725858b938b4102</td>\n",
|
149 |
+
" <td>quickstart</td>\n",
|
150 |
+
" <td>0x005e5be235ba39c5f17622d25e77557ee79a2cba0x2d...</td>\n",
|
151 |
+
" <td>2024-12-22 02:40:35+00:00</td>\n",
|
152 |
+
" <td>Will the Federal Reserve signal a plan to slow...</td>\n",
|
153 |
+
" <td>CLOSED</td>\n",
|
154 |
+
" <td>1.568561</td>\n",
|
155 |
+
" <td>1</td>\n",
|
156 |
+
" <td>0.015686</td>\n",
|
157 |
+
" <td>2.474096</td>\n",
|
158 |
+
" <td>...</td>\n",
|
159 |
+
" <td>False</td>\n",
|
160 |
+
" <td>False</td>\n",
|
161 |
+
" <td>0.000000</td>\n",
|
162 |
+
" <td>True</td>\n",
|
163 |
+
" <td>0.000000</td>\n",
|
164 |
+
" <td>0</td>\n",
|
165 |
+
" <td>0.0</td>\n",
|
166 |
+
" <td>-1.584247</td>\n",
|
167 |
+
" <td>-1.000000</td>\n",
|
168 |
+
" <td>non_Olas</td>\n",
|
169 |
+
" </tr>\n",
|
170 |
+
" <tr>\n",
|
171 |
+
" <th>4</th>\n",
|
172 |
+
" <td>0x2dd9f5678484c1f59f97ed334725858b938b4102</td>\n",
|
173 |
+
" <td>quickstart</td>\n",
|
174 |
+
" <td>0x0080b3768232e8a2f187eaaf342923034275e0b90x2d...</td>\n",
|
175 |
+
" <td>2024-12-13 04:32:35+00:00</td>\n",
|
176 |
+
" <td>Will Russia officially confirm Bashar al-Assad...</td>\n",
|
177 |
+
" <td>CLOSED</td>\n",
|
178 |
+
" <td>2.677632</td>\n",
|
179 |
+
" <td>0</td>\n",
|
180 |
+
" <td>0.026776</td>\n",
|
181 |
+
" <td>5.135035</td>\n",
|
182 |
+
" <td>...</td>\n",
|
183 |
+
" <td>False</td>\n",
|
184 |
+
" <td>True</td>\n",
|
185 |
+
" <td>5.135035</td>\n",
|
186 |
+
" <td>True</td>\n",
|
187 |
+
" <td>5.135035</td>\n",
|
188 |
+
" <td>0</td>\n",
|
189 |
+
" <td>0.0</td>\n",
|
190 |
+
" <td>2.430627</td>\n",
|
191 |
+
" <td>0.898765</td>\n",
|
192 |
+
" <td>non_Olas</td>\n",
|
193 |
+
" </tr>\n",
|
194 |
+
" </tbody>\n",
|
195 |
+
"</table>\n",
|
196 |
+
"<p>5 rows Γ 21 columns</p>\n",
|
197 |
+
"</div>"
|
198 |
+
],
|
199 |
+
"text/plain": [
|
200 |
+
" trader_address market_creator \\\n",
|
201 |
+
"0 0x23522318aebb55b55879b60fb3ad4682abc6cc2f quickstart \n",
|
202 |
+
"1 0x8c4abc95e0091bf3bffe723d2b3c958edf642549 quickstart \n",
|
203 |
+
"2 0xb3ead49f4797662511816d2798f774dee3603185 quickstart \n",
|
204 |
+
"3 0x2dd9f5678484c1f59f97ed334725858b938b4102 quickstart \n",
|
205 |
+
"4 0x2dd9f5678484c1f59f97ed334725858b938b4102 quickstart \n",
|
206 |
+
"\n",
|
207 |
+
" trade_id \\\n",
|
208 |
+
"0 0xeeaadfc4d0ef3f3bb1c430bc96657ed01a52e3e20x23... \n",
|
209 |
+
"1 0x6df8ac2c78c8a801d6b6f30e19d3c193daf54f1e0x8c... \n",
|
210 |
+
"2 0x4cb63dbf490e1f8f7c10d1e62be7ae6bbbb6d0790xb3... \n",
|
211 |
+
"3 0x005e5be235ba39c5f17622d25e77557ee79a2cba0x2d... \n",
|
212 |
+
"4 0x0080b3768232e8a2f187eaaf342923034275e0b90x2d... \n",
|
213 |
+
"\n",
|
214 |
+
" creation_timestamp \\\n",
|
215 |
+
"0 2024-12-23 12:36:05+00:00 \n",
|
216 |
+
"1 2024-12-24 07:22:50+00:00 \n",
|
217 |
+
"2 2024-12-23 12:50:40+00:00 \n",
|
218 |
+
"3 2024-12-22 02:40:35+00:00 \n",
|
219 |
+
"4 2024-12-13 04:32:35+00:00 \n",
|
220 |
+
"\n",
|
221 |
+
" title market_status \\\n",
|
222 |
+
"0 Will any additional Amazon facilities join the... CLOSED \n",
|
223 |
+
"1 Will the World Health Organization issue an of... CLOSED \n",
|
224 |
+
"2 Will Dominion Energy announce any additional p... CLOSED \n",
|
225 |
+
"3 Will the Federal Reserve signal a plan to slow... CLOSED \n",
|
226 |
+
"4 Will Russia officially confirm Bashar al-Assad... CLOSED \n",
|
227 |
+
"\n",
|
228 |
+
" collateral_amount outcome_index trade_fee_amount outcomes_tokens_traded \\\n",
|
229 |
+
"0 0.401540 0 0.004015 0.939802 \n",
|
230 |
+
"1 0.298503 0 0.002985 0.624681 \n",
|
231 |
+
"2 0.423050 1 0.004230 0.687175 \n",
|
232 |
+
"3 1.568561 1 0.015686 2.474096 \n",
|
233 |
+
"4 2.677632 0 0.026776 5.135035 \n",
|
234 |
+
"\n",
|
235 |
+
" ... is_invalid winning_trade earnings redeemed redeemed_amount \\\n",
|
236 |
+
"0 ... False True 0.939802 True 0.939802 \n",
|
237 |
+
"1 ... False True 0.624681 True 0.624681 \n",
|
238 |
+
"2 ... False False 0.000000 False 0.000000 \n",
|
239 |
+
"3 ... False False 0.000000 True 0.000000 \n",
|
240 |
+
"4 ... False True 5.135035 True 5.135035 \n",
|
241 |
+
"\n",
|
242 |
+
" num_mech_calls mech_fee_amount net_earnings roi staking \n",
|
243 |
+
"0 0 0.0 0.534247 1.317323 non_Olas \n",
|
244 |
+
"1 0 0.0 0.323193 1.071994 non_Olas \n",
|
245 |
+
"2 0 0.0 -0.427280 -1.000000 non_Olas \n",
|
246 |
+
"3 0 0.0 -1.584247 -1.000000 non_Olas \n",
|
247 |
+
"4 0 0.0 2.430627 0.898765 non_Olas \n",
|
248 |
+
"\n",
|
249 |
+
"[5 rows x 21 columns]"
|
250 |
+
]
|
251 |
+
},
|
252 |
+
"execution_count": 3,
|
253 |
+
"metadata": {},
|
254 |
+
"output_type": "execute_result"
|
255 |
+
}
|
256 |
+
],
|
257 |
+
"source": [
|
258 |
+
"unknown_traders.head()"
|
259 |
+
]
|
260 |
+
},
|
261 |
+
{
|
262 |
+
"cell_type": "code",
|
263 |
+
"execution_count": 4,
|
264 |
+
"metadata": {},
|
265 |
+
"outputs": [
|
266 |
+
{
|
267 |
+
"data": {
|
268 |
+
"text/plain": [
|
269 |
+
"1568"
|
270 |
+
]
|
271 |
+
},
|
272 |
+
"execution_count": 4,
|
273 |
+
"metadata": {},
|
274 |
+
"output_type": "execute_result"
|
275 |
+
}
|
276 |
+
],
|
277 |
+
"source": [
|
278 |
+
"len(unknown_traders)"
|
279 |
+
]
|
280 |
+
}
|
281 |
+
],
|
282 |
+
"metadata": {
|
283 |
+
"kernelspec": {
|
284 |
+
"display_name": "hf_dashboards",
|
285 |
+
"language": "python",
|
286 |
+
"name": "python3"
|
287 |
+
},
|
288 |
+
"language_info": {
|
289 |
+
"codemirror_mode": {
|
290 |
+
"name": "ipython",
|
291 |
+
"version": 3
|
292 |
+
},
|
293 |
+
"file_extension": ".py",
|
294 |
+
"mimetype": "text/x-python",
|
295 |
+
"name": "python",
|
296 |
+
"nbconvert_exporter": "python",
|
297 |
+
"pygments_lexer": "ipython3",
|
298 |
+
"version": "3.12.2"
|
299 |
+
}
|
300 |
+
},
|
301 |
+
"nbformat": 4,
|
302 |
+
"nbformat_minor": 2
|
303 |
+
}
|
scripts/closed_markets_divergence.py
CHANGED
@@ -85,9 +85,9 @@ def collect_liquidity_info(
|
|
85 |
if not tokens_info:
|
86 |
return None
|
87 |
|
88 |
-
# the
|
89 |
-
|
90 |
-
token_amounts = [int(x) for x in
|
91 |
time.sleep(IPFS_POLL_INTERVAL)
|
92 |
return {fpmm_id: token_amounts}
|
93 |
|
|
|
85 |
if not tokens_info:
|
86 |
return None
|
87 |
|
88 |
+
# the last item is the final information of the market
|
89 |
+
last_info = tokens_info[-1]
|
90 |
+
token_amounts = [int(x) for x in last_info["outcomeTokenAmounts"]]
|
91 |
time.sleep(IPFS_POLL_INTERVAL)
|
92 |
return {fpmm_id: token_amounts}
|
93 |
|
scripts/metrics.py
CHANGED
@@ -29,7 +29,7 @@ def compute_metrics(
|
|
29 |
total_nr_mech_calls_all_markets = 0
|
30 |
else:
|
31 |
total_nr_mech_calls_all_markets = get_weekly_total_mech_calls(trader_data)
|
32 |
-
|
33 |
agg_metrics["bet_amount"] = total_bet_amounts
|
34 |
agg_metrics["nr_mech_calls"] = total_nr_mech_calls_all_markets
|
35 |
agg_metrics["staking"] = trader_data.iloc[0].staking
|
@@ -39,22 +39,16 @@ def compute_metrics(
|
|
39 |
total_earnings = trader_data.earnings.sum()
|
40 |
agg_metrics["earnings"] = total_earnings
|
41 |
total_fee_amounts = trader_data.mech_fee_amount.sum()
|
42 |
-
|
43 |
-
total_bet_amounts + total_fee_amounts + previous_total * DEFAULT_MECH_FEE
|
44 |
-
)
|
45 |
total_costs = (
|
46 |
total_bet_amounts
|
47 |
+ total_fee_amounts
|
48 |
+ (total_nr_mech_calls_all_markets * DEFAULT_MECH_FEE)
|
49 |
)
|
50 |
total_net_earnings = total_earnings - total_costs
|
51 |
-
previous_net_earnings = trader_data.net_earnings.sum()
|
52 |
agg_metrics["net_earnings"] = total_net_earnings
|
53 |
agg_metrics["roi"] = total_net_earnings / total_costs
|
54 |
-
|
55 |
-
agg_metrics["roi_diff_perc"] = 100.0 * (
|
56 |
-
(agg_metrics["roi"] - agg_metrics["previous_roi"]) / abs(agg_metrics["roi"])
|
57 |
-
)
|
58 |
return agg_metrics
|
59 |
|
60 |
|
|
|
29 |
total_nr_mech_calls_all_markets = 0
|
30 |
else:
|
31 |
total_nr_mech_calls_all_markets = get_weekly_total_mech_calls(trader_data)
|
32 |
+
|
33 |
agg_metrics["bet_amount"] = total_bet_amounts
|
34 |
agg_metrics["nr_mech_calls"] = total_nr_mech_calls_all_markets
|
35 |
agg_metrics["staking"] = trader_data.iloc[0].staking
|
|
|
39 |
total_earnings = trader_data.earnings.sum()
|
40 |
agg_metrics["earnings"] = total_earnings
|
41 |
total_fee_amounts = trader_data.mech_fee_amount.sum()
|
42 |
+
|
|
|
|
|
43 |
total_costs = (
|
44 |
total_bet_amounts
|
45 |
+ total_fee_amounts
|
46 |
+ (total_nr_mech_calls_all_markets * DEFAULT_MECH_FEE)
|
47 |
)
|
48 |
total_net_earnings = total_earnings - total_costs
|
|
|
49 |
agg_metrics["net_earnings"] = total_net_earnings
|
50 |
agg_metrics["roi"] = total_net_earnings / total_costs
|
51 |
+
|
|
|
|
|
|
|
52 |
return agg_metrics
|
53 |
|
54 |
|
scripts/num_mech_calls.py
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
import pandas as pd
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
3 |
from datetime import datetime, timezone
|
4 |
from tqdm import tqdm
|
5 |
|
@@ -55,30 +60,28 @@ def compute_total_mech_calls():
|
|
55 |
except Exception as e:
|
56 |
print(f"Error updating the invalid trades parquet {e}")
|
57 |
|
|
|
|
|
58 |
try:
|
59 |
-
print("Reading trades weekly info file")
|
60 |
-
fpmmTrades = pd.read_parquet(DATA_DIR / "fpmmTrades.parquet")
|
61 |
fpmmTrades["creationTimestamp"] = fpmmTrades["creationTimestamp"].apply(
|
62 |
lambda x: transform_to_datetime(x)
|
63 |
)
|
64 |
-
fpmmTrades["creation_timestamp"] = pd.to_datetime(
|
65 |
-
fpmmTrades["creationTimestamp"]
|
66 |
-
)
|
67 |
-
fpmmTrades["creation_date"] = fpmmTrades["creation_timestamp"].dt.date
|
68 |
-
fpmmTrades = fpmmTrades.sort_values(by="creation_timestamp", ascending=True)
|
69 |
-
fpmmTrades["month_year_week"] = (
|
70 |
-
fpmmTrades["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d")
|
71 |
-
)
|
72 |
-
|
73 |
except Exception as e:
|
74 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
nr_traders = len(fpmmTrades["trader_address"].unique())
|
77 |
all_mech_calls = []
|
78 |
for trader in tqdm(
|
79 |
fpmmTrades["trader_address"].unique(),
|
80 |
total=nr_traders,
|
81 |
-
desc="creating mech calls
|
82 |
):
|
83 |
# compute the mech calls estimations for each trader
|
84 |
all_trades = fpmmTrades[fpmmTrades["trader_address"] == trader]
|
|
|
1 |
import pandas as pd
|
2 |
+
|
3 |
+
try:
|
4 |
+
from utils import DATA_DIR, TMP_DIR
|
5 |
+
except ImportError:
|
6 |
+
from scripts.utils import DATA_DIR, TMP_DIR
|
7 |
+
|
8 |
from datetime import datetime, timezone
|
9 |
from tqdm import tqdm
|
10 |
|
|
|
60 |
except Exception as e:
|
61 |
print(f"Error updating the invalid trades parquet {e}")
|
62 |
|
63 |
+
print("Reading trades weekly info file")
|
64 |
+
fpmmTrades = pd.read_parquet(DATA_DIR / "fpmmTrades.parquet")
|
65 |
try:
|
|
|
|
|
66 |
fpmmTrades["creationTimestamp"] = fpmmTrades["creationTimestamp"].apply(
|
67 |
lambda x: transform_to_datetime(x)
|
68 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
except Exception as e:
|
70 |
+
print(f"Transformation not needed")
|
71 |
+
|
72 |
+
fpmmTrades["creation_timestamp"] = pd.to_datetime(fpmmTrades["creationTimestamp"])
|
73 |
+
fpmmTrades["creation_date"] = fpmmTrades["creation_timestamp"].dt.date
|
74 |
+
fpmmTrades = fpmmTrades.sort_values(by="creation_timestamp", ascending=True)
|
75 |
+
fpmmTrades["month_year_week"] = (
|
76 |
+
fpmmTrades["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d")
|
77 |
+
)
|
78 |
|
79 |
nr_traders = len(fpmmTrades["trader_address"].unique())
|
80 |
all_mech_calls = []
|
81 |
for trader in tqdm(
|
82 |
fpmmTrades["trader_address"].unique(),
|
83 |
total=nr_traders,
|
84 |
+
desc="creating weekly mech calls dataframe",
|
85 |
):
|
86 |
# compute the mech calls estimations for each trader
|
87 |
all_trades = fpmmTrades[fpmmTrades["trader_address"] == trader]
|