Skip to content

Python script analyzes Tesla stock data, displaying candlestick chart, 3D scatter plot, & line chart (closing price, MA50, MA200). Generates buy/sell signals based on moving average crossovers.

Notifications You must be signed in to change notification settings

Mrtushar888/Tesla-Stock-Trading-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tesla Stock Market Analysis

This repository contains a Python script for analyzing and visualizing Tesla's stock price data. The purpose of this project is to gain insights into Tesla's historical stock performance and potentially identify trading opportunities using moving average crossovers.

Requirements

Pandas Plotly Matplotlib Ensure you have the required libraries installed. If not, you can install them using the following command:

pip install pandas plotly matplotlib

Getting Started

Download the Tesla stock price data CSV file and place it in the same directory as the script. The data should be in the format with columns like 'Date', 'Open', 'High', 'Low', 'Close', and 'Adj Close'.

Project Overview

This project includes the following steps:

Data Loading: The script uses the Pandas library to load the Tesla stock price data from the provided CSV file into a Pandas DataFrame.

Candlestick Chart: The script utilizes Plotly's graph_objects module to create a candlestick chart. This chart visualizes the stock's open, high, low, and close prices over time, offering insights into the stock's price fluctuations.

3D Scatter Plot: Using Plotly's express module, a 3D scatter plot is generated. This plot displays the relationship between the date, opening price, and closing price. The points are color-coded based on the high price, providing a comprehensive view of stock price trends.

Moving Averages: The script calculates the 50-day and 200-day moving averages (MA50 and MA200) of the adjusted closing price. These moving averages help to smoothen the data and identify potential trends.

Line Chart with Moving Averages: Matplotlib is used to create a line chart that visualizes the adjusted closing price along with the calculated MA50 and MA200. This chart helps in understanding the long-term trends and potential trading signals.

Buy and Sell Signals: Based on the moving average crossovers, the script generates buy and sell signals. A buy signal is triggered when the MA50 crosses above the MA200, indicating a potential uptrend. A sell signal is triggered when the MA200 crosses above the MA50, suggesting a potential downtrend.

Visualization of Trading Signals: The script marks the buy signals with green triangles (^) and the sell signals with red inverted triangles (v) on the line chart. This visualization aids in identifying trading opportunities.

File Description

tesla_stock_analysis.ipynb: The main Python script containing the analysis and visualization code. Tesla Stock Price (2010 to 2023).csv: The CSV file containing Tesla's historical stock price data.

Results and Interpretations

The script generates various visualizations, providing insights into Tesla's stock performance. The candlestick chart displays daily price movements, while the 3D scatter plot shows the relationship between opening and closing prices with the color-coded high price. The line chart with moving averages helps identify long-term trends and potential crossovers.

The buy and sell signals are crucial for trading decisions. When the green triangles appear, it may be a favorable time to buy, while red inverted triangles indicate a potential selling opportunity.

Please note that this analysis is for educational and informational purposes only. It does not constitute financial advice, and trading decisions should be made based on thorough research and analysis.

About

Python script analyzes Tesla stock data, displaying candlestick chart, 3D scatter plot, & line chart (closing price, MA50, MA200). Generates buy/sell signals based on moving average crossovers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published