clearing-member of the exchange = sponsor of a trade

Only the clearing members (big broker/dealer) of NYSE can trade on it. When you or any investor sells IBM short [1] using GS as a broker, NYSE always sees the trade under GS’s name. If investor can’t fulfill the obligation, GS is responsible.

Technically, GS “sponsors” your trade. I think most trades are sponsored this way (except trades GS does using its own money). A sponsor member like GS has to protect itself.

A pass-through broker who simply passes the order to the exchange without any check is running the greatest risk.

Same thing in other exchanges. I traded commodities in 1997. My broker was responsible to answer clearinghouse’s margin calls if I don’t. Integrity requires all margin calls satisfied (or clearinghouse has the right to liquidate your position). I had an account with the broker, not the clearinghouse, so all the positions were held under first-tier broker’s name, i.e. a member of the exchange.

[1] regular sell or buy also involve responsibilities and obvious financial risks to the broker.


top 3 subsystems – spot (and forward) FX dearler bank

There are 3 types of FX dealers – spot dealer, forwards dealer and (corporate)client-facing sales dealers covering spot and forward. They use the systems below differently.

Note ONLY the sales dealers would interface with clients (no retail client). Spot/Forwards dealers deal with sales dealers and counterparty dealers.

#1))) Heart of entire FX desk is the “position keeping system” or position-master. All “deals” are stored there, so as to “calculate current positions” and PnL. Same idea as MTS inventory-mgr and Reo main-grid.

Note sales dealers never keep positions. I believe they are internal brokers on bank’s payroll.

FX position systems usually show real time unrealized P/L.
#2))) AFTER (never before) a dealer executes trades via a voice broker, he needs to record trade details on a “deal-ticket” (see other post) and enter it in the “deal entry system”, just like MTS. Electronically executed trades don’t need this “deal entry system”

Spot trades are too many so seldom voice-based. Forwards dealers use voice brokers more often. Sales dealers do even more voice EXECUTION (often with a customer). These 2 groups definitely need the deal-entry system.

As of 2010, the most common execution model between clients and banks is not ECN (growing) or Reuters conversational dealing, but voice execution.

#3))) (Pending) order management — If a spot dealer wants to hold a position “open” overnight, she must leave a stop loss order. While she’s out, the order is looked after by the take-over time zone (NY -> SG/TK/HK -> London) which MIGHT execute the stop loss order.

Forwards dealers don’t leave overnight orders. Sales dealers often create customer orders for the spot/forwards dealers to execute.

Sales dealers can also create overnight limit orders on behalf of clients.

hide a source folder from eclipse

Background: i want “hide” an arbiturary directory (such as a source folder) from eclipse.

Conclusion: No easy way to mark a directory “please ignore me completely”, but a few tips:

* searcher — try “derived”. Also you can remove read permission from a directory.
* package explorer — try the filters, such as the “.*” is good

java String[] is O(1) for lookup-by-index

int[] has constant by-index lookup time, because system can compute address of 55th element from base address and offset ie base address + 54 * 4 since an int takes 4 bytes.

For a String[], I believe it’s the same formula. 55th string could be very long, but it’s not stored in the array’s memory block. I believe it’s the address of 1st char that’s stored in the array’s memory block, assuming the c-str implementation. Each address probably takes 4 bytes in a 32-bit machine.

More generally, any array of objects is probably implemented the same way. Note an array is also an object. If the elements in the outer array are array objects, then we get a 2D array. Outer array’s memory block holds 55 pointers to 55 inner arrays.

bond duration – learning notes

I like the official definition in Each payout has a payout-date and therefore a ‘distance’ from valuation-date. (Example: 47 months from now). Weighted average of all these “distances” is the Mac Duration.

* eg: zeros aka STRIPS — one payout-date only. If distance is 4.5 years then Mac Duration is the same. Zeros have the longest duration[1]
* eg: low coupon bond maturing in 4.5 years — Weighted average means Mac duration is dominated by the principal repayment’s distance of 4.5 years. Duration is slightly shorter than that that last distance.
* eg: high coupon bond with that same maturity of 4.5. Duration is much shorter than the last distance.

[1] among bonds of the same maturity date.

“distance” is a more visual word than the “time-to-maturity” or “term-to-maturity” technical jargon. I also like the TTL or time-to-live phrase.

Now, if we receive $50 coupons five times and then $1000, we get total $1250 [2]. Q: what’s a reasonable “average-payout-date” of this $1250? Answer is the Duration.

[2] actual formula uses present value of each payout.

Now let’s see why the zero is most volatile, i.e. “this bond’s current price swings wildly with interest rate”

Key assumption: yield is roughly correlated to benchmark interest rates (such as the overnight FedFund rate), an indication of market sentiment.

For a high-yielder, larger portions (half?) of the total PresentValue come early and suffer minimal discount (discount factor close to 100%) . Remember DF and yield are subject to semi-annual compound. STRIPS have no early payouts, so the final payout must be discounted deeply due to compounding. Impact of yield change is deep.

Remember yield of 7% is always semi-annually compounded to derive DiscountFactor. See posts on DF and yield.

container of (polymorphic) pointers (double-pointer)

If you have a vector of pointers (fairly common in practice), the iterator is nothing but a double pointer.

– If you have a deque of pointers …?
– If you have a multiset of pointers, the iterator is a pseudo-pointer of pointers.

Now shift gear to smart pointers. Container of smart pointer is extremely common in quant and other apps, perhaps more common than container of values.
– If you have a vector of smart pointers, the iterator is a pointer-to-smart-pointer.
– If you have a priority queue (binary heap) of smart pointers, the iterator is a pesudo-pointer-to-smart-pointer

P186 [[c++coding standards]] says to store polymorphic objects, best solution is
– avoid array
– avoid storing the objects directly
+ Use container of smart pointer to base class

Here are the 2nd-choice but acceptable alternatives
* array of raw   pointer to base class
* array of smart pointer to base class
* container of raw pointer to base class

assembly language programming – a few tips

C compiler compiles into binary machine code. I think pascal too, but not java, dotnet, python.

Assembly-language-source-code vs machine-code — 1-1 mapping. Two representations of the exact same program.

Assembly-language-source-code is by definition platform-specific, not portable.

A simple addition in C compiles to about 3 “Instructions” in machine code, but since machine code consists of hex numbers and unreadable, people represent those instructions by readable assembly source code.

Compared to a non-virtual, a virtual function call translates to x additional instructions. X is probably below 10.

There are many “languages” out there.
* C/c++ remain the most essential language. Each line of source code converts to a few machine instructions. Source code is portable without modification whereas the compiled machine code isn’t.
* Assembly is often called a “language” because the source code is human readable. However a unique feature is, each line of Assembly-language-source-code maps to exactly one line of machine code.
* newer languages (c# java etc) produce bytecode, not machine code.

balance-of-trade and related jargons

* balance of payment INCLUDES current-account (ca). [1] has a formula on that.

* When China sells $1B worth goods/services to US, China receives $1B USD and somehow leave that in the national forex reserve. Is that $1B foreign asset? The $1B is like $1B worth of gold in US owned by China?

— “The Economist” story 2009/01/24 —

* US current account (savings BY US – investment BY US)[2] are in deficit since 1992.

** Q9: what does “invest” mean?** A9: see [3]. In a different context, when economists talk about foreigners investing in US, i think it means foreigners spending USD in US, but not for consumption.

** Experts say US had to borrow[A] from abroad or sell[B] assets to pay for the annual deficits. (Why?)** B would decrease America’s Net Foreign Asset position.** Some articles suggest A is the main source; while other articles suggest B. I think the same transaction can be seen as A and B as 2 sides of a coin. [3] gave some examples of such transactions.** experts say this deficit was used to “finance” some “investment”, though [3] also says US sells assets (B) to “finance” the CA deficit. I guess that “investment” includes investment in biz, R&D, real estate…** experts widely believe China consumer save hugely, and their savings somehow compensate for the low savings of American consumers.

** Q7: how does “foreign SAVERS” and their money play a role?** A7: I guess they buy US properties, gov bonds, and lend to US businesses. Does exporting to US count as “investment” BY foreign savers?** Q8: in the economists eyes, Chinese savers save in USD or CNY?** A8: Neither. I think by “saver” the economists mean “China does not import so much American goods, so they earn more USD than they spend”. The surplus USD must go somewhere. I guess it mostly goes to buying/investing in US assets, which economists call “borrowing-by-US-from-China”

** Q: what does “borrow” mean? who? in what currency? I think economists mean something else

— digestibles —

* A higher savings rate generally corresponds with a trade surplus. China vs US.

* current accoutn includes balance-of-trade (bot) as the biggest component.* * Because exports generate positive net sales, and because the trade balance is typically the largest component of the current account, a current account surplus is usually associated with positive net exports.

* The net foreign asset (NFA) position of a country is the value of the assets that country owns abroad, minus the value of the domestic assets owned by foreigners.

* if a country runs a $700 billion current account deficit, it has to borrow exactly $700 billion from abroad to finance the deficit and therefore, the country’s net foreign asset position falls by $700 billion. Why? Here’s my theory. Suppose US buys $700B worth of Chinese goods/services. US must pay $700B, but US doesn’t earn that much from export to China. Mostly US sells its own assets to China to get that $700B.

* If an annual current account is a surplus of $2T, the country’s net foreign asset (NFA) position increases by that amount $2T.

* US trade deficit — Warren Buffett said “the rest of the world owns $3 trillion more of us than we own of them”, echoing [3]. I think this means over the years, accommulative US trade deficit adds up to $3T and that’s the US asset under foreign ownership.

— References —

[1][2] explained in 2009/01/24 The Economist, but why is this definition so different from balance-of-trade?[3]

error accounts

• Just like a client account, an EA (error account) can hold a security, like 100 shares of IBM.
• Just like a client account, it can hold cash.
• Just like a client account, it can hold cash in a short position like negative $1M.
• Just like a client account, it can hold a short position in a security, like -100 shares of IBM.

An error account holds any of these positions briefly. We try to reduce these positions to 0 ASAP, usually within the same day. We flatten the positions and flush the error account.

• If the EA holds cash, we *journal* it out to a firm account
• If the EA is short in cash, we journal cash in, perhaps from a firm account
• If the EA holds a security, we sell it (not sure if we journal that out)
• If the EA has a short position in IBM, we buy it to cover the short position.