Skip to content

feat(baseball): expanded API coverage - Transactions, RotoBoxScore, stats splits... - #691

Merged
cwendt94 merged 14 commits into
cwendt94:masterfrom
gdifiore:feat/baseball-expanded-api
May 4, 2026
Merged

feat(baseball): expanded API coverage - Transactions, RotoBoxScore, stats splits...#691
cwendt94 merged 14 commits into
cwendt94:masterfrom
gdifiore:feat/baseball-expanded-api

Conversation

@gdifiore

Copy link
Copy Markdown
Contributor

Summary

  • Transaction / TransactionItem - new model classes for reading league transactions, exported from espn_api.baseball. League.transactions(types, scoring_period) fetches and returns them with full support for filtering by transaction type and scoring period.
  • RotoBoxScore - new box score class for rotisserie leagues. League.box_scores() now correctly dispatches to RotoBoxScore for ROTO leagues, returning per-team cumulative category stats and league-wide ranks instead of a head-to-head result.
  • Player.stats_splits - player_info() now requests and exposes L7/L15/L30 rolling stat windows alongside the full season split under player.stats_splits. Backwards-compatible: player.stats still contains season totals and box score splits as before.
  • Expanded Player fields - jersey, laterality, stance, last_news_date, season_outlook, percent_owned_change, adp, adp_change, auction_value, auction_value_change, draft_ranks, on_team_id, lock flags (lineup_locked, roster_locked, trade_locked), keeper_value / keeper_value_future. Works for both roster entries and player_info() card responses.
  • Expanded Team fields - home/away/division W-L-T records, points_for, points_against, streak, current_projected_rank, waiver_rank.
  • Expanded Settings / BaseSettings fields - position_slot_counts, acquisition_limit, matchup_acquisition_limit, minimum_bid, waiver_process_days, waiver_process_hour, trade_revision_hours.
  • League.refresh() - re-fetches live league state without re-downloading the full player universe.

gdifiore added 13 commits April 6, 2026 19:46
- Settings class exposes position_slot_counts from rosterSettings
- Transaction/TransactionItem classes model ESPN transaction API responses
- League.transactions() fetches waiver/FA/trade activity for a scoring period
- League.player_info() looks up a player by name or ID
- League.refresh() updates league state without re-fetching all players
- League.load_roster_week() loads team rosters for a historical week
- League._fetch_league() now passes Settings as SettingsClass
- Add DEFAULT_POSITION_MAP for player.position (separate from lineupSlot)
- Add baseball Settings class with position_slot_counts
- Add Transaction / TransactionItem classes with League.transactions() method
- Expand Player with ownership, draft ranks, keeper/lock flags, news date, etc.
- Expand Team with split records, streak, projected/waiver rank
- Expand BaseSettings with acquisition limits, waiver settings, trade revision hours
- Remove debug pdb imports from matchup.py and team.py
- Add unit tests for Player, Settings, Transaction, Team
Adds STAT_SPLIT_MAP and player.stats_splits dict keyed by split label
(season, last_7, last_15, last_30, box_score). player.stats and
total_points remain unchanged for backwards compatibility.
…tems

- Switch view from kona_league_transactions to mTransactions2
- Default items to [] for transaction types that carry no items (e.g. TRADE_DECLINE)
- transactions(): tighten type hint from set to Set[str]
- Player: convert acquisitionDate to datetime (consistent with last_news_date)
- Player: use explicit key check for playerPoolEntry fallback
- Player: log warning for unknown statSplitTypeId instead of silently dropping
- Transaction: store team_id; guard __repr__ against None team
Add tests for BaseSettings core fields, Player.proTeam/total_points/
eligibleSlots/__repr__, Transaction optional fields (bid_amount, comment,
memberId, types filter header), TransactionItem.__repr__, and
League.standings() sort behaviour.
- Use ValueError instead of Exception in transactions() type validation
- Copy waiver_process_days list to prevent external mutation of settings
- Add type hints to Transaction.__init__ callback parameter
- Add comments on millisecond timestamp conversions, intentional stat
  split filtering, position slot exclusions, and -1 projected sentinel
- Normalize Transaction/TransactionItem fields to snake_case and use
  None defaults for comment and member_id
- Make RotoBoxScore inherit from BoxScore with None stubs for
  winner/home_team/away_team so isinstance checks work uniformly
- Fix box_scores() return type hint to List[BoxScore] and document
  the four concrete shapes
- Use `in` membership tests in Player stats_splits population to
  handle present-but-empty buckets safely
- Add comment explaining ESPN's 'Infinity' string for zero-denominator
  rate stats in RotoBoxScore
Fixes pitcher stats showing batter stats (e.g. '1B', 'SB-CS') by filtering
based on position eligibility. Handles multi-position players like Ohtani
who are eligible for both pitcher and batter slots.
@codecov

codecov Bot commented Apr 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.07%. Comparing base (cb8d8e0) to head (65e20fb).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #691      +/-   ##
==========================================
+ Coverage   71.09%   75.07%   +3.98%     
==========================================
  Files          62       64       +2     
  Lines        2425     2616     +191     
==========================================
+ Hits         1724     1964     +240     
+ Misses        701      652      -49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Guard the name→playerId reassignment on player_map membership so an
explicit playerId survives an unknown name.

Also lift inline pitcher/batter slot sets to PITCHER_POSITIONS /
BATTER_POSITIONS constants and compute eligibility flags once per
Player.
@gdifiore
gdifiore marked this pull request as ready for review April 19, 2026 19:58
@KStockton

Copy link
Copy Markdown

Would love to see these features.

@gdifiore

gdifiore commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for all the changes @cwendt94, I can split this into multiple PRs if you prefer. Just kinda how I ended up testing it all

@cwendt94

cwendt94 commented May 4, 2026

Copy link
Copy Markdown
Owner

This is great, thanks for all the feature updates and tests!

@cwendt94
cwendt94 merged commit 851c2bb into cwendt94:master May 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants