Skanislav
commited on
Commit
·
f24efd4
1
Parent(s):
4bead12
chore: add step to compress all_trades_profitability.parquet.gz
Browse files- scripts/nr_mech_calls.py +7 -0
- scripts/profitability.py +14 -0
scripts/nr_mech_calls.py
CHANGED
|
@@ -5,6 +5,8 @@ from typing import Dict, Any
|
|
| 5 |
from collections import defaultdict
|
| 6 |
from tools import IRRELEVANT_TOOLS
|
| 7 |
import re
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def update_roi(row: pd.DataFrame) -> float:
|
|
@@ -97,6 +99,11 @@ def update_trade_nr_mech_calls(non_agents: bool = False):
|
|
| 97 |
|
| 98 |
# saving
|
| 99 |
all_trades_df.to_parquet(ROOT_DIR / "all_trades_profitability.parquet", index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
|
| 102 |
def get_daily_mech_calls_estimation(
|
|
|
|
| 5 |
from collections import defaultdict
|
| 6 |
from tools import IRRELEVANT_TOOLS
|
| 7 |
import re
|
| 8 |
+
import gzip
|
| 9 |
+
import shutil
|
| 10 |
|
| 11 |
|
| 12 |
def update_roi(row: pd.DataFrame) -> float:
|
|
|
|
| 99 |
|
| 100 |
# saving
|
| 101 |
all_trades_df.to_parquet(ROOT_DIR / "all_trades_profitability.parquet", index=False)
|
| 102 |
+
|
| 103 |
+
# compress to gzip
|
| 104 |
+
with open(ROOT_DIR / "all_trades_profitability.parquet", "rb") as f_in:
|
| 105 |
+
with gzip.open(ROOT_DIR / "all_trades_profitability.parquet.gz", "wb") as f_out:
|
| 106 |
+
shutil.copyfileobj(f_in, f_out)
|
| 107 |
|
| 108 |
|
| 109 |
def get_daily_mech_calls_estimation(
|
scripts/profitability.py
CHANGED
|
@@ -23,6 +23,8 @@ from typing import Any
|
|
| 23 |
from enum import Enum
|
| 24 |
from tqdm import tqdm
|
| 25 |
import numpy as np
|
|
|
|
|
|
|
| 26 |
from web3_utils import query_conditional_tokens_gc_subgraph
|
| 27 |
from get_mech_info import (
|
| 28 |
DATETIME_60_DAYS_AGO,
|
|
@@ -167,6 +169,7 @@ def prepare_profitalibity_data(
|
|
| 167 |
print(f"{tools_filename} not found.")
|
| 168 |
return
|
| 169 |
|
|
|
|
| 170 |
# Check if fpmmTrades.parquet is in the same directory
|
| 171 |
print("Reading the new trades file")
|
| 172 |
try:
|
|
@@ -439,6 +442,12 @@ def run_profitability_analysis(
|
|
| 439 |
|
| 440 |
# save to parquet
|
| 441 |
all_trades_df.to_parquet(ROOT_DIR / "all_trades_profitability.parquet", index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
print("Profitability analysis Done!")
|
| 443 |
|
| 444 |
return all_trades_df
|
|
@@ -518,6 +527,11 @@ def add_trades_profitability(trades_filename: str):
|
|
| 518 |
)
|
| 519 |
all_trades_df.drop_duplicates("trade_id", keep="last", inplace=True)
|
| 520 |
all_trades_df.to_parquet(ROOT_DIR / "all_trades_profitability.parquet", index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 521 |
|
| 522 |
|
| 523 |
if __name__ == "__main__":
|
|
|
|
| 23 |
from enum import Enum
|
| 24 |
from tqdm import tqdm
|
| 25 |
import numpy as np
|
| 26 |
+
import gzip
|
| 27 |
+
import shutil
|
| 28 |
from web3_utils import query_conditional_tokens_gc_subgraph
|
| 29 |
from get_mech_info import (
|
| 30 |
DATETIME_60_DAYS_AGO,
|
|
|
|
| 169 |
print(f"{tools_filename} not found.")
|
| 170 |
return
|
| 171 |
|
| 172 |
+
fpmmTrades = None
|
| 173 |
# Check if fpmmTrades.parquet is in the same directory
|
| 174 |
print("Reading the new trades file")
|
| 175 |
try:
|
|
|
|
| 442 |
|
| 443 |
# save to parquet
|
| 444 |
all_trades_df.to_parquet(ROOT_DIR / "all_trades_profitability.parquet", index=False)
|
| 445 |
+
|
| 446 |
+
# compress to gzip
|
| 447 |
+
with open(ROOT_DIR / "all_trades_profitability.parquet", "rb") as f_in:
|
| 448 |
+
with gzip.open(ROOT_DIR / "all_trades_profitability.parquet.gz", "wb") as f_out:
|
| 449 |
+
shutil.copyfileobj(f_in, f_out)
|
| 450 |
+
|
| 451 |
print("Profitability analysis Done!")
|
| 452 |
|
| 453 |
return all_trades_df
|
|
|
|
| 527 |
)
|
| 528 |
all_trades_df.drop_duplicates("trade_id", keep="last", inplace=True)
|
| 529 |
all_trades_df.to_parquet(ROOT_DIR / "all_trades_profitability.parquet", index=False)
|
| 530 |
+
|
| 531 |
+
# compress to gzip
|
| 532 |
+
with open(ROOT_DIR / "all_trades_profitability.parquet", "rb") as f_in:
|
| 533 |
+
with gzip.open(ROOT_DIR / "all_trades_profitability.parquet.gz", "wb") as f_out:
|
| 534 |
+
shutil.copyfileobj(f_in, f_out)
|
| 535 |
|
| 536 |
|
| 537 |
if __name__ == "__main__":
|