#1 driver of long term FX #my take

Q: what is the #1 fundamental driver of long term FX rate between 2 currencies?

Is it PPP? I don’t think so.
Is it supply/demand? Short term yes; long term … this seems less relevant
%%A: “gold” backing.

In the beginning, every pound issued by the British monarch is as good as an ounce of gold (or whatever fixed amount of gold). Therefore anyone holding a pound note can exchange it for the equivalent amount of gold.  The monarch then decided to print more pound notes. Logically, all the existing and new pounds devalue. But the country also exports and, in a world of universal gold standard, earns gold. In a more realistic world, What is earned is foreign currency.

I believe Every Singapore dollar issued is backed by some amount of “gold” which in modern context means foreign reserve in a basket of hard currencies. By the way, there’s nothing harder than gold. As the national economy expands, more goods are produced domestically so the CB could issue more SGD, but I guess the CB waits until the goods are exported[2] and foreign currency earned. Such a prudent practice helps ensure every SGD is fully backed by sufficient “gold”.

[2] incoming tourists also spend their own currency, therefore contributing to the Singapore foreign reserve.

In general, a hard currency is more deeply *backed* by gold than a weak currency. Alternatively, the issuing central bank has other capabilities (besides gold reserve) to maintain the *strength* of her currency. This strength depends on Current Account and economic growth — the 2 fundamentals. Another factor is global competitiveness, but this is often measured by the capacity to export and compete on global markets. After all, it still seems to boil down to earning enough foreign currency to back our own currency — “gold” backing in disguise.


insert() — more versatile than assign() and range-ctor

[[effSTL]] P31 points out that range-iterators are used consistently across containers —

– Every (yes both sequence/associative) container supports a ctor taking a couple of range iterators
– All sequence (not associative) containers support assign() method taking a couple
– Every (yes both sequence/associative) container supports erase() method taking a couple

However, I’d argue the most versatile is the insert() method in Every Sequence and Associative containers.
* insert() can emulate the range-ctor
* insert() can emulate assign()

This is also more versatile than operator=().
This member function is also simpler than the free function copy().

y create custom STL iterators, briefly

Q: when would you write your own STL iterator?

I think if you create your own customized container, you probably need custom iterator Objects. You probably need to return such an Object from rbegin() etc.

In python, c# and (less commonly) in java, many data structures can be made iterable. There’s an implicit iterator.

[[STL tutorial]] has a 3-page chapter showing a debuggable-iterator that reveals interesting details of the inner workings of STL containers and STL algorithms.

libor vs gov bond — 2 benchmarks

Most credit instruments, all (secured/unsecured) loans, all IR products, most derivatives based on FX, IR or credit (I'd say virtually all derivatives) need to apply a spread on a reference yield. If the deal has a “maturity date” or “delivery date”, “call date” [1], then we look for that date on the reference yield curve and read a yield number like (222 bps pa) off that curve. That number is the reference yield, a.k.a reference spot rate. You can convert that to a discount factor easily. There are also straightforward and well-defined conversions to/from fwd rates, driven by arbitrage principles.

[1] perhaps among a series such dates.

Question is which reference yield curve to use. Most companies use a single, consolidated curve for each currency. One of the biggest muni security trading desks in the world has just one yield curve for USD, which is typical. Another megabank has a single live Libor curve for the entire bank, updated by the minute.

If you use more than one yield curve built from different data sources, then for any maturity date, you would read 2 yield numbers off them. If sufficiently different, you create arbitrage opportunity and your valuations are inconsistent.

On the short end of the IR space the reference curves are 1) Libor 2) Fed Funding (USD only). Libor is more popular.

On the long end, T-bond dominates the USD market. Many governments issue similar bonds to create a reference riskless rate.

However, the most liquid IR instruments are probably more realistic and reliable as a reflection of market sentiment. ED futures, Bund futures, T-bond inter-dealer market rates are examples.

c++highly parallel numerical programm`IV(smart ptr, threading…

These are mostly QQ type. Jap firm https://www.numtech.com

Q: What are the differences between win32 and linux threading Implementation? I probably won’t spend time reading this.

Q: given a bunch of 10-year old linear algebra c++ functions (using many VD or MD templates as function inputs), how would you go about extracting and packaging them into a DLL? No experience. Not on my Tier 1/2.
%%A: stateless
%%A: pure functions.
%%A: Thread safe
%%A: remove code duplication
%%A: for each function, there should usually be default parameters, so we can call it with 2 args, 3 args, 4 args etc
A: function parameters should not be templates. Ints, double are probably fine. DLL interface is defined by the platform, not the language.

Q: what’s wrong with boost libraries?
AA: (STL is fine) many of them aren’t proven — just 10 years

Q: Since you said shared_ptr is the most popular boost module, how is reference count done in heavily parallel programming
%%A: for regular shared_ptr, thread safety is a big design goal, so probably fine[1]. For intrusive_ptr, the pointee class must expose certain mutator methods, which must be made thread-safe by the pointee class author, not boost authors

[1] isn’t correct. The testing on shared_ptr thread safety isn’t sufficient for large number (thousands) of threads. See https://bintanvictor.wordpress.com/2017/07/09/shared_ptr-thread-safety-take/


double-ptr usage #2b — swap 2 pointers

(Note this is a special case of “special reseating” — http://bigblog.tanbin.com/2011/04/double-pointer-usage-2-special.html)

Q1: write a utility function to swap 2 pointer’s content.
%%A: swap(int** a, int** b) {….}
Obviously, the 2 pointer Variables must be declared to be compatible — to be elaborated [1], such as
int* a1, b1; …. swap(&a1, &b1);

To really understand why we need double pointers, consider

Q2: function to swap 2 nonref variables. In other words, after i call swap(..), x should have the value of y. If y used to be -17.2, x now has that value. Note this number isn’t an address.

In this case, you need to pass the address of x like &x….

To understand this Q2, it’s actually important to be be thoroughly familiar with

Q3: what does swap(char i, char j) do?
%%A: something other than swapping. I doubt it does anything meaningful at all. It receives two 8-bit chars by value. It doesn’t know where the original variables are physically, so it can’t put new values into those original variables, so it can’t swap them.

Any swap must use some form of pass-by-reference.

Q1b: function to swap 2 arrays. After the swap, array1 is still a pointer but it points to the physical location of array2
%%A: same signature as Q1.

[1] void ** is probably a feasible idea but may require casting. Usually the 2 arguments a1 and b1 should have the same declaration. If a1 is Animal* and b1 is Dog* (Note the single asterisks), then such a polymorphic swap is no longer straight-forward and fool-proof.

Forex trading is Singapore’s strength

(A personal blog.)

I think for the past few months in the Singapore job market (java or c++), i didn't notice any fixed income, credit, equity domain roles. There are some cross-asset system positions, and there are commodities and FX positions. I feel FX is roughly half (up to 66%) of all the roles that pays a reasonable salary.

This is a hard lesson learned — I have to deepen my FX knowledge and track record otherwise the biggest chunk of jobs stay beyond my reach.

I feel in terms of domain knowledge, FX is more relevant (to high-end software jobs in Singapore) than volatility, bond math, exchange trading, structured products, etc

But why does FX pay above other fields. Here's what I came up with
– equity is small, less active in S'pore than HK. The high-paying eq-related jobs are usually in HK
– FX is perhaps more profitable at this moment
– FX is Singapore's traditional strength for decades. #4 behind Ldn, Nyk, Tky
– FX is high speed and high volume (in terms of market-data) so this places some stringent criteria on developer skill
– FX is more electronic, more standardized, more inter-connected than FI, commodities or derivative markets, on par with cash equities. More technical skills required.

It's interesting that FixedIncome has more complexity and has more profit potential but doesn't really pay comparable salary.

real/fake market-order + limit order in FX ECN

Some popular institutional ECN’s offer 3 main types of orders. Taking buy orders for example, you can place

– limit order – to buy at or below a specified price. It might match some offers immediately. All remaining amounts on the order remain in the market
– IOC – fake mkt order – buy at or below a specified price. All unfilled amount is cancelled. This is more popular than the real mkt order
– real mkt order – order without a price

secDB — helps drv more than cash traders?

(Personal speculations only)

Now I feel secDB is more useful to prop traders or market makers with persistent positions in derivatives. There are other target users but I feel they get less value from SecDB.

In an investment bank, equity cash and forex spot desks (i guess ED futures and Treasury too) have large volume but few open positions at end of day [1]. In one credit bond desk, average trade volume is 5000, and open positions number between 10,000 to 15,000. An ibank repo desk does 3000 – 20,000 trades/day

In terms of risk, credit bonds are more complex than eq/fx cash positions, but *simpler* than derivative positions. Most credit bonds have embedded options, but Treasury doesn't.

In 2 European investment banks, eq derivative risk (real time or EOD) need server farm with hundreds of nodes to recalculate market risk. That's where secDB adds more value.

[1] word of caution — Having many open positions intra-day is dangerous as market often jumps intra-day. However, in practice, most risk systems are EOD. I was told only GS and JPM have serious real time risk systems.