What is financial trading

Financial Trading in Python

Chelsea Yang

Data Science Instructor

The concept of financial trading

Financial trading is the buying and selling of financial assets

Various financial instruments to trade:

  • Equities
  • Bonds
  • Forex
  • Commodities
  • Cryptocurrencies
Financial Trading in Python

Why people trade

To make a profit by taking calculated risks

  • Long positions: profit from upward price movement
  • Short positions: profit from downward price movement

 

Market participants:

  • Institutional traders
  • Retail traders
Financial Trading in Python

Trading vs. investing

Trading:
  • Shorter holding period
  • Focus on short-term trends or price fluctuations
  • Take both long and short positions
Investing:
  • Longer holding period
  • Focus on market fundamentals
  • Take mostly long positions
Financial Trading in Python

Financial time series data

Time series data: a sequence of data points indexed in time order

import pandas as pd
# Load the data
bitcoin_data = pd.read_csv("bitcoin_data.csv", index_col='Date', parse_dates=True)
print(bitcoin_data.head())
               Open     High      Low    Close      Volume
Date                                                      
2019-01-01  3746.71  3850.91  3707.23  3843.52  4324200990
2019-01-02  3849.22  3947.98  3817.41  3943.41  5244856835
2019-01-03  3931.05  3935.69  3826.22  3836.74  4530215218
2019-01-04  3832.04  3865.93  3783.85  3857.72  4847965467
2019-01-05  3851.97  3904.90  3836.90  3845.19  5137609823
Financial Trading in Python

Plot line chart of time series data

import matplotlib.pyplot as plt
plt.plot(bitcoin_data['Close'], color='red')
plt.title("Daily close price")
plt.show()

An example of a line plot of stock close price

Financial Trading in Python

Candlestick chart

Candlestick: On the left: a green, bullish candlestick and on the right: a red, bearish candlestick.

  • Each candlestick displays high, low, open, and close

  • The color indicates bullish (rising prices) or bearish (falling prices) movement

Financial Trading in Python

Plot candlestick chart with Python

import plotly.graph_objects as go

# Define the candlestick candlestick = go.Candlestick( x = bitcoin_data.index, open = bitcoin_data['Open'], high = bitcoin_data['High'], low = bitcoin_data['Low'], close = bitcoin_data['Close'])
# Create a plot fig = go.Figure(data=[candlestick])
# Show the plot fig.show()

Plot candlestick

Financial Trading in Python

Let's practice!

Financial Trading in Python

Preparing Video For Download...