Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 4.95 KB

README.md

File metadata and controls

89 lines (63 loc) · 4.95 KB

Actions Status License: MIT GitHub last commit GitHub issues Codacy Badge

Mind your stonks

35a1ly

The Story

BET.co.za does not have an easier way to track the changes in the user's account balance. All that it displays is the current account balance. In order to get an idea of how much you had vs how much you have in your account, you have to sift through lots and lots of pages on the transaction history, not to mention the brutal experience the user will have to go through to compute the account's balance at a particular moment in time from all that information.

The purpose of this project is to provide BET.co.za clients an easier way to keep track of the changes occurring in their account balance.

Basically there is utility script that run and log into the client's BET.co.za account (using Selenium) and read the value of the current balance and uploads the data to a Google Sheets, where then it can be visualized.

          AND JUST LIKE THAT YOU KNOW THE RISE & FALL OF YOUR STONKS !!!!

Get Started

  1. Obtain Google API for authentication:

    • Follow the instructions here
  2. Ensure that geckodriver for Firefox is installed.

    • Download geckodriver
      • wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
      • Extract: tar -xvzf geckodriver-v0.24.0-linux64.tar.gz
    • sudo cp geckodriver /usr/local/bin
  3. Install the library:

    • python setup.py install
  4. Upload a copy of the spreadsheet to your own GDrive or GSpeadsheet.

Screenshot from 2019-12-10 15-32-48 Figure 1. A snapshot of the spreadsheet and the respective columns (Note: Numbers may or may not have been doctored!).

Table columns

  • Date: date reading was made (yyyy-mm-dd).
  • Timestamp: indicated when the script logged into the account hh:mm PM/AM.
  • Balance: the current balance in the account in S.A rands.
  • Money in bets: the amount of money placed in a bet which is still unresolved.
  • Actual Loss/Gain: difference between the previous known balance and the current one (+ money in bets).
  • % Increase: calculated from the previous known balance and the current one (+ money in bets).
Other fields
  • Opening Balance: te amount of money in the account at the first of the month.
  • Closing Balance: te amount of money in the account at the end of the current month.
  • Graph: a plot of the account's balance.

Usage

python query_balance.py -h
usage: query_balance.py [-h] [--update-spreadsheet UPDATE_SPREADSHEET]
                        username password

Scrape the BET.co.za website to obtain the account balance. It also writes the
data to a Google Spreadsheet.

positional arguments:
  username              Bet.co.za registered email address
  password              Bet.co.za account password.

optional arguments:
  -h, --help            show this help message and exit
  --update-spreadsheet UPDATE_SPREADSHEET
                        Update spreadsheet with new data. This requires the
                        client_secret.json file for authentication. It is
                        downloaded from the Google Developers' Console.

Typical usage:

query_balance.py $USERNAME $PASSWORD --update-spreadsheet ./client_secrets.json

Github Actions automated daily balance reader

Github Actions can automatically run your Google App Engine based application, by encrypting your clients_secrets.json file and pushing it to GitHub. See example: https://github.com/kmadisa/mind-your-stonks/blob/master/.github/workflows/update_stonks_sheet.yml

Feedback

Feel free to fork it or send me a PR to improve it.