Creating a Financial Data Analysis Application Using ChatGPT-o1

Richard Cotton builds a stock analysis app in Google Colab using ChatGPT-o1, Yahoo Finance data, and sentiment analysis from financial news. The app includes price charts, technical indicators like Bollinger Bands, and VADER sentiment scoring. Cotton explains when o1's superior math and coding abilities justify its higher cost and latency.
Chapters
All right, all right, all right. I think we are live. Hello. Hello everyone. As you can see, I have my headband on. It's a bad hair day today, so please do excuse me. How's it going, everyone? I really appreciate you making the time. I am so excited about this one. We're going to be talking about how to create a financial data analysis app using chat GPT01 preview. It's still in preview mode. Do let us know everyone where you're joining from. Let us know in the comments in the chat. Where are you joining from, what you're looking to get out of today's session. And do let us know how you use ChatGPT and whether you've had any great use cases with ChatGPT. So with that, let's get started. I'll make sure to share as well some of the messages that we get on screen as we get them. I see here Faiza from Toronto, Canada. Great to see you, Faiza. I have a few slides that I'm going to get started with and then I'll jump in directly to prompt along with you. So first thing we're going to talk about first things. Hello, my name is Adal, VP Media Data Camp. I'll skip this for now, but let's talk about what's really important for today. This is creating a financial analysis data data analysis app with ChatGPT01 Preview. Right? So we're going to talk about one what you need to know about ChatGPT1 Preview, right? Why is it different than other iterations of the GPT models? We're going to talk about coding use cases for ChatGPT0. We're gonna have a bit of a Q A session then. Right? Then we're gonna dive in prompt along and then build the financial data analysis application using ChatGPT01. We're gonna have a bit of a discussion after we do our our code along here on when to use O1 versus other models. I'm seeing people more join in as Guardia TV from Bucharest, Romania. Bunaziwa actually be in Romania in a few weeks. I see George from from Romania, Marco from Hamburg, Germany. Great to see you. David from Kenya. Thank you so much for coming. Norman from Jamaica. Awesome to see so many people join us from across across the continents. Amazing to see that. And yeah, do let us know where you're joining from. Let us know what you use ChatGPT for. We'd love to hear from you. So with that, let's get started. First to prompt along, you need to go to chatgpt chat.OpenAI.com also I think chat.com now and chatgpt.com all take you there, right? If you don't have an account, where have you been? If you do have an account, sign in. You need a chat GPT plus teams or enterprise access to, to get access to 01 Preview and 01 Mini as far as I know, right? So do make sure to check that out. If you don't have premium access, follow along. Anyways, it's pretty useful. You probably can still do a lot of what we're doing today with ChatGPT4O, right? So do check it out. See here Pavel from Poland. We have Oscar from Honduras, traveling Nias from California. Great to see you. Nishad from Trinidad. Amazing. I thought of her from India. Amazing. So thank you all so much for coming. Um, so let's get started. What you need to know about ChatGPT One Preview and for that maybe let's discuss what made ChatGPT ChatGPT and how a One Preview changes some of the underlying architecture of ChatGPT. So I'll try to give an intuitive explanation. This is not a technical explanation. I'm not a machine learning researcher, right? But essentially what, what is ChatGPT? Kind of what is the underlying algorithm that powers ChatGPT? It's called the transformer model, right? It was invented in 2018 if I'm not mistaken. At least the, the attention mechanism that we're going to discuss here and the famous paper attention is all you need, that was published by Google actually. And essentially a transformer model is, has three main parts, right? The first one is an encoder model, right? That is, sorry, an encoder part. So that takes the input, right, that you have this sentence in English, for example, right? Here we have an example of the transformer model translating English to Spanish, right? It processes that input, right? And makes, it transforms it into a representation that the model can understand, right? And in a sequence into the model can understand. Then the decoder takes that encoded representation and tries to find based on the prompt that you give it, whether here, for example, translate English to Spanish, the desired output, right? And then the attention mechanism, which is kind of the magic sauce of the transformer model, what it does is that helps the model understand the relationships between words, whether in the input and the output to be able to find that best answer, right? And to find the, the. The meaning of the words being used in the sentence in context of each other, right? So yeah, just a kind of a recap here. Transform like usually chatgpt kind of generative models or use the transformer model which is made of these two, two parts and this kind of underlying attention mechanism, right? And this essentially makes generative models really good at predicting what you what the output is based on a problem that you get it. And you know GPT stands for generative pre trained transformer, right? And the pre trained here we talked about the transformer, but the pre trained part, you know, models like ChatGPT are trained on massive amounts of data, right? They learn the representations between inputs and outputs across a variety of data sets, right? And based off of that you're able to give that model, right? Like inputs such as hey, translate hello into Spanish and will come out as hola, for example, right? Or write an essay on data science and the style of Shakespeare, right? And you see here, transform this Pandas code into R code, right? And that all is done because it has representations of inputs and outputs right through that attention mechanism, which makes LLMs, right? Really great. Next token prediction machines. What that means is that they're really good at predicting the statistically most significant output based on the input that you provide it, right? You know, Tim Na Gibral and like AI ethicists from Google at the time, you know, there was a big debacle and drama in the AI space how they were like go over that paper, so on and so forth, right? Wrote this article on how LLMs are stochastic parrots, right? So they just parent what the most statistical likely answer is and that's essentially how they work, right? Which makes them not really effective at reasoning or agentic workflows. So for example, an agentic workflow is instead of translate this sentence from this language to that language would be like build an app, right? Figure it out. And agentic workflows are essentially open ended tasks that require to be chunked up into smaller ones by which you apply reasoning and you need to think about it. So for example, the first example, that real example of an agentic workflow I think that we saw was from Devin, right? Devin is like an AI system that tackles code problems. You give it just hey, build an application on this and it builds a GitHub repo, does it on its own, builds the code debug, searches for the, for the potential solution of a problem and so on and so forth. Whereas you know, we see here lots of concerns about Devin when Devin Wise came out. But if you look at for example the state of the art model on kind of the market before 01 preview was released, right. Which is here GPT4. Oh, on a lot of logic based tests, right. And evaluations, right? So for example here on competition on math competitions, the AIM 2024 math competition on a code on the code force code competition on PhD level science questions, right? These. And I'll. I'll try to shift my view here so you can see the, the graph rail, right? GPT4O is not that good, especially when you compare it to an expert human, for example, right? So yeah, that's just one thing to keep in mind however, with O1, the new paradigm that was introduced into this kind of model type, right? It's kind of interesting because they call it 01. It's a different model family than GPT 4 001, blah blah, so on and so forth, right? Is because the underlying architecture is different. O1 is essentially a transform model that's coupled with reinforcement learning, right? And it gives better capabilities for the LLM and reasoning tasks, right? So just a bit of a intuition here as well. Reinforcement learning is a paradigm in machine learning in which a agent is given a certain environment spot in a certain environment with a certain objective, right? So here assist, you know, an AI, right? And is asked to maximize a certain reward function, right? So a very easy example, kind of an intuitive example that you can think about is actually the ads that we get on Facebook for example, or Twitter, right? Not all forms of kind of ad selection algorithms or reinforcement learning, but some of them can be where it's essentially a system that is given the environment of your feed and an objective of maximizing your time spent on the ad and selects ads that maximize that objective function, right? In this context, a reinforcement learning algorithm is helping the LLM, right. Look at different solutions and find the most optimal route. Right? And then couple it with an additional kind of technique here, which is chain of thought reasoning. It's a technique that breaks down complex problems into smaller, more manageable components, right? Which ultimately result in an LLM that's able to one look at big problems and decompose the small problems and look at the potential solution space for a particular problem using reinforcement learning and choose the best possible solution. And what's interesting as well about 01 is that usually when LLMs were trained, a lot of the computing power is reserved for the pre training phase, right. When you train the model. But here a lot of the compute is actually dedicated for inference, right? So actually for that chain of thought and that on its own improves performance of these models, right? So what that looks like in practice is that you Have a model that can think, right? You know, here you're a game show, you're in a game show with three doors. Behind one door is a car, blah blah, this kind of famous mind twister, right? Or kind of puzzle, right? And then it gives you thought for a couple of seconds. I'm examining the Monty hall problem, so on and so forth, right? Here's. It thinks about the problem essentially. It tries to reason and logic around the problem, right? And what that means is that O1 is actually pretty good for coding use cases. So going back to that benchmark graph that I shared earlier, right? 01 Preview does a lot better on the AIM 2024 competition math and GPT4.O right. Almost four times as good code forces same things, almost six times as good or five times as good, right. And then om Preview actually outperforms human expert levels, right, on PhD level science questions, right. There's actually also a crazy video that I saw of a PhD grad student using chat GPT01 to essentially build code for his entire PhD thesis in one hour. So what took him to do one year, chatGPT1 was able to do in one hour. Now there's a lot of back and forth with him and ChatGPT and so on and so forth, right? But it's one of the examples to kind of show like the reasoning capabilities of these, these models and they're pretty impressive. And we go back as well, like on the improvements that you get, right. On like different benchmarks from math, the English exams to law exams to PhD level questions, right. So on and so forth. We see that, you know, across a lot of different tests, O1 improves by quite a bit, right? Here on math we see an improvement around 30.34.5 on the LSAT. Improve quite a lot. The LSAT, for those who are not aware, is essentially the main exam that you need to pass to be able to go into law school, right? For example, ap, calculus, A chemistry, so on and so forth, right? Which is quite an interesting development here since a lot of the. A lot of the value from A1 does not come from extra data or extra compute and there's more compute that's allocated towards inference, right? But a lot of the extra value comes from that chain of thought and, and reasoning capabilities that we discussed and reinforcement learning, right. Which is an interesting avenue because it goes beyond just scaling. So for example, a great way to show how agentic01 can be right is and kind of how much better it can be at Snake at at coding use cases, right? Here we they OpenAI also shared this example. I took the same exact prompt that they used and see to see how it works for me. Right? So can you create an implementation of the Snake game? It needs to be an HTML and I need to be able to copy into a single file and run it on my personal machine. Don't use any remote assets. So here what I mean, don't use any remote assets. I don't want you to use any assets you stored on a website or in a database, right? Because I just want to make it very easy for me. After opening the HTML, I need to be able to hit space to start or restart the game. So I don't want to dwell too much on this example, but I've run it already yesterday, right? And I will show you exactly how it looks like. So you can see here this was ran yesterday. Can you create an implementation of the Snake game? It needs to be an HTML, I need to be able to copy, paste it and run it on a personal machine. Don't use any remote assets, so on and so forth, right? So it thoughts thinks for 22 seconds. So it says mapping the game mechanics. I'm gathering details on implementing the classic Snake game in HTML, ensuring it operates offline without external resources. The game will run in a single file triggered by the spacebar here. It's mapping the game, set up the structure of the HTML and the CSS code. It's setting up the game, it's trying to map the environment of how the Snake will be guided. And here I don't know why it started either. I think this is in Portuguese. That was just weird, I don't know why. And it gave me. And if I download this, if I just, sorry, translate this. I think this is Portuguese. Yep, Building the direction. I'm controlling the direction of a Snake using arrow keys, right? So I don't know why I decided to to write this in Portuguese, but it is what it is and it gave me this code that you can see here right now I'm not going to go through the hassle of putting it on my machine, saving the file, so on and so forth, right. I have this online HTML editor here that you can go to, right? All you need to do is just paste this and run it, right? So this is just a. An HTML file. I'm just going to press space and as you can see, I have a successful implementation of the Snake game and it says game over when I hit the wall. So shows here the capabilities of the Snake for those who don't have O1 highly recommend that you try out this, this, this prompt, see what it gives you, right? Because it could be that this is a great use case for 0.1gpt, 4.0, 3.5, so on and so forth, right? Another use case that we saw online, this comes from this Twitter or X post, as the kids nowadays call it, of someone that just combined 01 and the cursor composer IDE and they created an iOS app in under 10 minutes. Right? So basically the outcome of the app combined with a one preview, right, is something that looks quite professional actually. And it looks like this, right? So this is a pretty, pretty beautiful looking application, right? And something that would have probably taken you a long time before you would have started to work on. Now, any questions, do let us know in the channel. Make sure to pause so that we can answer any questions, Right? I'd love to see. Guys, how are you using 01 preview? How are you using chat? I would love to learn from you here. So with that said, let's prompt along on building a financial data analysis tool using chat gp1. So just a few things. We're going to be sharing these links in the chat. We will be running our code using Google Colab, right? So do make sure to check that one out. We're going to be using the FinHub API so you can get. So this is for financial news sentiment analysis. You can get access to your free API key by going to FinHub IO, right? You need ChatGPT plus or Teams to be able to prompt along if we're going to use 01 Preview. But you don't need to use 01. You can probably get away with using lower models here, right? But it may just get difficult. But we'll see, right? So with that, let's get started. So I have this notebook here. I don't know that you can see, right? And essentially what I'm trying to build, what I'm trying to showcase from this code along, right, is. We build a system, right? Like if you're a financial analyst, right? And you want to. Here, I don't know why this is duplicated. Let me just update. Yeah. If you're a financial analyst, right, Your boss comes in, tells you, hey, I want you to build the system that takes streaming data from Yahoo. Finance and automatically visualizes the stock data and with some additional metrics, right. That are, you know, useful in financial data analysis, right. Depending on your skill set, that may be a daunting task, right? And this is something that can be, you know, packaged into an app, right. Where you can able to see how, how the particular set of stocks are behaving or performing according to set of metrics. Right. And where you're able for example, down the line look at the sentiment analysis of certain financial news as well. Right. So we can make better investment decisions. So what we're going to try to do today in the next 25 minutes, right, is build a system that takes streaming data from Yahoo. Finance, analyzes and visualizes that data and interactive visualization where we can choose our stock picker, where we can choose the time horizon, so on and so forth. Then we're going to update that and add additional indicators to look at. And then we're going to build in a system on the side as well that looks at FinHub API which collects that financial news data and gives us a very rough sentiment analysis of the latest headlines for a few companies. Okay, so with that let's get started. So set one, we're going to build just a stock data visualization, stock price visualization tool, right. And I have the prompt that I'm going to use here, so I'm just going to copy paste it, but you can see the prompt. I would like to build a stock price visualization tool using Python. The outcome of this application needs to be an interactive visualization that is embedded in Google Colab where there are two dropdowns, one for a given stock and one for different time horizons. Use matlotlib and Seaborn for the visualizations and Yahoo Finance to access the data. Please provide me detailed instructions on how I can paste the code into Google Colab. So with that said, let's get started. I'm going to open it here, I have on preview, right? And I'm going to paste here this prompt and I'm going to take it from there. It may give me an error right in the code and we'll fix it and we'll see how we approach it. So setting up the environment Python based talk price visualization tool within a Google Colab notebook and a leverage Yahoo Finance. I'll use Matlock level, okay. Detailing IPY widget. So this is important if I'm using a notebook for drop down menus and fetching data and plotting them out, okay. Mapping the process, outlining the setup, right. So it's going to give me as well detailed instructions and I'm trying to. I'm asking for this specifically because not all of you may be Python coders, right? So at least will give me a good idea. So I'm going to Go to Open Colab, sign into your account file New notebook. Okay, first thing we're going to need to do is install our libraries. So I'm going to add a code section here. And you can see here it knew that we're on Google Colab and it used the exclamation mark pip to use it in a code cell. So I'm just going to open a few code blocks just for the fun. Okay, then we're going to import our libraries. So here as you can see we're doing some installations. Yahoo Finance has been installed and IPY Widgets has been installed as well. Okay, Everything has been successfully installed. Then I'm going to import my packages. So as you can see, Y Finance, Matlock Lib, Seaborn, Daytime, so on and so forth. Okay, now then we're going to set up the stocks and the time horizons. Okay, so now what is defining? I'll explain the code as well. It's defining a list of stocks. So here we have Apple, Microsoft, Google, Amazon and Tesla. And the time horizons are one month, three months, six months and one year. So it's creating a dictionary here where I have the most likely. What it's going to build here is the indicator name and the indicator value in days. So go back here as well. Create a drop down widgets. So here it's, what it's doing is going to create the widgets that are going to be used in the visual. So it's one stock drop down. It's a drop down, correct. The options are stock list. Okay. And the value, the default value is Apple and the description is stock. Right. And then here widgets is dropped out, another one for the drop down. Then in a list we're gonna get the keys. So just this one month, three months, six months, one year. Right? The value, the default value is one month and the description is time horizon. Okay, so nothing stands out to me as incorrect here. Then we're going to build a plotting function. So this function, what it does is that it fetches the data and generates the plot based on the selected options. So let's see what we do here. Okay, So before I run it, create the plotting function. So here it clears the current output each time it's run. So that's how it starts it. Display the widgets that we see here. Right? The start date is time horizons, which is what's been defined here. Right? And we get the time period, which is one month, two months, three months, which is the value. Right? We're getting the key based on the time Period that we choose. And then we define the end date and the start date. Then we get the data based on the start date and the end date and the stock ticker that we choose. If data is empty, no data is available. Right. Otherwise we reset the index, we create the style, and then we plot the data. So on first principles, it does not look incorrect, but we'll put it to the test and then we're just going to be able to put it all together. We need to just put it in a widget. Sorry. So interactive plot equals widgets interactive update plot. So that's the function and these are the drop downs. And then we need to just display it. So let's see how it looks. Oh, we have an error. So I'm just going to copy this error. I'm going to tell. Can you please fix the code and please tell me which cell I need to update. Okay, just gonna zoom out just a bit. So if you want to add stocks, you can add more stock tickers to the stock list. If you want to create custom time horizons, you can update the dictionary, you can update the themes by changing SNS set style. Mm. So far I did not think about the error that we got on the troubleshooting. But let's see here. It's thinking about identifying the issue. Must be one dimensional data. So there's a data mismatch. I'm digging into a value error happening in Pandas. So there seems to be a value error that has to do with the shape of the data. Right. So the Data must be one dimensional, but we got a 23 dimension data set instead. So here it's saying it's going to flatten this 23, I think row area. So it's just about adding modify the SNS line plot by removing the marker O. Is that it? Let's see. So I'll just copy paste the full function here. Actually, let's see, if I just remove the marker O, will it work? Still doesn't work. So I'm just going to paste it again. See what? Huh. Okay, I'm just going to go back to. Still doesn't work. Please fix it and see what the update is. If you have any ideas on how to fix this code, do let us know. Okay. Okay, let's refine the code to use PLT with date as an index or series plot using one dimensional array. ChatGPT, you're failing us. Okay, I need to apologize to the issue. It's okay. Chat. Okay, here they're formatting the date time. Okay, Update the Plotting function. So this is the function that we need to update. And here it's explaining what's changing. Instead of passing the entire data frame to SNS flight plot, we extract the date and close columns into separate variables and they flattened the arrays and then updated the date. Formatting and then passing data to a plot. Okay, so let's see if this helps. So we are here stock ticker. And then we flatten the values and then we created X dates and Y dates. Let's see if this works. I think this should help it. Oh, we need to import pandas spd. So I'm just going to run the set of code again just to make sure I didn't initialize anything out of whack. Okay. Okay, we're operational. So I have here a drop down with I can choose the stock. It seems like we have the two representations. I'm not sure why. Right. Three months, six months. It may be due to something in the code here that we did and updated. Let me double check. If I do. So I need to double check. But this is not a game share. I want to be mindful of time as well. Yeah, we're able to change the time horizon. We're able to choose the stock. So we are pretty good here. Right. And now if I go back to the. To the. To the chat, I'm going to copy paste this prompt. The second step that I want to do now is update the script by adding date pickers for custom data ranges. Right. A drop down for different indicators to visualize. And what I want to do here is a simple moving average. An exponential moving average. And I want to visualize Bollinger bands. Right. So the simple moving average. What it does is calculates the average of a selected range of prices. Right. So here what it does is that smooth smooths out the data to identify a trend over a period. Right. Exponential moving average. What it does is that provides more weight to recent prices. Right. Makes it more responsive to new information. Right. And then Bollinger bands. What it does is usually provides you two bands and provide high and low range with a security. Right. Typically trade. So with that said, I'm going to open here a few code blocks because it probably will recreate everything for from scratch first. So let's hear. Okay, it worked first let's congratulate it. Let's see where's take it. CSJM is saying here actually want to make a project like this to keep up with the financial markets in shiny. Right? That's actually a great idea. And probably you can Use a lot of chat GPT here to help help out in building this. If you want to use Python for this as well, you can use Dash, which is a great dashboarding tool. And one of the great things of LLMs is like just how much it reduces the barrier to entry to working with type tools like shiny. Right? Because you can build amazing dashboards. Shiny. So it thought for about 12 seconds and he said enhanced the script. It's going to update and improve the date pickers. It's going to tweak the script to accommodate that. Right? And then it's going to update the interface for SMA and ema. So these are the simple moving average and exponential moving average to streamline data collection. Right. And then it will update the function. Right. So first of all what it did told me to update my imports, define the date picker widgets. So we're updating here. We're using a date picker instead of a drop down and an end date picker. Then it's creating another one for simple moving average, exponential moving average Bollinger bands. Then what it's going to do, it's going to update the plotting function. So if start date is none, right? So here it's going to update the the start date end date logic. It's going to fetch the data based on the start date end date logic and then depending on whether which indicator we use. So simple moving average is a window of 20. Okay. Then exponential moving average as well. I see here span of 20. Right. Same on Bollinger bands. We see here standard deviation plus 2, the plus standard 2 times standard deviations and minus standard deviation. Okay, that makes sense. And then plot selected indicator based on what we get and then update the interactive interactive function. And then it's going to give me the fully updated code. So I'm just going to do that. I'm going to take it here first, break it down. I don't need to reinstall my packages. I think the same libraries have been imported. But I'll just keep it there just in case. And now it needs me to display inline. The same stocks are here, I'll just do this. So again, stock dropdown, start date picker. I'll define all of these here. And then I'll take this plotting function here, add it to this own section and then I'll do the widgets here. Most likely it will also do an error like we had in the last time, but we'll be able to fix it. So I'll just break down what I did. I Took the entire script that it made, broke it down here. This is imports probably I didn't need to do this, but I just want to make sure that I don't run into any errors. Right. But if you're doing this in an actual real world projects, you import all of your packages up front. It's defining, you know, the stock tickers. Again, I don't think it's that different from what we defined last time. It's probably also the same variable name. There's a stock drop down. Right. So here we're able to choose the stock. We're able to pick the start date and the end date using these new pickers. And then now we have an indicator for what measure we want to use. So I'm going to run this as well. Then we're going to do is use it to update our plot. So here clear output. So we define what the start date and the end date is and then we fetch the data from Yahoo Finance and it even said put an error for a context where we put start date is above end date. So that's a smart one. So here if the start date is above the end date or it's higher than the end day. So if it starts on, I'll just want to zoom in, make sure that it's very clear. So if it starts next week and the end date is today, there's probably going to get an error. And then if the data is unavailable, no data available for the selected stock and date range. And then based on the calculation it will calculate the calculations and then plot the selected indicator. So let's run this. Sorry. Okay. And now what we need to do is display it. Let's see if we get an error or not. Oh actually we got it right from the get go it seems but I don't know why this is doubling down. We need to double check this. So we have Apple Microsoft changes the stock price. Okay. And then indicator, simple moving average. We have the simple moving average over the past period that we have defined here. Let's just change the start date to something a bit farther away. Oh, can compare date time to date time. Wait, let's try something. Okay, that was odd. So here, the more we go back the more we'll be able to see an sma. Maybe it has something to do with updating these and not the above. Changing the exponent exponential, moving average. We also see the updated content Bollinger bands. Right. We're able to see as well here the standard deviation in the sma. Right. So this is SMA and then SMA times plus two times standard deviation of this number and then minus two times standard deviation of this number. So overall it's working as expected minus these three things here that we would clean up if we had more time, we'd be able to clean them up. But I want to make sure that we also cover the financial news analysis, right? So that wraps up the visualization element of this prompt along and now we can move on to something a bit more complex, right? But actually is also kind of a way a lot of folks in the industry and the financial services industry use AI to get an advantage. So a lot of the times, right, a sentiment based approach to, to investment, right, can make sense. So for example, if you get a really negative news on a company, then you can anticipate that the market is most likely going to short that stock. So how do you get that news on mass. Right. A lot of hedge funds use, for example, sentiment analysis tools, right? To be able to do so today we're going to use a very rudimentary sentiment analysis. So it may not be like the most accurate model, but it just should give you a good starting point that you can improve. So with that, what we're going to use is the FinHub IO API. It's essentially a financial data API and we're going to use it to extract news in real time. And then what you need to do, Sorry, I'll go back here and show, show people what they need to do. You just need to press here, get free API sign in, right? And get this API key. It's free, you don't need to pay for anything, right? That's it. You make sure you sign up, right? I already signed in with a kind of a burner email. You need to copy the API key, right? And then what you need to do is press on this key here, right? You'll have add new secret and then name it Fin Hub API. Name it like that. Make sure to name it like, exactly like this. Because the code that we're going to use uses this name. And put your API key here in the value section, right? Once it's pasted there, you'll be able to use the following code here from Google Colab. Import user data and user data get quotes FinHub API to get your API key. So that way you can use this code without sharing your API key publicly like I just did. So that said, I'm going to copy this, this, this prompt. You can build now a simple financial news sentiment analysis bot that analyzes Headlines from financial news articles using the FinHub API. The outcome needs to be a data frame with four column, four columns, the stock, the date, title of the article, and the sentiment. So let's see what it does. It's going to go down. It's thinking. So it's thinking on the user's request for a financial news sentiment analysis bot, which will use the FinHub API to process news headlines and output data frames with data frame with columns. So stock date, title and sentiment. It's going to focus on the FinHub API, careful handling of API keys and personal data. It's going to use Analyze sentiment with text blob. Okay, interesting. Okay. It's even giving me how to access the FinHub API. That's good. First thing that we're going to do is use Vader Sentiment. It's pretty interesting because in the solution code, I ran this exact prompt yesterday. In the solution code, it seems like it's following a different set of tools than it used. It used NLTK yesterday. So first thing I'm going to use pip Install request, Pandas, Vader, Sentiment. Okay. Then we're going to import the libraries. So we're importing requests Pandas, spd, Vader, Sentiment, and Date time. Okay. We're going to fetch. Create a function here to fetch news from the FinHub API. So we're going to do. And as you can see here, there's this function called API key. Right. What I just need to do first is copy this. I'm gonna add it here. Yep. I'm gonna grant the access. Okay. So now my API key is here. And I'm just gonna replace this with here. Oops. And then we're going to perform sentiment analysis. So this fetches the news. And then here we're initializing a sentiment intensity analyzer. Right? We're going to look at the headline. It's going to give a score, a compound score. If the compound score is above 0.05, it's positive. If it's below 0.0, minus 0.05, it's negative, else it's neutral. I think the compound score is from minus one to one. And then we're going to put it all together where we create a function called Analyze new Sentiment. It takes as input the stock list, the API key, right? And then it returns a data frame. And here what it does for every, it stores all the news in a list. For every stock in stock list, we fetch news on the stock and we add it to the. To the, to the to the list and then we extract the sentiment using get sentiment of the title and append all this data in all news. Okay. And then what we need to do is display the frame. Oops. Okay, so here, replace this with your API key. Luckily, I already have an API key that I've already defined. It's called FinHub API. I've defined my stock list. Let's do it for Apple, Microsoft, Google, then data frame analyze new sentiment stock list. So I'll just replace it here. FinHub API. Right. And then let's print the DF head. Okay, so I'm just gonna do it like this so we can see in a table instead of printing it. Okay. So for example here I need to look at the overall title before I look at Google. Should face investigation over that sounds negative. UK competition Watch out recommends investigation. That sounds as well like positive to the UK maybe. But then Apple is giving Siri a makeover to compete with ChatGPT. I think that's the. If I'm not mistaken. Yeah, to compete with chatbots. So that's positive, right? Key insights from Apple's AI push. Right? And if I go 0 to 100. Okay, So it's not the best at capturing the sentiment, but this is a very rudimentary technique that we're using. We just built in 25 minutes, a notebook that extracts Yahoo. Finance data, visualizes stock pickers and interactive dashboards. Right, or interactive visual and. Calculates sentiment of financial news Data all in 25 minutes, which is great. And this is something that is amazing that you can do with AI and with something like O1 preview. Now with that said, if you have any questions, do let us know. BA wrap up with when to use O1 versus other models. So a couple considerations, right? Latency, complexity, quality of response and budget are all very important, right? So latency is how fast do you want the responses to be generated it, right? So like if you're building a chat bot that answers simple, simple questions like one plus one, if it takes 12 seconds to think about it, it's pretty bad user experience, right? So that's something to think about. Complexity is how complex is the problem, right? So if you're writing an email, don't use 01, right? Quality of the response, right? For example, sometimes 80% accuracy is good, sometimes 99 accuracy is bad, right? I'll give you an example. If you have a, you know a lot of the missile detection algorithms that operate in submarines, right? If they have 99 accuracy, right. It means 1 out of 100 times you're getting a false positive. Is that good enough? Or do you need to be 0.1 out of 100 times? Right. So that's there's a massive difference between 99 and 99.9%. Right? And what's really important here is that all models hallucinate, including O1. So with the current generation of models, you can't get to 100 accuracy, right? But something to think about if you're using the API on budget, right? Like here we're talking about using ChatGPT, the interface. But if you're building a system, you using the OpenAI API, O1 is much more expensive, right? You pay for the thinking tokens, you pay for the thoughts, right? So that's something to think about as well. So as a rule of thumb, use O1 if you care about the highest quality response. The tasks are complex, you don't have inference considerations. You don't mind if it takes a while for it to generate the answer. You can afford it in your application if it's API focused, use GPT4O or even an open source solution, right? If you can settle for good quality responses. But you don't want the that extra 5% of improvement tasks are simple and close ended, right? You need answers fast, right? And you care about being cost effective. And with that we can wrap up with this session. Word of caution. Never forget the human in the loop. It's amazing that you can have systems that you can, you know, if we were to do this code, code along and like just me coding, it would have probably taken us a couple of hours, right? But we were able to do it in 25 minutes, right? That's pretty significant. But never forget the human in the loop. Never forget why you're using these tools. It's very important. A couple of things as well, you know, as AI systems get better, right? Like what is the future of these systems, right? What's the future of, of work and society at large, right? You know, we had that push last year, a year and a half ago for pausing AI development, right? Because it's going to be exist, it's going to lead to existential risk, right? But the risks are actually different than that, right? The risks are about how do we make sure that AI systems are used in a way that is promotes fairness, that promotes transparency, that we don't put AI systems in critical infrastructure or decisions that affect people's lives, right? But if we're using AI to help us as a co pilot, right, like we see on the. Right, there is no reason why we are going down this Terminator path that you see on the left. So when we think about the risks, right, we have scalable misinformation. Here you see a picture of President Donald Trump or President Elect Donald Trump and being arrested, which is false. The one in the middle, when this is an early iteration of ChatGPT. Someone asked ChatGPT to create a function that in Python that predicts seniority based on race and gender. And you can predict how that went, right. Or you know, that, you know really bad phishing emails that you get. Right? That has not been the case. They're not as bad anymore with LLMs in the driver's seat. Right. So there's a lot of risks that go beyond the existential threat risk. Right. That we need to think about as a society together today. So embrace change, use it to your advantage, beware of the real risks and become a more digitally engaged citizen. Right? Tools like ChatGPT and generative AI can augment the roles of today and we'll transform them tomorrow. So learn as much as you can today and try to be ahead of the curve to be successful. And with that, I'll take Q A. I see a comment from Marco. All right. Funny enough, during the code along, 4oh created better and faster results than O1. Man didn't even get down those double drop down widgets. That's, that's. It's good that 4 oak and I mean 4 oh. It's pretty great. 4 oh is pretty great. Maybe we need to next. Next iteration of this colon, we need to make something even more complex to see. At one point in time do you get to the tasks that 4.0 cannot handle, but O1 can? Right? And that double digit dropdown, I also did not understand why it happened. I need to look at the code and one thing as well, funny enough, I'll share this on the screen again. I did mention that if you look at the last step here, we use the Vader sentiment, right. In the solution. I actually did this last night in preparation just to make sure that at least if we, if we reach A. If ChatGPT is not complying, we're able to. To work it out together. Right? It used nltk. It used a completely different package. Right. And then it also looked at kind of the function the way it was built completely different as well yesterday. So very interesting. Okay, Looking at additional questions. Sorry, there's from Nancy. Is there any data that shows whether O1 is better at some language than others, for example, error handling and garbage Collection in C. It's actually a great question. I. I'm sure there's evals that have been made on a. On a coding language level. LLM evals coding language by coding language. Need to double check this but that's a great question actually. But it should be good at C as well because a lot of the data that it's been trained on is GitHub data most likely and stack overflow data. And given that C is a top language, it has a lot of data on it. Okay, how does it compare to Claude 3.5 sonnet? Actually most I think today if we go to LLM benchmarks going here as well. I'm going to the Vellum AI1 today. Claude 3.5 Sonnet is. Where is OpenAI01? Let's just put it here. Yeah. Now let's get the. Yeah. Cloud 3.5 Sonic, the latest iteration. Yes, it is here. So they don't compare it to 4 to 01. Okay. Our evaluation. So actually they make a difference. Our evaluation tables Exclude Open or OpenAI's 01 right family as they depend on extensive free response computation time. Okay. But if I do to the sys LLM leaderboard. Sorry. So GPT4 Claude V1 are. These are old. I need to double check but there should be. Yeah. Okay. This is the one chat ball arena. Okay. Leaderboard. So Gemini is highest 4.001 Preview01 mini clone 3.5 is here but this is vibes based. This is important to think about. What's the Inside scope of GPT5? There's a lot of speculation and potential misinformation out there. If I knew I'd be a lot richer. But so GPT5 based on, you know, a lot of the feedback that we get from the community from data frame guests, from what we've seen other experts talk about, it seems like scaling is. It seems like the intelligence of these systems is plateauing. Right. Or at least you know, if you kind of take a step back. Right. I remember playing around GPT 2 when it was released and then the jump from GPT 2 to GPT 3 was really impressive. And the jump from GPT 3 to GPT 3.5 which is. Was. Which was accompanied I think with ChatGPT was also really impressive. And then the jump from 3.5 to 4 was really impressive. And then fourth 4. Oh, slightly less for. Right. And the. The iterate. The improvement size with each iteration became lower. Right. The. The size of the step became smaller and I think that trend will keep up with the GPT5 we're going to see what tricks OpenAI has up its sleeve when it comes to improving the performance of the model without without more data, right? Or without more scaling whether there's you can shift compute like this like O1 to reasoning or whether you need to change the architecture or whether they'll build a lot of different models that interact together that are really fine tuned on different tasks right? So it does not seem like it's I've heard that their next model, which is code named Orion, will I've read will go out before the end of the year. But at the same time I don't know if it's going to be GPT5 another one from Nazi. How does one keep up with all of this? They're rolling out faster than you can learn. Any suggestions for how to learn? I unfortunately I'm on Twitter a lot and it a lot. There's a lot of people talking about these things on Twitter so I just like catch what the market is doing. Also had the privilege of speaking to a lot of cool people on the Data Frame podcast, but my suggestions probably stick to your you know, find a few cool people that you that you rely on for for learning and use. Follow them, follow their work subscribe to newsletters right? Try as much as possible to like subscribe to sources of information that have only signal no noise. Okay I think this wraps up questions and we're at time. I want to say a huge thank you for everyone who attended today. It's a privilege, it's an honor to be able to host these sessions. I want to give everyone a huge thank you for everyone's joining from all over the world, difficult time zones, all of these things. Right. And with that said I'll wish you all a great weekend and.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







