Aquiring RSI data - Tkinter tutorial Python 3.4 part 27

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

Key Takeaways

This video tutorial demonstrates how to acquire RSI data using Tkinter GUI in Python 3.4, leveraging the Sea of BTC bitcoin API for data retrieval and processing. The tutorial covers creating a GUI, passing parameters to the API, encoding and decoding data, and plotting RSI data on a graph using Matplotlib.

Full Transcript

what's up everybody welcome to another tkinter tutorial video part of our tkinter Mega series making a baller program so uh where we left off we've got the chart actually showing some great stuff we've seen how our backend functionality allows us to add subplots remove subplots adds you know throw in SMA EMA that kind of stuff awesome pretty Candlestick charge based on the data we set and now we're ready to show the indicators so the top and bottom indicator so we just have two major indicators at the moment RSI and macd and so now I'm going to show you guys how we're going to grab those indicators and we're going to use the um the C of BDC API to grab the indicator information so uh come down to our animation function I'm just going to do contrl F my fingers are getting very tired from bulk scrolling and within the animation function is where we're going to put uh the other data like RSI indicator for example so enter enter and here we're going to Define not all caps Define RSI indicator like that and then RSI indicator you're going to pass the parameters of price data and then you're going to pass the location data and we'll go ahead and just make a default top parameter there um but I think we've actually we filled that in every time but then quickly the question that we ask is if location equals top uh we're going to say um the values equals and this is basically uh a dictionary of information here so we're going to say values equals what so we're going to say key this is the key that we pass through the API uh and then we're going to say the prices are the price data and that's why we have you know price data at the end um and I yeah we we did it for all the tick data and I believe it's covered even our on Hobe but we'll have to check and make sure um price data and then we have um the periods periods uh colon top indicator one so this is this kind of just matters just simply because and in theory I guess we could just just set periods under this um but in theory you could have an RSI indicator on the top and on the bottom and have them at like moving at different Paces or something right so anyway we're just we're going to preset these so if location equals top and then we're going to say if location equals bottom basically the exact same thing only it's bottom indicator one now now that we've done that we're ready to uh pass this information to the CF BDC API and get the return so the URL for this specific query is going to be HTTP colon cbc.com API indicator SL RSI so that is going to give us uh the RSI indicator information based on the data that we passed through so what we'll do now is we're going to say data equals url live. par. url encode so we're going to encode this values dictionary uh that we that we've defined here so we encode values and then we're going to say data equals Ur or actually I'm sorry data equals data. ncode into utf8 um and just for the if anyone is like confused about this I do have a URL lib basic tutorial in my uh Python 3 Basics playlist so if you don't quite understand what's happening here uh check that out uh we'll get rid of this slash there uh so data equals data. encode to utf8 now we're going to say the rec for request equals url. request. Capital request um and we're going to request that URL with the data um then we're going to do the response I'm so itchy today response equals URL li. request.url open and we want to open that the request that we want to make which will return the response that we want to get and then we're going to say resp data equals the resp. read and that is in uh byes so we need to decode that and again I my code is converting it to a string and removing the bees I'm not sure why I did that but we're going to just not do that so we're going to say uh new data equals let's see I'm trying to see here new this is a mess let's see let me look at uh the way I've done it is pretty sloppy but then I almost need the sloppy is here uh so new data dot uh new data equals resp data. decode so at least we decode the bytes there and then now we're going to split by I'm not really sure I like this uh we'll have to fix this later but we'll say price list equals new data. split by this absolutely nastiness uh and we might need to convert uh that should be in string format but we may need to actually convert that to string but we'll we'll see if we get away with this um and then we're going to say RSI data equals and we're going to do some uh sexy oneliner here float it's the float I for the i in price list so we're basically converting everything here everything here was a string right we we've split it by this commas space and it's still in string format and so now what we're actually doing here is we're basically converting for at for I in price list we do float I and so this is just a really like easy oneline function that that's what it does so it returns it to RSI data now uh we want to actually put the RSI data up so if the location is uh top it goes on the top graph so we're going to do a z that was the top subplot a z. plot date um and then we do ohlc and then it is npl dates and then uh we plot the RSI data and then um yeah light we'll do light color I guess we could do light or dark right really um and then label equals RSI now uh we might actually well we may Advance this a little bit um if you guys aren't familiar I I wrote uh the the customizing matap plot lib tutorial and we wrote some some fancy code there that like if if the RSI was greater or less than a specific number it would fill between so generally if the RSI is greater than 70 that shows that it's almost strong and it's going to bounce back down basically so anything above 70 it fills between the 70 Line and where the RSI is so it'll fill like like a block of red and then it comes down and then when it's generally like really really low it fills that with green and the idea there is with the RSI is it it designates whether something is overbought or oversold um so that's the point of that so anyway a z we do that um then we're going to say my code I use that label I guess we'll will continue that E equals um RSI uh and then generally you have RSI and then in parentheses you have the value so RSI this and for all those people that like to do percent s and all this stuff I'm really sorry uh feel free to uh do that if you'd like I've just always done it this way and I don't think I'll ever stop top indicator uh one and then we just need to plus and then the closing parentheses so if it's a 14 it would say RSI 14 okay so now a. setor y label and we set it to that label really professional code here so now we're going to say if location equals uh bottom basically the same code so let's just go ahead and um copy this colon paste and instead of a Zer it is A3 A3 uh uh everything else Remains the Same I believe and that should be it so let's save that and let's go ahead and run it and see what happens agree top indicator let's set it to the RSI indicators on tick data not available of course so let's pick one day dat time frame top indicator RSI nice little warning message if I if I do say so myself no could not convert string to float not a number filled in the nonic [Music] um it's really weird because we passed trying to think of why because we've we we've removed not a number already so that shouldn't actually be a problem we let's remove uh dat label just I don't it doesn't seem to me like it would be dat label but um let's go ahead and remove that really quick one day RSI see it's clearly like sending the data and it's coming back as cannot convert string to float failing and that um let me let's see we're graph oh this is driving me nuts cuz we were plotting date here um it's got to be failing in here so let's go ahead and add a quick try here uh except exception whoops as e print uh failed in RSI string e and while we're doing that also let's scroll up to the very top and instead of tick we want let's just start it with we'll do one day let's go back to our program here one day top indicator RSI and it should give us an error in RSI right failed RSI could not convert string to float not a number why is not a number in my um H okay so it's just weird that we're returning a noted number uh here now what if um let's go animate it's probably failing right here right so price list it's failing in the conversion there well um cuz you can't convert you know not a number to that but why are we failing on the RSI let's see I'm just running the main one at the moment I just want to make sure that my API isn't down or something right okay so the API is not down I'm just a little concerned then um H I'm too tired I think we'll have to we'll have to just come back to this um but for now I'll just give you guys uh the code that will just you know tear this apart at least um I hate to do this so rest data equals rest. read um that's fine and then basically what we can do at this point is we can say new data uh equals the string version of resp data uh do replace I still don't understand why n it's driving me nuts anyway replace uh the B and bite code with nothing and then do replace uh the brackets with nothing this is ugly ugly replace uh closing brackets with nothing and then we have a quote there that we need to replace and that would do it okay so that gets rid of everything then we would have price list equals uh new data. spit uh by comma space that would be the price list and then the RSI data would not should be unchanged so let's try that and at least we have RSI data there um obviously I'm not very happy with that if you can't tell we'll definitely have to uh fix that could I don't this is so just pathetic so so we'll have a fix for that hopefully in the coming videos uh the next video will cover macd although we'll probably maybe before the next video we'll have to have a solution for this because otherwise we're going to run into the same problem with macd so anyways that's that stay tuned to next video if you have any questions or comments besides how bad that was uh please feel free to leave them below otherwise as always thanks for watching thanks for all the support subscriptions and the donations and until next time

Original Description

Tkinter GUI TutorialPlaylist: http://www.youtube.com/playlist?list=PLQVvvaa0QuDclKx-QpC9wntnURXVJqLyk This Tkinter GUI programming tutorial covers how we can get RSI data based on the data we pass through the Sea of BTC bitcoin API. http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This tutorial teaches how to create a GUI application using Tkinter to retrieve and plot RSI data from the Sea of BTC API. It covers key concepts such as API data retrieval, GUI programming, and data visualization. By following this tutorial, viewers can learn how to build a functional GUI application and handle errors in their code.

Key Takeaways
  1. Define the RSI indicator function within the animation function
  2. Pass parameters to the RSI indicator function
  3. Encode the values dictionary to be sent in the URL request
  4. Make a GET request to the API using the URL request library
  5. Decode bytes to string and remove commas and spaces
  6. Convert string to float for RSI data
  7. Plot RSI data on a graph
  8. Customize plot with colors and labels
  9. Add try-except block to handle exception
  10. Modify code to remove non-numeric characters from RSI data
💡 The tutorial highlights the importance of error handling in code, demonstrating how to use try-except blocks to handle exceptions and modify code to remove non-numeric characters from RSI data.

Related AI Lessons

Up next
How to Open HPL Files (HP-GL Plotter)
File Extension Geeks
Watch →