Stock Exchange Visualizations

in Python


August 25, 2022

Philippe Lambot

In a Snapshot

  • In this project, I will focus on interactive stock quote visualizations in Python. Data have been extracted from Yahoo! Finance . They relate to the stocks of eight financial institutions over the period starting in 2000.
  • TAGS: stock exchange quotes, interactive visualizations, Python, Bollinger Band® charts, candlestick charts, line charts, highest/lowest prices and returns, return scatter matrices, return correlation matrices

Financial Institutions

When choosing eight financial institutions, special attention has been paid to international diversity. These eight financial institutions originate from China, France, Germany, Japan, the Netherlands, the United Kingdom, or the United States. They have been picked up using Yahoo! Finance and LexisNexis. The eight financial institutions are listed below with their names and ticker symbols.

Out[40]:
Name of Financial Institution Ticker Symbol
Bank of China Limited BACHY
Barclays PLC BCS
BNP Paribas SA BNPQY
Citigroup Inc. C
Deutsche Bank Aktiengesellschaft DB
ING Groep N.V. ING
JP Morgan Chase & Co. JPM
Mitsubishi UFG Financial Group, Inc. MUFG

Stock exchange information used in this project consists of stock quote prices: open, high, low, and close. They have been retrieved from Yahoo! Finance. They cover the period from 2000 until August 25, 2022. Three institutions have partial data: MUFG's data start on April 2, 2001, BNPQY's on June 5, 2003, and BACHY's on December 29, 2009. Stock quotes originate from the NYSE except for BACHY and BNPQY (OTC). All stock quotes are denominated in US$.

Closing Price Line Charts

Line Charts

All Institutions

Let's draw a closing price line chart for the eight financial institutions together.

The y-axis scale is determined by the sharp drop of Citigroup's stock price. Consequently, let's split the group of eight financial institutions into three subgroups in accordance with the range of closing price variation over the whole period since 2000. In the first subgroup, we'll keep just Citigroup, in the second subgroup, BCS, BNPQY, DB, ING, JPM, and in the third subgroup, BACHY and MUFG.

Citigroup

Let's start with Citigroup on its own.

BCS-BNP-DB-ING-JPM

Let's draw line charts for these five financial institutions. Each institution will be presented separately but all will have the same y-axis scale with a view to fostering comparability.

BACHY-MUFG

And now, let's draw closing price line charts for both financial institutions with the smallest range of closing price fluctuation in absolute value: BACHY and MUFG.

Extreme Prices

The line charts above have displayed all closing prices. Let's pinpoint here the extreme closing prices throughout the whole period for the eight financial institutions.

Highest Prices

What is the highest closing price for each financial institution's stock over the whole period?

Out[46]:
Ticker Symbol Highest Closing Price
BACHY 17.990000
BCS 57.566818
BNPQY 63.900002
C 588.750000
DB 152.280533
ING 47.180000
JPM 171.779999
MUFG 16.680000

Lowest Prices

Out[47]:
Ticker Symbol Lowest Closing Price
BACHY 7.200000
BCS 2.829493
BNPQY 13.280000
C 10.200000
DB 5.480000
ING 3.030000
JPM 15.450000
MUFG 3.020000

Candlestick Charts

Fundamentals

JPM Candlestick Chart

BACHY Candlestick Chart

BACHY is displayed on the same period as JPM.

Bollinger Bands®

In this section, we'll use data about closing prices, "high" prices, and "low" prices, on a daily basis. These data will be used to build up Bollinger Bands®.

Fundamentals

  • The simple moving average is typically a 20-day simple moving average of the typical price, that is to say the mean of high price, low price, and closing price of a stock on a daily basis, which will be done in this presentation. It could also be the 20-day simple moving average of the closing price itself. The upper band is typically two standard deviations of the typical price above the middle band. The lower band is typically two standard deviations below the middle band. A candlestick graph can be inserted.

Bollinger for BNP

Let's draw Bollinger Bands® for BNPQY's stock since June 2022. BNP Paribas SA is the biggest bank in Europe on the basis of assets as of the end of 2020, as shown by InsiderIntelligence. On July 29, 2022, Reuters reported that "BNP Paribas thrived in Q2, shares jump [...] French bank BNP Paribas reported better than expected profit in the second quarter [...]"

Bollinger for DB

Bollinger for ING

Returns

Current Definition

  • In this working paper, stock returns will be computed on closing prices as the percentual change from day to day. Computation in percent ensures better comparability between financial institutions.

Extreme Returns

Worst Returns

Out[54]:
Ticker Symbol Date of Closing Price Deepest Drop in %
BACHY 2011-08-08
BCS 2009-01-20
BNPQY 2009-01-20
C 2009-02-27
DB 2009-01-20
ING 2008-10-17
JPM 2009-01-20
MUFG 2008-10-27

The worst closing price drop was on January 20, 2019 for four financial institutions out of the eight that have been picked up for this working paper; JPM is among them. January 20, 2019 was Inauguration Day. Let's quantify the drop for these four institutions.

Out[55]:
Ticker Symbol Closing Price Drop in % on January 20, 2009
BCS -42.620697
BNPQY -24.455203
DB -18.940550
JPM -20.727430

Best Returns

Out[56]:
Ticker Symbol Date of Strongest Closing Price Increase in %
BACHY 2011-08-11
BCS 2009-01-26
BNPQY 2009-03-10
C 2008-11-24
DB 2008-11-24
ING 2010-05-10
JPM 2009-01-21
MUFG 2003-10-01

JPM's closing price had lost almost 21% on January 20, 2009. But its strongest percentual increase happened one day later, on January 21, 2009, and it almost completely erased the drop on January 20. This can be clearly visualized on Macrotrends.

Scatter Plot Matrix

With a view to retrieving some visual evidence from relationships between the eight return time series of the eight financial institutions, let's draw a scatter plot matrix, which is comprised of 56 bilateral scatter plots. For readability purposes, the period has been limited to July and August 2022. Also for readability purposes, the graphs on the diagonal, which could have been histograms, have been removed.

  • On the first row of graphs, most point clouds are rather flat. This might indicate rather limited correlation coefficients between BACHY and most other institutions.
  • On the basis of the graph above, a relatively high positive correlation could be expected between ING and DB because most points are in the first quadrant ‒ where both institutions have positive returns ‒ and in the third quadrant ‒ where both institutions have negatives returns.
  • In most cases, the scatter plots above do not give clear visual indication about correlation because most points are amalgamated and density does not show clearly. Consequently, let's switch to correlation matrices, first over the same period, namely July-August 2022, and then over a much longer period.

Correlation Matrices

July-August 2022

  • As expected from the first row of scatter plots above, the correlation coefficients between BACHY and the other institutions are rather limited in value.
  • As expected as well from the scatter plots between ING and DB, the correlation coefficient between the two institutions is positive and rather important. It is even one of the highest coefficients with a value of +0.8.
  • All correlation coefficients are strictly positive.

2010-2022

The picture is completely different if we broaden the period by starting in 2010.

When comparing the correlation matrix for the period 2010-2022 and the correlation matrix for July-August 2022, many statements can be made. Let's express a few ones:

  • there is only tiny variation among the correlation coefficients of BACHY with the other institutions; the same holds for MUFG, with the exception of its correlation coefficient with ... BACHY;
  • all correlation coefficients are strictly positive;
  • BACHY has the lowest correlation coefficients and MUFG comes next ‒ which gives that visual impression of a darker rectangle surrounded by lighter hues;
  • outside of BACHY and MUFG, all correlation coefficients are between +0.7 and +0.9, the value +0.9 relating to Citigroup and JPM.
*       *
*