Table of Contents

Stock Charting

Step 1. Install Python, VS Code, Setup Python Virtual Environment, and Run an Example

Install Python

The easiest way (and with best shell integration) to install Python is to get it from Microsoft Store. The latest version is Python 3.12

Install VS Code

VS Code (or Visual Studio Code) is also available in Microsoft Store. VS Code is one of the best IDEs for many programming languages. It manage language specific intelligences via extensions. Please install the following two extensions for better Python programming experience:

If not installed, VS Code will prompt you to install these extensions when you start writing your first python code.

Setup Python Virtual Environment

Read this online resource:

for answers to these questions:

You don't need to read all at once.

A Simple Example

Run the following simple code (from Credits) to demonstrate a simple stock charting.

Notes: You will need to install plotly and pandas Python packages using pip. Reference to this if you don't know how.

import plotly.express as px

df = px.data.stocks()
fig = px.line(df, x='date', y=["MSFT","GOOG",'FB',"AMZN"])
fig.show()

Step 2. Learning to Use Git

Watch this Official Video to learn how to use Git in VS Code.

Note: Create a .gitignore file to exclude Python virtual environment folder.

Step 3. Data Extraction from Yahoo Finance

Try out the following simple example - getting Amazon stock price data by reading this resource.

# IMPORT THE LIBRARY
import yfinance as yf
from datetime import datetime

# CREATE TICKER INSTANCE FOR AMAZON
amzn = yf.Ticker("AMZN")

# GET TODAYS DATE AND CONVERT IT TO A STRING WITH YYYY-MM-DD FORMAT (YFINANCE EXPECTS THAT FORMAT)
end_date = datetime.now().strftime('%Y-%m-%d')
amzn_hist = amzn.history(start='2022-01-01',end=end_date)
print(amzn_hist)

Step 4. Plot Single Stock Chart

Combining Step 2 and Step 3 to plot Amazon stock price and volume over the past two years.

Step 5. More Indicators, Plot Layout

Step 6. UI for Taking Multiple Stock Symbols

Step 7. Putting All Together