Spaces:
Runtime error
Runtime error
cyberosa
commited on
Commit
Β·
8a73d91
1
Parent(s):
f95e119
updating weekly data for the traders
Browse files- app.py +3 -3
- data/closed_markets_div.parquet +2 -2
- data/daily_info.parquet +2 -2
- data/unknown_daily_traders.parquet +2 -2
- data/weekly_mech_calls.parquet +2 -2
- notebooks/trader_agent_metrics.ipynb +97 -24
- scripts/num_mech_calls.py +2 -2
- scripts/utils.py +2 -2
- tabs/market_plots.py +2 -2
- tabs/trader_plots.py +6 -6
app.py
CHANGED
|
@@ -118,13 +118,13 @@ def prepare_data():
|
|
| 118 |
by="creation_timestamp", ascending=True
|
| 119 |
)
|
| 120 |
traders_data["month_year_week"] = (
|
| 121 |
-
traders_data["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d")
|
| 122 |
)
|
| 123 |
unknown_traders["month_year_week"] = (
|
| 124 |
-
unknown_traders["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d")
|
| 125 |
)
|
| 126 |
closed_markets["month_year_week"] = (
|
| 127 |
-
closed_markets["opening_datetime"].dt.to_period("W").dt.strftime("%b-%d")
|
| 128 |
)
|
| 129 |
return traders_data, closed_markets, daily_info, unknown_traders
|
| 130 |
|
|
|
|
| 118 |
by="creation_timestamp", ascending=True
|
| 119 |
)
|
| 120 |
traders_data["month_year_week"] = (
|
| 121 |
+
traders_data["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d-%Y")
|
| 122 |
)
|
| 123 |
unknown_traders["month_year_week"] = (
|
| 124 |
+
unknown_traders["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d-%Y")
|
| 125 |
)
|
| 126 |
closed_markets["month_year_week"] = (
|
| 127 |
+
closed_markets["opening_datetime"].dt.to_period("W").dt.strftime("%b-%d-%Y")
|
| 128 |
)
|
| 129 |
return traders_data, closed_markets, daily_info, unknown_traders
|
| 130 |
|
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:f6b6ff11a79e22ddcfcc3e24305ed6a0892e06888254b6360e89e2ad956529a1
|
| 3 |
+
size 52009
|
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:23cc8b305b1f2f5b6cc7b4a6017c1aeb2a003ec5cc921be1ad66f380d29a6102
|
| 3 |
+
size 658465
|
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:1480859c96b05ac94e54f2a69c0ad46d3b840c37111051bb2a0174aa60d90a73
|
| 3 |
+
size 25003
|
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:04536d62dc403476e4b21032b86e781f38aab5c08d69ebc9ccc917e005b9af95
|
| 3 |
+
size 50976
|
notebooks/trader_agent_metrics.ipynb
CHANGED
|
@@ -111,32 +111,33 @@
|
|
| 111 |
"output_type": "stream",
|
| 112 |
"text": [
|
| 113 |
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 114 |
-
"RangeIndex:
|
| 115 |
-
"Data columns (total
|
| 116 |
" # Column Non-Null Count Dtype \n",
|
| 117 |
"--- ------ -------------- ----- \n",
|
| 118 |
-
" 0 trader_address
|
| 119 |
-
" 1 market_creator
|
| 120 |
-
" 2 trade_id
|
| 121 |
-
" 3 creation_timestamp
|
| 122 |
-
" 4 title
|
| 123 |
-
" 5 market_status
|
| 124 |
-
" 6 collateral_amount
|
| 125 |
-
" 7 outcome_index
|
| 126 |
-
" 8 trade_fee_amount
|
| 127 |
-
" 9 outcomes_tokens_traded
|
| 128 |
-
" 10 current_answer
|
| 129 |
-
" 11 is_invalid
|
| 130 |
-
" 12 winning_trade
|
| 131 |
-
" 13 earnings
|
| 132 |
-
" 14 redeemed
|
| 133 |
-
" 15 redeemed_amount
|
| 134 |
-
" 16 num_mech_calls
|
| 135 |
-
" 17 mech_fee_amount
|
| 136 |
-
" 18 net_earnings
|
| 137 |
-
" 19 roi
|
| 138 |
-
"
|
| 139 |
-
"
|
|
|
|
| 140 |
]
|
| 141 |
}
|
| 142 |
],
|
|
@@ -1359,6 +1360,78 @@
|
|
| 1359 |
"source": [
|
| 1360 |
"compute_weekly_metrics_by_market_creator(trader_agent_metrics)"
|
| 1361 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1362 |
}
|
| 1363 |
],
|
| 1364 |
"metadata": {
|
|
|
|
| 111 |
"output_type": "stream",
|
| 112 |
"text": [
|
| 113 |
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 114 |
+
"RangeIndex: 88355 entries, 0 to 88354\n",
|
| 115 |
+
"Data columns (total 21 columns):\n",
|
| 116 |
" # Column Non-Null Count Dtype \n",
|
| 117 |
"--- ------ -------------- ----- \n",
|
| 118 |
+
" 0 trader_address 88355 non-null object \n",
|
| 119 |
+
" 1 market_creator 88355 non-null object \n",
|
| 120 |
+
" 2 trade_id 88355 non-null object \n",
|
| 121 |
+
" 3 creation_timestamp 88355 non-null datetime64[ns, UTC]\n",
|
| 122 |
+
" 4 title 88355 non-null object \n",
|
| 123 |
+
" 5 market_status 88355 non-null object \n",
|
| 124 |
+
" 6 collateral_amount 88355 non-null float64 \n",
|
| 125 |
+
" 7 outcome_index 88355 non-null object \n",
|
| 126 |
+
" 8 trade_fee_amount 88355 non-null float64 \n",
|
| 127 |
+
" 9 outcomes_tokens_traded 88355 non-null float64 \n",
|
| 128 |
+
" 10 current_answer 88355 non-null int64 \n",
|
| 129 |
+
" 11 is_invalid 88355 non-null bool \n",
|
| 130 |
+
" 12 winning_trade 88355 non-null bool \n",
|
| 131 |
+
" 13 earnings 88355 non-null float64 \n",
|
| 132 |
+
" 14 redeemed 88355 non-null bool \n",
|
| 133 |
+
" 15 redeemed_amount 88355 non-null float64 \n",
|
| 134 |
+
" 16 num_mech_calls 88355 non-null int64 \n",
|
| 135 |
+
" 17 mech_fee_amount 88355 non-null float64 \n",
|
| 136 |
+
" 18 net_earnings 88355 non-null float64 \n",
|
| 137 |
+
" 19 roi 88355 non-null float64 \n",
|
| 138 |
+
" 20 staking 88355 non-null object \n",
|
| 139 |
+
"dtypes: bool(3), datetime64[ns, UTC](1), float64(8), int64(2), object(7)\n",
|
| 140 |
+
"memory usage: 12.4+ MB\n"
|
| 141 |
]
|
| 142 |
}
|
| 143 |
],
|
|
|
|
| 1360 |
"source": [
|
| 1361 |
"compute_weekly_metrics_by_market_creator(trader_agent_metrics)"
|
| 1362 |
]
|
| 1363 |
+
},
|
| 1364 |
+
{
|
| 1365 |
+
"cell_type": "code",
|
| 1366 |
+
"execution_count": 2,
|
| 1367 |
+
"metadata": {},
|
| 1368 |
+
"outputs": [],
|
| 1369 |
+
"source": [
|
| 1370 |
+
"tools_df = pd.read_parquet(\"../tmp/tools.parquet\")"
|
| 1371 |
+
]
|
| 1372 |
+
},
|
| 1373 |
+
{
|
| 1374 |
+
"cell_type": "code",
|
| 1375 |
+
"execution_count": 3,
|
| 1376 |
+
"metadata": {},
|
| 1377 |
+
"outputs": [
|
| 1378 |
+
{
|
| 1379 |
+
"data": {
|
| 1380 |
+
"text/plain": [
|
| 1381 |
+
"error\n",
|
| 1382 |
+
"0 780323\n",
|
| 1383 |
+
"1 214538\n",
|
| 1384 |
+
"Name: count, dtype: int64"
|
| 1385 |
+
]
|
| 1386 |
+
},
|
| 1387 |
+
"execution_count": 3,
|
| 1388 |
+
"metadata": {},
|
| 1389 |
+
"output_type": "execute_result"
|
| 1390 |
+
}
|
| 1391 |
+
],
|
| 1392 |
+
"source": [
|
| 1393 |
+
"tools_df.error.value_counts()"
|
| 1394 |
+
]
|
| 1395 |
+
},
|
| 1396 |
+
{
|
| 1397 |
+
"cell_type": "code",
|
| 1398 |
+
"execution_count": 4,
|
| 1399 |
+
"metadata": {},
|
| 1400 |
+
"outputs": [
|
| 1401 |
+
{
|
| 1402 |
+
"data": {
|
| 1403 |
+
"text/plain": [
|
| 1404 |
+
"994861"
|
| 1405 |
+
]
|
| 1406 |
+
},
|
| 1407 |
+
"execution_count": 4,
|
| 1408 |
+
"metadata": {},
|
| 1409 |
+
"output_type": "execute_result"
|
| 1410 |
+
}
|
| 1411 |
+
],
|
| 1412 |
+
"source": [
|
| 1413 |
+
"len(tools_df)"
|
| 1414 |
+
]
|
| 1415 |
+
},
|
| 1416 |
+
{
|
| 1417 |
+
"cell_type": "code",
|
| 1418 |
+
"execution_count": 5,
|
| 1419 |
+
"metadata": {},
|
| 1420 |
+
"outputs": [
|
| 1421 |
+
{
|
| 1422 |
+
"data": {
|
| 1423 |
+
"text/plain": [
|
| 1424 |
+
"21.564620585187278"
|
| 1425 |
+
]
|
| 1426 |
+
},
|
| 1427 |
+
"execution_count": 5,
|
| 1428 |
+
"metadata": {},
|
| 1429 |
+
"output_type": "execute_result"
|
| 1430 |
+
}
|
| 1431 |
+
],
|
| 1432 |
+
"source": [
|
| 1433 |
+
"(214538/994861)*100"
|
| 1434 |
+
]
|
| 1435 |
}
|
| 1436 |
],
|
| 1437 |
"metadata": {
|
scripts/num_mech_calls.py
CHANGED
|
@@ -60,7 +60,7 @@ def compute_total_mech_calls():
|
|
| 60 |
tools["request_date"] = tools["request_time"].dt.date
|
| 61 |
tools = tools.sort_values(by="request_time", ascending=True)
|
| 62 |
tools["month_year_week"] = (
|
| 63 |
-
tools["request_time"].dt.to_period("W").dt.strftime("%b-%d")
|
| 64 |
)
|
| 65 |
|
| 66 |
except Exception as e:
|
|
@@ -79,7 +79,7 @@ def compute_total_mech_calls():
|
|
| 79 |
fpmmTrades["creation_date"] = fpmmTrades["creation_timestamp"].dt.date
|
| 80 |
fpmmTrades = fpmmTrades.sort_values(by="creation_timestamp", ascending=True)
|
| 81 |
fpmmTrades["month_year_week"] = (
|
| 82 |
-
fpmmTrades["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d")
|
| 83 |
)
|
| 84 |
|
| 85 |
nr_traders = len(fpmmTrades["trader_address"].unique())
|
|
|
|
| 60 |
tools["request_date"] = tools["request_time"].dt.date
|
| 61 |
tools = tools.sort_values(by="request_time", ascending=True)
|
| 62 |
tools["month_year_week"] = (
|
| 63 |
+
tools["request_time"].dt.to_period("W").dt.strftime("%b-%d-%Y")
|
| 64 |
)
|
| 65 |
|
| 66 |
except Exception as e:
|
|
|
|
| 79 |
fpmmTrades["creation_date"] = fpmmTrades["creation_timestamp"].dt.date
|
| 80 |
fpmmTrades = fpmmTrades.sort_values(by="creation_timestamp", ascending=True)
|
| 81 |
fpmmTrades["month_year_week"] = (
|
| 82 |
+
fpmmTrades["creation_timestamp"].dt.to_period("W").dt.strftime("%b-%d-%Y")
|
| 83 |
)
|
| 84 |
|
| 85 |
nr_traders = len(fpmmTrades["trader_address"].unique())
|
scripts/utils.py
CHANGED
|
@@ -22,10 +22,10 @@ def get_current_week():
|
|
| 22 |
|
| 23 |
# Get the start and end dates of the current week (starting on Sunday)
|
| 24 |
current_week_start = current_date - timedelta(days=current_date.weekday() + 1)
|
| 25 |
-
return current_week_start.strftime("%b-%d")
|
| 26 |
|
| 27 |
|
| 28 |
def get_next_week():
|
| 29 |
current_date = datetime.now()
|
| 30 |
next_week_start = current_date + timedelta(days=7 - (current_date.weekday() + 1))
|
| 31 |
-
return next_week_start.strftime("%b-%d")
|
|
|
|
| 22 |
|
| 23 |
# Get the start and end dates of the current week (starting on Sunday)
|
| 24 |
current_week_start = current_date - timedelta(days=current_date.weekday() + 1)
|
| 25 |
+
return current_week_start.strftime("%b-%d-%Y")
|
| 26 |
|
| 27 |
|
| 28 |
def get_next_week():
|
| 29 |
current_date = datetime.now()
|
| 30 |
next_week_start = current_date + timedelta(days=7 - (current_date.weekday() + 1))
|
| 31 |
+
return next_week_start.strftime("%b-%d-%Y")
|
tabs/market_plots.py
CHANGED
|
@@ -134,12 +134,12 @@ def plot_total_bet_amount_per_trader_per_market(
|
|
| 134 |
# Convert string dates to datetime and sort them
|
| 135 |
all_dates_dt = sorted(
|
| 136 |
[
|
| 137 |
-
datetime.strptime(date, "%b-%d")
|
| 138 |
for date in total_bet_amount["month_year_week"].unique()
|
| 139 |
]
|
| 140 |
)
|
| 141 |
# Convert back to string format
|
| 142 |
-
all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
|
| 143 |
fig = px.box(
|
| 144 |
total_bet_amount,
|
| 145 |
x="month_year_week",
|
|
|
|
| 134 |
# Convert string dates to datetime and sort them
|
| 135 |
all_dates_dt = sorted(
|
| 136 |
[
|
| 137 |
+
datetime.strptime(date, "%b-%d-%Y")
|
| 138 |
for date in total_bet_amount["month_year_week"].unique()
|
| 139 |
]
|
| 140 |
)
|
| 141 |
# Convert back to string format
|
| 142 |
+
all_dates = [date.strftime("%b-%d-%Y") for date in all_dates_dt]
|
| 143 |
fig = px.box(
|
| 144 |
total_bet_amount,
|
| 145 |
x="month_year_week",
|
tabs/trader_plots.py
CHANGED
|
@@ -115,12 +115,12 @@ def plot_trader_metrics_by_market_creator(
|
|
| 115 |
# Convert string dates to datetime and sort them
|
| 116 |
all_dates_dt = sorted(
|
| 117 |
[
|
| 118 |
-
datetime.strptime(date, "%b-%d")
|
| 119 |
for date in traders_filtered["month_year_week"].unique()
|
| 120 |
]
|
| 121 |
)
|
| 122 |
# Convert back to string format
|
| 123 |
-
all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
|
| 124 |
fig = px.box(
|
| 125 |
traders_filtered,
|
| 126 |
x="month_year_week",
|
|
@@ -243,12 +243,12 @@ def plot_total_bet_amount(
|
|
| 243 |
# Convert string dates to datetime and sort them
|
| 244 |
all_dates_dt = sorted(
|
| 245 |
[
|
| 246 |
-
datetime.strptime(date, "%b-%d")
|
| 247 |
for date in total_bet_amount["month_year_week"].unique()
|
| 248 |
]
|
| 249 |
)
|
| 250 |
# Convert back to string format
|
| 251 |
-
all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
|
| 252 |
total_bet_amount["trader_market"] = total_bet_amount.apply(
|
| 253 |
lambda x: (x["trader_type"], x["market_creator"]), axis=1
|
| 254 |
)
|
|
@@ -330,12 +330,12 @@ def plot_active_traders(
|
|
| 330 |
# Convert string dates to datetime and sort them
|
| 331 |
all_dates_dt = sorted(
|
| 332 |
[
|
| 333 |
-
datetime.strptime(date, "%b-%d")
|
| 334 |
for date in active_traders["month_year_week"].unique()
|
| 335 |
]
|
| 336 |
)
|
| 337 |
# Convert back to string format
|
| 338 |
-
all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
|
| 339 |
color_mapping = [
|
| 340 |
"royalblue",
|
| 341 |
"goldenrod",
|
|
|
|
| 115 |
# Convert string dates to datetime and sort them
|
| 116 |
all_dates_dt = sorted(
|
| 117 |
[
|
| 118 |
+
datetime.strptime(date, "%b-%d-%Y")
|
| 119 |
for date in traders_filtered["month_year_week"].unique()
|
| 120 |
]
|
| 121 |
)
|
| 122 |
# Convert back to string format
|
| 123 |
+
all_dates = [date.strftime("%b-%d-%Y") for date in all_dates_dt]
|
| 124 |
fig = px.box(
|
| 125 |
traders_filtered,
|
| 126 |
x="month_year_week",
|
|
|
|
| 243 |
# Convert string dates to datetime and sort them
|
| 244 |
all_dates_dt = sorted(
|
| 245 |
[
|
| 246 |
+
datetime.strptime(date, "%b-%d-%Y")
|
| 247 |
for date in total_bet_amount["month_year_week"].unique()
|
| 248 |
]
|
| 249 |
)
|
| 250 |
# Convert back to string format
|
| 251 |
+
all_dates = [date.strftime("%b-%d-%Y") for date in all_dates_dt]
|
| 252 |
total_bet_amount["trader_market"] = total_bet_amount.apply(
|
| 253 |
lambda x: (x["trader_type"], x["market_creator"]), axis=1
|
| 254 |
)
|
|
|
|
| 330 |
# Convert string dates to datetime and sort them
|
| 331 |
all_dates_dt = sorted(
|
| 332 |
[
|
| 333 |
+
datetime.strptime(date, "%b-%d-%Y")
|
| 334 |
for date in active_traders["month_year_week"].unique()
|
| 335 |
]
|
| 336 |
)
|
| 337 |
# Convert back to string format
|
| 338 |
+
all_dates = [date.strftime("%b-%d-%Y") for date in all_dates_dt]
|
| 339 |
color_mapping = [
|
| 340 |
"royalblue",
|
| 341 |
"goldenrod",
|