Skip to main content

bbcmd

PyPI version shields.io PyPI pyversions PyPI license

Command Line Baseball Data Tools. This project includes 2 command line tools for generating a variety of stats and scraping data from the web.

Contents

Installation

Use pip via PyPi

pip install bbcmd

Or use git

git clone git://github.com/luciancooper/bbcmd.git bbcmd
cd bbcmd
python setup.py install
Install Notes

This project depends on cmdprogress for command line progress bars

Commands

After installation, the bbsim and bbscrape commands should be in your systems path, via the Scripts directory of your Python installation

Scraper

The bbscrape command is a tool that scrapes data from the following websites:

Simulator Setup

Step 1. Download Data

Download the necessary play by play data source files that the simulator depends on to run simulations. These files are stored on github in the bbsrc repository. The data in these files is derived from the play by play data provided by retrosheet.org. Retrosheet is an amazing organization that has painstakingly compiled the play by play data for every MLB game dating back to 1921. Find out more about the Retrosheet project here.

bbsim setup --env years path
  • years - required: the specified MLB seasons you wish to download play by play data for, can be a single year (2016), range of years (2014-2016) or comma separated combination of the two (2012-2014,2016 or 2012-2014,2015-2017, etc.)
  • path - optional: the local path in which you wish to keep store your play by play data files. You will want to remember this location, as you will have to come back later if you want to delete these files. If not specified, the current working directory will be used

Step 2. Create Data Pointer

bbsim setup --xml years path
  • years - required: the specified MLB seasons you wish bbdata.xml to point to. Can be a single year (2016), range of years (2014-2016) or comma separated combination of the two (2012-2014,2016 or 2012-2014,2015-2017, etc.)
  • path - optional: the local path in which you wish to create the pointer file in. This is the directory you will be running your simulations in later, so again, remember this location. If not specified, the current working directory will be used. If you want to keep it simple, specify the same path as in the previous command

Step 3. Run a test

If the current path does not contain your bbdata.xml file, navigate to that path. Run the following command, which will simulate the games for all the seasons specified by bbdata.xml, without recording any of the data.

bbsim test game

Simulator Usage

The following simulations are currently supported by this project

Gamescores

The gamescore command generates data grouped by mlb game. Columns include:

ascore,hscore,aout,hout

bbsim gamescore [-v] [-y YEARS]

Generate Aggregated Stats

The batting, fielding, pitching, and rbi commands generate aggregated stats. By default, the simulator will group the outputted data by season. The following optional flags will change how the data is grouped.

  • -l : by league (AL and NL).
  • -t : by team
  • -g : by game
  • -p : by player (8 character playerid)
  • -ph : by player hand (batting hand or pitching hand)
  • -phm : by player hand matchups

batting command

The batting command generates offensive stats. Columns include:

O,E,S,D,T,HR,BB,IBB,HBP,K,I,SH,SF,GDP,R,RBI,SB,CS,PO

The batting command has an additional optional flag: -np or --nopitcher. If this is included, the simulator will ignore pitchers when aggregating results.

bbsim batting [-l | -t | -g | -p | -ph | -phm] [-v] [-np] [-y YEARS]

fielding command

The fielding command generates defensive aggregated stats. Columns include:

UR,TUR,P,A,E,PB

bbsim fielding [-l | -t | -g | -p] [-v] [-y YEARS]

pitching command

The pitching command generates aggregated pitching stats. Columns include:

W,L,SV,IP,BF,R,ER,S,D,T,HR,BB,HBP,IBB,K,BK,WP,PO,GDP

bbsim pitching [-l | -t | -g | -p | -ph | -phm] [-v] [-y YEARS]

rbi command

The rbi command generates details about each event in which an RBI was credited

RBI,O,E,S,D,T,HR,BB,IBB,HBP,K,I,SF,SH,GDP

bbsim rbi [-l | -t | -g | -p | -ph | -phm] [-v] [-y YEARS]

Generate Appearance Stats

appearance command

bbsim appearance [normal | lahman | position | simple] [-v] [-y YEARS]
  • -v - optional:
  • -y YEARS

Generate Advanced Stats

Currently two sub commands supported:

  • woba: simulates the seasonal linear weights used for calculating weighted
bbsim advcalc (woba | war) [-v] [-y YEARS]

Metadata

Release files for bbcmd 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bbcmd 1.2
File Size Uploaded Provenance
bbcmd-1.2.tar.gz 43.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bbcmd 1.2
File Interpreter ABI Platform
bbcmd-1.2-py3-none-any.whl Python 3 none any Details

Total release size: 102.2 kB

Release files / bbcmd-1.2.tar.gz

Download URL bbcmd-1.2.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f80da7ec78e663ec74d2ba1a3bdc4f93e4108c4502ae76116937f6e390e3efc5
BLAKE2b-256 checksum
How to use checksums
18751a3d40f52f45b8126bccdd67e2f7e62cf4f1848d65bbe239bb5e18fda99e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.14.2 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.1

Release files / bbcmd-1.2-py3-none-any.whl

Download URL bbcmd-1.2-py3-none-any.whl
Size 58.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11ddccaa7c429bfa392b00be0d72101b03b207fa0dac49cdc0bb5850efb32c29
BLAKE2b-256 checksum
How to use checksums
266f294cdebf268af288d3e88d343599cd41c76aee28a1745af6ea374c3082ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.14.2 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.1

Security for bbcmd 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page