From Setup to Strategy: Creating Your Python Trading Bot

Опубликовано: 05 Октябрь 2024
на канале: OnePageCode
260
11

Download the source code from here:
https://onepagecode.substack.com/

Unlock the potential of automated trading with our detailed tutorial 'From Setup to Strategy: Creating Your Python Trading Bot'. This video walks you through every step needed to build your own trading bot using Python, from installing essential libraries to implementing the Opening Range Breakout (ORB) strategy. Dive into setting up APIs, processing stock data, calculating key financial metrics, and visualizing trading results. Perfect for both beginners and seasoned traders looking to enhance their programming and trading skills. Start automating your trades with precision today!

00:00:00 Install Python packages for analysis
00:00:53 Install python-docx package using pip
00:01:21 Install or update Kaleido package
00:01:47 Imports necessary libraries for project
00:03:17 Set up Plotly for Google Colab
00:04:16 Retrieve current risk-free interest rate
00:05:27 Sets credentials and stock data parameters
00:06:24 Posts credentials to ZeroDha for login and sets access token for KiteConnect API
00:07:17 Sets up authentication and fetches token
00:07:57 Creates a list of dates
00:09:00 Function to get historical data
00:10:08 Retrieve stock data for specified dates and instruments
00:10:50 Extract year and day from date
00:11:32 Renames column 'date' to 'datetime'
00:12:09 Displays first few rows of data
00:12:58 Calculate profit percentage based on stock trading
00:14:18 Prints total return percentage of ORB
00:15:15 Analyzes data by year using ORB
00:16:15 Generates yearly analysis for stock data
00:17:01 Function: Create report for each weekday
00:18:03 Prints the day of the week
00:18:49 Calls a function to analyze stocks dataset
00:19:39 Calculates profit based on daily data
00:20:51 Analyzes yearly profits by week
00:22:03 Calculates yearly week analysis for stocks
00:22:48 Calculates Calmar ratio for investment strategy
00:23:55 Calculates Sortino ratio for given returns
00:25:16 Calculates the maximum drawdown percentage
00:26:25 Calculates Sharpe ratio of returns
00:27:31 Calculates average drawdown percentage from prices
00:28:56 Converts values of a dictionary to a list
00:29:22 Calculates stock equity based on price movements
00:30:49 Calculates ORB2 indicator for stocks
00:31:34 Convert dictionary to DataFrame and rename columns
00:32:21 Install or update Kaleido package
00:32:53 Interactive plot of performance data
00:33:30 Creates a line plot and saves
00:34:34 Converts values from a dataframe
00:35:13 Converts dictionary values to list
00:35:51 Flattens a list of lists
00:36:30 Calculates and prints performance ratios
00:37:46 Performs daily analysis on stock data
00:38:29 Prints the daily report
00:39:12 Print yearly, weekly, and daily ORB strategy analysis
00:40:19 Replaces colon with underscore in instrument
00:40:49 Calculates various financial ratios and factors
00:41:52 Prints items in a dictionary
00:42:17 Installs the WeasyPrint Python package
00:42:44 Code creates a trading strategy document
00:43:51 Installs reportlab library using pip
00:44:28 Generate a PDF on trading strategy
00:45:26 Calculate profits from trading using Opening Range Breakout strategy
00:46:29 Display first 75 rows of dataframe
00:47:01 Interactive plot of exit time vs profit
00:47:44 Get all weekday dates in range
00:48:39 Obtains daily trading data for a given time period
00:49:52 Retrieve full data for specified parameters
00:50:44 Prints information about the full dataset