cyberosa commited on
Commit
42c51a5
·
1 Parent(s): 73f254c

Adding weekly data

Browse files
active_traders.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:192e8d90765a4f527a7e586073d5b45d8ae8df448a4c5299751d8d75303adb97
3
- size 24287817
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0e650d48126feb97c14a9337a00a733499d04fe1f1d70b7a38343ae028e9e10
3
+ size 23929002
all_trades_profitability.parquet.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:65e8f94ca3e200a33b964703ba94287c54f25b570baf8c93678d633ab5b4d026
3
- size 8018110
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edb44893c1b2dfb3e033295d06f7f5a349ee028c43a05092380b4b7fd8f87989
3
+ size 7894061
closed_market_metrics.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:70974eec51a7a0b2bc801be6750b41368dc424622d856b8edd55c3375617d9a4
3
- size 127569
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2520c89416f816c78b6bc098e2933495f9a790702a6abaddb2ad0b270597e014
3
+ size 128151
closed_markets_div.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ee408e439e8a097c4e75f355148928fccc7db067d4a3d17ffe03b117405f8c30
3
- size 80942
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bde79c511fd36dd1fe595d9ce9022e3ab257019e54cb7d458232f620d6977e72
3
+ size 80767
daily_info.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a28d241c18c655eb716379af98b5bb0b4ae1cb04fe056465dc6608366740dfef
3
- size 1809366
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39cd14af66f77a36a52859c2f878ccef4d83b96eae22e8ae28576608e9ac3d5e
3
+ size 1741346
daily_mech_requests.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:40998fb828a2eb0518c27e79afb225101a72a436e38959747a70ae8f6c044746
3
- size 10884
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1d2d81aee3378f6006a1f24254a51d9e408e88c7d4faea7140fa8624d622fe8
3
+ size 10871
error_by_markets.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:41abf5c9c7d05bcde84ec6aa79a83373b55c7acd781ddb0fc24e12f858b5ca58
3
- size 11542
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6235e2fd4293abb3d3de27cf669090cdfeca791f899b6aa962b90ae224cf19f5
3
+ size 11342
errors_by_mech.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:694b16506864a56cb10b63dc35499672b654ddea686a94e48e8d82bc3dddd6a9
3
- size 5885
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8bab5dcb558742c5a244eb53687fc98cdd33fbbae8ae126b6b93395b8d450b78
3
+ size 6005
gnosis_txs_dataset.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbdbc142ac5e27676a70fa478f0e38f10de107cc4d919826f420f3e83ba546e9
3
+ size 31531602
invalid_trades.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2264c8d7cf43b5cc792e69921869221ae55432c0ac735e50345b581018e1c0af
3
- size 111651
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b25e7481394da77811d00805a80a6d015a0b1eb2e58b15fc66c232898754fb3f
3
+ size 144790
retention_activity.parquet.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:703359220518d84d464368ec1d60d2d4a1e51652a98f6861a203da05d8f2a773
3
- size 6917979
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7644d9f6eedc523f8c129da8cc33e88a905a2a070bad1862a4a5098d7fb55d50
3
+ size 6827332
scripts/daa.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from datetime import datetime, timedelta, UTC
3
+ from web3_utils import ROOT_DIR
4
+ from utils import measure_execution_time
5
+ from get_mech_info import fetch_block_number, get_last_block_number
6
+ from tqdm import tqdm
7
+ import requests
8
+ from concurrent.futures import ThreadPoolExecutor
9
+ from gnosis_timestamps import get_all_txs_between_blocks_from_trader_address
10
+
11
+ DATETIME_60_DAYS_AGO = datetime.now(UTC) - timedelta(days=60)
12
+
13
+
14
+ def get_block_number_from_datetime(datetime_sample) -> int:
15
+ """Function to get the block number from a datetime sample"""
16
+ print(f"Datetime sample = {datetime_sample}")
17
+ five_seconds = timedelta(seconds=5)
18
+ block_number = fetch_block_number(
19
+ int(datetime_sample.timestamp()),
20
+ int((datetime_sample + five_seconds).timestamp()),
21
+ )
22
+ block_number = block_number.get("number", "")
23
+ if block_number.isdigit():
24
+ return int(block_number)
25
+
26
+
27
+ def safe_get_txs(session, trader_address, market_creator: str, start_block, end_block):
28
+ try:
29
+ df = get_all_txs_between_blocks_from_trader_address(
30
+ session, trader_address, market_creator, start_block, end_block
31
+ )
32
+ if df is None:
33
+ return pd.DataFrame() # Return empty DataFrame if None
34
+ return df
35
+ except Exception as e:
36
+ print(f"Error getting transactions for {trader_address}: {e}")
37
+ return pd.DataFrame() # Return empty DataFrame on error
38
+
39
+
40
+ @measure_execution_time
41
+ def prepare_gnosis_txs_dataset():
42
+ """Function to extract the gnosis txs from the Olas traders"""
43
+
44
+ # To read current all trades profitability
45
+ all_trades = pd.read_parquet(ROOT_DIR / "all_trades_profitability.parquet")
46
+
47
+ # to filter only traders of the trader_type Olas
48
+ olas_traders = all_trades[all_trades["staking"] != "non_Olas"]
49
+
50
+ # To extract the list of unique trader addresses from olas_traders and their corresponding market creator
51
+ olas_traders = olas_traders[["trader_address", "market_creator"]].drop_duplicates()
52
+ olas_traders = olas_traders.reset_index(drop=True)
53
+ print(f"Number of unique traders = {len(olas_traders)}")
54
+ print(olas_traders.market_creator.value_counts())
55
+
56
+ # Get the starting block number
57
+ starting_block = get_block_number_from_datetime(DATETIME_60_DAYS_AGO)
58
+ print(f"Starting block = {starting_block}")
59
+ # Get the ending block number
60
+ ending_block = get_last_block_number()
61
+ print(f"Ending block = {ending_block}")
62
+ print(f"Number of blocks to fetch = {ending_block - starting_block}")
63
+ # Parallelize getting the transactions from the trader addresses
64
+ results = []
65
+ session = requests.Session()
66
+ # Use this session for all requests
67
+ with ThreadPoolExecutor(max_workers=10) as executor:
68
+ results = list(
69
+ tqdm(
70
+ executor.map(
71
+ lambda x: safe_get_txs(
72
+ session,
73
+ x.trader_address,
74
+ x.market_creator,
75
+ starting_block,
76
+ ending_block,
77
+ ),
78
+ olas_traders.itertuples(index=False),
79
+ ),
80
+ total=len(olas_traders),
81
+ )
82
+ )
83
+ results = [r for r in results if isinstance(r, pd.DataFrame)]
84
+ return pd.concat(results, ignore_index=True)
85
+
86
+
87
+ if __name__ == "__main__":
88
+ # Measure the execution time of the function
89
+ txs_dataset = prepare_gnosis_txs_dataset()
90
+ # Save the dataset to a parquet file
91
+ txs_dataset.to_parquet(
92
+ ROOT_DIR / "gnosis_txs_dataset.parquet", index=False, compression="gzip"
93
+ )
94
+ print(f"Number of transactions = {len(txs_dataset)}")
scripts/gnosis_timestamps.py CHANGED
@@ -2,8 +2,9 @@ from web3 import Web3
2
  import os
3
  import requests
4
  import time
 
5
  import pickle
6
- from datetime import datetime, timezone
7
  from functools import partial
8
  import pandas as pd
9
  import pytz
@@ -11,6 +12,7 @@ from tqdm import tqdm
11
  from utils import ROOT_DIR, TMP_DIR, measure_execution_time
12
  from concurrent.futures import ThreadPoolExecutor
13
 
 
14
  GNOSIS_API_INTERVAL = 0.2 # 5 calls in 1 second
15
  GNOSIS_URL = "https://api.gnosisscan.io/api"
16
  GNOSIS_API_KEY = os.environ.get("GNOSIS_API_KEY", None)
@@ -33,6 +35,65 @@ def transform_timestamp_to_datetime(timestamp):
33
  return dt
34
 
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  def get_tx_hash(trader_address, request_block):
37
  """Function to get the transaction hash from the address and block number"""
38
  params = {
 
2
  import os
3
  import requests
4
  import time
5
+ import random
6
  import pickle
7
+ from datetime import datetime, timezone, UTC, timedelta
8
  from functools import partial
9
  import pandas as pd
10
  import pytz
 
12
  from utils import ROOT_DIR, TMP_DIR, measure_execution_time
13
  from concurrent.futures import ThreadPoolExecutor
14
 
15
+
16
  GNOSIS_API_INTERVAL = 0.2 # 5 calls in 1 second
17
  GNOSIS_URL = "https://api.gnosisscan.io/api"
18
  GNOSIS_API_KEY = os.environ.get("GNOSIS_API_KEY", None)
 
35
  return dt
36
 
37
 
38
+ def get_all_txs_between_blocks_from_trader_address(
39
+ session, trader_address: str, market_creator: str, starting_block, ending_block
40
+ ) -> pd.DataFrame:
41
+ """Function to get all the transactions from a trader address between two blocks"""
42
+ # https://docs.gnosisscan.io/api-endpoints/accounts
43
+ params = {
44
+ "module": "account",
45
+ "action": "txlist",
46
+ "address": trader_address,
47
+ "startblock": starting_block,
48
+ "endblock": ending_block,
49
+ "page": 1,
50
+ "offset": 5000,
51
+ "sort": "asc",
52
+ "apikey": GNOSIS_API_KEY,
53
+ }
54
+ max_retries = 5
55
+ for attempt in range(max_retries):
56
+ try:
57
+ response = session.get(GNOSIS_URL, params=params)
58
+ tx_list = response.json()["result"]
59
+ # time.sleep(GNOSIS_API_INTERVAL)
60
+ if len(tx_list) == 0:
61
+ print("No transactions found")
62
+ return pd.DataFrame()
63
+ # Extract only blockNumber and timeStamp
64
+ filtered_tx_list = [
65
+ {
66
+ "blockNumber": tx["blockNumber"],
67
+ "timeStamp": tx["timeStamp"],
68
+ "trader_address": trader_address,
69
+ "market_creator": market_creator,
70
+ "hash": tx["hash"],
71
+ }
72
+ for tx in tx_list
73
+ if "blockNumber" in tx and "timeStamp" in tx
74
+ ]
75
+ df = pd.DataFrame.from_records(filtered_tx_list)
76
+ # Convert the timestamp to datetime
77
+ if not df.empty:
78
+ df["tx_datetime"] = df["timeStamp"].apply(
79
+ lambda x: transform_timestamp_to_datetime(int(x))
80
+ )
81
+ # Convert the block number to int
82
+ df["blockNumber"] = df["blockNumber"].astype(int)
83
+ return df
84
+ except Exception as e:
85
+ if attempt < max_retries - 1:
86
+ sleep_time = (2**attempt) + random.random()
87
+ print(
88
+ f"Attempt {attempt+1} failed. Retrying in {sleep_time:.2f} seconds..."
89
+ )
90
+ time.sleep(sleep_time)
91
+ else:
92
+ raise
93
+ print(f"Error getting transactions for {trader_address}: {e}")
94
+ return pd.DataFrame()
95
+
96
+
97
  def get_tx_hash(trader_address, request_block):
98
  """Function to get the transaction hash from the address and block number"""
99
  params = {
scripts/pull_data.py CHANGED
@@ -135,7 +135,7 @@ def only_new_weekly_analysis():
135
 
136
  save_historical_data()
137
  try:
138
- clean_old_data_from_parquet_files("2025-03-14")
139
  clean_old_data_from_json_files()
140
  except Exception as e:
141
  print("Error cleaning the oldest information from parquet files")
 
135
 
136
  save_historical_data()
137
  try:
138
+ clean_old_data_from_parquet_files("2025-03-18")
139
  clean_old_data_from_json_files()
140
  except Exception as e:
141
  print("Error cleaning the oldest information from parquet files")
service_map.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f72b0ef80baf352680c060b4d436e6ab96f18b76f6874572f8442b425a250cdf
3
- size 206230
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:529fc70ba1743d4aa857d59ea81ce8702555173477026a530996fb8da14ca2b0
3
+ size 206368
tools_accuracy.csv CHANGED
@@ -1,13 +1,13 @@
1
  tool,tool_accuracy,total_requests,min,max
2
- claude-prediction-offline,60.77737447065941,66120,2025-03-14 05:58:40,2025-05-13 21:55:05
3
- claude-prediction-online,62.836010376993976,36234,2025-03-14 00:00:35,2025-05-13 23:07:50
4
- prediction-offline,55.20349988804492,290295,2025-03-14 00:00:05,2025-05-14 21:35:50
5
- prediction-offline-sme,52.338530066815146,3143,2025-03-14 00:00:55,2025-05-13 20:16:20
6
- prediction-online,45.43903752917939,11138,2025-03-14 07:18:15,2025-05-14 20:52:40
7
- prediction-online-sme,47.43523760507806,5829,2025-03-14 08:27:05,2025-05-14 17:20:40
8
- prediction-request-rag,45.07042253521127,284,2025-03-14 11:52:15,2025-05-11 21:35:05
9
- prediction-request-rag-claude,50.602409638554214,249,2025-03-14 07:14:25,2025-05-12 17:47:40
10
- prediction-request-reasoning,52.409874974303385,107018,2025-03-14 07:02:40,2025-05-14 22:49:50
11
- prediction-request-reasoning-claude,67.38197424892704,233,2025-03-14 13:27:10,2025-05-13 16:42:35
12
- prediction-url-cot-claude,60.547667342799194,986,2025-03-14 00:24:30,2025-05-13 20:03:25
13
- superforcaster,52.55152109911678,16304,2025-03-14 00:28:25,2025-05-14 21:22:30
 
1
  tool,tool_accuracy,total_requests,min,max
2
+ claude-prediction-offline,59.6009936584839,64811,2025-03-18 00:03:55,2025-05-17 23:32:30
3
+ claude-prediction-online,62.110541112367045,34503,2025-03-18 00:04:30,2025-05-17 23:03:00
4
+ prediction-offline,55.13734075734771,285021,2025-03-18 00:00:25,2025-05-18 23:42:20
5
+ prediction-offline-sme,49.43551146082792,2923,2025-03-18 00:34:45,2025-05-17 18:47:55
6
+ prediction-online,46.3707616288976,11738,2025-03-18 07:37:50,2025-05-18 21:55:40
7
+ prediction-online-sme,47.47508866745483,5921,2025-03-18 07:38:35,2025-05-18 21:20:20
8
+ prediction-request-rag,45.348837209302324,258,2025-03-18 08:06:20,2025-05-17 20:43:25
9
+ prediction-request-rag-claude,50.65502183406113,229,2025-03-18 13:32:45,2025-05-16 15:02:00
10
+ prediction-request-reasoning,52.527100088764556,111531,2025-03-18 07:00:10,2025-05-18 23:45:00
11
+ prediction-request-reasoning-claude,68.80733944954129,218,2025-03-18 14:11:20,2025-05-17 18:24:25
12
+ prediction-url-cot-claude,59.32203389830508,944,2025-03-18 08:06:50,2025-05-17 22:14:10
13
+ superforcaster,52.69106237399963,16369,2025-03-18 00:00:45,2025-05-18 21:15:50
unknown_traders.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e1acea992138bc4199642b2bb50024b3c3e50aefb11d7dd030bb76e02c30302
3
- size 1159303
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0d89f255e732a8e3195127aae7c712e90982ae70256ac42e88c15a6cee78b5a
3
+ size 1163518
weekly_mech_calls.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f1315acafc862ae346383e3c7a683e3148101b14c27b5ce559f85c215c56858b
3
- size 56265
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ff101ecae9df43de0a588d07a2afc5292144995dfa66d1f8a4adc023df5191a
3
+ size 55083
winning_df.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:29a27d5df322828826902c69fd5e5cad3c5c393f15fddd6ee21a00481e3c1aa5
3
- size 11799
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2c97214810548fb1ec6fbced86e58a13753a25fad9e90b8ae24ebb4f3c7eeb6
3
+ size 11368