Friday, August 2, 2013

C++ Parsing Gotchas

C++ is a complicated language. Even just parsing the language is troublesome. Scott Meyer included the most vexing parse as part of his Effective STL book (Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library ). Recently, I encountered another parse issue that ultimately warranted new syntax in recent C++ revisions: the dependent type parse. The idea is simple, type names and value names (i.e., functions or variables) may overlap. That is to say, one might have a type t and a function or variable t in the same namespace. Thus, the parser has to disambiguate. This potential overlap comes up when parsing dependent type names (e.g., set<T>::iterator). Specifically, when declaring a function with a dependent type parameter such as void f(set>T<::iterator I), the compiler will complain that the keyword typename must be inserted in front of the whole dependent type name. Thus, void f(typename set>T<::iterator I) compiles.

What C++ parse gotchas have you encountered?

Thursday, July 25, 2013

Quality of Computer Science Higher-Education, Part 1

A recent discussion about H1-B quotas and tech workers on Hacker News brought up a very interesting question for me. The observation is that US companies are finding it hard to staff programming positions. Some comments suggested that higher-education is producing a lot of unqualified graduates. There was also a claim that the quality of CS education has declined substantially. Having been on three sides alluded to in this discourse, doing the hiring, teaching, and job-seeking, I thought it would be interesting to see what data we have and what we can glean from the said data.

Aside: I like to collect some data on the whole fizzbuzz phenomenon (i.e., the majority of job applicants not being able to program fizzbuzz). If you like to contribute your perspective and see the aggregate results of where the skills gap is, please consider taking my survey.

Tuesday, July 23, 2013

Munis

Over the past few months, munis have a hit hard, very hard. Even after the mild recovery since the end of June, index funds such as MUB (duration 7.17 yrs, distribution yield 2.97%) are down in excess of 7% YTD. High-yield munis, HYMB (duration 12.02 yrs, distribution yield 5.89%), are taking it even worse with a YTD drawdown of almost 12%. In a perfect storm of rising yields, illiquidity, high redemptions, and a default from Detroit to boot, munis are facing considerable challenges. HYMB, especially, is exhibiting considerable discount to NAV at the 3-5% level. Unfortunately, as others have noted, for highly illiquid assets such as muni bonds, the market price might actually be more accurate than the NAV. That said, even with the Detroit bankruptcy, which has been thrown back into court, the credit impact on HYMB should be muted as Detroit only comprises 1.33% of NAV and even all of Michigan only 3.53%. There is, however, the risk of other municipalities defaulting, but that risk has been there for a while. Note that muni bonds typically have high recovery rates (as high as 68%). The remaining headwinds of rising rates and redemptions will likely be challenging enough for the muni market. As the economy recovers and state coffers get replenished, the credit spread ought to tighten, but whether enough to counter the effect of rising rates is another question.

Thursday, February 28, 2013

Max Drawdown

When it comes down to it, finance is about risk and return. One of the purest measures of risk is max drawdown. This is pretty much the worst-case scenario: one bought at a peak (not necessarily the absolute peak) and a trough (not necessarily the absolute trough) such that the drawdown is maximum, i.e., you have maximum loss. I was curious, if one takes a look at the S&P 500 components from max drawdown only, what does it look like? The time period for this simple study spans 5 years from today, February 28, 2013. Choosing a 5 year period does unfortunately eliminate 25 of the S&P 500 right off the bat due to those symbols not having data running that far back.

S&P component Max drawdown (5 yrs) Std Dev (daily return)
AZO0.1312920.179530
MCD0.1549240.141842
GWW0.1914370.190390
ABC0.1963780.275510
SRCL0.2142330.210143
CERN0.2175810.338044
WEC0.2329360.133349
DTV0.2351170.235420
XEL0.2429850.103072
FDO0.2460840.184564

The above table shows the 10 components with the least max drawdown over the period. An interesting variety of businesses are represented here. It isn't just a list of defensive utilities or consumer staples. We have automotive parts retail, the Golden Arches, industrial equipment, a pharmaceutical, a pharmaceutical waste disposal, healthcare IT, two utilities, and a discount retailer. Note that although these names tend to be low beta, they are hardly low PE. Note that having the least max drawdown doesn't necessarily imply having the smallest standard deviation of daily returns.

S&P component Max drawdown (5 yrs)
BAC0.921133
XL0.925845
GCI0.932099
TXT0.940085
HIG0.950989
FITB0.955382
C0.960199
FSLR0.962171
GNW0.964527
AIG0.992874

This second table shows the 10 components with the greatest max drawdowns. This list is certainly more concentrated than the first table. All except for 3 are financials/insurers/reinsurers. We have the old guard news media represented by Gannett (GCI), aerospace/defense by Textron (TXT), and renewable energy by First Solar (FSLR). If risk averseness is the game, then drawdowns is quite an interesting measure. It shows the worst-case for a single roundtrip trade. Note that trading results may be much, much worse than the max drawdown if a strategy gets repeatedly drawn down in a losing streak. Nevertheless, max drawdown gives some insight into the amount of risk we are taking on. In particular, max drawdown should give some insight into what kind of reserves should be kept. This, of course, isn't foolproof since past drawdowns do not necessarily predict future drawdowns.

Another interesting aspect of max drawdown is that there is really no relationship between max drawdown and daily returns. A regression between the two shows an R2 of a mere 0.0027.