rosacastillo
commited on
Commit
·
ab97b32
1
Parent(s):
0031424
updating gitignore and markets map
Browse files- .gitignore +2 -0
- scripts/markets.py +1 -0
- scripts/utils.py +55 -1
- tabs/metrics.py +2 -2
.gitignore
CHANGED
@@ -22,6 +22,8 @@ parts/
|
|
22 |
sdist/
|
23 |
var/
|
24 |
wheels/
|
|
|
|
|
25 |
share/python-wheels/
|
26 |
*.egg-info/
|
27 |
.installed.cfg
|
|
|
22 |
sdist/
|
23 |
var/
|
24 |
wheels/
|
25 |
+
json_data/
|
26 |
+
tmp/
|
27 |
share/python-wheels/
|
28 |
*.egg-info/
|
29 |
.installed.cfg
|
scripts/markets.py
CHANGED
@@ -59,6 +59,7 @@ DEFAULT_FILENAME = "fpmms.parquet"
|
|
59 |
SCRIPTS_DIR = Path(__file__).parent
|
60 |
ROOT_DIR = SCRIPTS_DIR.parent
|
61 |
DATA_DIR = ROOT_DIR / "data"
|
|
|
62 |
|
63 |
|
64 |
class RetriesExceeded(Exception):
|
|
|
59 |
SCRIPTS_DIR = Path(__file__).parent
|
60 |
ROOT_DIR = SCRIPTS_DIR.parent
|
61 |
DATA_DIR = ROOT_DIR / "data"
|
62 |
+
market_creators_map = {"quickstart": CREATOR, "pearl": PEARL_CREATOR}
|
63 |
|
64 |
|
65 |
class RetriesExceeded(Exception):
|
scripts/utils.py
CHANGED
@@ -3,7 +3,7 @@ import json
|
|
3 |
import os
|
4 |
import time
|
5 |
from tqdm import tqdm
|
6 |
-
from typing import List, Any, Optional, Union
|
7 |
import numpy as np
|
8 |
import pandas as pd
|
9 |
import gc
|
@@ -222,6 +222,18 @@ EVENT_TO_MECH_STRUCT = {
|
|
222 |
}
|
223 |
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
def parse_args() -> str:
|
226 |
"""Parse the arguments and return the RPC."""
|
227 |
if len(sys.argv) != 2:
|
@@ -364,6 +376,48 @@ def measure_execution_time(func):
|
|
364 |
return wrapper
|
365 |
|
366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
def _to_content(q: str) -> dict[str, Any]:
|
368 |
"""Convert the given query string to payload content, i.e., add it under a `queries` key and convert it to bytes."""
|
369 |
finalized_query = {
|
|
|
3 |
import os
|
4 |
import time
|
5 |
from tqdm import tqdm
|
6 |
+
from typing import List, Any, Optional, Union, Tuple
|
7 |
import numpy as np
|
8 |
import pandas as pd
|
9 |
import gc
|
|
|
222 |
}
|
223 |
|
224 |
|
225 |
+
def measure_execution_time(func):
|
226 |
+
def wrapper(*args, **kwargs):
|
227 |
+
start_time = time.time()
|
228 |
+
result = func(*args, **kwargs)
|
229 |
+
end_time = time.time()
|
230 |
+
execution_time = end_time - start_time
|
231 |
+
print(f"Execution time: {execution_time:.6f} seconds")
|
232 |
+
return result
|
233 |
+
|
234 |
+
return wrapper
|
235 |
+
|
236 |
+
|
237 |
def parse_args() -> str:
|
238 |
"""Parse the arguments and return the RPC."""
|
239 |
if len(sys.argv) != 2:
|
|
|
376 |
return wrapper
|
377 |
|
378 |
|
379 |
+
def get_vote(p_yes, p_no) -> Optional[str]:
|
380 |
+
"""Return the vote."""
|
381 |
+
if p_no == p_yes:
|
382 |
+
return None
|
383 |
+
if p_no > p_yes:
|
384 |
+
return "No"
|
385 |
+
return "Yes"
|
386 |
+
|
387 |
+
|
388 |
+
def get_win_probability(p_yes, p_no) -> Optional[float]:
|
389 |
+
"""Return the probability estimation for winning with vote."""
|
390 |
+
return max(p_no, p_yes)
|
391 |
+
|
392 |
+
|
393 |
+
def get_result_values(result: str) -> Tuple:
|
394 |
+
if result == "Invalid response":
|
395 |
+
return 1, "Invalid response from tool", None
|
396 |
+
error_message = None
|
397 |
+
params = None
|
398 |
+
try:
|
399 |
+
if isinstance(result, str):
|
400 |
+
params = json.loads(result)
|
401 |
+
error_value = 0
|
402 |
+
|
403 |
+
except JSONDecodeError:
|
404 |
+
error_message = "Response parsing error"
|
405 |
+
error_value = 1
|
406 |
+
|
407 |
+
except Exception as e:
|
408 |
+
error_message = str(e)
|
409 |
+
error_value = 1
|
410 |
+
return error_value, error_message, params
|
411 |
+
|
412 |
+
|
413 |
+
def get_prediction_values(params: dict) -> Tuple:
|
414 |
+
p_yes = float(params.pop("p_yes"))
|
415 |
+
p_no = float(params.pop("p_no"))
|
416 |
+
confidence = float(params.pop("confidence"))
|
417 |
+
info_utility = float(params.pop("info_utility"))
|
418 |
+
return p_yes, p_no, confidence, info_utility
|
419 |
+
|
420 |
+
|
421 |
def _to_content(q: str) -> dict[str, Any]:
|
422 |
"""Convert the given query string to payload content, i.e., add it under a `queries` key and convert it to bytes."""
|
423 |
finalized_query = {
|
tabs/metrics.py
CHANGED
@@ -243,9 +243,9 @@ def get_trade_metrics_text() -> gr.Markdown:
|
|
243 |
metric_text = """
|
244 |
## Description of the graph
|
245 |
These metrics are computed weekly. The statistical measures are:
|
246 |
-
* min, max
|
247 |
* the upper and lower fences to delimit possible outliers
|
248 |
-
* the average values as the
|
249 |
"""
|
250 |
|
251 |
return gr.Markdown(metric_text)
|
|
|
243 |
metric_text = """
|
244 |
## Description of the graph
|
245 |
These metrics are computed weekly. The statistical measures are:
|
246 |
+
* min, max, 25th(q1), 50th(median) and 75th(q2) percentiles
|
247 |
* the upper and lower fences to delimit possible outliers
|
248 |
+
* the average values as the dotted lines
|
249 |
"""
|
250 |
|
251 |
return gr.Markdown(metric_text)
|