Feng Li
School of Statistics and Mathematics
Central University of Finance and Economics
The candlestick chart is a style of financial chart describing open, high, low and close for a given x coordinate (most likely time).
The boxes represent the spread between the open and close values and the lines represent the spread between the low and high values.
Sample points where the close value is higher (lower) then the open value are called increasing (decreasing). By default, increasing candles are drawn in green whereas decreasing are drawn in red.
## This allows for saving the notebook as interactive html
import plotly.io as pio
pio.renderers.default='notebook'
import pandas as pd
df = pd.read_csv('data/finance-charts-apple.csv')
df
Date | AAPL.Open | AAPL.High | AAPL.Low | AAPL.Close | AAPL.Volume | AAPL.Adjusted | dn | mavg | up | direction | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2015-02-17 | 127.489998 | 128.880005 | 126.919998 | 127.830002 | 63152400 | 122.905254 | 106.741052 | 117.927667 | 129.114281 | Increasing |
1 | 2015-02-18 | 127.629997 | 128.779999 | 127.449997 | 128.720001 | 44891700 | 123.760965 | 107.842423 | 118.940333 | 130.038244 | Increasing |
2 | 2015-02-19 | 128.479996 | 129.029999 | 128.330002 | 128.449997 | 37362400 | 123.501363 | 108.894245 | 119.889167 | 130.884089 | Decreasing |
3 | 2015-02-20 | 128.619995 | 129.500000 | 128.050003 | 129.500000 | 48948400 | 124.510914 | 109.785449 | 120.763500 | 131.741551 | Increasing |
4 | 2015-02-23 | 130.020004 | 133.000000 | 129.660004 | 133.000000 | 70974100 | 127.876074 | 110.372516 | 121.720167 | 133.067817 | Increasing |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
501 | 2017-02-10 | 132.460007 | 132.940002 | 132.050003 | 132.119995 | 20065500 | 132.119995 | 114.494004 | 124.498666 | 134.503328 | Decreasing |
502 | 2017-02-13 | 133.080002 | 133.820007 | 132.750000 | 133.289993 | 23035400 | 133.289993 | 114.820798 | 125.205166 | 135.589534 | Increasing |
503 | 2017-02-14 | 133.470001 | 135.089996 | 133.250000 | 135.020004 | 32815500 | 135.020004 | 115.175718 | 125.953499 | 136.731280 | Increasing |
504 | 2017-02-15 | 135.520004 | 136.270004 | 134.619995 | 135.509995 | 35501600 | 135.509995 | 115.545035 | 126.723499 | 137.901963 | Decreasing |
505 | 2017-02-16 | 135.669998 | 135.899994 | 134.839996 | 135.350006 | 22118000 | 135.350006 | 116.203299 | 127.504333 | 138.805366 | Decreasing |
506 rows × 11 columns
import plotly.graph_objects as go
fig = go.Figure(data=[go.Candlestick(x=df['Date'],
open=df['AAPL.Open'],
high=df['AAPL.High'],
low=df['AAPL.Low'],
close=df['AAPL.Close'])])
fig.show()