anonymous classes — usage

* Usage: GUI. Event handlers and listeners
* Usage: threads.
* Spring callbacks in templates
(See other posts on sample codes for both.)

anonymous static and non-static classes are routinely used inside static/non-static methods to create a thread and start it.

–> concurrency developers had better get thoroughly familiar with the basic rules of anon classes


career planning – next 5Y c2010

update… I feel if last job is a small no-name company (without a much higher salary), then it would affect my “image” for next job search.

See also post in 610610

Over the next 5 years, though i want to stay in a big bank for many years, circumstances might force me to change job every 1-2 years. Aiming to grow stronger in 3 areas.

Brank) leadership job title in big banks — a door opener and a little halo. When job market declines, employers have too many candidates, they prefer known brands.

T) keep my technical skills relevant — I realize every time I change job, technical skill requirement is always (at least one of) the biggest factor. A lot of tech interviews and quizzes are non-trivial[1]. If we stop doing hands-on work with current technology, we will weaken and become obsolete.

F) mainstream financial domain knowledge esp. security trading. This would open up a lot of high-worth job opportunities. They are not open to me now due to my limited mainstream financial experience. Maybe i
don’t need such a job — i can read up and pretend to have, say, risk analytic experience?

For my next (2? 3?) job searches in the next 5 years, I’m unlikely to apply to PM or business analyst roles. Technical is my strength.

[1] Rarely do i get an easy tech interview on wall street.

lab49 iview

reentrant locks?

classloader hierarchy?

what's the challenge when notifyAll wakes up all the waiting threads?

why do we want to consider a synchronized block rather than a method?

why do we need primitive types when we have the wrapper classes?


call dtor explicitly@@

quiz time! Give one use case for calling dtor explicitly

ARM P279 says placement new can be coupled with placement-destruct. Syntax is 



synchronized static init block@@

I vaguely remember a static init block can have “synchronized”. I guess 2 threads might (in theory) run the block concurrently.

But each classloader (and all its ancestors) can only load a class once, so i guess the 2 threads will load the same class into separate class loaders that aren’t in parent-child@@


hidden this._target field in a delegate Instance

As stated else where on this blog, an “item” in a delegate inv list holds nothing but 2 pointer fields. sheds light on one of them —

Internally an “item” stores its target in a private field named _target.

Normally, public property Target just returns a value of _target. For static delegates though, _target contains a reference to the delegate instance itself. “Get” accessor of Target makes a quick check, and if _target references a delegate Instance (likely to be itself), returns null.


3 ways to instantiate the same c# delegate Type

In c++ or java, you can instantiate a class Animal many ways, like
Animal myCat; // exactly like declaring an int variable
Animal myCat(2); //age
Animal* myCat = new Animal(“kit”);

C# delegate is more complicated. has a concise list of about 5 different ways to Instantiate a delegate Type. Extremely insightful. Among other things, it reveals that in the instance method case the delegate Instance must “remember” the target

public delegate string FirstDelegate (int x); // type declaration.
// The following two creation expressions are equivalent,
// where InstanceMethod is an instance method in the class
// containing the creation expression (or a base class).
// The target is "this".
FirstDelegate d1 = new FirstDelegate(InstanceMethod);
FirstDelegate d2 = new FirstDelegate(this.InstanceMethod);

// Here we create a delegate instance referring to the same method
// as the first two examples, but with a different target.
FirstDelegate d3 = new FirstDelegate(anotherInstance.InstanceMethod);

// This delegate instance uses an instance method in a different class (and 
// obviously different target),
// specifying the target to call the method on
FirstDelegate d4 = new FirstDelegate(instanceOfOtherClass.OtherInstanceMethod);

// This delegate instance uses a static method in host class containing
// the creation expression (or a base class). Target is NULL for ALL static
FirstDelegate d5 = new FirstDelegate(StaticMethod);

// This delegate instance uses a static method in a different class
FirstDelegate d6 = new FirstDelegate(OtherClass.OtherStaticMethod);

how citi stays on top in munis

Other underwriters do try but can’t catch up with the leader.

–IPO market
When an underwriter gets a deal, they travel around the country to collect bids. Citi muni has a good distribution network (remember Global Transaction Service?) reaching out to hedge funds, pension funds, mutual funds etc.

citi often joins a syndicate to share the risk and share the profit. I guess the gorilla often influence the terms and enjoys the best margin.

muni issuers always call citi first – the market leader.

— secondary market
any muni salesforce need a lot of small “local” licenses to sell muni bonds in each local market. I guess it’s due to the tax implications. It takes a lot of effort to get those local licenses.


simplified ATM call/put valuation(mental arithmetic

Develop a mental valuation for ATM European call/put assuming 0 dividend/interest rate with 1 year TTL. (Note put and call have identical valuation in this context.)

if σai (annualized implied volatility) = 100%, then valuation/spot = 1/ =~ 0.4
if σai = 50%, then valuation/spot = 0.5 /   =~= 0.2. In other words, “leverage” is proportional to σai.

More generally, leverage is proportional to maturity-adjusted volatility. For example, 100 vol but 3 mth TTL, leverage is same as 50 vol 12 month.

Now the quick mental calc —
$1 spot = strike, 100% σai, 1 year, val = 0.4. This is the reference level.
50% σai, 1 year, val = reference * 50% = 0.2
100% σai, 3 month, val = reference * 3/12 = 0.2
80% σai, 3 month, val = reference * 0.8 * 3/12 = 0.16. (80% σai =~ 5% daily vol)


gamma measures non-linearity of curve – valuation-vs-spot

(Similar indications —
  risk-reversals quote measures skewness of smile curve
  strangle quote measures convexity of smile curve

Very roughly, gamma is an indication of the non-linearity of an instrument’s valuation wrt underlier price. All linear instruments have 0 gamma. Every security in the world including cash has non-zero delta. Zero delta is meaningless.

Sound bytes —

Short put/call have negative gamma.
Long put/call have positive gamma, i.e. at higher[1] spot, call delta gets more positive and put delta gets Less Negative.
* Further, at the same strike/TTL, call vs put share identical gamma. Reason is simple — their deltas in absolute terms add up to 100%

[1] let’s avoid “growing” or “increasing” as these words imply variation over time .