Monday, May 27, 2019

Intro to Python for Webscraping

A friend recently reached out to me, having been asked to build a database with tens of thousands of lines of data points.

Luckily, this should be quite feasible with some of the following tools.

Let's start with getting a good installation of what one will need.

First, I highly recommend using Anaconda. It provides Python as well as most of the essential packages for data analysis. As of the day of publishing, its download page can be found here.

Next one will need a text editor. While I personally use Notepad ++ due to its simplicity (and because it was advised to be back in "Learn Python the Hard Way" and I stuck with it, another very popular one is Sublime.

For my friends problem, I believe Beautiful Soup should be more than enough to gather the data. I recall watching this tutorial a while back and finding it very intuitive and thorough. The creator starts with the assumption of no prior experience, and walks viewers from installing all the necessary software all the way through the webscraping process and explaining how beautiful soup uses HTML markups to extract data. I believe he also explains For-Loops, which will be necessary for this.

Generally I have been able to avoid scraping by always using APIs (such as the Yahoo Finance one). But sometimes tools like these are needed.

Best of luck! 

Tuesday, January 15, 2019

A Brief Collection of Econometrics / Time Series Analysis Resources

I didn't plan on posting two of these so close together, but I came across some resources I had forgotten about, and wanted to note it down here.

- How do you detect that a time series is following an ARMA process?
- Cite 5 types of automated strategies and give brief descriptions.
- Give a description of a possible strategy to be long volatility in trading only the stock.
- What kind of asset is usually modeled by a GARCH process? Give a brief description.


Analysis of Financial Time Series by Ruey Tsay

This paper spans over four-hundred pages and is meant to be a comprehensive introduction to time series analysis and different branches of analysis and forecasting which are related to it. In the introduction, Dr. Tsay states that about two chapters would be enough material for the core of an MBA course, with some brief references to other chapters (perhaps to add other intersections such as machine learning).

It is based off of his experience and work teaching these concepts since 1999 at U Chicago's Booth School of Business, and states that it is meant to provide masters students as well as senior undergraduates insight into time series analysis, and enough of an understanding to appreciate potential uses.

Introduction to Econometrics by Stock and Watson (link)

A strongly suggested introduction to the topic, which could be interchanged as a first step with Analysis of Financial Time Series. 

Econometrics by Hayashi (link

This one is criticized a bit for its focus on mathematical theory over use cases. Not that there's anything wrong with that, but for practitioners in a hurry to build this skill-set, this might not be the best starting-point. 

Mostly Harmless Econometrics by Angrist and Pischke (link)

This book has been described as backing away from the theory to discuss the bigger picture econometrics is forming. However, its explanations are brief which often mean reading a more in-depth text first is necessary if you haven't already studied time series analysis. 

New Introduction to Multiple Time Series Analysis by Lutkepohl (link)

This one was suggested as a very advanced textbook, being aimed entirely at the graduate level onward. 


Hopefully this is useful! 

Wednesday, January 9, 2019

A Brief Collection of Distressed Debt Resources

Sometimes this site is just a place for me to organize resources for future easy reference.

I sometimes peruse Reddit's /r/SecurityAnalysis (link) to see what other people are discussing, and Distressed Debt Forums came up this morning. This lead me to the following:

Reddit's Distressed Debt subreddit (decent resources) link

They have some interesting articles in their sidebar and are just active enough to be worth subscribing to.

Motley Fool - How Distressed Debt Investing Works link

This article provides a brief overview, and some different use cases (i.e. vanilla distressed debt investing versus the benefits of distressed debt over equity as an entrance to turnaround investing).

Buyside Focus - How to Value Distressed Debt - the Practical Guide to Distressed Investing link

This article was linked in the subreddit, and claims to be written by someone in JPM Special Situations in 2008. He even includes an excel model in the body of the article, and provides a great hypothetical case study.

There were also a couple books which I saw mentioned in this post. They are:

Distressed Debt Analysis by Stephen Moyer (Amazon)

Leveraged Financial Markets by William Maxwell (Amazon)

Corporate Financial Distress and Bankruptcy by Edward Altman (Amazon)

Hopefully this is of some use and worth referring back to!




Monday, January 7, 2019

All Eyes on Taiwan

Embed from Getty Images There have been a slew of interesting articles published since the start of 2019 which have indicated China's continued focus on retaking Taiwan.

The Japan Times has reported that Mr. Xi has urged the PRC's military, the People's Liberation Army or PLA, to prepare for the possibility of war.

"Xi’s warning comes amid territorial disputes in the South and East China seas and rising tensions with the United States over issues ranging from trade to Taiwan." "A military that can fight and win a war will be presented then,” the Global Times quoted Beijing-based military expert and commentator Song Zhongping as saying."

The Taiwan News highlighted that on January 2nd Mr. Xi gave an address on the 40th anniversary of the Chinese Communist Party's "Message to Compatriots in Taiwan." Mr. Xi stated, "Taiwan is so close, yet so far away." While his most recent speech continued to push, "one country, two systems," the terminology used in the reclamation of Hong Kong and Macao, he did call for specific action, with sites set on a bridge linking Taiwan's Kinmen Island and the PRC's Fujian. This would be intended to link resources such as water and electricity.

Perhaps the most insightful piece Deng Yuwen's Op piece in the South China Morning Post. I highly recommend reading the piece in full, but want to point to a few things he mentioned:

 - In Mr. Xi's report to the 19th Communist Party Congress, a new era to 2050 is laid out as the period of the "Great rejuvenation of the Chinese nation"

 - There are 14 points which define this new era, one of them referring to the reunification of Taiwan

 - In this context, Mr. Xi specifically refers to the "one country, two systems" solution

 - In December 2018, Li Kexin, who works in the Chinese embassy in Washington said:
“The day a US Navy vessel arrives in Kaohsiung is the day that our People’s Liberation Army unifies Taiwan with military force.”
While Deng Yuwen does not explicitly call upon Trump's isolationist rhetoric (instead he points to Trump's condemnation of China and Russia's focus on growing military strength from December 2017), I cannot help but wonder if there are ramifications for the PLA's timeline for engaging Taiwan.

Lastly, I find the piece particularly interesting as Deng Yuwen is a member of the Charhar Institute. This NGO, which claims its goals are "the development of international relations in a more orderly manner." It was founded by Dr. Han Fangming, who received his doctorate at Peking University and conducted post-doctoral research at Harvard. He was also a member of the National Committee of the Chinese People's Political Consultative Conference (CPPCC) for the 10th, 11th, and 12th sessions, and sits on the board of Chinese State companies such as the Sinohydro Group. In other words, the particular aims and leanings of this NGO are odd to me, in that the membership appears to be very aligned with CCP's interests, but their membership seems willing to be more critical of the PRC than one would expect from such a group. 

Sunday, December 30, 2018

NYSE Tick & the Dow's 1k Point Resurgence

(Screenshot from Investing.com)

Google recently recommended an article discussing some recent record-setting trades as measured by the NYSE Tick Index. In short, Zerohedge noted that three ticks of record-size (1631 or higher) in the course of ten minutes on December 27th (the day of the Dow's resurgence).

That week, Reuters reported the Dow having the worst week since 2008, and then reported a 1,000 point single-day surge, the first in its history.

Wells Fargo equities derivative strat Pravit Chintawongvanich was being quoted frequently for positing that the rally came from $60 bn in orders from pension funds looking to profit on the Dow's down-swing.

But back to the NYSE Tick - I had not heard of the index before, so I did some minor reading and here is simply how it works:

The NYSE Tick takes the approximately 2,800 equities listed and simply sums the number of "upticks" (stocks which had a price increase) and "downticks" (stocks which had a price decrease) in a given time interval, and then prints the sum.

Not to quote Investopedia too much, but they claim being either +1,000 or -1,000 ticks are considered extreme moves.

I think this would be a data point which would be well worth revisiting, but it's the holidays and I'm just looking to take a brief look and some notes.

Tuesday, December 4, 2018

Yield Inversion, Dow down, May loses votes, & more



A couple pieces of news over the past 48 hours:

- A number of news outlets noted that the 3 year & 5 year T-bill yields inverted on Monday morning, an occurrence which last occurred in 2007. While this is less significant than the 10 year - 2 year curve, it affected trading today.

- The Dow is reported down 800 points (about 3%) this morning and the markets are poised to close day trading each down between 3.1% - 3.8%

- British PM lost three votes in Parliament today. A vote is set to take place next Tuesday (December 12th) on the deal May reached with the EU. If the vote does not pass, the Brexit process will be taken over by Parliament.

- In related news, May is being charged as in contempt of Parliament (interfering with law makers), as she had not published the full legal advice for her Brexit deal.

- Republican thought-leaders Lindsey Graham and Bob Corker asserted that Saudi Prince MBS was certainly complicit in the murder of Khashoggi. This came as they left a briefing by the CIA. Graham went so far to say that he no longer supported arm sales to Saudi Arabia.

Sunday, December 2, 2018

US - China 90 Day Trade Ceasefire

Some notes on the 90-Day Trade Ceasefire between the US & China

(Photo Carlos Barria / Reuters)
I defer to this excellent write-up by SCMP, but have summarized a few points:

- Xi will be happy to meet Trump's demands because he knows China can find all sorts of ways to come out on-top

- It furthers a US-China power coalition in Asia which favors Chinese interests  (a la Trump's attitude over Saudi Arabia)

Other interesting points:

- Fentanyl will be viewed more strictly under PRC law, stemming its flow out of Asia (pharma interest?)

- A major semiconductor merger will be allowed

- This seems to play into Xi's interest in strengthening China's presence in Asia by taking advantage of Trump's soft understanding of foreign policy (i.e. I'd have a hard time imagining Mattis would be ok getting closer to China as they increasing look to reclaim HK and Taiwan)

I think it be worth reading further into coverage from Taiwan in the coming days. My understanding is that news coverage there is relatively split between the Democratic Progressive Party -leaning China Times and Kuomintang -leaning Liberty Times.

Further, there has been recent reporting on a new 200-page report published by the Hoover Institution covering US-China relations. I've been meaning to get to that report, and feel that it would be interesting as it would provide in-depth analysis after the 19th National Congress of the Communist Party of China aimed to remove term limits on Prime Minister Xi.