|
| 1 | +class Model: |
| 2 | + def __init__(self, client): |
| 3 | + self.client = client |
| 4 | + self._path = "/preds" |
| 5 | + |
| 6 | + def rankings(self, f_format: str = "json") -> dict: |
| 7 | + """ |
| 8 | + Returns top 500 players according to DG model predictions. |
| 9 | + :return: dict |
| 10 | + """ |
| 11 | + return self.client.get( |
| 12 | + resource=f"{self._path}/get-dg-rankings", format=f_format |
| 13 | + ) |
| 14 | + |
| 15 | + def pre_tournament_pred( |
| 16 | + self, |
| 17 | + tour: str = "pga", |
| 18 | + add_position: str = None, |
| 19 | + dead_heat: bool = True, |
| 20 | + odds_format: str = "percent", |
| 21 | + f_format: str = "json", |
| 22 | + ) -> dict: |
| 23 | + """ |
| 24 | +
|
| 25 | + :param tour: pga, euro, kft, opp, alt |
| 26 | + :param add_position: 1, 2, 3 (csv separated values) |
| 27 | + :param dead_heat: bool - Adjust odds for dead-heat rules. |
| 28 | + :param odds_format: percent (default), american, decimal, fraction |
| 29 | + :param f_format: json (default) |
| 30 | + :return: |
| 31 | + """ |
| 32 | + query_p = {"tour": tour} |
| 33 | + if add_position: |
| 34 | + query_p["add_position"] = add_position |
| 35 | + |
| 36 | + query_p["dead_heat"] = "yes" if dead_heat else "no" |
| 37 | + query_p["odds_format"] = odds_format |
| 38 | + |
| 39 | + return self.client.get( |
| 40 | + resource=f"{self._path}/pre-tournament?", params=query_p, format=f_format |
| 41 | + ) |
| 42 | + |
| 43 | + def pre_tournament_pred_archive( |
| 44 | + self, |
| 45 | + event_id: str = None, |
| 46 | + year: str = None, |
| 47 | + odd_format: str = "percent", |
| 48 | + f_format="json", |
| 49 | + ) -> dict: |
| 50 | + """ |
| 51 | + Returns pre-tournament predictions for a specific event or year. |
| 52 | + :param event_id: The event id for the tournament. |
| 53 | + :param year: The year for the tournament. |
| 54 | + :param odd_format: percent (default), american, decimal, fraction |
| 55 | + :param f_format: json (default) |
| 56 | + :return: dict |
| 57 | + """ |
| 58 | + |
| 59 | + query_p = {} |
| 60 | + |
| 61 | + if event_id: |
| 62 | + query_p["event_id"] = event_id |
| 63 | + if year: |
| 64 | + query_p["year"] = year |
| 65 | + query_p["odds_format"] = odd_format |
| 66 | + query_p["file_format"] = f_format |
| 67 | + |
| 68 | + return self.client.get( |
| 69 | + resource=f"{self._path}/pre-tournament-archive", |
| 70 | + params=query_p, |
| 71 | + format=f_format, |
| 72 | + ) |
| 73 | + |
| 74 | + def player_skill_decompositions( |
| 75 | + self, tour: str = "pga", f_format: str = "json" |
| 76 | + ) -> dict: |
| 77 | + """ |
| 78 | + Returns player skill decompositions for a specific tour. |
| 79 | + :param tour: pga, euro, kft, opp, alt |
| 80 | + :param f_format: json (default) |
| 81 | + :return: dict |
| 82 | + """ |
| 83 | + query_p = {"tour": tour} |
| 84 | + return self.client.get( |
| 85 | + resource=f"{self._path}/player-decompositions", |
| 86 | + params=query_p, |
| 87 | + format=f_format, |
| 88 | + ) |
| 89 | + |
| 90 | + def player_skill_ratings( |
| 91 | + self, display: str = "value", f_format: str = "json" |
| 92 | + ) -> dict: |
| 93 | + """ |
| 94 | + Returns our estimate and rank for each skill for all players with sufficient Shotlink measured rounds (at least 30 rounds in the last year or 50 in the last 2 years). |
| 95 | + :param display: value, rank |
| 96 | + :param f_format: json (default) |
| 97 | + :return: dict |
| 98 | + """ |
| 99 | + query_p = {"display": display} |
| 100 | + return self.client.get( |
| 101 | + resource=f"{self._path}/skill-ratings", |
| 102 | + params=query_p, |
| 103 | + format=f_format, |
| 104 | + ) |
| 105 | + |
| 106 | + def detailed_approach_skill( |
| 107 | + self, period: str = "l24", f_format: str = "json" |
| 108 | + ) -> dict: |
| 109 | + """ |
| 110 | + Returns detailed player-level approach performance stats (strokes-gained per shot, proximity, GIR, good shot rate, poor shot avoidance rate) across various yardage/lie buckets. |
| 111 | + :param period: l24 (last 24 months) (default), l12 (last 12 months), ytd (year to date) |
| 112 | + :param f_format: json (default) |
| 113 | + :return: dict |
| 114 | + """ |
| 115 | + query_p = {"period": period} |
| 116 | + return self.client.get( |
| 117 | + resource=f"{self._path}/approach-skill", |
| 118 | + params=query_p, |
| 119 | + format=f_format, |
| 120 | + ) |
| 121 | + |
| 122 | + def fantasy_projection( |
| 123 | + self, |
| 124 | + tour: str = "pga", |
| 125 | + slate: str = "main", |
| 126 | + site: str = "draftkings", |
| 127 | + f_format: str = "json", |
| 128 | + ) -> dict: |
| 129 | + """ |
| 130 | + Returns our fantasy projections for a specific tour and slate. |
| 131 | + :param tour: pga (default), euro, opp (opposite field PGA TOUR event), alt |
| 132 | + :param slate: main (default), showdown, showdown_late, weekend, captain |
| 133 | + :param site: draftkings (default), fanduel, yahoo |
| 134 | + :param f_format: json (default) |
| 135 | + :return: dict |
| 136 | + """ |
| 137 | + query_p = {"tour": tour, "slate": slate, "site": site} |
| 138 | + return self.client.get( |
| 139 | + resource=f"{self._path}/fantasy-projection-defaults", |
| 140 | + params=query_p, |
| 141 | + format=f_format, |
| 142 | + ) |
0 commit comments