You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Make Candlestick Chart with Python (Pandas Library Notes)
Hacer Gráfico de Velas con Python (Apuntes de librería Pandas)
The video provides a step-by-step guide on how to create candlestick charts using Python's Pandas library with CSV data. It starts with importing the CSV data and creating a data frame to use for chart creation. The tutorial also covers the installation of the mpl finance library used for financial plots. The video highlights the importance of understanding Pandas to effectively use it in Python and how to alter the chart type and date range for accurate representations of the data. This is useful even for tasks such as modeling for automated trading.
Algorithmic Trading with Python (Decision Tree)
Trading Algorítmico con Python (Árbol de decisiones)
In this video about algorithmic trading with Python, the speaker uses a decision tree approach to predict the price movement of Bitcoin based on historical correlations between SP500, gold, and ethereum. The model is trained using current day data, and then used to predict the next day’s results. While decision trees can be useful for predictions, the speaker notes that it may not be perfect with only a small data sample. Viewers can access more algorithmic trading strategies, courses and articles related to artificial intelligence and Python on the website provided in the video.
Python for investments: How to get Dollar Index? DXY
Python para inversiones: ¿Cómo sacar Dollar Index? DXY
The video covers the extraction of the DXY Index data, which measures the strength of the US dollar against other currencies, using Python's Beautiful Soup and Pandas libraries. The presenter provides a code that extracts variation percentage information from the DXY data and saves it in a CSV file for further data analysis and machine learning purposes. Additionally, they share their website with free courses on Python, finance, and algorithmic trading. Thus, the video is a useful guide for extracting financial data using Python.
Algorithmic Trading Using Python - Full Course
Algorithmic Trading Using Python - Full Course
00:00:00 - 01:00:00 This video explains how to use Python to trade stocks algorithmically. It starts by introducing the basics of the pandas library, and then demonstrates how to use it to create a data frame. The course then shows how to execute an HTTP request for a stock and how to use the results of the API call to populate the data frame. Finally, the course discusses how to improve the performance of the code by batching API requests.
01:00:00 - 02:00:00 This video covers how to use Python to trade stocks using an automated algorithm. It starts by creating a list of stocks and symbols, and then transforming those stocks into strings. Next, the video creates a URL to launch an HTTP request using that string. Finally, the video demonstrates how to run that request and get the data back.
02:00:00 - 03:00:00 This video teaches how to use Python to create an algorithmic trading strategy that uses the price-earnings ratio as a value metric. The strategy screens for stocks based on this metric and makes buy and sell recommendations based on the current stock price.
03:00:00 - 04:00:00 This video tutorial explains how to use Python to trade stocks algorithmically. It covers how to calculate various indicators of success, how to deal with missing data, and how to use Exception Handling to replace missing values.
04:00:00 - 04:30:00 This video explains how to calculate percentile scores for different stock metrics using Python. It also covers how to use Python to create an Excel file containing stock prices and position sizes for calls and puts, and how to format the file for printing.
Part 1:
Part 3:
Part 4:
Part 5:
Algorithmic Trading Python 2023 - FULL TUTORIAL Beginner
Algorithmic Trading Python 2023 - FULL TUTORIAL Beginner
In this video tutorial, the author delves into the process of installing and utilizing a Python program for algorithmic trading. They provide step-by-step instructions on creating a basic Python 3 file specifically designed for housing code related to algorithmic trading strategies. Moreover, they demonstrate how to execute the code and print the resulting outputs for analysis. The tutorial primarily focuses on harnessing the power of the Python programming language for algorithmic trading purposes. It covers a range of essential functions and libraries applicable to algorithmic trading, including the yfinance library. The tutorial highlights the significance of using these functions and libraries while also exploring data download and processing techniques using spreadsheets.
Additionally, the video tutorial showcases the process of writing and reading CSV files using Python. It explains the necessary steps for creating a CSV file and demonstrates how to read and manipulate the file within a Python environment. Continuing with the theme of Python-based stock trading, the tutorial elucidates the creation of a stock index and demonstrates how the Python function "convert" can be used to modify the index format. Furthermore, it explains how the Python function "start.columns" facilitates changes to the column list specifically for stocks.
The next video tutorial also revolves around using Python for stock trading. It commences by illustrating the download and parsing of stock data, followed by employing the "describe" function to analyze the acquired data effectively. Lastly, it demonstrates the utilization of the "dot lock" function to monitor and track stock prices. Moving on, the subsequent video tutorial provides a comprehensive explanation of using Python to create algorithms for stock trading. It begins by visualizing different starting points for three distinct stocks, subsequently illustrating the normalization of values to represent them within a uniform 100-point range. The tutorial then guides viewers on plotting the normalized closing prices of a stock and utilizing the "dot" (mole) function to multiply the values by 100, enhancing readability.
Similarly, another video tutorial focuses on utilizing Python to create stock trading algorithms. The tutorial outlines the process of creating a new column within a dataset to store information regarding closed stocks. It further explains the utilization of the "shift" function to relocate data to the bottom of the column. Additionally, it showcases the calculation of percentage changes in stock prices from the previous day. Shifting gears, another tutorial introduces learners to utilizing Python for statistical calculations related to algorithmic trading. It provides guidance on employing functions such as "shift," "subtract," and "divide" to compute lag and diff-related data.
Next, the video delves into calculating percentage changes for financial assets using Python. It demonstrates modifying the "change" function to improve readability by renaming it as "pst." Furthermore, it sets the "periods" variable to one and multiplies the percentage change by 100 to represent it in point value format. The video also covers calculating the standard change for an asset, subtracting it from the percentage change to eliminate the impact of the first day. The dataframe for a specific asset is renamed as "change," and the "change" column is created. The tutorial concludes with running a check on the "change" column using "aafl" and saving the dataframe.
Moreover, the tutorial author explains how to calculate mean, standard deviation, percentage change, and returns for a given dataset. They also demonstrate plotting a histogram and creating a hit system graph.
Continuing with statistical calculations, another video tutorial explains calculating the mean, variance, and standard deviation of a stock's returns. Additionally, it provides guidance on determining the annual mean return and the annual variance return.
Expanding further, the tutorial showcases calculating the annual standard deviation of a stock's returns using the "std" function in Python. This approach efficiently analyzes large datasets by taking data from a ticker symbol instead of individual data points. The tutorial also demonstrates creating columns to track the mean and standard deviation of a stock's return, as well as the mean and standard deviation of a stock's percentage change. It further explains calculating the mean and standard deviation of a stock's return using the "summary" function.
The author also covers the creation of scatter plots and annotating them to illustrate the return and risk associated with different stocks. This visualization helps in understanding the relationship between returns and risks in the context of stock trading. Moving on, the video tutorial delves into using Python to create algorithms for trading stocks. It explores the usage of for loops and functions such as covariance and correlation. Additionally, it showcases the graphical representation of the algorithm's results, enabling traders to visualize and analyze the performance of their trading strategies effectively.
Furthermore, the tutorial explains how to leverage the seaborn library to create a heatmap depicting stock correlations. It provides a step-by-step guide along with a code download for the entire project, facilitating the implementation of stock correlation analysis using Python. Shifting focus, the presenter in a video tutorial educates viewers on calculating the risk and reward potential of a portfolio of stocks using Python. They discuss the limitations of simple returns and introduce the concept of log returns, demonstrating their practical application in assessing risk and reward. This analysis helps traders make informed decisions regarding their portfolio composition and risk management.
Another tutorial elucidates the process of calculating a simple moving average using the "rolling" function in Python. By applying this technique, traders can smoothen the fluctuations in stock prices and identify trends more effectively. In addition, a tutorial demonstrates the calculation of the mean, median, and moving average of a dataset, emphasizing their significance in analyzing and understanding data patterns.
Moreover, a video tutorial showcases the calculation of various moving averages, including the 50-day moving average, 200-day moving average, and EMA (earnings-to-price) of a stock. These moving averages are then plotted on a graph, aiding traders in identifying key trends and potential trading signals. Continuing with data manipulation techniques, a video tutorial explains the utilization of the re-index function in pandas to replace missing values within a dataframe. It also covers the application of forward and backward fill functions to manage data when encountering holidays and weekends.
The video tutorial further demonstrates the calculation of returns for a stock over time, encompassing buy and hold returns, cumulative returns, and maximum returns. Additionally, it explores the computation of cumulative maximum returns and visualizes the data through graph plotting. Furthermore, the tutorial explains how to calculate drawdowns for a stock, as well as the maximum cumulative return and maximum cumulative drawdown. Understanding drawdowns helps traders assess the risk associated with investments and identify potential loss scenarios. In a similar vein, another video tutorial discusses calculating drawdown and maximum drawdown for a stock. Additionally, it provides an overview of calculating percent drawdown, a crucial metric in risk management.
A Python 2023 tutorial on YouTube introduces viewers to creating a moving average crossover strategy for trading. This strategy involves utilizing two moving averages, a 50-day moving average, and a 100-day moving average, to determine the stock's trend and generate trading signals accordingly. Moreover, a video tutorial explains how to write Python code for trading stocks. It demonstrates the process of determining whether to buy or sell a stock based on its current price and past price data. It also covers using a library to track a stock's position over time, allowing traders to monitor and manage their portfolio effectively.
The tutorial video enlightens viewers on backtesting an algorithmic trading strategy using returns and standard deviation. It showcases a strategy that outperforms a 50-day moving average in terms of returns but comes with higher standard deviation, highlighting the trade-off between risk and reward. Additionally, the video tutorial guides users through creating an investment strategy and comparing it to other strategies. It emphasizes that the strategy with the best returns is the one with a long bias, indicating a preference for bullish positions.
Furthermore, the author introduces a function to create a test strategy for algorithmic trading. This function takes parameters such as stock name, start and end dates, and returns key performance metrics such as daily return, cumulative return, and SMA (Simple Moving Average). By utilizing this function, traders can assess the effectiveness of their trading strategies and make data-driven decisions. The tutorial then proceeds to demonstrate how to build an algorithmic trading Python script. The script incorporates a simple stop-loss and take-profit strategy, aiming to achieve better overall performance compared to a traditional buy-and-hold investment approach. This script serves as a foundation for developing more sophisticated trading algorithms.
The presenter also showcases the process of backtesting a trading strategy written in Python. The strategy, created by the presenter, is tested on historical stock market data from 2017, enabling traders to evaluate its performance and viability. Moreover, the tutorial explains how to code a Python2023 algorithm for trading stocks and cryptocurrencies. It covers the utilization of APIs to access data from various stock and cryptocurrency exchanges, enabling traders to analyze real-time market data and implement trading strategies accordingly. The video tutorial further explores using Python to trade stocks and cryptocurrencies. It encompasses data entry, analysis, storage, manipulation, and the execution of trade strategies using API services. By leveraging these techniques, traders can automate their trading processes and efficiently manage their portfolios.
Additionally, the tutorial provides comprehensive guidance on using Python to trade stocks and other financial assets. It covers fundamental concepts such as price analysis and trading, as well as advanced topics like backtesting and utilizing APIs for data integration. This tutorial equips traders with the necessary knowledge and tools to engage in algorithmic trading effectively.
In conclusion, these tutorials and videos offer a wealth of information on using Python for algorithmic trading. They cover a wide range of topics, including data processing, statistical analysis, visualization, strategy development, backtesting, and real-time trading. By following these tutorials, traders can enhance their understanding of algorithmic trading principles and leverage Python's capabilities to make informed trading decisions.
dot (mole) function to multiply the values by 100 to make them easier to read.
How to Get a List of Stocks on an Exchange || Stock Analysis with Python Part 1
How to Get a List of Stocks on an Exchange || Stock Analysis with Python Part 1
This is the first part of my series on using Python for stock analysis. The series will be divided into three sections. In the first section, we will focus on obtaining and organizing data for analysis. Part two will cover individual securities, and finally, I will demonstrate how to package our code for easy installation using pip. The code will be available on GitHub (link in the video description). You can use any text editor of your choice.
The most important aspect of stock analysis is the data source. I will be using comprehensive end-of-day historical data, which includes global data. You can start with a free plan, but it has limitations on the number of API calls per day. If you require more, you can subscribe to a data bundle with special pricing (link in the video description).
Let's begin by importing the necessary modules. We will start by downloading metadata about securities from a specific exchange. We need to provide an API key and specify the exchange (defaulting to the New York Stock Exchange). I will provide some examples for the US market, but you can explore international markets using the documentation on the end-of-day historical data website.
Once we have the documentation set up, we will make a call to the API endpoint, passing the exchange and API key. We will use the requests module for this. The response will be in JSON format, which we will transform into a pandas DataFrame.
Finally, I will add some print statements to show the progress, and we can test the code by running an entry point function. Make sure to replace the API key with your own. The result will be a DataFrame containing the retrieved data. We can further filter this data based on the types of securities we are interested in, which will be covered in the next video.
I hope you find this information helpful, and I look forward to seeing you in the next part of the series.
How to Download S&P 500 Stock Symbols, Filter by Sector || Stock Analysis with Python Part 2
How to Download S&P 500 Stock Symbols, Filter by Sector || Stock Analysis with Python Part 2
This is part two of my series on stock analysis with Python. If you haven't seen part one, I recommend checking it out. In the previous video, we downloaded data from a specific stock exchange and obtained a DataFrame with metadata. Now, we want to filter out symbols based on their security type, such as common stock, ETF, or fund. This will allow us to focus on specific securities before downloading data.
I'll add a new function called "get_security_type" that takes the exchange data DataFrame as input. By default, we'll filter for common stock, but you can specify a different type if needed. The function will return a list of symbols that match the specified security type.
Additionally, I noticed that the end-of-day historical data doesn't include the S&P 500 symbols. So, I'll write another function called "get_sp500_symbols" to fetch the symbols from a CSV file. This function accepts an optional "sector" parameter to filter the symbols based on sectors. By default, it returns all symbols. The function will return a DataFrame with symbol, name, and sector columns.
To implement this, we'll use the pandas library to read the CSV file and apply the desired filters based on the parameters provided.
Once implemented, we can test the functions. By default, "get_security_type" will return all symbols, and "get_sp500_symbols" will also return all symbols. We can specify a sector to filter the S&P 500 symbols.
With these functions in place, we can now filter symbols based on security types and explore stocks from the S&P 500. In the next part of the series, we will focus on downloading and curating the data.
I hope you find this information useful, and I look forward to continuing the series with you.
How to Download and Save Stock Price Data || Stock Analysis with Python Part 3
How to Download and Save Stock Price Data || Stock Analysis with Python Part 3
This is part three of my series on using Python for stock analysis. You can find the first two videos in the link provided in the video description. All the code used in the series is available on a GitHub repository, which is also linked in the description.
In the previous videos, we learned how to obtain a list of securities on a specific exchange and how to filter them based on specific criteria. We also wrote a function to filter out the S&P 500 stocks. In this video, we will focus on downloading and organizing the data we are interested in.
To get started, we need to install a helper library called "eod" that simplifies the interaction with end-of-day data. We can use this library instead of making traditional API calls. After installing it using pip, we import the "EodHistoricalData" class from the library, which allows us to make API calls easily. Additionally, we import the "datetime" module for setting time limits and the "os" module for working with the file system.
Next, we set some default dates for the time period we want to retrieve data for. In this case, we set it to be approximately a year. We also set the current date as a reference if we need both the start and end dates.
Now, we can proceed to write the main function called "get_data." This function accepts a variety of inputs, including a single symbol, a comma-separated list of symbols, or a list of symbols. It also requires an API key and a path where the data will be stored. The function retrieves data for the specified tickers using the EodHistoricalData class and saves it as a CSV file in the specified folder. It keeps track of the number of downloaded and skipped securities and provides information about the download process.
After writing the function, we can test it by passing in some sample arguments and checking the output. We can see the downloaded securities and any skipped ones. The function successfully retrieves and saves the data in the specified folder.
In the upcoming videos, we will work with the downloaded data, such as extracting closing prices and returns, and explore visualization techniques.
Stock Analysis with Python: How to Extract Price Data from Files || Part 4
Stock Analysis with Python: How to Extract Price Data from Files || Part 4
Welcome to part four of my Python series for stock analysis. You can find links to the first three parts in the video description and also access the code on the GitHub repository.
In the previous videos, we covered obtaining a list of securities, filtering the list, and downloading data into CSV files. Now, in this video, we will focus on extracting the closing price column from the downloaded data.
To do this, we'll create a function called "get_closing_prices." The function takes a folder as input, with a default value set for the data files. By default, it extracts the close column, but you can choose the adjusted close column if desired.
First, we read all the valid files in the specified folder, excluding the file starting with "zero" to avoid duplication. Then, we set up an empty DataFrame.
Next, we loop through the files and check if the adjusted close is set to true. If it is, we create a temporary DataFrame using pandas' read_csv function, specifying the folder and file. We set the index column to be the date and select the adjusted close column. Finally, we rename the column to the ticker symbol.
If the adjusted close is not true, we follow a similar process for the close column. We replace the existing DataFrame with the temporary DataFrame for the first file and concatenate the new DataFrame onto the existing one for subsequent files.
Finally, we return the DataFrame containing the closing prices. Additionally, we write the DataFrame to a CSV file named "closes.csv" if desired.
You can test the function by calling it with the desired folder name. The function will return the DataFrame with the closing prices. In the example shown, it successfully extracted the closing price column for the specified securities.
In part five, we will calculate return data based on these closing prices.
Calculate Returns, Create Correlation Matrix, Plot Performance || Stock Analysis with Python Part 5
Calculate Returns, Create Correlation Matrix, Plot Performance || Stock Analysis with Python Part 5
Welcome to part five of my series on using Python for stock analysis. In the video description, you'll find links to the previous four parts as well as a link to the GitHub repository where you can access the code.
In part four, we obtained the closing prices for selected securities and saved them into a file. Now, in part five, we'll focus on calculating returns based on these closing prices. Before we proceed, we need to import the NumPy library.
We'll create a function called "calculate_returns" that takes a folder and a file name as input. To handle potential errors, we'll use a try-except block. Inside the function, we'll use pandas to read the data from a CSV file. We'll set the index column to the date and return the DataFrame of returns.
We can test the function by printing the result, passing the folder name and the file name. In the example shown, it successfully calculates the returns for the selected securities.
From here, there are several possible next steps. One common task is to calculate the correlations between the securities. While I won't dive into the specific implementation, you can use the result of the previous function to build a function for calculating correlations. You can explore different options, such as reading the data from a file (e.g., Excel or CSV) to enhance flexibility.
Another useful function we can write is one to plot the closing prices. For this, we need to import the matplotlib library. The function "plot_closes" takes the closes as input, which can be a CSV or Excel file. Additionally, we can choose to plot the prices relative to the starting price.
Within the function, we read the data using pandas, and based on the relative parameter, we plot the prices as they are or plot the performance relative to the starting price. We can customize the plot with options like grid lines and a horizontal line at zero (or one, depending on the desired representation).
Testing the function, we can see the resulting plot for the selected securities. By setting the relative parameter to true, we can observe the performance relative to the starting price.
In part six, we will continue working with closing prices and changes, focusing on saving that data to a separate file.