Oil Market Analysis as of March 14, 2017

The following chart displays the historical oil prices and the prices of oil declined by 10% recently.

Rplot04

The late drop in the oil price was little too much and it is believed to rebound soon.

Rplot01

However, the forecasting model projects that the oil prices will increase gradually for next 12 month.

 

Rplot07

The following chart displays the historical oil import by U.S. and the import has been increasing again.

Rplot02

The following chart shows the oil export by U.S. and it has been significantly increasing lately.

Rplot03

 

The following chart displays the net export (Export -Import) of petroleum for U.S. the next export was decreasing, but it begins to increase again due to improvement in U.S. economy.

Rplot05

The following R codes produces the charts above:
library(Quandl)
library(ggplot2)
library(forecast)
library(‘quantmod’)

mydata1=Quandl(“EIA/PET_MCRIMUS1_M”)
mydata2=Quandl(“EIA/PET_MCREXUS1_M”)

oil_price=Quandl(“OPEC/ORB”)

oil=Quandl(“OPEC/ORB”, api_key=”ucUWoKV_gnNZAgY8AQvL”, type=’xts’)

# Quantmod for oil
chartSeries(oil, subset=’last 12 months’)
addMACD()
addBBands()
addCCI()
names(mydata1)[2]<-“Import”
names(mydata2)[2]<-“Export”
names(oil_price)[2]<-“oil_price”

Mergedata<-merge(mydata1, mydata2)

summary(Mergedata)
head(Mergedata)
tail(Mergedata)

Mergedata$netexport<-Mergedata$Export-Mergedata$Import

head(Mergedata)

ggplot(Mergedata,aes(x=Date))+geom_line(aes(y=Import, Color=”Import”))+
geom_line(aes(y=Export, color=”Export”))

ggplot(Mergedata,aes(x=Date))+geom_line(aes(y=Import, Color=”blue”))
ggplot(Mergedata,aes(x=Date))+geom_line(aes(y=Export, Color=”blue”))
ggplot(oil_price,aes(x=Date))+geom_line(aes(y=oil_price, Color=”blue”))
ggplot(Mergedata,aes(x=Date))+geom_line(aes(y=netexport, Color=”blue”))
fit <- arima(oil_price, order=c(2, 0, 1))

fit

summary(oil_price)

Diff365
# predictive accuracy
library(forecast)
accuracy(fit)

# predict next 5 observations
library(forecast)

forecast(fit, 365)

plot(forecast(fit,365))

 

Baltic Dry Index – with R

Baltic Dry Index. Source: Lloyd’s List. The Baltic Dry Index (BDI) is a measure of the price of shipping major raw materials such as metals, grains, and fossil fuels by sea. It is created by the London Baltic Exchange based on daily assessments from a panel of shipbrokers. The BDI is a composite of 3 sub-indices, each covering a different carrier size: Capesize, Panamax, and Supramax. Capesize carriers are the largest ships with a capacity greater than 150,000 DWT. Panamax refers to the maximum size allowed for ships traveling through the Panama Canal, typically 65,000 – 80,000 DWT. The Supramax Index covers carriers with a capacity of 50,000 – 60,000 DWT.

Source: http://www.lloydslist.com/ll/sector/markets/market-data.htm

The following R codes would generate the following charts:
library(Quandl)
library(ggplot2)
library(forecast)
library(‘quantmod’)
Baltic_Index=Quandl(“LLOYDS/BDI”, type=”xts”)

plot(Baltic_Index)

Rplot01

 

 

 

chartSeries(Baltic_Index, subset=’last 12 months’)
addMACD()
addBBands()

Baltic Index in last 12 months – Baltic Index is rising.

Rplot

 

Diff365<-Delt(Baltic_Index, k=365)*100

plot(Diff365)

The following chart shows the changes from previous year (365 days ago)

Rplot03

 

fit <- arima(Baltic_Index, order=c(2, 0, 1))

 

# predictive accuracy
library(forecast)
accuracy(fit)

# predict next 5 observations
library(forecast)
forecast(fit, 365)
plot(forecast(fit, 360))

The following chart shows the projection for next 365 days with ARIMA (2,0,1) model

Rplot02

Pulling data from Quandl with R

The following R codes would pull the U.S. Treasury yields from Quandl and make the chart below.

#Treasury Yield

Treasury=Quandl(“USTREASURY/REALYIELD”)

ggplot(Treasury,aes(x=Date))+geom_line(aes(y=Treasury$`5 YR`, Color=”5 Year”)) +

geom_line(aes(y=Treasury$`10 YR`, color=”10 Year”))+
geom_line(aes(y=Treasury$`20 YR`, color=”20 Year”))

Rplot01

Source: https://www.quandl.com/