How to Integrate Yahoo Finance with Python Kivy

In this Python Kivy tutorial we are going to learn about How to Integrate Yahoo Finance with Python Kivy, Kivy is Python framework used for building cross platform applications. it provides graphical user interface (GUI) toolkit that makes it easy to create and customize GUI elements such as buttons, labels and text fields. in this article we want to show you how to use Kivy to create a simple application that retrieves real time stock prices using the Yahoo Finance API.

 

How to Integrate Yahoo Finance with Python Kivy

First of all we need to install required libraries.

 

 

This is the complete code for this article

In the above example we have imported Kivy and the necessary modules from Kivy to create the app. after that we imports yfinance library. inside the build method of the StockPriceApp class, we have defined stock symbol as MSFT, which is the stock symbol for Microsoft. and then we have used yf.Ticker() method to retrieve the stock data for Microsoft.

Next we use the info attribute of the stock_data object to retrieve the current stock price, which is stored in regularMarketPrice key. and after we creates a label to display the stock price using f-strings to include the stock symbol and stock price in the text of the label.

and lastly we return the label from the build method, which will display the stock price when the app is run. you can modify this code to retrieve stock prices for other publicly traded companies by changing the stock_symbol variable to the appropriate stock symbol. You can also customize the label or add additional UI elements to the app as desired.

 

 

Run the code and this will be the result

How to Integrate Yahoo Finance with Python Kivy
How to Integrate Yahoo Finance with Python Kivy

 

 

Learn More on Python GUI

Leave a Comment