GithubHelp home page GithubHelp logo

kmadisa / mind-your-stonks Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 191 KB

When making a bad investment, the least one can do is keep track of it.

License: BSD 2-Clause "Simplified" License

Python 100.00%
selenium python google-sheets google-sheets-api geckodriver python3 account-balance bets gspread sports-betting money monitoring

mind-your-stonks's Introduction

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.

mind-your-stonks's People

Contributors

kmadisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nftercel sxcntqnt

mind-your-stonks's Issues

WIP- Add support for betway.co.za clients

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Support multiple pages on the betting history page

At the moment we only scraping data on the first page only because we do not place a lot of bets and most of them are resolved when the script runs overnight.

Moving forward we would like to run multiple cron jobs during the day and depending on the user's activity that might result in the list of Unsettled bets populating more than one page on the betting history. Therefore we will need to be able to switch between different pages.

Screenshot from 2019-07-25 11-23-25
Figure 1. A snapshot of the Betting History page showing links to multiple pages.

Show win/loss ratio metrics

I want to gather all the betting history data and get a sum of all the money won and lost on bets and calculate the net loss/gain.

This depends on issue #10.

Capture the holistic account balance

Sometimes when we capture the account balance, we never take into account the funds that made have been invested in the market at that current moment.

BET.co.za website revamped

The BET.co.za site has been revamped and that means the client might need to be modified to accomodate those changes ASAP.

Update documentation

Update the README.md file with instructions on what the repository does and how it works.

Archive betting history data

Now that I can scrape all of the betting history data, I need a way to persist it so that I can be able to query it in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.