Machine reading IMF data with Python: an example

UPDATE June 16, 2016: The IMF API has changed. My updated tutorial is here:

https://briandew.wordpress.com/2016/05/01/machine-reading-imf-data-data-retrieval-with-python/


Download PDF Example – Machine Reading IMF Data with Python

During the past 18 months, the International Monetary Fund has made all of its data available free-of-charge, and developed an API to allow access to data. This means data from sources such as International Financial Statistics (IFS) can be collected without the need for manual download.

I’ve written a crude example using Python. The example retrieves IMF Direction of Trade Statistics to show the declining U.S. share of world exports and the rapid rise of China’s export-led economy.

imf_api-Copy1_26_0

If you are getting started with Python for economic research, I recommend the free version of the Enthought Canopy deployment, which integrates several useful tools.

Dashboard update: recent economic data

Macro and Markets Dashboard: United States (March 19, 2016 — PDF)

As expected, the Fed left key interest rates unchanged. New economic data covering prices, industrial production, jobless claims, and inventories did not offer any dramatic surprises. Equity markets were up on the week, while treasury bond yields fell. The dollar weakened against nearly all major currencies.

Markets reacted positively to the Fed’s key interest rate decision and reduction of their forecast for 2016 rate hikes to two from four. The Nasdaq composite index increased one percent on the week, while the S&P 500 climbed 1.35 percent. Ten-year treasury bond yields fell to 1.88 percent on Friday.

Monthly CPI figures for February showed a year over year consumer price level increase of one percent, compared with a 1.3 percent increase in January. Energy and transportation costs fell more in February than January. Energy costs dropped 12.7 percent over their February 2015 level, while transportation costs fell 3.6 percent over the one-year period.  Healthcare, food, housing, and apparel prices all increased over the previous year’s level. Healthcare costs were up 3.5 percent.

cpi_mar192016

The industrial production index and total capacity utilization figures were both down slightly in February, following a modest increase in January.

iptcu_mar192016

New weekly jobless claims, at 265,000, showed no sudden increase, further supporting the so far solid labor market data. January data on manufacturing and trade inventories and sales, from the U.S. Census Bureau, showed that sales were down 1.1 percent over their January 2015 level, while inventories were up 1.8 percent over the same period, pushing the inventories to sales ratio to 1.4.

jobinv_mar192016

Over the past week, the U.S. dollar weakened against all major currencies except for the Egyptian pound, which was devalued by 14 percent against the dollar during the week. The dollar fell roughly two percent or a bit more against the Euro, Yen, and Canadian Dollar, and nearly a percent and a half against Pound Sterling and Swiss Francs. The dollar fell against the Yuan by nearly three quarters of a percent on Friday.

fx_mar192016

 

 

Dashboard update: expectations and central bank signaling

Macro and Markets Dashboard: United States (March 12, 2016 — PDF)

Friday’s bull market led equity and commodity prices to their third consecutive weekly increase. Market volatility has continued to return to more comfortable levels. Investors views on the current macroeconomic environment and expectations about the future are important determinants of market behavior. While the global macroeconomic picture still includes low growth, I worry that unorthodox monetary policy may have its effectiveness counteracted by the signals it sends.

Oil prices, as measured by front-month contracts of West Texas Intermediate crude oil, increased nearly six percent during the week (see below). The S&P 500 and Dow Jones Industrial Average increased by more than a percentage point during the week, while the Nasdaq Composite Index was up two-thirds of a percent.

wti_mar0122016

The CBOE Volatility Index (VIX) fell to its lowest level of the year on Friday, closing at 16.5. Possibly supporting the relative calm in markets, the week offered very little new domestic macroeconomic data. Next week should provide more food for investor thought.

vix_mar0122016

A quiet week for domestic data provides opportunity for reviewing the global picture. The IMF forecasts global growth to remain weak but gradually improve. Emerging markets, including China, continue to experience relatively slower growth and lower demand. Commodity exporters continue to be hurt by the collapse in prices. Global trade has slowed, and some economists have asked whether we have reached the end of globalization.

The European Central Bank (ECB) expanded quantitative easing and cut all interest rates during their meeting this week. Other central banks in the region will likely follow the ECB further into negative interest rate territory. I worry that negative interest rates and other unorthodox monetary policy are not as effective as anticipated. What Keynes termed “animal spirits” plays a role in explaining why the continued lowering of borrowing rates may not lead to more lending.

Negative interest rates send a mixed message. A bank is simultaneously being enticed to lend by the low cost of money while being told that the economy is in unprecedentedly bad shape. Near to zero, the actual effect of small changes to the interest rate can be overpowered by the message that is sent by the direction of movement. When central banks tighten from zero, as the Fed did in December, it signals that monetary policy is moving away from uncharted waters and that the economy is improving. A tightening central bank adds basis points to its arsenal for handling future crises. When central banks such as the ECB and Bank of Japan (BOJ) loosen monetary policy further, they move farther into a territory which scares investors and lenders and constrains their future movement.

In the U.S., labor market tightening, wage growth, core inflation, and signs of modest economic growth push the Fed towards another quarter point rate hike. Most economists, however, do not expect a rate increase from the Fed during its meeting next week. Despite other concerns, such as the weak global picture and the continued strength of the dollar, the animal within me would like to see a Fed funds rate increase in one of the next two meetings.

 

Dashboard update: data marches forward

Macro and Markets Dashboard: United States (March 5, 2016 — PDF)

This week brought more strong labor market data and more relief for commodity markets. Equity markets were also up on the week, while treasury and high-grade bond yields remain low. Decomposition of broad equity market growth shows that investors are still risk-off. Value stocks have climbed while riskier investments still seem reasonably priced, providing additional evidence that risk aversion persists.

February jobs data showed continued tightening of U.S. labor markets. The unemployment rate remains 4.9 percent while the labor force participation rate increased by two tenths of a percent to 62.9, a one-year high.

CIVPART_mar052016

The S&P 500 closed on Friday at 1999.99, as if priced by a nineties consumer psychologist. The index climbed 2.7 percent during the week. A crude decomposition shows value opportunities favored over growth opportunities so far in 2016. Year-to-date, the S&P 500 Growth ETF is down 3.03 percent, while the S&P 500 Value ETF is down only 0.37 percent.

SP500_mar052016

Meanwhile, treasury bond yields remain very low. The real yield curve rate on a five year U.S. treasury bond was negative on Thursday, at -0.03%, and closed Friday at 0.02%. People are willing to sacrifice returns for the relative safety of government debt. Japan issued new ten year bonds with a negative yield for the first time this week. Investors clearly do expect the markets to adjust so that these safe assets provide some future positive yield, but are willing to pay the government of Japan for short-term security.

FiveYrReal_mar052016

While equity and commodity markets have become gradually less volatile over the past two weeks, foreign exchange markets continue to move in all directions, reflecting both stories–commodities relief and risk aversion. I’ve pasted below the full table from my dashboard. Over the past week, the dollar returned some of the previous week’s gains against the pound, but continued to strengthen against the euro and yen. Notably, the Brazilian real strengthened four percent against the dollar during the past week.

EXR_mar052016