superclass param, subclass argument

      Dog(Number o) {
      Dog(Integer s) {
      public static void main(String[] a) {
            Number ptr = new Integer(22);
             * won’t call the (Integer) ctor.
             * Won’t compile if you remove the (Number) ctor. Compiler doesn’t know
             * ptr points to an Interger object. Compiler only knows ptr is a Number (or
             * subclass) object. Runtime type of the pointer ptr is known only at runtime.
            new Dog(ptr);

RBS IV – risk

Q: have u used atomic variables like AtomicInteger?

Q: A web app showing on demand employee address + employee investment valuation which could take a while to compute and return. As a server side java guy, how do you show the employee address on the browser and then show the valuation when it becomes available.
A: I often have another thread (pool) for long-running jobs

Q: is there some rule saying a web app should not start new threads?

Q: what DB tuning techniques did you use?

Q: if you have so much data in DB and it is a bottleneck, did you try to avoid the DB?

Q: did you try partitioning?

Q: why does polymorphism only apply to methods and not fields?

##what zbs skills differentiate java trading developers

I said before that core java trading system developers need a few special skills

1) multi-threading
2) messaging
3) data structures and algorithms
?) distributed caching — trading system often avoid hitting database, so they keep large amounts of data in memory
?) java tuning
?) distributed computing using RMI, web services, ejb etc
?) Spring DI beyond MVC
?) serialization

#1 and 2 are the most broadly recognized requirements.

Now I feel most of these skills are built on top of fundamental java skills. Messaging system uses threading, serialization, data structures. Caching uses threading, data structures, serialization …

I don’t know a well-defined list of “fundamental java skills” but interviewers often zoom into threading, collections and OO. Among these, threading presents the highest complexity, but most applications stick to well-tested fool proof patterns.

I feel java generic collections (in a multi-threaded environment) is perhaps the 2nd in complexity. (I realized this after reading c++. C++ generic collections are quite a bit messier than java.) Most java developers I know never need to go beyond scratching the surface of generics.

In conclusion, to pass interviews, over-prepare on threading and collections, and prepare for high-level questions on messaging. To be a good trading programmer, become really good at threading and serialization… among other things

net revenue, unrealized pnl

For a financial controller overseeing a trading desk, MTD [1] net revenue is the profit or loss of a trading account [2]. One way to compute this number is


  Realized pnl + unrealized pnl [3] – sales force commissions [4] paid out + interest accrued while holding the security


[1] or daily or YTD – just some period

[2] or a group of trading accounts

[3] paper loss or paper profit

[4] aka sales credit

##growing in java: where to focus when learning c++/c#

I feel stronger than a rookie java developer because we are comfortable with both GTD and IV:
1) IDE
** (remote) debugging. Also consider my Perl sss()
2) threading — idioms, principals
** thread creation, synchronized, wait…
** threadlocal
** thread pool
** immutable
3) reflection + proxy
) syntax of overriding, constructors, final, singletons, generics
) design patterns — large idioms
) unit test

other signs of strength:
) generics — creating generic classes
) serialization
) garbage collections
) inner classes
) collections and data structures — choosing

What about spring, hibernate …? I feel these fads come and go.

trading sys arch IV : coding IV@best practice

Most of the SG/HK employers (UBS, RBS, Mdaq) perceive a wall street veteran (like me) more as an architect/tech-lead candidate than a senior dev. However, the tough tests are coding tests.

You would think an architect interview would not focus so much on the fine details. Well, many details (by definition of the word) are not important to an arch interview, but some (1%?) of the details are. Fundamentally, this is because any large of small software architecture is always conceived and ultimately implemented using __basic_comp_science_constructs, such as stackVar/heapVar/staticVar, thread safe iterators (loops), queues (linked list), circular array, concurrency primitives …

Another reason — the team lead would define and enforce low-level design and coding standard.

Fact is, these architect roles are extremely hands-on. In low-latency architect roles, a key value-add is the experience, insight, techniques, tools on low-level optimizations.

Among the 3 types of domain knowledge (see my other blog), your jargon/math experience is not relevant in a coding test. How about your trading arch experience? Relevant to some extent.

hibernate mock interview question

short and imprecise? ok
[m=answer found in official hibernate manual such as ]
page numbers -> [[ java enterprise in a nutshell ]]

  1. how do you process a bunch of records when you select half the columns? What kind of data structure does hibernate return? P 650
  2. how do u update a “disconnected object”
  3. why proxy?
  4. Lazy loading? (seems to be important)
  5. write a finder statement used in your (pushmail) DAO class to illustrate the difference hql ^ sql
  6. big signature of Session.load(). AR-revealing!
  7. access modifier for fields in a domain object? P 630
  8. name the 2 types of hib config files
  9. generator class=”native” means? P 627
  10. what typical java types to use for persistent fields?
  11. what happens if there’s a clash in an id field/column when writing to DB? P627
  12. describe exactly when hibernate writes to DB. I think this is covered in my blog. P643
  13. what’s a bag?
  14. describe the session object
  15. describe the query object
  16. what’s the difference between the properties file vs the xml file
  17. what performance issues did you face using hibernate?
  18. how did you integrate hibernate with proc?
  19. 2 types of hibernate caching? (2nd-level caching)

non-iview questions:
* how does hibernate manage connection pool(s)? P641
* what if you try to load one object and all the linked objects are loaded and it takes huge memory and db query resources?

common quote pricing rules + live feeds for munis

Rule: (same as FX day trader, and applicable to market making only) based on inventory changes
Rule: dollar cost averaging
Rule: based on BMA index, which is typically 70% of Libor, assuming a 30% tax exemption
Rule: on the muni desk, the swap positions and quotes are priced using SIFMA swap index and ED futures
Rule: on the muni desk, the T (and futures) positions and quotes are priced using T/T-futures price feed
Rule: based on ETF prices. If one of our quoted bonds is part of one (or several) ETF, we price our bid/ask using live ETF prices
Rule: based on Evaluation prices, received twice daily (JJ Kenny and InteractiveData)
Rule (one of the most important): based on MSRB last-traded quantity/price reported to MSRB
Rule: based on “pins” controlled by senior traders of the desk
Rule: based on The One Muni Curve of the trading desk
Rule: stock (hedging) positions (not quotes) are priced using stock price feeds

Other feeds – ION, SBA (SmallBizAdmin) feed

“Based on” generally
Always apply a bid/ask spread matrix (call dates/quantity as x/y dimensions)
Always apply a commission matrix
Apply odd lot discount matrix
Always convert from clean to dirty price
Always check for occurrence of bid/ask inversion