My objective is to simplify and clarify economics, making it accessible to everyone. It is important to remember that the opinions expressed in my writing are solely my own and should not be considered as financial advice. Any potential losses incurred from acting upon the information provided in my writing are the responsibility of the individual, and I cannot be held liable for them.
Translate
Sunday, April 23, 2023
New Home Housing Market
The following charts display the trends of new one-family homes sold, new privately owned housing units started, homeownership, and the U.S. National Home Price Index. In recent years, there has been a decline in the number of new homes sold and new housing units started. The U.S. National Home Price Index has also started to decline. Despite these trends, homeownership rates have continued to increase, although the rates of increase have slowed down.
Python codes - import pandas_datareader.data as web
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
start = '1990-01-01'
Housing = web.DataReader(['HSN1F'], 'fred', start=start)
Diff_Housing = Housing.pct_change(periods=12) * 100
fig, axs = plt.subplots(2, 1)
axs[0].bar(Housing.index[-252*20:], Housing['HSN1F'][-252*20:],
color='blue', width=20)
axs[0].set_title('New One Family Sold')
axs[0].set_ylabel('Thousands')
axs[1].bar(Diff_Housing.index[-252*10:], Diff_Housing['HSN1F'][-252*10:],
color='blue', width=10)
axs[1].set_title('New One Family Houses Sold (HSN1F) Changes from same period in previous year')
axs[1].set_ylabel('Percent')
axs[1].set_xlabel('Year')
plt.show()
HOUST = web.DataReader(['HOUST'], 'fred', start=start)
Diff_HOUST = HOUST.pct_change(periods=12) * 100
fig, axs = plt.subplots(2, 1)
axs[0].bar(HOUST.index[-252*20:], HOUST['HOUST'][-252*20:],
color='blue', width=20)
axs[0].set_title('Housing Starts: Total: New Privately Owned Housing Units Started (HOUST)')
axs[0].set_ylabel('Thousands')
axs[1].bar(Diff_HOUST.index[-252*20:], Diff_HOUST['HOUST'][-252*20:],
color='blue', width=20)
axs[1].set_title('Housing Starts: Total: New Privately Owned Housing Units Started (HOUST)')
axs[1].set_ylabel('Percent')
axs[1].set_xlabel('Year')
plt.show()
RSAHORUSQ156S = web.DataReader(['RSAHORUSQ156S'], 'fred', start=start)
Diff_RSAHORUSQ156S = RSAHORUSQ156S.pct_change(periods=12) * 100
fig, axs = plt.subplots(2, 1)
axs[0].plot(RSAHORUSQ156S.index[-252*20:], RSAHORUSQ156S['RSAHORUSQ156S'][-252*20:])
axs[0].set_title('Homeownership Rate for the United States (RSAHORUSQ156S)')
axs[0].set_ylabel('Percent')
axs[1].bar(Diff_RSAHORUSQ156S.index[-252*20:], Diff_RSAHORUSQ156S['RSAHORUSQ156S'][-252*20:],
color='blue', width=20)
axs[1].set_title('Homeownership Rate for the United States (RSAHORUSQ156S)')
axs[1].set_ylabel('Percent')
axs[1].set_xlabel('Year')
plt.show()
CSUSHPINSA = web.DataReader(['CSUSHPINSA'], 'fred', start=start)
Diff_CSUSHPINSA = CSUSHPINSA.pct_change(periods=12) * 100
fig, axs = plt.subplots(2, 1)
# plot the time series data
axs[0].plot(CSUSHPINSA.index[-252*20:], CSUSHPINSA['CSUSHPINSA'][-252*20:])
axs[0].set_title('U.S. National Home Price Index (CSUSHPINSA)')
axs[0].set_ylabel('Index Value')
# plot the annual percentage change
axs[1].bar(Diff_CSUSHPINSA.index[-252*20:], Diff_CSUSHPINSA['CSUSHPINSA'][-252*20:],
color='blue', width=20)
axs[1].set_title('Annual Percent Change in U.S. National Home Price Index (CSUSHPINSA)')
axs[1].set_ylabel('Percent')
axs[1].set_xlabel('Year')
# show the plot
plt.show()
Saturday, April 22, 2023
China GDP (1960-2020 )
China's nominal GDP has experienced an average growth rate of approximately 10%
since 1960. Remarkably, the country has not experienced a recession since 1990.
However, given the recent slowdown in China's GDP growth rates since the
mid-2010s, it remains to be seen whether China can continue to sustain its
growth without experiencing a recession.
Friday, April 21, 2023
Assets and Liabilities of Commercial Banks in the United States - H.8 as of March 2023
The Federal Reserve's statistical release "H.8 - Assets and Liabilities of Commercial Banks in the United States", which provides data on the assets and liabilities of commercial banks in the US. The release provides data on a weekly basis, and includes information such as total assets and liabilities, loans and leases, and deposits. The data is broken down into various categories, such as type of loan, size of deposit, and type of security. The release is important for understanding trends in the banking industry and can be used by policymakers and researchers to monitor the health of the financial system.
The report on the Assets and Liabilities of Commercial Banks in the United States for March 2023 shows a positive trend with a 6.5% increase in total assets and a 3.1% increase in total liabilities. Among the assets, loans to commercial banks saw a significant surge of 345.5%. However, treasury and agency securities experienced a dip of 24.1% in March. On the liabilities side, borrowing showed a substantial rise of 249.8%, whereas other deposits witnessed a decrease of 28.3%. These figures highlight the dynamic nature of the banking sector and provide valuable insights into the trends that are shaping it.
According to the latest report on the Assets and Liabilities of Commercial Banks in the United States - H.8, as of March 2023, real estate loans, including residential and commercial ones, experienced an increase, although the overall trend has been declining since the second quarter of 2022."
Percent change at break adjusted, seasonally adjusted, annual rate.
Source: https://www.federalreserve.gov/releases/h8/current/default.htm
Friday, February 24, 2023
Tuesday, February 21, 2023
Allocation of Investments by Country as of 02/2023
library(quantmod)
library(PortfolioAnalytics)
# Define the portfolio symbols
symbols <- c(
"EWJ", #iShares Japan
"EWG", #iShares Germany
"EWU", #iShares UK
"EWC", #iShares Canada
"EWY", #iShares South Korea
"EWA", #iShares Australia
"EWH", #iShares Hong Kong
"EWS", #iShares Singapore
"EWT", #iShares Taiwan
"EWZ", #iShares Brazil
"EFA", #iShares EAFE
"ERUS", #iShares Russia
"EZA", #iShares South Africa
"EPP", #iShares Pacific Ex Japan
"FXI" ,#iShare China Large-Cap
"SPY" #US
)
# Fetch the closing prices
#prices <- data.frame(lapply(symbols, function(sym) Ad(getSymbols(sym, auto.assign = FALSE))))
prices <- data.frame(Date = as.Date("1970-01-01"))
for (sym in symbols) {
sym_data <- data.frame(Date = index(getSymbols(sym, auto.assign = FALSE)),
Ad(getSymbols(sym, auto.assign = FALSE)))
colnames(sym_data)[-1] <- sym
prices <- merge(prices, sym_data, by = "Date", all = TRUE)
}
# Define the portfolio
portfolio <- portfolio.spec(assets = symbols)
# Add constraints
portfolio <- add.constraint(portfolio, type = "weight_sum", min_sum = 0.95, max_sum = 1.05)
portfolio <- add.constraint(portfolio, type = "box", min = 0.01, max = 0.5)
# Define the optimization objective
portfolio <- add.objective(portfolio, type = "risk", name = "var", arguments = list(p = 0.95))
library(xts)
# Set the date column as row names
rownames(prices) <- prices$Date
prices$Date <- NULL
# Convert to a time series object
prices_xts <- xts(prices, order.by = as.Date(rownames(prices)))
names(prices_xts) <-c("Japan","Germany","UK","Canada","South Korea","Australia","Hong Kong",
"Singapore","Taiwan","Brazil","EAFE","Russia","South Africa","Pacific Ex Japan",
"China","U.S.")
tail(prices_xts)
# Run the portfolio optimization
opt_portfolio <- optimize.portfolio(prices_xts, portfolio)
# Optimize the portfolio
#opt_portfolio <- optimize.portfolio(prices, portfolio)
# Display the optimized weights
print(opt_portfolio$weights)
opt_portfolio
#Create a vector of values for the pie chart
values <- c(opt_portfolio$weights)
#Create a vector of labels for the pie chart
labels <- c("Japan", "Germany", "UK", "Canada", "South Korea", "Australia", "Hong Kong", "Singapore", "Taiwan", "Brazil", "EAFE", "Russia", "South Africa", "Pacific Ex Japan", "China", "U.S.")
#Create the pie chart
pie(values, labels = labels)
#Add a title to the pie chart
title("Allocation of Investments by Country")
percent <- paste0(round(values * 100, 1), "%")
legend("topleft", legend = paste(labels, percent, sep = " - "), cex = 0.8, fill = rainbow(length(values)))
Saturday, February 18, 2023
CPI by Expenditure Category, January 2023
As of January 2023, the Consumer Price Index (CPI) is a measure of inflation that is used to track changes in the price of a basket of goods and services purchased by households in the United States. It provides valuable insight into the overall cost of living for Americans and is an important economic indicator used by policymakers and businesses alike.
According to the latest data released by the Bureau of Labor Statistics, the CPI increased by 0.5% in January 2023, which is the same increase as in December 2022. Over the past 12 months, the CPI has risen by 6.2%, which is the largest year-over-year increase in over 40 years. This substantial increase is primarily due to rising prices for energy, food, and shelter, which account for a significant portion of the CPI basket.
In January 2023, energy prices rose by 2.4%, which was driven by increases in the cost of both gasoline and natural gas. Food prices also increased by 0.6%, with notable increases in the prices of beef and poultry products. Additionally, the cost of shelter increased by 0.3%, with rising prices for both rent and home ownership.
Despite the overall increase in the CPI, there were some categories of goods and services that experienced price declines in January 2023. For example, the cost of clothing and transportation services both decreased by 0.2%, while the price of medical care services remained unchanged.
Overall, the January 2023 CPI data suggests that inflation continues to be a significant concern for American households and businesses. While the Federal Reserve has implemented measures to address inflation, including raising interest rates, it remains to be seen whether these actions will be enough to curb rising prices in the long term.
Source: BLS
R code to generate the graph
df<- data.frame((MON_CPI["2023-01-01"]))
df
df1 <- data.frame(
category = c("Food & Beverage", "Housing", "Apparel", "Transportation",
"Medical Care", "Recreation", "Education", "Other Goods & Services",
"Commodities", "Services", "All items", "Core items"),
value = c(df$Food...Beverage,df$Housing,df$Apparel, df$Transporation,
df$Medical.Care, df$Recreation, df$Education, df$Other.Goods...Services,
df$Commodities,df$Services,df$All.items,df$Core.items),
date = as.Date("2023-01-01")
)
df1
library(ggplot2)
ggplot(df1, aes(x = category, y = value, fill = category)) +
geom_col() +
labs(x = NULL, y = "Change (%)", fill = NULL,
title = "Consumer Price Index by Expenditure Category, January 2023") +
theme_minimal()
Subscribe to:
Posts (Atom)