Build an Advanced AI-Powered Technical Analysis Stock Dashboard (Gemini 2.0 Flash + Streamlit)

Deep Charts www.youtube.com

Kurze Zusammenfassung

Dieses Video zeigt, wie man ein KI-gestütztes technisches Analyse-Dashboard mit Streamlit, Gemini 2.0 und verschiedenen Python-Bibliotheken erstellt. Es werden die notwendigen Schritte zur Einrichtung der Umgebung, zum Abrufen von Aktiendaten, zur Erstellung von Charts mit technischen Indikatoren und zur Verwendung der Gemini 2.0 API zur Analyse der Charts und zur Generierung von Kauf-, Halte- oder Verkaufsentscheidungen erläutert.

  • Verwendung von Gemini 2.0 zur automatischen Aktienanalyse.
  • Erstellung eines interaktiven Dashboards mit Streamlit.
  • Integration verschiedener Python-Bibliotheken wie yFinance, Pandas und Plotly.

Motivation und Einführung

Das Video behandelt die Entwicklung eines KI-gestützten Dashboards für die technische Analyse, das auf dem Gemini 2.0 Modell von Google basiert. Im Gegensatz zu einem früheren Projekt mit dem Llama 3.2 Vision Modell, das sich als ungeeignet erwiesen hat, zielt dieser Ansatz auf Automatisierung und Skalierbarkeit ab. Das Dashboard soll Kauf-, Halte- und Verkaufsentscheidungen für ein gesamtes Portfolio innerhalb von Sekunden liefern.

Wie man diese Analyse noch erweitern kann

Das erstellte Dashboard dient als Ausgangspunkt und bietet Raum für weitere Innovationen. Es wird vorgeschlagen, mehrere KI-Agenten zu orchestrieren, um technische Analysen zu verifizieren und zu verfeinern, oder spezifische Strategien zu testen, um deren potenzielle Ergebnisse zu bewerten. Die Entscheidung, dieses Tool einzusetzen, hängt von den eigenen Marktvorstellungen und dem Vertrauen in KI und technische Analyse ab.

Überlegungen zur Durchführung dieser technischen Analyse

Die Eignung und der Einsatz dieses Tools hängen von den individuellen Marktvorstellungen und dem Vertrauen in KI und technische Analyse ab. Es ist wichtig, die Ergebnisse kritisch zu hinterfragen und das eigene Fachwissen einzubringen, da LLMs experimentell sind und hohe Fehlerraten aufweisen können.

Bibliotheken und Modelle, die zur Erstellung des Dashboards verwendet wurden

Das Tool wird mit Streamlit erstellt, einem Framework für interaktive Dashboards. Es werden verschiedene Python-Bibliotheken verwendet, darunter yFinance zum Abrufen von Aktiendaten, Pandas zur Datenverarbeitung und Plotly zur Erstellung von Datenvisualisierungen. Das Gemini 2.0 Modell von Google wird für die Verarbeitung von Chartbildern eingesetzt.

Ablauf des Workflows

Der Workflow umfasst das Abrufen von Aktienkursdaten mit yFinance, die Verarbeitung mit Pandas und die Visualisierung mit Plotly, um ein Candlestick-Chart mit technischen Indikatoren zu erstellen. Das Chart wird als Bilddatei gespeichert und zusammen mit einer Prompt an die Google AI Studio API gesendet. Die Antwort der KI wird zurückgesendet, um die Analyse zu überprüfen und in den Entscheidungsprozess einzubeziehen.

Wo man den Code für dieses Tutorial sowie Premium-Code findet

Der Code für das Tutorial ist in der Videobeschreibung verfügbar. Es gibt auch einen Link zu einer erweiterten Version, die neben täglichen Candlesticks auch wöchentliche und minutenweise Candlesticks anzeigen kann, was die Nutzung für langfristige Investitionen und Daytrading verbessert. Diese Version bietet auch anpassbare technische Indikatoren.

Haftungsausschluss - dies ist keine Finanz- oder Anlageberatung

Es wird betont, dass das Video keine Finanz- oder Anlageberatung darstellt, sondern ein Tutorial zur Verwendung von LLM Vision Modellen in Python mit Finanzdaten. LLMs sind experimentell und können hohe Fehlerraten aufweisen, daher ist kritisches Denken und Fachwissen bei der Überprüfung der Ergebnisse erforderlich.

So erstellen Sie einen Google AI Studio API-Schlüssel für Gemini 2.0 Flash

Um zu beginnen, muss man sich bei Google AI Studio anmelden und einen API-Schlüssel erstellen. Dies ermöglicht die Nutzung der Gemini API, wobei ein kostenloses Kontingent verfügbar ist, aber auch die Möglichkeit besteht, ein Google Cloud-Abrechnungskonto zu verknüpfen, um höhere Nutzungslimits zu erhalten. Es wird empfohlen, ein Budget festzulegen, um Benachrichtigungen bei Erreichen des Budgets zu erhalten.

So richten Sie Ihre Python-Umgebung für dieses Tutorial ein

Es wird eine neue virtuelle Umgebung mit Python 3.9 erstellt und die erforderlichen Bibliotheken installiert: Streamlit, Google Generative AI, yFinance, Pandas, Plotly und Kido. Es ist wichtig, die exakten Versionen der Bibliotheken zu installieren, um die Funktionalität des Dashboards zu gewährleisten.

Streamlit Technical Analysis Dashboard Code Walkthrough

Der Code beginnt mit dem Importieren der relevanten Pakete und Hilfsprogramme wie tempfile, os, JSON und datetime. Der Google AI Studio API-Schlüssel wird konfiguriert, und das Gemini 2.0 Flash-Modell wird als generatives Modell festgelegt. Die Streamlit-Seite wird mit einem breiten Layout konfiguriert, und die Sidebar dient als Bedienfeld, in dem Benutzer Aktienticker und Datumsbereiche eingeben können. Es werden technische Indikatoren wie Simple Moving Average, Exponential Moving Average und Bollinger Bands zur Auswahl angeboten. Ein Button in der Sidebar lädt historische Aktiendaten mit der yFinance-Bibliothek herunter und speichert sie im Streamlit-Session-State. Die Funktion analyze_ticker erstellt ein interaktives Candlestick-Chart mit Plotly und fügt technische Indikatoren hinzu. Das Chart wird als PNG-Datei gespeichert, und die Bilddaten werden zusammen mit einer Prompt an die Gemini 2.0 API gesendet, um eine technische Analyse durchzuführen. Die Antwort der API wird geparst, und das Chart zusammen mit der Analyse wird im Dashboard angezeigt.

Demo des technischen Analyse-Dashboards

Nach der Einrichtung kann das Dashboard durch Ausführen von streamlit run in der Python-Umgebung gestartet werden. Benutzer können Aktienticker-Symbole hinzufügen, einen Datumsbereich auswählen, technische Indikatoren auswählen und die technische Analyse initialisieren. Das Dashboard zeigt eine Zusammenfassung der Empfehlungen und detaillierte Begründungen für jede Aktie an. Der Link zum vollständigen Code und einer erweiterten Version ist in der Videobeschreibung verfügbar.

Fasse jedes YouTube-Video in Sekunden zusammen

Hol dir Zusammenfassungen wie diese für jedes Video, in deiner Sprache, mit der kostenlosen Summ-App.

Laden im App Store
Jetzt bei Google Play

Transkript

Vollständiges Transkript von „Build an Advanced AI-Powered Technical Analysis Stock Dashboard (Gemini 2.0 Flash + Streamlit)“. Klicke auf einen Zeitstempel, um das Video an dieser Stelle zu öffnen. Du brauchst ein anderes Video? Nutze den YouTube-Transkript-Generator.

0:00 a few months ago I shared a video exploring the use of llm vision models to interpret stock market technical indicator charts the setup featured meta's llama 3.2 Vision model running locally via an O llama server as a case study the goal was to make this accessible to those with older Hardware like my 5-year-old Macbook without relying on paid services from open AI or Google but as it turns out the Llama 3.2 Vision model kind of sucks for this task so I decided to revisit the idea with the latest multimodal Google Gemini 2.0 models focusing on Automation and scale in this tutorial we'll prioritize performance over cost and build an updated AI powered technical analysis dashboard that delivers buy hold sell decisions for your entire portfolio

0:47 within seconds even with these upgrades this remains a starter dashboard leaving plenty of room for Innovation you might experiment with orchestrating multiple AI reasoning agents to cross verify and refine technical analysis interpretations or you might back test specific strategies to evaluate how they would have yielded different outcomes how and whether to deploy this tool depends on your own Market theories and your confidence in both Ai and technical analysis we're going to create this tool using streamlet which is an interactive dashboard framework if you've never used streamlit before I've posted a bunch of tutorials in the video description below to help you get started we'll use a bunch of python libraries as well including y Finance to

1:32 pull the latest stock ticker data pandas to process the data and plotly to create data visualizations and as mentioned earlier we'll be using the latest state-of-the-art Gemini 2.0 multimodal models that can process chart images let's walk through the workflow we'll first retrieve stock price data using the Y Finance library then process it with pandas and visualize it using plotly to generate a Candlestick chart with key technical indic indicators once the chart is ready we'll save it as an image file using a buil-in python library next this image is sent to the Google AI Studio API along with a prompt instructing the llm to analyze it as if it were a stock Trader specializing in technical analysis will request both a

2:17 narrative explanation of how it interprets patterns signals and Trends as well as a structured output of buy sell or hold recommendations this structured data allows us to compile a table summarizing AI generated insights for all the stocks we input finally the ai's response is sent back to our local machine where we can review its analysis and incorporate it into our decision-making process you can find the link to the code in the video description below I've also included a link to a more advanced version that can display not just daily candlesticks but also weekly and minute level candlesticks too enhancing its use for both long-term investing and day trading this up upgraded version also features customizable technical indicators

3:03 allowing you to adjust various parameters to suit your needs while it's still a starter script it offers greater functionality and is available for a download fee also before we begin I want to stress that this video is not Financial or investment advice it's an educational tutorial on using llm Vision models in Python using financial data llms are still experimental and can have high error rates even with an advanced model like Gemini 2 .0 so you need to apply critical thinking and subject matter expertise when reviewing the results start by going to AI studio. google.com and click sign in and this will prompt you to log in using a Google account you'll next reach this page that says build with Gemini and you'll want to click the get API key and then create

3:50 API key on the next page at this point you can copy and save your API key someplace safe you can get started for free with the Gemini API free plan but there are limits on how many API calls you can send at a time alternatively you can connect a Google Cloud billing account to Google AI Studio the price per token is extremely cheap so you're going to be paying at most a fraction of a penny for a bunch of runs of the dashboard with that said I'd still suggest placing A5 to $10 Budget on your Google billing account so that you are notified with alerts as you reach your budget next open up your command prompt or terminal and create a new virtual ual or cond environment with python version 3.9 activate the new environment and

4:35 install the following libraries streamlit Google generative AI y Finance pandas plotly and Kido you'll need to install the exact versions of these libraries as seen on the screen in order to ensure that the dashboard will work with the prerequisites out of the way let's walk through the code we first import the relevant packages and then also bring in utilities like temp file o Json and datetime temp file will be used later on to store the technical indicators plot and the rest of the utilities do stuff like managing file operations as well as doing Json parsing and date calculations we next set our Google AI Studio API key through the generative AI libraries configure function I've

5:20 hardcoded the API key here but you could also set it with a streamlit Secrets file or as an environment variable we're going to use the Gemini 2.0 flash model and set it as the generative model we'll now configure our streamlit page with a wide layout and set the title of the dashboard the sidebar will be our control panel users will be prompted to enter multiple stock tickers separated by commas the input is cleaned up by stripping extra white space and converting tickers to uppercase to ensure consistency additionally the sidebar provides date inputs where the default range is set from one year ago to today we then create a section for technical indicators which will let users select from options like simple moving average

6:07 exponential moving average and Ballinger bands we will set the calculations for the technical indicators later in the code we now create a button in the sidebar that when clicked will Loop through each stock ticker and use the Y Finance library to download historical stock data each ticker's data is stored in streamlet session State ensuring the data persists as the user interacts with the app if any ticker does not return data a warning will be displayed to notify the user at this point the workflow kicks into gear with stock data available in the session State the application moves into its analysis phase by defining a few key functions the primary function analyze ticker takes in a stocks ticker symbol and its

6:53 corresponding data and Begins by constructing an interactive Candlestick chart using plotly with an analyze ticker an inner helper function add indicator is defined to handle the technical analysis components this helper applies the appropriate calculation to the stock data and overlays the result on the chart for example if the user has chosen the 20-day simple moving average the function computes the rolling mean of the closing prices over a 20-day window and adds that as a new line on the chart this is the part of the code where you can add and customize the parameters of specific technical indicators that you want included in your dashboard once all chosen indicators have been added the chart layout is

7:39 refined by disabling the default range slider resulting in a cleaner visual presentation the next step is to prepare the chart for technical analysis by our AI model the code temporarily saves the plotly chart as a PNG file using Python's temp file module writes the image to your computer and then reads its binary content into memory memory immediately after reading the file it is removed from your computer to ensure no unnecessary files remain these image bytes along with their mime type are then packaged into a dictionary forming what we refer to as an image part this image part combined with a detailed text prompt sets the stage for the Gemini 2.0 model to perform a technical analysis the text prompt instructs the AI to act

8:24 as a seasoned stock Trader specializing in technical analysis at a top financial institution it asks the AI to scrutinize the Candlestick chart along with the displayed technical indicators describe observed patterns signals and Trends and ultimately provide a recommendation the output is expected as a Json object containing two keys recommendation and justification both the text prompt and the image part are bundled together into a single contents list with each entry assigned a user role this structured content is then sent to the Google AI Studio AP via the generate content function once the API returns its response the code attempts to parse a Json object from the response text by identifying the first

9:09 opening brace and the last closing brace if a valid Json segment is found it is parsed into a structured result if not or if any errors occur during parsing the code catches these exceptions and constructs an error message that includes the raw API response for debugging finally the analyze ticker function returns both the fully built plotly chart and the structured result from the AI analysis this dual output enables the application to display the interactive chart alongside the simple Buy sell hold recommendation and the detailed justification after analyzing each ticker individually the application organizes the results into several tabs it starts by constructing a list of tab

9:55 names an overall summary tab followed by one tab for each stock ticker available in the session State and then uses streamlets tabs function to create these distinct sections we then initialize an empty list named overall results to collect the recommendations for each ticker the code then Loops through every ticker retrieves its Associated data and calls the analyze ticker function which we previously discussed each ticker's recommendation and justification are appended to the overall results list within each ticker specific tab the dashboard displays a subheader indicating the stock being analyzed followed by the interactive chart and the ai's detailed justification finally in the overall

10:40 summary tab the application converts the overall results list into a panda's data frame and displays it as a table this summary provides a quick comprehensive overview of all recommendations if no stock data is available an info box prompts the user to fetch the data using the sidebar now that you've set everything up it's time to see the dashboard in action open up a terminal and activate your python environment then type streamlit run followed by the path to yourp file this command will launch the dashboard in your web browser you can now add stock ticker symbols select a date range choose several technical indicators and then click fetch data to

11:26 initialize the technical analysis you'll first see the overall summary of recommendations but can then click onto a stock Tab and read the detailed justification as mentioned before the link to the full code as well as a souped up version are available in the video description below and if you found this video useful make sure to like comment and subscribe to the Deep charts channel for more videos on how to leverage the latest a AI tools

Share

Weitere Video-Zusammenfassungen