Stocks monitoring

Introduction

The stock monitoring project was realized in 2024 to simulate the evolution of a fictious stocks portfolio. The real idea behind was to find an interesting topic which could help me to learn Dash and to reinforce my Pandas knowledge. Indeed, It's one thing to read a technical documentation but it becomes more challenging when you start practicing it :-).

It's not a big deal to monitor stocks, especially using the pyfinance package, and I really encourage you to check the documentation of that package. In my case, I could not use it 'as is' in the DASH graphs because I wanted to perform 'on the fly' calculation on the values; so I had to manipulate the informations in Pandas first...
DASH is easy to use, you design a layout with 'components' and this allows you to describe the look and feel of the app. Then you define in a callback, how do you want to create the interaction between the elements (ie: a radio button interact with a graph). The DASH magic is that the components are accessible in Python and they generate behind the scenes HTML tags & Javascript codes.
The rest of the code is pure Python and in my case I used the Pandas library in order to make data transformation: Dataframe filters, calculations, concatenations, columns selections, loop iterations....

Finally, in order to put that code in 'production', I encapsulated it into a Docker container. Now the app is running on my NAS, like this, it's running even if my laptop is switched off, to access it via mobile phone.

At the end I learned/revied lot of things:

    • Discovered DASH plotly package which can be used EASILY to create dashboards
    • Review data manipulation with Python and Pandas
    • Review Docker containerization
    • Nice packages: yfinance (to get stocks values and infos) and yahooquery (to get the ETF composition).
    • Finnhub and NLTK have been also used to respectively extract last 3 days of Stocks news and compute a Vader sentiment analysis located on the right most column of the grid.
          For the Sentiment analysis, the scores is normalized to be between -1 (most extreme negative) and +1 (most extreme positive. Typical threshold values are:
        • Positive sentiment: compound score >= 0.05
        • Neutral sentiment: (compound score > -0.05) and (compound score < 0.05)
        • Negative sentiment: compound score <= -0.05

The Dashboard

Grid and cards

Video

By Christophe Kabacinski Duration 11 mn

In this video the project is explained and couple of Python codes are presented

Get this app ?

If you want to get this app on your own machine?That's super easy :

    • Install Docker Desktop on your machine and create a Docker account
    • Create a folder on your machine and put these files in the folder : docker-compose and MyStocks
    • Replace the values in the excel by yours :-)
    • Open a command line prompt in your folder and type "docker-compose up -d" then press "enter" (docker-compose down to stop it)
    • Wait one minute maximum and access the app on your browser in the url "localhost:5010"

Dashboard detail screenshots

  • Grid and cards
  • Porfolio evolution
  • Porfolio repartition
  • ETF main holders
  • Stocks evolution

This site uses cookies. .

By continuing to browse the site you are agreeing to our use of cookies. Review our cookies information for more details.