Platinum and palladium Quandl Python data

In a previous post I demonstrated how one can query automotive data via Quandl directly from within a Python script.

In this post I will document how to query platinum and palladium exchange prices from Quandl in Python. The data has been verified by London Palladium and Platinum market (http://www.lppm.com).

In the code below I retrieve a data set with platinum prices from Quandl
import quandl
# setting up API key
quandl.ApiConfig.api_key = "your key here"
import numpy
import pandas
# retrieving data from quandl in numpy format, then converting into pandas DataFrame
data = pandas.DataFrame(quandl.get('LPPM/PLAT', returns="numpy"))

The data set obtained includes daily opening and closing prices from metal exchange markets around the world. We can take a look at the header of the data frame obtained:

data.head()
DateUSD AMEUR AMGBP AMUSD PMEUR PMGBP PM
01990-04-02471.00NaN289.65470.50NaNNaN
11990-04-03475.80NaN291.35477.25NaNNaN
21990-04-04475.70NaN289.95476.75NaNNaN
31990-04-05481.75NaN292.60481.85NaNNaN
41990-04-06481.00NaN293.10480.25NaNNaN

As can be seen the daily opening and closing prices are noted in USD, EUR, and GBP. Some of the columns are empty, however. Let us see if this is only the case for early entries by also checking the tail of the data frame retrieved:

data.tail()
DateUSD AMEUR AMGBP AMUSD PMEUR PMGBP PM
75742020-03-30721.0650.43581.45726.0658.80585.25
75752020-03-31723.0657.87586.61727.0662.72586.53
75762020-04-01723.0660.27585.19714.0653.25576.04
75772020-04-02727.0665.75585.35727.0668.20585.82
75782020-04-03719.0666.05584.55714.0662.34582.62

For revent days prices were listed for all currencies. Since opening and closing prices were listed in USD both in 1990 and in 2020 I choose to focus on prices in USD only.

In the code below I plot platinum closing price history in USD, using matplotlib
import matplotlib.pyplot as plt
plt.figure(figsize = (10,10))
plt.plot(data["Date"], data["USD PM"],color = "red")
plt.title("Daily platinum closing prices",size=26)
plt.ylabel("closing price [USD]",size = 16)
plt.xlabel("date", size = 16)
Text(0.5, 0, 'date')
In the code below I repeat above workflow for palladium price history

First, I query the data from Quandl:

data = pandas.DataFrame(quandl.get('LPPM/PALL', returns="numpy"))

Next, I review the header of the data frame:

data.head()
DateUSD AMEUR AMGBP AMUSD PMEUR PMGBP PM
01990-04-02128.00NaN78.70127.65NaN78.55
11990-04-03128.35NaN78.60128.50NaN78.75
21990-04-04128.35NaN78.25128.00NaN77.90
31990-04-05128.40NaN78.00127.75NaN77.65
41990-04-06128.75NaN78.45128.50NaN78.40

And I review the tail of the data frame too:

data.tail()
DateUSD AMEUR AMGBP AMUSD PMEUR PMGBP PM
75742020-03-302236.02017.141803.232242.02034.481807.34
75752020-03-312317.02108.281879.922307.02103.011861.23
75762020-04-012314.02113.241872.932236.02045.751803.95
75772020-04-022288.02095.241842.192123.01951.291710.72
75782020-04-032234.02069.481816.262140.01985.161746.23

Again, I choose to focus on closing prices in USD. I plot the price history below, using matplotlib in Python:

plt.figure(figsize = (10,10))
plt.plot(data["Date"], data["USD PM"],color = "red")
plt.title("Daily palladium closing prices",size=26)
plt.ylabel("closing price [USD]",size = 16)
plt.xlabel("date", size = 16)
Text(0.5, 0, 'date')

You May Also Like

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.