Merge branch 'main' of github.com:nidionis/svr
This commit is contained in:
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
# === AUTO INSTALL ===
|
||||
def ensure(pkg):
|
||||
try:
|
||||
__import__(pkg)
|
||||
except ImportError:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", pkg])
|
||||
|
||||
ensure("pandas")
|
||||
ensure("matplotlib")
|
||||
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# === ARGS ===
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python graph.py data.csv [output_dir]")
|
||||
sys.exit(1)
|
||||
|
||||
FILE = sys.argv[1]
|
||||
OUTDIR = sys.argv[2] if len(sys.argv) > 2 else "graphs"
|
||||
|
||||
os.makedirs(OUTDIR, exist_ok=True)
|
||||
|
||||
# === LOAD ===
|
||||
df = pd.read_csv(FILE)
|
||||
|
||||
required_cols = ["datetime", "profit", "buy_in"]
|
||||
for col in required_cols:
|
||||
if col not in df.columns:
|
||||
print(f"Missing column: {col}")
|
||||
sys.exit(1)
|
||||
|
||||
df["datetime"] = pd.to_datetime(df["datetime"], errors="coerce")
|
||||
df = df.dropna(subset=["datetime"])
|
||||
df = df.sort_values("datetime")
|
||||
|
||||
# === CLEAN NUMERIC ===
|
||||
df["profit"] = pd.to_numeric(df["profit"], errors="coerce").fillna(0)
|
||||
df["buy_in"] = pd.to_numeric(df["buy_in"], errors="coerce").fillna(0)
|
||||
|
||||
# === CUMULATIVE PROFIT ===
|
||||
df["cum_profit"] = df["profit"].cumsum()
|
||||
|
||||
plt.figure()
|
||||
plt.plot(df["datetime"], df["cum_profit"])
|
||||
plt.title("Cumulative Profit")
|
||||
plt.xlabel("Time")
|
||||
plt.ylabel("€")
|
||||
plt.xticks(rotation=45)
|
||||
plt.tight_layout()
|
||||
plt.savefig(f"{OUTDIR}/cum_profit.png")
|
||||
plt.close()
|
||||
|
||||
# === PROFIT PER GAME ===
|
||||
plt.figure()
|
||||
plt.scatter(range(len(df)), df["profit"])
|
||||
plt.title("Profit per Game")
|
||||
plt.xlabel("Game #")
|
||||
plt.ylabel("€")
|
||||
plt.tight_layout()
|
||||
plt.savefig(f"{OUTDIR}/profit_scatter.png")
|
||||
plt.close()
|
||||
|
||||
# === ROI BY CATEGORY (SAFE) ===
|
||||
if "category" in df.columns:
|
||||
df_valid = df[df["buy_in"] > 0]
|
||||
|
||||
if not df_valid.empty:
|
||||
roi = df_valid.groupby("category").apply(
|
||||
lambda x: x["profit"].sum() / x["buy_in"].sum()
|
||||
)
|
||||
|
||||
plt.figure()
|
||||
roi.plot(kind="bar")
|
||||
plt.title("ROI by Category")
|
||||
plt.xlabel("Category")
|
||||
plt.ylabel("ROI")
|
||||
plt.tight_layout()
|
||||
plt.savefig(f"{OUTDIR}/roi_category.png")
|
||||
plt.close()
|
||||
|
||||
# === SESSION PERFORMANCE ===
|
||||
if "session" in df.columns:
|
||||
session_profit = df.groupby("session")["profit"].sum()
|
||||
|
||||
plt.figure()
|
||||
session_profit.plot(kind="bar")
|
||||
plt.title("Profit by Session")
|
||||
plt.xlabel("Session")
|
||||
plt.ylabel("€")
|
||||
plt.tight_layout()
|
||||
plt.savefig(f"{OUTDIR}/session_profit.png")
|
||||
plt.close()
|
||||
|
||||
# === POSITION DISTRIBUTION ===
|
||||
if "position" in df.columns:
|
||||
pos_counts = df["position"].value_counts()
|
||||
|
||||
plt.figure()
|
||||
pos_counts.plot(kind="bar")
|
||||
plt.title("Position Distribution")
|
||||
plt.xlabel("Position")
|
||||
plt.ylabel("Count")
|
||||
plt.tight_layout()
|
||||
plt.savefig(f"{OUTDIR}/positions.png")
|
||||
plt.close()
|
||||
|
||||
print(f"✅ Graphs saved in: {OUTDIR}")
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
# === AUTO INSTALL ===
|
||||
def ensure(pkg):
|
||||
try:
|
||||
__import__(pkg)
|
||||
except ImportError:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", pkg])
|
||||
|
||||
ensure("pandas")
|
||||
ensure("matplotlib")
|
||||
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# === ARGS ===
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python script.py input.txt [output.csv]")
|
||||
sys.exit(1)
|
||||
|
||||
INPUT = sys.argv[1]
|
||||
OUTPUT = sys.argv[2] if len(sys.argv) > 2 else "poker_clean.csv"
|
||||
|
||||
# === HELPERS ===
|
||||
def money(x):
|
||||
if not x or x.strip() in ["-", ""]:
|
||||
return 0.0
|
||||
return float(x.replace("€", "").replace(",", ".").strip())
|
||||
|
||||
def category(name):
|
||||
n = name.lower()
|
||||
if "freeroll" in n: return "freeroll"
|
||||
if "nitro" in n: return "nitro"
|
||||
return "expresso"
|
||||
|
||||
def stake(b):
|
||||
return "micro" if b <= 1 else "low" if b <= 5 else "mid" if b <= 20 else "high"
|
||||
|
||||
def session(h):
|
||||
if 6 <= h < 12: return "morning"
|
||||
if 12 <= h < 18: return "afternoon"
|
||||
if 18 <= h < 24: return "evening"
|
||||
return "night"
|
||||
|
||||
# === PARSE ===
|
||||
rows = []
|
||||
errors = 0
|
||||
|
||||
with open(INPUT, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
raw = line.strip()
|
||||
if not raw:
|
||||
continue
|
||||
|
||||
parts = re.split(r"\s{2,}", raw)
|
||||
|
||||
try:
|
||||
# DEBUG FIRST RUN ONLY (comment after)
|
||||
# print(parts)
|
||||
|
||||
dt = datetime.strptime(parts[0], "%d/%m/%Y %H:%M:%S")
|
||||
name = parts[1]
|
||||
buy = float(parts[2]) if len(parts) > 2 else 0.0
|
||||
players = int(parts[5]) if len(parts) > 5 and parts[5].isdigit() else None
|
||||
|
||||
pos = parts[6] if len(parts) > 6 and parts[6] != "-" else None
|
||||
prize = money(parts[7]) if len(parts) > 7 else 0.0
|
||||
net = money(parts[8]) if len(parts) > 8 else 0.0
|
||||
|
||||
profit = net - buy
|
||||
h = dt.hour
|
||||
|
||||
rows.append({
|
||||
"datetime": dt,
|
||||
"game": name,
|
||||
"buy_in": buy,
|
||||
"players": players,
|
||||
"position": pos,
|
||||
"prize": prize,
|
||||
"net": net,
|
||||
"profit": profit,
|
||||
"category": category(name),
|
||||
"stake": stake(buy),
|
||||
"hour": h,
|
||||
"day": dt.strftime("%A"),
|
||||
"session": session(h),
|
||||
"result": "win" if pos == "1" else "itm" if prize > 0 else "loss"
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
errors += 1
|
||||
if errors < 5:
|
||||
print("Skip:", raw)
|
||||
print("Reason:", e)
|
||||
|
||||
# === VALIDATION ===
|
||||
if not rows:
|
||||
print("❌ No valid rows parsed. Your format is different. Enable debug print.")
|
||||
sys.exit(1)
|
||||
|
||||
df = pd.DataFrame(rows)
|
||||
|
||||
if "datetime" not in df.columns:
|
||||
print("❌ Broken parse. Columns:", df.columns)
|
||||
sys.exit(1)
|
||||
|
||||
# === PROCESS ===
|
||||
df = df.sort_values("datetime")
|
||||
df["cum_profit"] = df["profit"].cumsum()
|
||||
|
||||
# === SAVE ===
|
||||
df.to_csv(OUTPUT, index=False)
|
||||
print(f"✅ Saved {len(df)} rows → {OUTPUT}")
|
||||
print(f"⚠️ Skipped lines: {errors}")
|
||||
|
||||
print("Games:", len(df))
|
||||
print("Total profit:", df["profit"].sum())
|
||||
print("ROI:", df["profit"].sum() / df["buy_in"].sum())
|
||||
print("Win rate:", (df["position"] == "1").mean())
|
||||
print("ITM:", (df["prize"] > 0).mean())
|
||||
|
||||
# === GRAPH ===
|
||||
plt.figure()
|
||||
plt.plot(df["datetime"], df["cum_profit"])
|
||||
plt.xlabel("Time")
|
||||
plt.ylabel("€")
|
||||
plt.title("Cumulative Profit")
|
||||
plt.xticks(rotation=45)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASE_DIR=${1:-"/tmp"}
|
||||
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
echo "usage: $0 <base_dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOCKER_DIR="$BASE_DIR/docker"
|
||||
SRC_DIR="$BASE_DIR/AOO"
|
||||
|
||||
mkdir -p "$DOCKER_DIR" "$SRC_DIR"
|
||||
|
||||
cd "$DOCKER_DIR" || exit 1
|
||||
wget https://svn.apache.org/repos/asf/openoffice/devtools/build-scripts/4.2.0/containers/linux/Dockerfile
|
||||
|
||||
docker build -t aoo_centos .
|
||||
|
||||
cd "$SRC_DIR" || exit 1
|
||||
git clone https://gitbox.apache.org/repos/asf/openoffice.git .
|
||||
|
||||
docker run -ti -v "$SRC_DIR:/workspace/AOO" aoo_centos
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
|
||||
nameserver 1.1.1.1
|
||||
nameserver 0.0.0.0
|
||||
nameserver 8.8.8.8
|
||||
|
||||
@@ -29,7 +29,7 @@ alias s="sudo -E"
|
||||
function src() {
|
||||
source $HOME/.bashrc || true
|
||||
d="$PWD"; while [ "$d" != "/" ]; do
|
||||
for a in "$d/bin/activate" "$d/.env/bin/activate"; do
|
||||
for a in "$d/bin/activate" "$d/.venv/bin/activate" "$d/.env/bin/activate"; do
|
||||
[ -f $a ] && echo "found at $a" && . "$a" && break 2
|
||||
done
|
||||
d=$(dirname "$d")
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ if [ -f /home/.bash_aliases ]; then
|
||||
fi
|
||||
|
||||
# permet les accents
|
||||
setxkbmap us -variant intl
|
||||
#setxkbmap us -variant intl
|
||||
|
||||
#envsubst < ${MACHINE_PATH}/dotfiles/ssh/config.template > ~/.ssh/config
|
||||
|
||||
|
||||
Reference in New Issue
Block a user