initialize array-of-pointer to all nulls

Suggestion 1: LimitOrder* orders[howManyOrders] = {};

Suggestion 0: P37 [[c++ coding standards]] suggests “.. = {NULL}“, consistent with P115 [[c++primer]].

See also

See also on c++11 array-init:

For an array (on stack or heap), an empty pair of braces indicates default initialization. Default initialization of POD types usually means initialization to binary zeros, whereas for non-POD types default initialization means default construction


parse FIX msg to key/value pairS #repeating group is the context.

     * Parsing to array is faster than parsing to a HashMap
    public static ArrayList quickParse(String fromServer) {
        ArrayList ret = new ArrayList(Collections.nCopies(
            MAX_FIX_TAG, (String) null));
        for (String pair : fromServer.split(SOH)) {
            String[] tmp = pair.split("=");
            if (tmp.length != 2)  continue;
            int tag = Integer.parseInt(tmp[0]);
            ret.set(tag, tmp[1]); //treat ArrayList as array -- efficient
        return ret;

Repeating group is not supported in this simplistic scheme, but could be accommodated. I can think one simple and one robust design:

Design 1: array<list<string>>, so a regular non-repeating tag will hit a singular list.

Design 2: we ought to know which tags are repeating. The message specification must tell us which tag (NoRoutingIds in the example) signals the arrival of a repeating group. Therefore, at compile time (not runtime) system knows what tags are special i.e. potentially repeating. We will build a separate data structure for them, such as a list<groupMember>. So each FIX message will have one regular array + one list

bond ref data service – practical caching strategy

Data change frequency is lower than market data. JMS-based cache update.

There's a thin database layer, supported by a dedicated developer — minimal (if any) stored proc. There's a thick java api layer, supported by a team of developers.

To avoid hitting the DB too frequently, there's an in-memory cache, to be updated whenever data changes in the DB. Some places use RV, some use JMS.

static nested classes unnecessary?

As stated in another post, I always start my nested class as “private static” and relax gradually when justified.

Now, some say static nested classes can always be pulled out as first-class citizens i.e. top level classes. No. A major feature (perhaps 2) I rely on everyday is the private access modifier in the context of nested classes.

Nested class can refer to private members (fields/methods) of the enclosing class; enclosing class can refer to private members of the nested class.

virtual inheritance diamond malformed

Both C1 and C2 should virtually derive from Base. You see the D class instantiation only calling Base ctor once. See

Now, what if we omit one of the “virtual” keywords? Base ctor called twice — tested in GCC

struct B {
    B() {
        cout << "B\n";
struct C1: virtual public B {
    C1() {
        cout << "entering C1()\n";
struct C2: virtual public B {
    C2() {
        cout << "entering C2()\n";
class D: public C1, C2 {

int main() {
    D d;

select2perform cpp questions – easy

Q: given char * const cp = ….; can you do cp[0] = ‘b’
AA: yes. const is about the pointer (no rebinding), not the char pointee.

Q: can friend-class to Derived access Base protected field?
AA: yes in gcc

Q: what are the narrow-character iostream objects?

Q[u]: anything wrong with static_cast(MyClass var2)
%%A: This is a silly question. Bad coding style.
AA: illegal in gcc

Q[u]: if a ctor takes an int arg, can you call it with a char literal?
AA (confirmed): implicit conversion from char to int

Q: can a C struct be subCLASSed?
AA: yes struct differs from class in one way only

Q: if u catch by value, modify the exception object, then do an empty throw all within your catch block, then the does downstream catch the original or the modified object?

Q[u]: what’s wrong with

char * charArray = someString.c_str()

%%A (confirmed): c_str() returns a pointer to const char. Const radiates leftward

Q[u]: when you pass std::less to list.sort(), must you append “()” as “std::less()”?
AA: illegal without ().
%%A: std::less is a class, so we are instantiating it.

Q[u]: can catch(…) be the first among many catchers?
AA: must be last — illegal otherwise

Q[u]: a class template’s static function uses the T as parameter type. Callable without ?
AA: this follows the CLASS template instantiation rule, not the function template instantiation rule. No implicit detection by compiler. You must provide explicit type argument when referring to the class template

Q: bind1st or bind2nd on std::less when used as find_if() filter
AA: here’s the idiom. We are binding 2nd parameter to the literal 1000.
Note std::less is a Class template not function template, so the template type arg is mandatory.


central bank rate hikes bring currency up or down?

Higher interest rate helps a currency short-term. Inflation (sometimes associated with increasing IR) is sure to weaken a currency. According to Wikipedia — By increasing interest rates a central bank stimulate traders to buy their currency (carry trades) as it provides a high return on investment and this would strengthen the currency against others.

I feel this might reduce inflation and increase purchasing power.When inflation is perceived to rise (easy borrowing), central banks dampen it by rate hikes (expensive to borrow).

Very roughly, Interest rate is 70% influenced by gov; FX rate is 30% influenced by gov. Central bank has 90% control on the supply of their currency (but not other currencies). FX adjustment is one of the goals of Central bank IR actions. IR actions have other serious consequences not to be ignored. In this sense, FX trading desk needs IR expertise.

The interest rate is higher on some currency because there is a probability that it will depreciate. As long as the depreciation does not materialize, the carry trade is profitable, but makes big losses when it does. High yielder currencies aren’t always safe bets.

credit risk analysis in Singapore

(a blog post. Your comments are appreciated.)

To me, credit risk is all about default risk. There's a whole industry around the rating, measurement/analysis, monitoring, hedging and control of default risk. As such, Credit risk is relevant to both investment banking (buy/sell, underwriting, M&A etc) and commercial banking (ie lending), but how relevant? I feel credit risk is one of many components of market risk in investment-banking, but credit risk is absolutely central to commercial banking.

For the Singapore financial industry, commercial banking generates (much) larger revenue than i-banking, and is a far more important industry to the national economy. Most S'pore businesses need to borrow from banks.

I guess credit risk analysis is more important than market risk analysis in S'pore.