Spaces:
Sleeping
Sleeping
Create betting.py
Browse files- visualization/betting.py +35 -0
visualization/betting.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
import plotly.graph_objects as go
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def create_edge_chart(df: pd.DataFrame) -> go.Figure:
|
| 9 |
+
if df.empty or "edge" not in df.columns:
|
| 10 |
+
return go.Figure()
|
| 11 |
+
|
| 12 |
+
fig = px.bar(
|
| 13 |
+
df,
|
| 14 |
+
x="sportsbook",
|
| 15 |
+
y="edge",
|
| 16 |
+
color="market_key" if "market_key" in df.columns else None,
|
| 17 |
+
title="Edge by Sportsbook",
|
| 18 |
+
)
|
| 19 |
+
fig.update_layout(template="plotly_dark")
|
| 20 |
+
return fig
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def create_bankroll_chart(df: pd.DataFrame) -> go.Figure:
|
| 24 |
+
if df.empty or "bet_id" not in df.columns or "cum_profit" not in df.columns:
|
| 25 |
+
return go.Figure()
|
| 26 |
+
|
| 27 |
+
fig = px.line(
|
| 28 |
+
df,
|
| 29 |
+
x="bet_id",
|
| 30 |
+
y="cum_profit",
|
| 31 |
+
markers=True,
|
| 32 |
+
title="Bankroll Growth",
|
| 33 |
+
)
|
| 34 |
+
fig.update_layout(template="plotly_dark")
|
| 35 |
+
return fig
|