Wednesday, February 28, 2007


Happiness map
    Today's BBC News
Adrian White, from the UK's University of Leicester, used the responses of 80,000 people worldwide to map out subjective wellbeing...
    complete map (pdf)
  • Moving to Denmark (1st) or Switzerland (2nd) might just make you live much happier.
  • US is ranked 23rd while UK at 41st.
  • Chinese are "marginally happy" at 82nd. The survey must be conducted before yesterday's market crash. I'm sure there are less happy faces out there today.
  • It's not so bad considering that we are doing better than Japan (90th) and India (125th).

Tuesday, February 27, 2007

RSS Aggregator, FeedBurner

I'm sure that all earthlings know about aggregators, and they are using one as well. But there is always someone from caveman age, like myself, keep refreshing some twenty browser tabs to read all the blogs and news every day. Anyhow, I'm finally getting tired of it and decided to find a good feed reader:

  • IE7 and Outlook 2007 both support RSS feeds directly (check out the RSS icon on the IE toolbar), but I don't quite like the way IE displays the feed content.
  • I'm trying out RSSOwl. The interface is clean and the way it organizes feeds is also very intuitive.
  • Also, check out NewsFire for Mac OSX.
  • You can add a feed into Google Personalized Homepage (check the Add by URL link on the right of search bar).
  • I also came across FeedBurner, a site that provides feed distribution and statistics services. You can check the number of subscribers of your feed through their website. But there doesn't seem to be an easy way to aggregate these numbers with the website statistics. FeedBurner also provides some HTML snippets you can eaily put on your website for different types of aggreagators (check RSS Feed section on my blog page banner, for example).

Monday, February 26, 2007

Web 2.0?

Call it WebX or Web Vista if you want to. While technologies such as RSS/Atom, SOA and Ajax are the necessary steps taking us further in the right direction, hollow terms such as "Web 2.0" are no more than the outcome of putting alphabetic soup in a mixer. The fundamental question of how to organize data, retrieve data and represent data has not really changed since day one. On the other hand, they do make the water muddier so that the "high-tech" start-ups could feast on the clueless consumers and investors without an actual business model. This is like Déjà vu all over again. We might as well just call it Bubble 2.0.

The Departed

The Departed won four awards, including Best Picture, Best Director, Best Film Editing, and Best Adapted Screenplay, last night. The Oscar made a big mistake when announcing the award for Best Adapted Screenplay: the original, "Internal Affairs"(«无间道»), is a HONG KONG movie, not Japanese. In fact, the term "Departed" is almost a direct translation of the original film's Chinese name, from its Buddhism root to Catholicism. I don't know for which part the "Adapted Screenplay" award emphasizes: had it been "Screenplay", the director of the Hong Kong movie should better qualify because "The Departed" is almost a scene by scene replica of the original; had it been "Adapted", the few additional twists in "The Departed" aren't that Oscar-ish: for example, the somewhat surprising ending by the added character Sergeant Dignam (Mark Wahlberg) is such a classic American style, almost Spiderman-alike, interpretation of justice, it makes the entire movie more like a violate comic. IMHO, the original is far better, in both screen play and story line. You can judge for yourselves (nowadays most Hong Kong movies do have English subtitles).

Friday, February 23, 2007

China's "Big Four" Banks

China Construction Bank
IPO Date:October, 2005
Shares Outstanding:195 billion (H Share)
Share Price:HK$4.83
Market Capitalization:$120 billion
Largest Share Holders:Central Huijin (70%) Jianyin Investment (10%) Bank of America (10%) Asia Financial Holdings (6%)
Bank Of China
IPO Date:June, 2006
Shares Outstanding:76 billion (H Share) 178 billion (A Share)
Share Price:HK$3.85 (H Share) $4.95 (A Share)
Market Capitalization:$125 billion
Largest Share Holders:Central Huijin (69%) Royal Bank of Scotland (8.3%) Asia Financial Holdings (4.2%) China Social Security Fund (3.4%) UBS AG (1.34%) Asia Development Bank (0.2%)
Industrial and Commercial Bank of China
IPO Date:October, 2006
Shares Outstanding:41 billion (H Share) 300 billion (A Share)
Share Price:HK$4.56 (H Share) $5.14 (A Share)
Market Capitalization:$200 billion
Largest Share Holders:Ministry of Finance (36%) Central Huijin (36%) Goldman Sachs (5%) China Social Security Fund (4%) Allianz (2%) American Express (0.4%)
Agricultural Bank of China
Planed IPO :2008
  • Central Huijin Investment is fully owned by Chinese Government. It was created when Ministry of Finance injected massive funds into the banking system in 2002. This means Chinese Government still retains at least 70% shares of all four banks. The IPOs only mark banks' transfermation from SOE (state owned enterprises) into State Controlled Companies.
  • Aside from the usual wall street big names (Goldman, BOA, UBS, etc), Singapore Government also has a sizable stake in these Chinese Banks through its investment arm, Temasek Holdings (AFH is a wholly-owned subsidiary of Temasek).
  • The price discrepancy between A share and H share makes market capitalization calculation difficult. Although representing the same share of ownership, A Share normally trades at a premium above H Share because of capital control. The figures above were derived with H Share price, to be conservative.
  • At $200 billion, ICBC is the second largest bank in the world by market capitalization, after Citigroup. The other two banks could also rank in top ten.

Thursday, February 22, 2007

Algorithmic Trading

Algorithmic trading means the use of computer systems to trade in electronic markets. However, the primary focus of Algorithmic trading is quite different between buy-side and sell-side firms. For the buy-side firms, Algorithmic trading is mainly used to generate trading profits. The program monitors various market indicators, awaits trading signals and trades automatically whenever a profitable opportunity is present. The signal utilized by such system can be fairly simple (I.E. trending following, momentum strategies) or very complicated (I.E. statistical arbitrage, index arbitrage, etc). Despite equipped with very complex trading algorithms, these systems are relatively simple from a software engineering point of view. The architecture is pretty much a single node message processor: it deals with a limited number of external systems (for market data feed and automated trade); although response time can be critical, required throughput is usually low. Because the systems are normally hosted in house, there isn't much requirement for security either. For the sell-side firms, on the other hand, Algorithmic trading is primarily used to enhance order execution, attract new customer and generate commission revenue. Their clients sometimes need to execute order of massive sizes compare to the trading volume on the exchange. Especially for the relatively illiquid issues, the orders are like pushing full turkeys down your kitchen sink. So these brokers would spend millions of dollars to build sophisticated computer systems to chop up the order into small slices and feed them slowly into the market. The objective is to minimize the impact of the large order and get the best execution price. The Algorithmicbuilt into these systems to control the size and timing for each slice is no less complex than those employed by the buy-side firms. The software architecture underpins these systems are even more demanding: each system is like a major message hub. It receives orders electronically from different clients, monitors market ticks and routes small-sized orders to different venues for best execution (exchange trading floors, various ECNs, for example). Both response time and throughput for such systems are critical as orders could arrive in massive volumes. Security is also a big concern because if the order book in the system is leaked, trades will front run these orders hence hurt their clients. In theory, even the prop traders of the brokerage house should not be allowed to touch these systems.

Wednesday, February 21, 2007

Wii'd like to play

Finally got my hands on a Wii console at a local Target store after a week long Wii-hunt. Why would such a relatively easy to make (compare to XBOX360 and PS3 --- not saying that it's less fun though) game console still at shortage almost three months after launch is beyond comprehension. Nintendo and the speculative resellers must have got into some kind of implicit collusion: by limiting the shippment and contributing to the shortage, Nintendo could get some free marketing exposure as media report how people stand inline 6am in the morning to buy a Wii --- XBOX360 and PS3 both pulled such stunt during their releases; and the ebayers will scoop up whatever amount comes to available on retailers' shelfs, put them up on ebay and earn a hefty profit. Besides, the return policy of the retailers always serves as a put option-alike protection. It's not hard to imagine that thousands of Wii consoles are seating in the closets of ebayers as we speak. Anyway, I'm now waiting to receive the The Legend of Zelda for the real fun to begin... Here are some tips on how to locate a Wii:

  • The Wii-tracker tracks the availability of Wii console and bundles (very bad deal, I have to say) on major online retailers.
  • Target has been the only retailer that has a relatively steady flow of shipments. Check the availability of Wii in Target local store here (check zip code to your location).
  • And this thread on Fatwallet.

Saturday, February 17, 2007

Happy Chinese New Year

The movie is actually a bit old but it says what I want to say to all my friends (in Cantonese).

Friday, February 16, 2007

The Year of Golden Pig

Many friends of mine have got plans to have a baby in the Chinese New Year starting 2/18. According to Chinese Zodiac, this will be the Year of Pig, which is considered a "lucky" year --- although I still struggle to understand the profound link between "pig" and "lucky". What makes THIS pig year especially special is that most people believe this is the once-every-60-year "golden pig", so child born this year is going to be both "lucky" and "rich", or so it seems.

Okay, a bit of Feng Shui lessons here: In Chinese Astrology system, there are two separate yet equally important cycles: the five elements, which include gold, wood, water, fire and earth (No, Leeloo, the girl who saved the world, isn't one of them...), and the twelve animals: rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig. And these are their stories... Each year is assigned one element from the five and one animal from the twelve, hence on a 60 year rotation.
Naively, I thought this is the year when "gold" and "pig" come togather. However, according to the methodology described here. The actual combination is going to be "fire" and "pig". So it's really a "flaming pig" year (we are just one step short from "roast pork" here). I couldn't quite figure out where "golden pig" came from. There are some references to some historical events in the Tang Dynasty, but these aren't very significant by themselves.
That, however, doesn't stop the new year from becoming a baby booming year. The chart in this article on Economist might give an idea as what a spike we can expect (the last baby boom was in 2000, when people rushed for the Millennium Babies).

Thursday, February 15, 2007

Investing is no monkey business

In the debate of passive v.s. active investing, the proponents of index funds often refer to the famous chimpanzee experiment, where a chimp picks stocks by tossing coins on Wall Street Journal and out performs half of the mutual fund managers (in this book, for example). As much as I believe in the Efficient Market Hypothesis --- at least in its weak form and partly the semi-strong form --- I'd have to say that this argument is invalid. It's just like asking a two year old to draw one piece of paper from a stack of graded college exams, then claim the child can beat half of the students in that exam. The market is built by the professional money managers in the first place. The chimp simply gets the luxury of efficiency already in existence. A truely valid test would be to host a zoo of chimpanzees, let them "pick" stocks as they wish and actually trade following these pickings in the order size an average money manager trades. I bet our chimps will be exploited down to their underpants --- if they ever had one. Market being efficient or not, investing is no monkey business.

Tuesday, February 13, 2007


I was asked what WeakReferences can be used for in an interview today. I sure have played with it but, honestly, I haven't really used it in any real world project. The only legid use that I can think of is caching, where objects are cached in memory by means of WeakReference. Subsequent access to the same object will become more efficient. Yet once memory becomes the bottleneck, CLR can always reclaim the memory and the objects can always be re-generated later from persistent storage (Database, file, etc). But even this is not ideal: an efficient cache manager would implement some type of replacement algorithm, LRU (least recent used) or LFU (least frequently used), etc. These requirements would make the use of WeakReferences much less effective than it seemed. Another potential use of it is so called "Weak Delegates", to prevent the leakage of event handler --- in case you forget to remove it from the delegate chain. IMO a WeakReference isn't really the best solution here either: when the strong reference to the underlying event handler is lost, it implys that the application is intended NOT to handle the event any more. With WeakReference, the event handler is still being called until garbage collection claims it through the WeakReference, which introduces some sort of random behavior to the application. So is there really a real world necessitiy for WeakReferences?

Darth Vista

Bill Gates interview by Newsweek.

Microsoft LBO

It seems my idea of a Microsoft LBO wasn't quite as original as I thought (darn it... but I was joking, really). Financial Times had an article last year to actually analyze the possibility:

And here are three reasons it can't be done. With the size of PE funds growing at exponential rate, the first, and probably the most important reason, won't hold for long.

Monday, February 12, 2007

New York Subway Stations on Google Map

Just noticed that Google (finally) has added NYC MTA subway stations to GoogleMap. Previous you'd have to compare the MTA map and google map to figure out your trip route. PATH stations are also marked. No NJ Transit Bus stops though. However, "directions" page still only gives driving directions, which is not that useful in the City. And a business search of "Subway", not so suprisingly, returns this.

Friday, February 9, 2007

The Buyout Boom

Private Equity firms are setting record deal sizes literally every month:

Here is a list of deals in 2006. Also, there is an article (requires subscription) in today's Journey about Goldman Sachs gearing up its own $20b Private Equity fund. So who's next? By all measures, Microsoft seems to be a excellent LBO target: it's cash rich, almost debt free and has a stream of stable cash flows. It's share price has not been doing so well recently. Yeah, it's a bit too big. At today's stock price, Microsoft has a market cap of about $300b. If the LBO is 15% funded with equity, the PEs would need to put up some $45b in cash. But with more PE funds clearing the $20b watermark, nothing is impossible... Who is who in Private Equity.

Wednesday, February 7, 2007

Painting Vista Wallpapers

Breath-taking views from the photographer of Windows Vista Wallpaper collection. Enjoy.

Prison Break, Chicago

Haywire is dead. Technically it happened in Monday's episode but I only got to watch it yesterday on my DVR. I wasn't seriously expecting him to raft all the way to Holland, but I wasn't expecting such an interesting character to be dropped so fast either. Maybe the director has opened way too many threads and his processing power has been drowned. Haywire's biography indicates that he was a doctorate candidate in mathematics prior to the nerve breakdown. That reminds me of a college friend, and Ph.D candidate I must add, once said about what Ph.D really stands for: Permanent Head Damadge --- No offence to the real world rocket scientists...

Tuesday, February 6, 2007

.NET Security: Limit Access to a Class Library

I have used StrongNameIdentityPermission in a few projects to ensure only my own applications get access to my libraries. Here is how it was done. However, the fine print on this page seems to indicate that the old trick is not gonna work on .NET 2.0.

...In the .NET Framework version 2.0, demands for
identity permissions are ineffective if the calling
assembly has full trust...
In 2.0, the alternative is Friend Assemblies , or InternalsVisibleToAttribute: suppose you are writing a class library (SecureLib.dll) and an application (SecureApp.exe), and you want to ensure that only SecureApp can access SecureLib classes and functions:
  1. Use sn.exe to generate a key file (mykey.snk) and use the same key file to sign both assemblies (Property -> Signing):
  2. sn -k mykey.snk
  3. Use the following commands to print the public key in the keyfile: the public key is a long hex string.
  4. sn -p mykey.snk mypublickey.snk
    sn -tp mypublickey.snk
  5. Declare ALL public classes in SecureLib project as internal, and add following attribute declaration (replace the long hex string with the output from step 2):
  6. [assembly: InternalsVisibleTo("SecureApp,
              PublicKey=long hex string")]
Now, only SecureApp can successfully link to SecureLib. Any other application trying to link to SecureLib will fail at compile-time.

Monday, February 5, 2007


A new addition to my home theater system. DVP5960I have been looking for a decent upscaling DVD player for a while and this one definitely fits the bill on every aspect: DVD upscaling throught HDMI connection, DivX support and most important of all, a front USB port that can directly read audio and video files off a USB compitible storage device (thumb drive or external HD). Setup was far easier than I thought. I planed to connect the player with my Onkyo receiver via HDMI port and use the receiver as a HDMI switch. Base on my bitter experience with Comcast HD box (needs firmware upgrade) and Samsung upscaling DVD recorder (HDMI version incompatible), I thought this connection schema was going to be a problem. To my surprise, once everything was connected, both audio and video worked right on. I have also tried the USB interface with a few DivX videos downloaded from Stage6, no problem (the USB drive needs to be formatted to FAT first). There are sure some minor issues with it: for a starter, there is no optical audio. This might be a problem if your receiver doesn't have HDMI switching and you need to connect to TV and Receiver separately. The USB interface is rather rudimentary, file names are displayed in short format. The remote could have been made better too (again, not a problem for me as I have taught my Universal URC-300 remote some new tricks). As most of my video collections are in RMVB format (don't ask me where I got them. Coz if I tell you, I'd have to kill you ;), I need to convert them into DivX now. Here is a guide I found on internet. Now, I'm in the market for a 500GB external harddrive...

.NET Interop: Native function that returns struct array

Most of the time, .NET Interop is straight forward once you mastered the MarshalAs, StructLayout and a few other attributes and the mapping of various unmanaged types. However, A notable exception is for native functions that return variable length struct array:

     extern "C" {
     _declspec(dllexport) MYSTRUCT* GetMyStructs(int* pcnt);
The function returns an array of MYSTRUCTs, and pcnt is set to the length of the array. Since the array is variable in length, CLR would not able to marshal it into MYSTRUCT[] automatically on its own. Instead, you have to do the dirty work yourself:
     public extern static IntPtr GetMyStructs(out int cnt);

  IntPtr ptr = GetMyStructs(out cnt);
  for(int i = 0; i < cnt; ++ i) {
      obj = (MYSTRUCT)Marshal.PtrToStructure(
            ptr, typeof(MYSTRUCT)
      //use obj here
      ptr = (IntPtr)(ptr.ToInt32() +
The pointer returned by native function must be freed, by either calling another native function provided by library (this is the only option when the memory is allocated with malloc or new, or with Marshal.FreeHGlobal. One potential problem in this approach is the IntPtr math. By converting it into Int32, we are assuming the machine is 32 bits.

Friday, February 2, 2007

Super Bowl and Complete Market

The only places on this planet that most closely resemble an ideal "Complete Market" are probably inside the investment firms, where any form of uncertainty can be assigned a price --- like the outcome of the superbowl: a "fair game" is quickly developed in the research department, the "speculators" would then rush in, some even with "margins". Soon enough, the quant-types would figure out the expected return and volatility for each of the investor base on historical data. Had there been a longer investment horizon, I'm sure various types of derivatives would have been in-place, think of exotic options and total return swaps, for example. These would come handy for the teams themselves to hedge risks --- even if they lose the game, they can still come home with a gain on investment.

How Software Engineers add value to their products

Thursday, February 1, 2007

Fashion Inspiration from Chinese Migrant Workers?

Something that might worth a good laugh:

The new fashion handbag by Luis Vuitton looks EXACTLY the same as the luggage Chinese migrant workers carry when they travel between their rural home and the cities where they work. These bags are a dime a dozen at the train stations. Who said you have to be rich to be in fashion?

Single Factor Interest Rate Models

Although I haven't got into multi-factor short rate models yet, the single factor ones look quite straight forward once the notion of Geometric Brownian Motion becomes clear. The Vasicek Model, for example, is simply the standard Brownian Motion with an added twist of Mean Reversion:

This interest rate model is different from that of stock because it's believed that there is a long term stable rate (around 6%). The short term interest rate tends to be pulled towards this long term mean. In the formula, b represents the mean rate and a represents the speed at which the random variable gets pulled. Here is a graph representation of the Vasicek model:

Library of Economics and Liberty

Econlib has a huge collection of online books on Economics, including some of the classics:

Adam Smith
[H]e intends only his own gain, and he is in this, as in many other cases, led by an invisible hand to promote an end which was no part of his intention. Nor is it always the worse for the society that it was not part of it. By pursuing his own interest he frequently promotes that of the society more effectually than when he really intends to promote it. I have never known much good done by those who affected to trade for the public good. ---- Adam Smith, Wealth of Nation