Code Monkey home page Code Monkey logo

automated-portfolio-tracking's People

Contributors

modothprav avatar

Watchers

 avatar

automated-portfolio-tracking's Issues

Possible use of Third-Party app to for better tracking

Website - www.simplywall.st

Transaction table

image

Feature request

Website has the feature to track holdings in a portfolio, under the edit portfolio section, we are presented with a web table in which transactions can be entered. Can be automated with selenuim. Would mean to implement separate classes with all simply wall street pages similar to sharesies pages.

Possible XPath to help with selenium

//table[@class='htCore']/tbody/tr[ROW]/td[COL]

Make Date input args Dynamic

Dynamic Runtime Date Arguments

The transactions will always be entered for the previous month with respect to the time it was triggered.

e.g if the workflow was triggered in June the transactions for May will be entered.

Bash script which determines the full name of the previous month also decrements the Year if the last month was December

#!/bin/bash

# Get Current Year and Previous Month
YEAR="$(date +%Y)"
export LAST_MONTH="$(date -v-1m +%B)"

# Check if previous month is December by converting
# to numerical form. If it is then decrease year
if [[ $LAST_MONTH == "December" ]] 
then
  YEAR="$(date -v-1y +%Y)"
fi

echo "Program being run for - $LAST_MONTH $YEAR"

export YEAR

Run command

. ./script.sh

Setup ChromeDriver

The chromedriver already installed in the repo for use will only work on Apple Macs with the m1 chip

The GitHub actions runs on a linux machine hence the appropriate binaries will need to be downloaded. Therefore along with chrome, chromedriver will also need to be downloaded.

Installation Script - from Selenium

#!/bin/bash

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update -qqy
sudo apt-get -qqy install google-chrome-stable
CHROME_VERSION=$(google-chrome-stable --version)
CHROME_FULL_VERSION=${CHROME_VERSION%%.*}
CHROME_MAJOR_VERSION=${CHROME_FULL_VERSION//[!0-9]}
sudo rm /etc/apt/sources.list.d/google-chrome.list
export CHROMEDRIVER_VERSION=`curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION%%.*}`
curl -L -O "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
unzip chromedriver_linux64.zip && chmod +x chromedriver
export CHROMEDRIVER_VERSION=`curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION%%.*}`
curl -L -O "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
unzip chromedriver_linux64.zip && chmod +x chromedriver
chromedriver -version

Script above will install chorme and chromedriver

Update Sharesies Elements

Shareises Website Update

Sharesies recently updated their website, some elements cannot with the current search criteria, hence they need to be updated to match the current state of the website.

image

Allow Main Automation method to accept arguments

This way can specify the month and year to run the process through the command line.

Command to run the program

mvn compile exec:java -Dexec.mainClass=automate.Automation -Dexec.cleanupDaemonThreads=false

Running With Arguments

mvn exec:java -Dexec.mainClass=autoamte.Automation -Dexec.cleanupDaemonThreads=false -Dexec.args="Janurary 2022 February 2022"

Page Validation

From the Login page onwards the title for all pages loaded after seems to be the same. Improve validation upon page initialization, to distinguish among the different web pages.

Track Stock progress in Yahoo Finance

Possible Xpath

This xpath can be used for initial selection of the stock for the data to be entered

//table/tbody["index"]/tr[2]/td/button 

image

The xpath above will click on the arrow drop-down button for a stock based on the index specified. Once clicked will display another table to then enter the individual transactions for that stock

image

Xpath to access inner element

//table/tbody["stock-row-index"]/tr[3]/td/table/tbody/tr["transaction-index"]/td["transaction-property-index"]

Create Monthly running GitHub actions workflow

Workflow steps to include

May have to include a step to download chrome if the machine does not have it.

Possible Solutions - Chrome setup

Include and run a bash script which installs chrome

#!/bin/bash
set -ex
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

Use another Github action - Setup Chrome

steps:
  - uses: browser-actions/setup-chrome@latest
  - run: chrome --version
    with:
      chrome-version: beta

Cron Trigger

on:
  schedule:
    # Second day of the Month
    - cron: 0 0 2 * *

Maven Command #70

mvn exec:java -Dexec.mainClass=autoamte.Automation -Dexec.cleanupDaemonThreads=false -Dexec.args="Janurary 2022 February 2022"

Evnironment Variables assignment

steps:
  - name: "Run Main Process"
  run: mvn exec:java -Dexec.mainClass=autoamte.Automation
  env:
    YAHOO_USERNAME: Pravin

Add Send email step, with error screenshot attached

Send Email Action

- name: Send mail
  uses: dawidd6/action-send-mail@v3
  with:
    # Required mail server address:
    server_address: smtp.gmail.com
    # Required mail server port:
    server_port: 465
    # Optional (recommended): mail server username:
    username: ${{secrets.MAIL_USERNAME}}
    # Optional (recommended) mail server password:
    password: ${{secrets.MAIL_PASSWORD}}
    # Required mail subject:
    subject: Github Actions job result
    # Required recipients' addresses:
    to: [email protected],[email protected]
    # Required sender full name (address can be skipped):
    from: Luke Skywalker # <[email protected]>
    # Optional whether this connection use TLS (default is true if server_port is 465)
    secure: true
    # Optional plain body:
    body: Build job of ${{github.repository}} completed successfully!
    # Optional HTML body read from file:
    html_body: file://README.html
    # Optional carbon copy recipients:
    cc: [email protected],[email protected]
    # Optional blind carbon copy recipients:
    bcc: [email protected],[email protected]
    # Optional recipient of the email response:
    reply_to: [email protected]
    # Optional Message ID this message is replying to:
    in_reply_to: <[email protected]>
    # Optional unsigned/invalid certificates allowance:
    ignore_cert: true
    # Optional converting Markdown to HTML (set content_type to text/html too):
    convert_markdown: true
    # Optional attachments:
    attachments: attachments.zip,git.diff,./dist/static/*.js
    # Optional priority: 'high', 'normal' (default) or 'low'
    priority: low

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.