Coding for Finance: samFinance using Python

So, I’ve started a Project to write a code to help me monitor stocks prices and to have some indicators that allows me to make investment decision. Right now, I’ve done up a preliminary (but working) version of that automated script for monitoring of my investments — samFinance.

For your information, the code is in my git repository: https://bitbucket.org/telboon/samfinance

Before I do all there, I just felt the need to show off my Vim environment!

vim vim env

Overall samFinance Structure
The whole tool is structured into 4 segment. They are built for the following purpose:

  • samStock: Provides structure for managing individual stocks and their data
  • samWatchlist: Provides structure & tools for managing full portfolio. This allows many stocks to be stored in each portfolio for monitoring purpose
  • algo: Provides functions for the purpose of calculation and any analytical tools for analyzing of each stock/portfolio
  • samMail: Provides function to allow automatic sending of emails

Source Tree 1 Source Tree 2

Execution of Automated Monitoring
To monitor the portfolio live, the code needs to run on a constant-on machine. For my own use, I run it on a VPS that I have:

Server

After running a tmux, which allow persistent running of code (and allow me to go back and stop/view if necessary). The code then runs and send me a report such as this via email every 6 hours (I currently don’t need high update interval):

status check

Batteries Included
To give some convenience and to look at some of the price data in a visual way, I’ve included a charting tool that allows me to cycle and look through my portfolio and their historical prices:

charts sia chart

Learning & Follow-Up

  • I learnt to think of scalable coding, especially in an OOP setting. This allow much better code maintenance, and code reusability
  • More functions will be built on this, especially on the algo aspect, where more indicators can be built inside

I’ll continue to work on this code. To see the code in my git repository, you can visit: https://bitbucket.org/telboon/samfinance

Cheers!

LEAVE A COMMENT