Friday, March 30, 2007

Driving Direction from NY to London

"Driving" Direction from NY to London, according to the smart a$$ GoogleMap. Be sure to check out step 23.

Wednesday, March 28, 2007

WTF is WF?

Ever wonder why there is WCF (Windows Communication Foundation) and WPF (Windows Presentation Foundation) but Windows Workflow Foundation is only called WF? This slide probably explains it: The WWF (World Wildlife Foundation) even forced World Wrestling Federation to rename itself to WWE (World Wrestling Entertainment). In a word, don't mess with the panda! Seriously, here is world’s most trivial and useless Windows Workflow Foundation (WF) application, best for beginners.

Tuesday, March 27, 2007

Fun with XLL

The oldest comment I found while poking around the XLL project is dated Nov, 1996, a bit over ten years ago. I probably wrote my "hello, world" in C around the same time. Anyway, the goal is to call the excel plugin functions in C#/.NET. This should be straight forward, at least in theory: XLL files are merely DLLs with a few special functions. There is no reason they can't be loaded and called via DllImport. However, the following code throws a DllNotFoundException, and GetLastErr promptly returns no error code:

  [DllImport("myxll.xll", EntryPoint="GetVersion")]
  public static extern string XLGetVersion();
Digging a bit deeper with Depends, I found an excel library called XLCALL32.DLL, referenced by the XLL is the cause of trouble. The library can't be loaded with LoadLibrary outside Excel. I suspect that has something to do with the mysterious looking importing variable shown in the right panel below.A suprisingly simple solution is to manually pre-load XLCALL32.DLL with LoadLibraryEx and choose NOT to resolve any external references:
  IntPtr ptr = LoadLibraryEx("XLCALL32.DLL", 
        IntPtr.Zero, DONT_RESOLVE_DLL_REFERENCES);
Then the old P/Invoke trick turns back on (because XLCALL32 has been loaded). This obviously won't work if the XLL contains callback functions into Excel. But for everything else, there is DllImport... And here is a reference to the structure of XLL files. (link to complete e-book).

Monday, March 26, 2007

Walking Backwards

During the past two years, I have been walking completely backwards on the path of technology innovation:

So what's the coming attraction? A bit of 80x86 assemble would be fun...

Thursday, March 22, 2007

BlackStone S-1 Filing

BlackStone's planned IPO is definitely the latest hype in the PE space. The pros are already having fun with its S-1 filing. WSJ/BreakingViews suggests that the managing directors at BlackStone should actually take a pay cut in order to maximize their personal wealth.

Tools I have been using...

Time to create a list of tools I have been using in my current project before jumping into a new bunker next week:

  • SubVersion
  • I honestly don't have a preference when it comes to version control software. I have used VSS, CVS and now SVN. The differences in terms of file lock, branch etc are not really that big a deal. TortoiseSvn sure makes your life a lot easier by integrating version control into windows explorer though.
  • CruiseControl.NET
  • I had been using home-made daily/weekly automated build process and regression tests to ensure continuous integration, before I got to know CruiseControl.NET, that is. Make sure you install the client tool CCTray.
  • BugTracker
  • I feel that bug tracking tools are generally understated in the software development methodologies such as XP. Most developers are probably put off by the term "bug". But bug tracking tools are not limited to track "bugs", they can be used to track new feature developments, document design limitations and provide a structured "knowledge base" for the project. I have used Bugzilla in the past. Built on .NET platform, Bugtracker is not super sophisticated, but it's small enough to get your hands dirty on. And it probably provides enough functionalities for Scrum-sized development teams.
  • TWiki
  • I'm so obsessed with Wiki style documentation at one time, I was called the WikiMan... The benefit of using Wiki for knowledge sharing is that the documents created are naturely structured, and most Wiki implementations provide full-text search functionality. And also because it's so easy to use, a Caveman can do it... TWiki is not .NET based. It's on Perl and Apache. And I never got into the TWiki plugin stuff, which can probably be used instead of the bugtracker. I'd be interested to see a .NET implementation of Wiki --- it has to be at least as good as TWiki though.
  • Reflector
  • Any .Net developer NOT using Reflector? I use it primarily to get a peek into framework library implementations (and Whispering: third party tools). If, however, you want to gain some insights into CLR itself (GC, thread pool, etc), SSCLI is a better bet.
  • Regulator
  • If you ever need to write a multiline regular expression, you need this. Period.
  • ManagedXLL
  • Anyone in Finance will tell you that Excel is the best product of Microsoft. And any developer ever wrote a XLL plugin for Excel will tell you how painful that experience was. Creating Excel plugins in C# with ManagedXLL, on the other hand, is almost pain-free. You still need to watch out for the mysterious way in which Excel updates the spread sheets though.
  • CodeSmith
  • In retrospect, I probably used CodeSmith in a not-so-effective way: we used it to produce the DAO and Store Procs. The design of the system is less clean-cut:
    • If we take a data centric view of the world, we should probably take the typed datasets and push it all the way through out the system.
    • If the view is object centric, an O/R mapping tool (such as NHibernate) would be a better fit.
    There is nothing wrong with CodeSmith though. It's very useful when you need to produce large batches of template based classes.
  • Spring.NET
  • I dont' pretend to be an expert on IOC/DI or AOP. I have only used Spring.NET framework as a generic configurable Factory pattern implementation (IoC, in its simplest sense). Still, I feel the extreme flexibity the framework provides. In fact, I think the downside is that it makes developer easily over-design their system by abusing the pattern with too many dependency injections.
  • GenuineChannels
  • A bidirectional TCP channel implementation. A feature .NET Remoting developers have cried out for since the day .NET came to existence.
  • MSAS/PivotTable/ADOMD
  • This is the first time I tried OLAP reporting. The Microsoft OLAP pipeline is quite impressive, even with MSAS 2000. MSAS integration with Excel pivot table is seamless and it freed up developers from writing an ocean of custom reports as customers could easily slice and dice the pivot table in their liking, not to mention the update is realtime.
Of course, these are only from the special menu. The usual would undoubtedly include NUnit, Nant, log4net etc.

The Birth of "Bernanke Put"

After the "Greenspan Put" expired last year, a new one was born @ 2:15pm yesterday.

Tuesday, March 20, 2007

South Park Chess Set

Saw this on a friend's website today. There are a total of 16 Kennies, so it's 16 "bastards" waiting to happen. Any why aren't cartman the King?

Socialism with Chinese characteristics

A WSJ piece on Chinese Property Rights (the second part, after Citigroup's ABN Opening).

China's new law guaranteeing private owners the same rights as public and collective entities might sound like a capitulation to capitalist ideology. Not so, says National People's Congress Vice Chairman Wang Zhaoguo. Equal property rights are required to "uphold and improve the basic economic system of socialism." Whatever the words, Adam Smith would approve. ... And if 1.3 billion Chinese want to call it "socialism," why argue?
Welcome to the world of "Socialism with Chinese characteristics".

Sunday, March 18, 2007

Yen Carry Trade

The stock market and Yen have been trading in locked oppsite steps in the past few weeks. See DJIA and JPY 3 months daily chart above (the JPY chart is in Yen per Dollar). Does this mean that the power of yen carry trade is in its full force? When the stock market advances, speculators borrow more yen, convert them into dollar and invest in the market, hence contributing to the depreciation of JPY; when the trend in stock market is reversed, they unwind their positions and repay the Yen debt, pushing JPY up. The carry trade schema is no more sustainable in the long term than US current account deficit. The reversal of a depreciating yen could pose serious threat to equity investors. Could subprime or the emerging market problems pull the trigger? There is no way to know...

Friday, March 16, 2007

The Road to Market Economy

Thursday, March 15, 2007

What's Volatility?

Think you know what volatility is? Think again:

A stock (or a fund) has an average return of 0%. It moves on average 1% a day in absolute value; the average up move is 1% and the average down move is 1%. Assume that we live in the Gaussian world in which the returns (or daily percentage moves) can be safely modeled using a Normal Distribution. Assume that a year has 256 business days. The following questions concern the standard deviation of returns (i.e., of the percentage moves), the "sigma" that is used for volatility in financial applications. What is the daily sigma? What is the yearly sigma?
See this paper for the answers. This probably doesn't have much real world implication though. Once presented the full time serie of stock prices, instead of this "on average" stuff, I can't imagine any one would make similar mistake.

Tuesday, March 13, 2007

Solving the Enterprise Architecture puzzle

The best articles(one, two) I have read on AJAX, SOA and EDA in the context of Enterprise Architecture. Most of the time, the nature of these technologies is much simpler than the marketing gurus would like us to believe (I understand ROI is important. But a paper talks about nothing but ROI hardly helps on that front). Or the arguments about the literal of terms ("SOA and EDA, who is the father" type, do I sense another StarWars comic?). SOA and EDA are simple design patterns, or reusable designs to solve common problems. (I always think of EDA as some combination of the old "chain of responsibility" and "observer" patterns). While SOA is a pattern focusing on decoupling the functioning components and implementing a tight control relationship among them, EDA focuses on integrating loosely-coupled components and services. The following graph from the article summerizes it nicely: UPDATE: Among the comments of the original article, Gerry posted:

Come on guys, this is trivial stuff. SOA and EDA are NOT rocket science. SOA is just another way of enforcing loose coupling and high cohesion. EDA is so trivial (and as a concept has been around for decades) that I can't believe its being bandied around as the 'next big thing'. Sigh, I think I've been in this business too long.
My feeling exactly.

Monday, March 12, 2007

How we remember only what we choose to remember

6 month price chart for Shanghai Stock Exchange Composite Index. Before the Feb. 27 plunge, the index actually had a sizable correction towards the end of January. It declined 12% in three trading sessions, then recovered quickly and made new high above 3000, only to see the 9% drop in Feb. 27th. The index is now on its way to make another attempt at 3000 level. We only remembered what we choose to remember. We remembered what happened to the index on Feb. 27th because it's blamed for the near 400 points drop in DJIA, along with Yen carry trades and problems in subprime mortgages.

Friday, March 9, 2007

Gamma Scalping

An article on Gamma Scalping, the option trading strategy that takes advantage of the difference between implied vol and realized vol, not easy to find in any introductory option trading materials.

Thursday, March 8, 2007

Spoiled Gamers

Once up a time, we were happy playing games like this: Yet today, we call Games with DVD quality picture "low resolution". So what's next? The Virtual Reality Helmet? How far are we to The Matrix? And are we really heading to the right direction? Anyway, just some random thoughts while reading the history of "Legend of Zelda" series. UPDATE: Speaking of which, Shigeru Miyamoto, the designer of the series, just received Lifetime Achievement Award today on Game Developers Conference 2007.

Wednesday, March 7, 2007

Barbarian at the Gate

Barbarian at the Gate
The story of $25 billion buyout of RJR Nabisco Corporation, a record KKR kept for almost two decades. An interesting read when today's LBOs are getting bigger and bolder.
The Billion Dollar Club
The latest hedge fund "Billion Dollar Club" survy by Hedge Fund Intelligence.
With the biggest chunk of profit coming from prop trading and asset management, is Goldman still a investment bank or a big hedge fund?

Tuesday, March 6, 2007

Was Last Week's Mini Crash "Made in China"?

There has been a lot of talk on how last week's rout indicates China's stock market has become an integrated part of global capital market. To put things in perspective, I've put togather the following data comparison from various sources(news releases from NYSE and SSE, CIA World Factbook):

                              China          US
-------------------------------------------------
GDP ($ Trillion)                2.50        13.22
  
                                SSE         NYSE
-------------------------------------------------
Total Market Cap.              895.15      24,500
Floating Shares                205.35         N/A
Percent of GDP                     8%        182%
  
2006 Volume (in $)            715.56       21,730
2006 Daily Volume (in $)        2.97        86.92
2006 Daily Volume (in Share)    3.41         2.35


* Dollar and share amounts in billions.
* Assume an average exchange rate of 8.
  • Although Shanghai Stock Exchange's total market capitalization is on par with its emerging market couterparts (Korea Stock Exchange, India's National Stock Exchange, for example), the actual floating (or tradable) shares only account for about $200 billion, less than 1% of that of NYSE.
  • In fact, several Dow components (GE, Exxon, Microsoft, etc) have higher market cap. than all SSE listed companies combined.
  • The stock market is not really an important source of capital for Chinese companies. They still rely heavily on traditional venues such as bank loan. The market cap. of SSE is only about 8% of China's GDP, the same number for NYSE is 182%.
  • Interestingly, the daily trading volume in shares on SSE is HIGHER than that of NYSE.
  • Currently the companies traded on SSE have an average P/E of 33.30. According to data here, the last time SP500 had such a high PE was between 1999 to 2002. We all know what happened after that, don't we?
So what's the conclusion? I don't think China was the cause of last week's global stock market plunge. It can only be the catalyst, at best. China's stock market has shown little correlation with Chinese economy in the past, let alone global.

MSBuild QuickStart

One obvious advantage of using MSBuild over NAnt is that Visual Studio 2005 uses MSBuild script as its default project file format. However, when you want to get your hands dirty on the details of MSBuild files, you'd likely find that the documentation is not as organized as NAnt help in MSDN. Here are two places that might give you a quick start on MSBuild:

Monday, March 5, 2007

DLL Hell: A ghost from the past

It can be quite surprising how this ghost from the past can still haunt you in the era of .Net.
The Problem
We have a .Net Excel PlugIn, developed with ManagedXLL under .Net Framework 1.1 and we have been relying on Visual Studio 2003 to debug it (Run Excel, then "Attach to Process"). Today, however, this process suddenly stopped working. Visual Studio gives the following error message ("Unable to attach to process"? very "informative", I must add) when attemp to attach to Excel:
The Solution
It became quite obvious that this has something to do with .Net Runtime versioning when I realize the only difference is that I installed .Net 2.0 last Friday (Yeah, I know this makes me look like a caveman...). Visual Studio 2003 should work with .Net Framework 1.1 only. No surprises here. And we have set the PlugIn and ManagedXLL to work with .Net 1.1 exclusively. So why would it messes around with .Net Framework 2.0? After a couple attempts, I found a somewhat odd solution: to define a configuration file for Excel. Save the following as Excel.exe.config in the same directory as Excel.exe (requires Admin account):
<configuration>
   <startup>                                
      <supportedRuntime version="v1.1.4322"/>
   </startup>
</configuration>
It seems this config file would force Excel to load 1.1 version of the Runtime. But why would an unmanaged executable such as Excel require .Net runtime (even without the plugin) in the first place is beyond my understanding.

Friday, March 2, 2007

Warren Buffett’s 2006 Letter to Shareholders

Warren Buffett’s 2006 Letter to Shareholders. Some interesting remarks:

On Risks
Don't think, however, that we have lost our taste for risk. We remain prepared to lose $6 billion in a single event, if we have been paid appropriately for assuming that risk... Our behavior here parallels that which we employ in financial markets: Be fearful when others are greedy, and be greedy when others are fearful.
On Accounting
We sometimes encounter accounting footnotes about important transactions that leave us baffled, and we go away suspicious that the reporting company wished it that way. (For example, try comprehending transactions "described" in the old 10-Ks of Enron, evenafter you know how the movie ended.)
On Residential Real Estate & Mortgages
The "optional" contracts and "teaser" rates that have been popular have allowed borrowersto make payments in the early years of their mortgages that fall far short of covering normal interest costs. Naturally, there are few defaults when virtually nothing is required of a borrower. As a cynic has said, "A rolling loan gathers no loss." But payments not made add to principal, and borrowers who can't afford normal monthly payments early on are hit later with above-normal monthly obligations. This is the Scarlett O'Hara scenario: "I'll think about that tomorrow." For many home owners, "tomorrow" has now arrived.
On US Trade Deficit

As our U.S. trade problems worsen, the probability that the dollar will weaken over time continues to be high. ...Like a very wealthy but self-indulgent family, we peeled off a bit of what we owned in order to consume more than we produced. These transfers will have consequences, however. Already the prediction I made last year aboutone fall-out from our spending binge has come true: The "investment income" account of our country---positive in every previous year since 1915 --- turned negative in 2006. Foreigners now earn more on their U.S. investments than we do on our investments abroad. In effect, we've used up our bank account and turned to our credit card. And, like everyone who gets in hock, the U.S. will now experience "reverse compounding" as we pay ever-increasing amounts of interest on interest.

On Derivatives
The answer is that derivatives, just like stocks and bonds, are sometimes wildly mispriced. For many years, accordingly, we have selectively written derivative contracts --- few in number but sometimesfor large dollar amounts. We currently have 62 contracts outstanding. I manage them personally, and they are free of counterparty credit risk.
On Efficient Market Theory
When I talked about Walter 23 yearsago, his record forcefully contradicted this dogma [EMT]. ... The faculties of the schools went merrily on their way presenting EMT as having the certainty of scripture. Typically, a finance instructor who had the nerve to question EMT had about as much chance of major promotion as Galileo had of being named Pope. Tens of thousands of students were therefore sent out into life believing that on every day the price of every stock was "right" (or, more accurately, not demonstrably wrong) and that attempts to evaluate businesses --- that is, stocks --- were useless. Walter meanwhile went on overperforming, his job made easierby the misguided instructions that had been given to those young minds. After all, if you are in the shipping business, it's helpful to have all of your potential competitors be taught that the earth is flat.

Thursday, March 1, 2007

The DJIA Technical Glitch

What happened
According to the statement published by Dow Jones Index, the heavy trading volume caused a 70 minutes delay in the calculation of Dow Jones Industrial Average on Feb 27th, around 2pm. The market data feed for the underlying prices was congested. When the problem was resolved by switching to a redundaent market data system, DJIA suddenly moved to its correct level, causing an almost 200 point drop in 5 minutes.
Effects on Future and ETF
Originally I thought this would cause a bit of chaos in the DIA ETF and Dow Future, both track the value of the index. However, this post compares the intraday charts and reached the conclusion that both the ETF and Future were tracking the correct value of the index all the time. The algorithm trading system at the index arbitrage desks must have been working very hard to squeeze profit out of the system (and eliminating the very arbitrage opportunity at the same time).
Was there an arbitrage opportunity?
Here is some discussion on the subject. I think this eventually boils down to the question of whether there are traders using DJIA as a reference for Future or ETF trading. If these poor souls do exist, they would be trading at wrong prices and give more informed traders immediate profit opportunities.