diff --git a/custom/players.py b/custom/players.py index 3a1302e..c489127 100644 --- a/custom/players.py +++ b/custom/players.py @@ -119,10 +119,10 @@ def builder(self, ownership, tqdm_desc): "status": status, "team_short_name": teams[player["team"]]["short_name"], "pos": pos, - "latest_price": f"£{latest_price}", - "price_change": f"£{price_change}", - "xg": player["expected_goals"], - "xa": player["expected_assists"], + "latest_price": latest_price, + "price_change": price_change, + "xg": float(player["expected_goals"]), + "xa": float(player["expected_assists"]), "sum_xg_xa": float(player["expected_goals"]) + float(player["expected_assists"]), "pts_prev_n_gw": pts_prev_n_gw, @@ -133,6 +133,14 @@ def builder(self, ownership, tqdm_desc): "fdr_avg": round(fdr_sum / total_games, 1), } + # this is an experimental feature + xg_weightage = 0.3 + xa_weightage = 0.25 + perf_weightage = 0.2 + fda_weightage = 0.15 + price_weightage = 0.1 + stats[fpl_id]["weighted_value"] = round((stats[fpl_id]["xg"] * xg_weightage) + (stats[fpl_id]["xa"] * xa_weightage) + (stats[fpl_id]["total_pts_prev_n_gw"] * perf_weightage) + (1 / stats[fpl_id]["fdr_avg"] * fda_weightage) + (1 / stats[fpl_id]["latest_price"] * price_weightage), 1) + if ownership is not None: stats[fpl_id]["ownership"] = f"{ownership[fpl_id]}%" self.stats = stats @@ -183,6 +191,7 @@ def get_table(self, top=None): + [f"GW{Gameweek.NEXT_GW} xP"] + [f"GW{gw} Fxt" for gw in Gameweek.NEXT_N_GWS] + ["FDA"] + + ["Value"] ) if "ownership" in list(dict(islice(self.stats.items(), 1)).values())[0]: header.append("Top 10k Ownership") @@ -194,7 +203,7 @@ def get_table(self, top=None): f'{v["web_name"]} {v["status"]}', v["team_short_name"], v["pos"], - v["latest_price"], + f'£{v["latest_price"]}', v["xg"], v["xa"], ] @@ -205,6 +214,7 @@ def get_table(self, top=None): for fixture in list(v["fixtures"].values()): row.append("\n".join(fixture)) row.append(v["fdr_avg"]) + row.append(v["weighted_value"]) if "ownership" in list(dict(islice(self.stats.items(), 1)).values())[0]: row.append(v["ownership"]) table.add_row(row)