preferred stock ^ convertible bond

regular preferred-stock trades in the ….. corp bond desk, along with regular corp bonds.

convertible-bond and convertible-preferred-stock trade in the the ….. equity desk, along with common stocks

Deciding factor is interest-rate sensitive. See P187 [[after the trade is made]]. In general, anything that’s IR-sensitive trades in the fixed income side. For example, convertible preferred stock can pay a fixed amount of dividend now, but can be converted to common stock, so it’s not IR-sensitive.

Advertisements

gold standard #1: inflation etc

In reality, few governments follow the gold standard, but it’s instructive to consider what if they do.

Annual gold mining output is steady and presumably quite low.

If there’s an authority controlling the total number of HK dollars in circulation [1] and that authority ensures every dollar “created” is backed by a fixed quantity of gold in its reserve, and if every country adopts a similar gold standard, then any time we would be able to mathematically convert all the dollars to gold and all the yens to gold…. and the total gold reserve is still less than total physical gold ever “dug up”. This would be a truly effective control on inflation.

Central banks could print currency easily (inflation) when there’s no gold standard, but no CB can suddenly get 10 times more gold. To obtain more gold, the country must export and receive payment in foreign currency, which are legal claims on the gold reserve of that country. In the late 19th century, many colonial powers coerced China to pay “compensation” in the form of gold.

[1] But how does that authority control banks lending huge amounts in dollars therefore creating dollars? I think answer lies somewhere around the regulation. An unregulated private lender (e.g. loan shark, venture capital, pure-play investment banks) can lend $10b and charge an exorbitant interest amount of $1t, but how does the debtor get the $1t to repay? It has to sell something then collect real USD, which is controlled by the authority. When inflation rises to 50% a year, that can only be a central bank action, not a market action.

arch: skills needed^skill-tests in IV?

Most items below are relevant for a senior developer too, but this discussion is about software architects. By “Skill” I mean something practical, relevant, value-adding… An architect should bring some of these skills to a team. Think of these as job duties, if you like.

skill – insight on the limitations of a large number of impractical/discredited designs. Everyone can come up with some solutions on-paper, but most of them won’t work.
skill – know a large number of common errors and solutions — usually available on google but way too many. You don’t need insight. Just awareness is valuable enough. This comes from “mileage”.
skill – insight on weakness and limitations of dominant, default solutions (like Oracle, linux, WCF, protobuf…)
skill – insight on project best practices and their limitations
skill – know a large number of FOSS and commercial solutions
skill – write library component for others. The more developers use the component, the more senior this author is
skill – multiple technologies (non-trivial skill with each). Most financial/non-financial apps need more than one of DB, java/c#/c++, javascript, GUI, MOM, so an architect needs proficiency with more than one technology.
skill – practical testing strategy, automated or not. Junior guys may be too busy to worry about these. Testing can be tricky.
skill – tuning, optimization. Often overrated relative to GettingThingsDone.
** memory mgmt
** data structures nitty-gritty
** threading

Those are the skills interviewers like. Here are some evidence interviewers look for —

evidence – ability to clearly describe past systems, their design trad-offs, architecture, challenges, limitations,
evidence – ability to draw simple (but effective!) diagrams to illustrate any technical design
evidence – contribution to FOSS
evidence – know algorithms and their computational complexities. Google? Often overrated.
evidence – can identify and apply comp science constructs to programming problems, independently, without guidance — tough. Often overrated.
evidence(?) – know the “gory” details of popular languages
evidence – brain teaser mastery
evidence – design patterns. This is one of the laziest interview tests — ask the candidate to describe how he employed DP.

flow ^ prop trading – according to a young quant

Consider a typical flow trader Fay and a prop trader Peng in an investment bank.

Fay only trades with the registered clients of the bank, typically institutional clients, but also some ultra-rich individuals. Peng seldom trades against the clients of the bank. Peng has an unfair information advantage over those clients. Peng typically trades against other counterparties.

Peng doesn't have to hedge, whereas Fay needs to hedge every trade. Each trade with a client creates a position with a risk. At COB those will contribute to VaR. If it exceeds the VaR limit for Fay, then manager will require Fay to hedge or liquidate. Sometimes Fay's trade creates no position at all.

upstream, knowledge-intensive, high-margin sectors for S’pore

Upstream/strategic, knowledge-intensive, high-margin, high-barrier sectors for Singapore

Singapore is traditionally not a high-tech economy…. To compete, Singapore must seek greener pastures and keep a steady foothold therein. This is what every advanced economy does.

Role models? Switzerland, Hongkong, Taiwan, Silicon Valley, Boston

Entry barriers due to large capital, specialized know-how, talent shortage… Singapore EDB likes a sector with such barriers.

RnD – upstream, knowledge-intensive and entry barrier.

— Now the sectors —
$ finance — #1 most special (“sacred”) sector. One of the pillars of the economy but finance is first among equals [1]. Unlike other pillars, finance is part of the life support of this nation. Singapore gov needs long term strategies to protect (its currency and) financial health, even survival, of the nation. It grows a deep foreign reserve and invests it long term.

Not sure if finance is the most high-margin sector. Commercial banking is lower margin; AssetMgmt, security trading and investment banking create few jobs.

[1] if you shortlist the pillar industries of { oil, logistics}, where Singapore competes successfully on the global arena.

$ oil — perhaps the #2 sacred sector.
$ medical
($ life science? not sure what this includes)
$ electronics
$$ semiconductor fabrication – at the higher end of electronic sector
$$ IC design, esp. microprocessor design – still higher margin

$ telecom equipment and telecom operator — 2 big sectors by revenue
$ enterprise IT solutions, including software production and distribution
$ consumer IT product creation. Not a big sector, but look at Creative Lab
$ aviation — at the higher end of the logistic sector. Servicing, component design, research, airport ..
$ higher education and training

————
Now a small sample of the opposite list. Many traditional sectors don’t meet all the criteria in the title but do support a lot of jobs for Singaporeans —
– logistics?? Singapore’s traditional bread-and–butter economic contributor (commerce is another), but margin is deteriorating.
— distribution, warehousing
– commerce
— traditional retail – i.e. consumer shopping
– construction
– tourism and hospitality, casino
– entertainment – online/electronic gaming, music and film
– marketing and advertising, media, publishing, exhibition, conferencing

Many of these above sectors are domestic. They don’t directly contribute to the Singapore Team on the international front — contrast electronics, aviation, medical, tourism… Every advanced economy must show competitiveness and high value-add on a number of major global markets.

troubleshooting bloodshed c++

If you get 
[Linker error] undefined reference to `__dyn_tls_init_callback’
Then maybe 2 mingw versions are in conflict. Try renaming c:\mingw to something else
Here’s a better solution — http://www.allegro.cc/forums/thread/472245
Use the /lib and /mingw32 folders in your own mingw to overwrite those originals in the dev-cpp folder.
It may be safe to remove the mingw32 folder.

savings bank making loans

Edward,

(New thoughts below. We were distracted by “fractional reserve banking” concept, which doesn’t apply to Thomas, OrangeUnion or KS. For a real example, I actually deposited $1600 in Citibank but I know I can’t take out $5000.)

Suppose Thomas is a small venture fund with $2 million of real cash. Thomas likes a start-up called Prism so he invests $2m in Prism. Now Thomas has $0 balance. Thomas likes another start-up CakeHealth, so he invests $1m in CakeHealth.  Both cases, Thomas gives a check from his CapitalOne corporate account. Both start-ups have bank accounts in Chase. When CakeHealth cashes in the $1m check, it bounces.

In theory, CapitalOne may implicitly give Thomas a credit line of $1m when CakeHealth cashes the CapitalOne check drawn against Thomas’s depleted account. Question is how much credit. In fact, since there’s no collateral, I doubt CapitalOne will give the $1m unsecured loan. If CapitalOne were so generous, then many Thomas’s would queue up to take advantage of it — deposit $100k and take out $200k to buy gold. Bank would soon collapse. I know that in reality a commercial bank like CapitalOne looks at each application when handing out loans — not implicitly or automatically approved.

That’s story 1. Now Story 2. Orange bank is a tiny private (unregulated) savings union not registered with Fed or FDIC. It can’t even print checks. OrangeUnion takes deposits from local residents totalling $20m. Depositors mostly use CD’s. Then a McDonald’s franchise shows up to borrow $20m so OrangeUnion lent her. Then KFC wants to borrow $10m and OrangeUnion lent him. Both loans mature in a month and get repaid. Then McDonald’s borrows $22m and KFC $11m, but for 10 years. Now OrangeUnion must be careful because it can’t get the money back quickly. 

But let’s analyze the first OrangeUnion 2 loans. Suppose the $20m deposit is maintained in a Citibank account owned by OrangeUnion. McDonald’s gets the loan amount in a $20m Citibank check. McDonald’s owner deposits that in her corporate account in Citibank (Citi just transfers the $20m from one account into the other.) Then she writes a check of $20m to pay her supplier. No problem. Orange’s Citibank account and McDonald’s bank account both become $0. Now KFC gets the $10m loan from OrangeUnion in a Citibank check and tries to deposit it into KFC’s account with Wachovia. Check Bounce? In that case, this OrangeUnion has absolutely no leverage as a lender. It can only lend out $20m if it has $20m deposit.
I now think OrangeUnion (or Thomas) has no leverage.

Story3 is a regular savings bank — say AppleBank. Somehow AppleBank does have leverage. If it has $20b deposit, it CAN lend out more than that. What’s the real difference between AppleBank and OrangeUnion? I guess answer is the regulation. The central bank gives AppleBank its leverage and central bank has some kind of control over its lending practice.

Story 4 is an investment bank KS. No Fed no FDIC. KS __borrows__ $3b from short term money market, but how can it lend $2b to Shell and then $4b to BP in investment banking deals? Say KS checks are issued from BofA, when both Oil companies take money out of the checks, they will more than deplete the $3b cash KS puts into its account with BofA! The BP check will bounce?

Note KS has to _borrow_ from money market because it can’t freely borrow from central bank — no fractional reserve banking for KS.

every trader has a view on at least one primary "variable"

All traders have an view/forecast on some fluctuating “price”. If someone says “I don’t forecast”, she probably follows the majority’s view. Majority is wrong most of the time — See http://bigblog.tanbin.com/2011/11/more-information-you-have-less.html.

$ FX traders (buy/sell side) — forecast forex movement. Corporate treasurers are typically see long term. HF and market makers are often short-term. I believe a typical dealer bank worries about even an “overnight” position in any foreign currency.
$ Government bond and IRS traders — forecast IR movement.
$ Crop bond traders — forecast IR and also credit changes, because (my observation) perceived credit quality of issuers affects market value of bond.
$ Stock traders (b/s side) — forecast stock movements. Most mutual funds (most are in equity) add value by forecasting long term, including W. Buffett.
$ Index traders — forecast an entire stock market’s movements.
$ Volatility traders — forecast volatility movements, in addition to underlier movements. Even though vol traders can delta hedge, they still have a view about underlier movement.
$ Commodity traders — forecast commodity price movement. There are probably other factors, but I feel supply/demand is more important in this domain than other domains, because supply is limited and demand is steady. Both are less subject to manipulation.

ADO.net^linq^EF #random notes

churn alert …

Inside Microsoft camp, I feel the 3 generations of dominant[1] DB access tools are ado, linq2sql and EntityFramework. I feel this is a churning field, so a lot of popular technologies will come and go. ADO/ODBC tends to survive longer. (My experience and focus is WPF/WCF…)

[1] Any time in the dotnet history, there would be “chims” challenging the gorilla. I don’t even know their names, though some may grow quite popular.

A) Ado.net is like the basic jdbc. ADO works with DataSet and DataTable. Better performance than any ORM (Linq/EF), because it doesn’t do mapping to objects.
http://msdn.microsoft.com/en-us/library/bb399365.aspx says There are three separate ADO.NET based LINQ technologies: LINQ to DataSet, LINQ to SQL, and LINQ to Entities. 1) LINQ to DataSet provides richer querying over the DataSet; 2) LINQ to SQL enables you to directly query SQL Server; 3) LINQ to Entities is less popular and probably more ambitious and complicated.

B) L2sql and EF both generate SQL queries, often unoptimized.

B1) The DataSet is a disconnected programming model in ADO.NET. L2DataSet is an  upgrade/enhancement/expansion

B2) LINQ to SQL is for developers who do not require mapping to a customized, conceptual model. LINQ to SQL enables developers to generate entity classes from DB tables. Rather than mapping to a conceptual data model, these generated classes map directly to database tables. You can easily mix LINQ to SQL code with existing ADO.NET applications

C) the competition between the simpler L2SQL vs the bigger EntityFramework.
LINQ to SQL is a simple and easy to use ORM system. It allows for only simple inheritance or association features. There was talk awhile back about Microsoft retiring it, but it is likely to be around for awhile.

EF is more suitable for complex object graphs. It allows for more complex inheritance or association features. EF shares many features with Nhibernate.

tick data feed – mkt-data distributor

  • You have a ticker feed, a queue that the feed can push onto, data workers that consume the queue, and subscribing listeners to the data workers.
  • Explain a non-blocking, scalable algorithm for how the data workers can transfer the data to the listeners.
  • Suppose some listeners consume messages slower than others. Suppose some listeners are only interested in certain tickers.
  • Suppose the ticker feed pushes data on the queue in bursts, how might you ensure the data workers don’t needlessly poll an empty queue?

That’s original question. I feel this is fairly realistic market data system. I covered a a similar requirement in http://bigblog.tanbin.com/2011/08/max-throughput-live-quote-distribution.html

I feel a data worker deals with 2 “external systems” — big queue + listeners. The queue is a messaging FIFO thing (not necessarily JMS queue) to be polled. When it’s empty, data worker threads should wait in wait(). A socket thread can probably receive new data and notify data workers. When all the workers have processed a given message, it needs to be removed — See the same blog above.

I feel non-blocking kind of comes by-default, but maybe I don’t understand the question.

Message filter should probably be implemented in the data worker. See the same blog above.

To ensure slow listeners don’t block fast listeners, I feel we need multiple threads per data worker. In contrast, the Simple design is that data worker thread is also the thread running the onMessage() methods of all the listeners.  Multi-threaded data worker is probably a common design.

slist iteration with concurrent add()

Mithun,

Thanks for the interview question —

Q: Can you iterate over a LinkedList while another thread adds or removes elements? How might you make it thread safe?

If a long linked list is super busy with a lot of add/remove, then we may never finish iterating — we get ConcurrentModificationException every time.

I feel solution depends on length of the list, how critical is iteration vs add()/remove(), performance requirement etc.

I feel your initial idea is plausible — make a copy of the entire linked list before iterating. But when we make a copy, we need to iterate — chicken and egg problem.

How about iteration-free copying? Get a node, copy it, then read the “nextNode” pointer to reach the next node. This way I implement my own loop. Must handle concurrent modification. Not easy, but at least I don’t get exceptions. In contrast, Similar home-made solution is harder on vector/hashtable/deque as their reallocation is more complex.

I also like your 2nd idea of a custom linked list, where add() operations are customized. This is fine if iteration can finish quickly or add() is infrequent. However, If add()/remove() are time-critical, then we need other solutions.

If we need to iterate a long linked list that’s super busy, then the __design__ is probably wrong. Why not use a database?

Alternatively, split the long linked list into shorter lists. Easier to iterate.

matrix: 4×3 = 4 ROW * 3 COLUMN

Matrix A is a 4 x 3 matrix — 4 rows * 3 columns. “4 x 3” is a shorthand, with missing words implied. You need to fill in the missing words “rows” and “columns”. Recall C# rectangular array.

—- 2nd step on your journey: matrix multiplication.
Consider first a simple multiplication: a 2x9 * 9x1 is possible, because each 9-element ROW in A (left operand) matches each 9-element COLUMN in B (on the right). Only then can they multiply.

Result is a 2x1. [2]

Easiest example to start with is a tiny LHS matrix and a one-column RHS matrix. Note this is simple but practically useful. Multiplying larger matrices always boils down to a one-column RHS matrix —

Using 3 as an example,
3×3 * columnar  = another columnar matrix of length 3. Very common pattern.

Matrix multiplication emulates linear systems [1]. For this to work, the matrix must be square and the N unknowns must be written as a Column matrix.

[1] linear system of order-4 consists of 4 unknowns in 4 LINEAR equations — no x2 or y3. I think polynomial equations are not solved with linear algebra.
[2] this multiplication succinctly describes a family of 2 linear equations involving 9 unknowns. Result of the multiplication is a 2-row, 1-column matrix i.e. the 2 values on the right of “=”

—- next lessons

identity matrix
inverse matrix

eigenvector
determinant

c++ private ctor – purpose, subverting …

Q1: what are the consequences of making a class’s ctors all private?
A1a: can’t subclass.
A1b: can’t Embed in another class as a nonref field.
A1c: Outsiders can’t instantiate stack instances, and call qq(new MyClass) either — tested in my IDE. There lies a difference with private dtor —

$ A private Destructor prevents instantiation of ALL nonref like qq(Myclass myObj), either as a stack instance or as a global variable !!
$ A private Destructor prevents explicit delete of MyClass like qq(delete myPtr) but
$ A private Destructor doesn’t prevent qq(new MyClass).

See also P146 [[more eff c++]]

Now back to private ctor.
Q1b2: but how about java-style has-a? Note in java, all reference type fields live in the host object as a 32-bit pointer whereas the pointee lives outside the real estate of host object. C# struct fields live right on THAT real estate. C++ nonref fields are like c# struct.
%%A: I think a private MyClass ctor won’t affect host object instantiation because host object can use a null ptr field. Later on that ptr can reseat to a MyClass instance returned from some function.

Q: how about protected ctor?
%%A: can subclass. I think this is used mostly for virtual inheritance.

Q: what are the alternatives?
%%A: make Destructor private. See also P146 [[more eff c++]]

Q: justification?
%%A: there’s just one dtor to manage, but any number of ctor’s.

Q: if it’s not water tight, then how can it be subverted?
%%A: friends

parity rules in security valuations, briefly

Each is arbitrage-enforced, but to different extents.

parity – Put-call parity – doesn’t hold for American style. Most listed options are American style.
parity – In-out parity in barrier options

parity – Uncovered interest rate parity. Not widely observed.
parity – covered interest rate parity. Widely observed. See evidence in http://bigblog.tanbin.com/2008/09/spotforward-fx-and-ir-of-both.html

parity – PPP i.e. purchasing power parity

learning multiple comp languages — interference? slowing down?

XR,

You once mentioned that some developers feel frustrated that learning too many languages together can be slower than learning one at a time, because the language differences are confusing, and can mess up the mental structure[1] of a single language, in our head. When we start, we may know 200 features of C++. By the end, we have a shaken confidence in 30 features because we no longer remember if Feature A is for C++ or C#, and we may mistakenly assume Feature B (belonging to C#) is also in C++.

I seldom have such a problem. Every time I discover a language difference about a bunch of features, those features become quite hard to forget.

For me, the key is to discover the difference by myself and then blog about it, like I did in http://bigblog.tanbin.com/search/label/c%2B%2B_vs_%20java_vs_c%23.

If a language difference is presented to me in someone's write-up, i often have difficulty internalizing it. I often reach a deeper or higher level of understanding, then write about my own findings. Then, this difference is no longer spoon-fed to me, but metamorphose into my own discovery.

Such a process takes effort each time, so I don't do this every time. I feel learning multiple languages inevitably takes effort, if we want to compete with others in the “knowledge” contest. No pain, no gain.

[1] Speaking of the =:structure:=, all well-designed languages have a ton of nitty-gritty features (200++ pages) organized into a clean structure built on a small number of key principles. Without such a structure, a language is hard to learn and won't catch on. In fact, this is a criticism on perl. I know perl the language has structure and strong principles, but perl appears less structured than most languages.

[11] fwd: chicken head vs phoenix tail

JL,

My 2 cents worth as a fellow software programmer…

I feel you have potential as a lead developer or even chief architect in a team, but I don’t know how large (by headcount) a team. I myself don’t have enough political sensitivity or influencing power to operate at the top technical echelon or a large company (like Intuit), so I only aim at the team lead or better still, lead developer level. (I feel I have the perception to see through confusing/subtle technical issues though.) It’s important to have a specific self-assessment as to how high you feel you can rise, so my suggestion #1 is to think hard about “how high” and in what type of company (big/small, start-up, product vendor, RnD…).

Some things we can do at age 55; other things we can’t (meaning unlikely) do after we pass 40. For example, switching from team lead to a director is doable at an older age. Mastering (beyond the basics) java/c# on large enterprise projects takes years and can be hard when we are old — very few people at that age accept a junior java dev role; most team members are in their 20’s; interviewers may not like the idea… My suggestion #2 is to list out what kind of opportunities will disappear in 2 years.

Personally, I always emphasize Accumulation. These 2 years of working should build on my previous 10 years, and make me a more valuable contributor. Random jumps won’t accumulate, as a rolling stone won’t gather moss. It’s rare for a big company to need skill in both java and php. If my long term specialization is java, then 2 years in php is not effective accumulation. My Suggestion #3 is to avoid dispersion of energy or “spreading yourself too thin”. A questionable exception — If someone is already expert in win32 programming (for example), then she might want to branch out to database tuning or whatever, because of “diminishing return”.

I think all my suggestions so far are rooted in a long term career vision. However, software guys often witness/experience too many destructive changes to have a vision. If you aren’t sure about long term, then perhaps play it safe. Go for more money, better family life, more job security, more mainstream technologies and brand name companies (adding credibility to resume). These choices are less likely to be a waste of time.

Let’s face it, thanks to destructive changes or whatever, most of our past years are a waste of time. (If you remember thermodynamics) We are particles in hot air, getting knocked left and right. The trick is how to reduce loss of energy and accumulate momentum.

I feel you have always wanted to get into java in a big shop. In that case this is a rare opportunity.

java IV for quant #ANZ

JNI is not thread safe? Suppose we have 10 simultaneous requests from Swing GUI and 10 threads in the java server, each calling the same JNI quant function. What’s the threading scenario? Will there be 10 independent JNI calls that don’t interfere with each other? I feel in the c++ codebase the 10 threads may clash.

Q: What RMI reliability issues and solutions did you see (you said JMS is rather reliable)?
%%A: In my apps, there are few reliability issues observed — because it’s production, but the request volume is probably much lower than the JMS requests. Once a while, there are error messages in the log, possibly related to RMI calls.

Q: For swing-server communication, when would you use RMI and when JMS?
%%A: JMS for large volume, request queuing.
%%A: JMS for request forwarding.
%%A: JMS is flexible for asynchronous request/reply
%%A: JMS requires queue/topic set-up in the broker (except temporary queues) — extra admin effort. Tibrv is clean and nice. RMI is also simpler.
%%A: RMI is quick and dirty (inefficient). Requestor blocks briefly to get a quick response.
%%A: if you must get a response before proceeding, then RMI or web service is better than MOM

What’s the memory organization in an JNI process?
%%A: java+C stack + java heap + c heap + c globals

Q: Between sync and async, What’s the difference in your application code?
%%A: sender app is indifferent. Receiver uses sync receive() call or onMessage()

return value optimization, again

See also http://bigblog.tanbin.com/2010/09/return-value-optimization.html. There’s also a brief but complete item in [[More eff c++]]

Q : what are required for RVO? (From MS CVA interview. Obscure detail but a halo)
A: copy/move must be available (not private not deleted)

Q: when would RVO kick in?
%%A:
– object created as a nonref auto/local/stackVar in the called function
– return by value (pbclone)
– return value is assigned to a new variable.

Q: what conditions would suppress RVO?
??

Such performance features are good to know, but I feel we don’t need to predict, count on or avoid RVO. In a given context, it may or may not happen and our app should work correctly nevertheless.

sell at exactly $55.5, !!higher !!lower

Sometimes you want to sell at exactly $55.5, not higher not lower.

If your FA/broker sells lower than you asked, then you are obviously unhappy.

If you get sold higher than you planned, you may regret too, because you bought at $57! You wish for the price to recover. You have a max loss tolerance (and a stop-loss order) so you want to wait till $55.5 and then give up. In this case you gave up too early. If you repeat this frequently, you are a chicken.

Now turn to buying….
Q: As a buyer, when would you regret buying lower than your target of $55.5?

A: say you tell broker to buy at $55.5 if market condition remains calm. Earthquake! Broker bought at $27, half your target price. You fire Broker because he didn't know how to judge “market condition”.

interpret a buy trade — non-trivial

When someone BUYS a block BUY, she may want price to RISE, so that she can sell sooner. In this very realistic scenario, if she sees part of her big order filled at 10% below the original “arrival price”, she would be devastated. As a margin trader, she may collapse. Her broker would force a big sell at the market price, sinking the entire market further.

For a high-frequency buyer, rise is better AFTER her buy executes. Fall is unfortunate, but now he could buy more.

Rule — Most buyers (big or small, short or long term) wish that their buy was at some kind of turning point.

When someone BUYS a block BUY, she may want price to NOT RISE, so as to minimize impact. She may want to slowly and discreetly execute a big trade.

When someone buys, price generally tend to rise — think of the order book. However, she may want price to FALL, so she can buy more at a better price. This would be the scenario of a agency trader executing a large buy order at the “arrival price”. Client might be Warren Buffett, who wants to buy and hold 900m shares. In this case buyer wants price to FALL during order execution.

Rule — In conclusion, a buyer may want a price drop or price rise.

Rule — a buyer may be either bullish or bearish.

A bear may have sold first, and is now buying back.

uncontended lock grab !! as cheap as unsynchronized #pthread

Some java authorities claim that uncontended lock acquisition is so cheap that it's almost “free” — comparable to no locking at all. I see opposite evidence

Evidence: java Vector and HashTable are superceded by no-lock classes. Even if a HashTable object is never shared by 2 threads, the uncontended synchronization is still considered expensive.

Evidence: pthreads standard recognizes that synchronized versions of getc() will result in “serious” performance hits for single-threaded apps, and added 4 unsynchronized functions —

getc_unlocked
getchar_unlocked — same as getc_unlocked ( stdin )
putchar_unlocked
putc_unlocked

These are like the ArrayList and HashMap in java.

hibernate losing popularity on Wall St?

XR,

I’m always rather suspicious about newer app-dev technologies – android, distributed cache, weblogic, ruby, php, jaxb, xls, web service… I feel all of these (including superpowers Spring and WPF) will have to stand more tests of time.

With the decline of EJB, I don’t know what weblogic, websphere and JBoss are good for. Servlet containers? But tomcat is quite adequate?

Now I feel hibernate is not as popular as it used to be, at least in finance. My recent Wall St projects all decided not to use hibernate. We chose JDBC. It’s not that we don’t know hibernate. We know it well enough to avoid it.

It actually took these many years (5 +) for wall st developers to see the value/cost/benefit/limitations of Hibernate. Therefore, in the first few years of a new technology, it’s hard to predict if it will catch on, dominate and become entrenched. Over the past 30 years, only a small number of app development technologies achieved that status – SQL, MOM, threading, browser-based enterprise app, Excel, socket, javascript, and of course java/c++.

the more information you have, the less randomness you see

Nick,

In a given market (say some commodity – favorite example), big players don’t see randomness. They see price actions as a result of a few big players’ positions and decisions. Small players (I was once trading copper, soybeans, wheat..) see randomness.

When I was a boy I enjoyed pouring various liquids into the “home” of ants — random events to the insects. I guess some “smart ants” could record rainfall and build statistical models based on this kind of observed randomness. It gives me nightmares of building a nice-looking palace on quicksand.

Here’s a gross simplification — When we don’t have the information about what move the market, we build some theory of randomness to explain it.

Another analogy – a falling leaf in a wind lands in random spots around the tree. We could build a theory of randomness, but what if the wind come from 10 powerful electric fans?

In hindsight people see nothing random in any market. This is remotely related to the 3rd part of the black swan theory. In hindsight we often know exactly who (possibly a large herd of investors) did what to create a surprise (possibly a black swan) and cause a big loss to a lot of uninformed investors. In such a scenario, the math models are not extremely useful.

“Herd” reacts to wolf howls and shepherd.

pushd popd – top 5 tips

  • pushd dirA ###  1) push current dir, 2) push dirA, 3) Enter (i.e. cd into) dir1 i.e. the new top
  • popd ### without arg — means 1) pop 2) Enter the new top in the stack. I guess the item “removed” is forgotten completely.
  • pushd ### without arg — means 1) swap top two on the stack. 2) “Enter” (i.e. cd into) new top
 –Gory details
### I feel top item is always, always kept in sync with current dir. An understanding of the stack is essential. The stack is shared by cd, pushd, popd.
  • cd – ### a single dash — means “Enter” previous directory (in history, not the stack). Overwrite top.
  • pushd +2 ### means 1) identify the 3rd (not 2nd) on the stack. Rotate it to top. 2) Enter new top
  • cd dir1 # replace top item on the stack with dir1
  • dirs -v # print stack. Readonly operation.
  • popd +2 # identify the 3rd (not 2nd) on the stack and remove it. Don’t change current directory, since top is unaffected.
  • popd +0 # Probably pop the top. Enter the new top.

credit business vs rates business

YH,

You asked about credit business vs rates business. Here’s a simple difference —

A bank’s credit department are interested in and monitors individual bond issuers including corporations and municipalities.

Interest rate department are interested in national economies. The issuers in this contexts are national governments, with the ultimate power to print money. Usually these issuers have no credit default risk.

Now is special time. I feel Greece doesn’t t have the power to print money which is euro, but the European Central Bank feels reluctant to print money for Greece.

another example of Forex-IR interdependency

When a government (Argentina,Greece…) is facing escalating borrowing cost …

It can devalue currency by printing lots of money (Germany in 1923)

It can default (and also devalue currency), like Argentina did around 2002

It can tighten its belt, increase taxes, reduce gov spending like welfare, increase productivity, endure increasing unemployment …

When Argentina’s new bond’s interest rate hits 700bps, why would existing bonds devalue on the secondary market? (Let’s put aside the factor of default risk.) I already discussed this on my blog, but now i feel invariably it’s related to currency depreciation. Rational Investors feel the supply of this currency has to increase and therefore devalue, because the government must print more of this currency to service debt.

But events in late 2011 are different. I’m not sure if currency is even a factor. When Italy’s new bond hits 700bps, we know the Italian government can’t print more euro as ECB is now in control. I would say the main reason for the escalating borrowing cost is default risk. Secondary bond market is unrelated to issuer’s borrowing cost, but here bond yield also increased, probably due to default risk.

One thing for sure — exchange rates, interest rates and credit risk affect each other in many ways.

intuitive – basic equivalence among option positions

To a person unfamiliar with options, there’s confusion over the interchange-ability among

Long call
Long put
Short put
Short call

(Focus on regular options and ignore barrier option for now.)

Simple rule – in FX options,
– call-buying===buying-put;
– call-writing===writing-put. Not equities, index or commodity options though.

There’s never any equivalence between long vs short option positions. A short position (call or put) represents unlimited downside in FX. An experienced FX option trader once said option-writing is abhorrent.

After we get comfortable with these equivalence rules, then we can throw in PCP (put-call parity). Mixing PCP and the equivalence rule too early leads to brain-damage.

import/export always involves forex trade#my take

A Chinese toy maker may advertise her products in both RMB and USD, and you may think that Walmart buying these products doesn’t involve any forex transaction.

However, what about the suppliers (and workers, and rent) of the Chinese manufacturer? Those payments must be in the local currency. (Most manufacturers have a margin below 30%, so) typically at least 70% of the money Walmart paid must be converted to RMB sooner or later.

Even the remaining 30% (or less) is often repatriated to local currency as well, but i can only speculate some of the reasons —
– dividend payout or owners taking out profit
– expand the business
– fund a new business

Incidentally, I believe the advertised USD price is often uncompetitive. Walmart (the buyer) gets more competitive prices from a forex dealer bank. Larger amount and higher credit of Walmat’s would help narrow the bid/ask spread. The advertised USD price is either rather high (for smaller customers) or requires a large order size.

async (almost)always requires buffer and additional complexity

Any time I see asynchronous (swing, MOM etc), i see additional complexity. Synchronous is simpler. Synchronous means blocking, and requires no object beside the caller actor and service actor. The call is confined to a single call stack.

In contrast, async almost always involves 2 call stacks, requires a 3rd object in the form of a buffer [1]. Async means caller/sender can return before responder/callback even gets the message. In that /limbo/, the message must be kept in the buffer. If responder were a doctor then she might be “not accepting new patients“.

Producer/consumer pattern … (details omitted)
Buffer has capacity and can overflow.
Buffer is usually shared by different producer threads.
Buffer can resend.
Buffer can send the messages out of order.

[1] I guess the swing event object must be kept not just on the 2 call stacks, but on the event queue — the buffer

Q: single-threaded can be async?
A: yes the task producer can enqueue to a buffer. The same thread periodically dequeues. I believe swing EDT thread can be producer and consumer of tasks i.e. events. Requirement — each task is short and the thread is not overloaded.

Q: timer callback in single-threaded?
A: yes. Xtap is single-threaded and uses epoll timeout to handle both sockets and timer callbacks. If the thread is busy processing socket buffers it has to ignore timer otherwise socket will get full. Beware of the two “buffers”:

  • NIC hardware buffer is very small, perhaps a few bytes only, processed by hardware interrupt handler, without pid.
  • kernel socket buffer is typically 64-256MB, processed under my parser pid.
    • some of the functions are kernel tcp/udp functions, but running under my parser pid

See which thread/pid drains NIC_buffer}socket_buffer

biggest market mover: seldom a large number of small players

(need a better title…) When people say things like

“the market has discounted …”, or
“the market has priced in …”, or
“the market rejected …”, or…

they seem to suggest a large number of roughly equal players collectively feel a certain way and the resulting market price[1] reflects their collective reactions, interpretations, outlook and sentiment. (Some may argue that the result reflects 2 camps — bears vs bulls.) But I feel it’s naive and simplistic. Often market price is (legitimately) influenced by a small number of power players.

Case in point – The largest markets — currency, interest rates, sovereign debt — are supposed to be the hardest to manipulate due to sheer sizes, but are actually influenced by a few individuals in big hedge funds and governments, people like Soros.

People tell me investment banks are not prop traders and legally restrained from hedge-fund tactics, so these people feel i-banks actually have less influence on these markets. I am skeptical. Big banks operate at the center of “information vortex”, an enviable position of influence. They WILL exploit it.

Speaking of forex, how about the non-speculative “hedgers” — like big multinational corporations who transact in multiple countries? I feel they aren’t in the business of moving billions of dollars everyday to manipulate market, (though they move billions annually). I might be uninformed.

In a typical forex market, a 100mio [3] order is likely to cause market impact as it sweeps up a lot of limit orders on the other side. I feel many players have the credit limit to send 100mio orders. If a forex rate gains some pips over 24 hours, it might be due to such orders. However, these effects are still small and temporary — A forex rate often shifts 20% over 12 months.

[3] this figure is mentioned by some FX veterans in 2011. It’s documented since the 90’s that a single large trade by a corporation CAN indeed move the best bid/ask, at least in the short term.

Another factor to market movement is information asymmetry. Information is key to investor behavior. Big players gets more information. They radiate and manipulate information while small players largely receive (then filter) information. Among the consequences, a large number of small players can be influenced to buy/sell a security and therefore move a market.

Let’s ignore herd instinct[2]. In any market with a standard order book, the mid-price is the most prominent but its design gives a lot of influence to a single player with deep pockets. All the smaller players can be sidelined quite easily.

[2] (which is the more important reason big players can influence a market).

Case in point – Commodities markets are influenced by big suppliers/wholesalers, and to a lesser extent big investment banks.

Case in point — Corporate securities – bonds, stocks, CDS – are easier to influence and susceptible to manipulation.

[1] Note the one numeric indicator referred to is …. the oscillating mid-price. In these statements, “The market” actually has a more complete meaning including
– depth of market — sizes of “next best” quotes
– all the recent trades in that security
…but it’s ok to simplify everything to a single number.

prop trading =\= principal investment

An investment bank does both proprietary trading and principal investment, using house money (bank's own capital), but what's the difference between the 2?

PT is trading – short cycle, fairly frequent.

PI is investment — supposed to be long term strategic investment. Quite often, security is not publicly traded, in which case you can't quickly sell out.

I believe PT is now being moved out of investment banks, but no PI. An i-bank's PT desk can “bet against” its clients. PI is less harmful/damaging, at least on the surface.

 
Example of PI — Goldman's long term strategic invesment in ICBC.

deleverage and deposit-taking bank holding company

A common theme in finance — Pure play investment banks push into high leverage to achieve profit margins much higher than commercial banks could. Any Downside?

1) profit is magnified by leverage, so is loss. I guess Lehman collapsed under the weight of leverage.
2) Leverage always requires borrowing. In a credit crunch, cost-of-funding, i.e. borrowing cost could suddenly escalate for no apparent reason.

Leverage means borrow $1m to trade $20m worth of security. Leverage is a power tool in the hands of masters. In Goldman's case, the big share holders are the (skilled) partners. I guess these “masters” decided to push up leverage (with risk control in mind) to increase profit and return on their share holdings.

Investment banks achieved such leverage because they weren't highly regulated and restrained as commercial banks. In 2008, GS and MS abandoned that “freedom” due to Item 2) above. As nominal owners of commercial banks (i.e. bank-holding) , they could now borrow at a much lower rate, probably from the US central bank. I guess the amount they could borrow from government was about a trillion dollars for each bank. See http://www.newyorkfed.org/markets/pdcf_faq.html.

Commercial banks and universal banks typically borrow at the deposit rate — the rate on your regular savings accounts. In a credit crunch, these banks have trillions of deposit dollars to provide liquidity to themselves (banks), which means these banks could use the deposit dollars to pay creditors. Icing on the cake — in many countries, deposit dollars are insured by governments to protect consumers, and also to reassure depositors not to create a run on a bank.

With more regulation, leverage ratio must reduce, so does profit margin. However, I am not sure if GS or MS had lower profit margins as a result.

Another (related) form of leverage is margin trading and wide spread in
– listed option
– futures
– FX spot, options
– a lot of cash equity trades

requirements to debug into c++ from another language

The driver app (java, c#, MS-excel …) had better use dynamic linked library to access C++ code. (Not sure if a static library can suffice.) Before the app terminates, we attach our debugger (gdb, MSVC etc) to that process.

http://forums.codeblocks.org/index.php/topic,6419.0.html has a popular write-up about MSVC debugger. i guess if you use g++ to compile, then you may need gdb; if you used MSVC to compile, then you may need MSVC debugger.

Obviously We need source code used to compile the library. Of course, the library must be compiled with -G.

FX swap – keywords

2 “legs”

opposite – the 2 legs are always opposites — HKD to CHF, then CHF to HKD but quantity will be slightly different due to interest differential.

bundle – both legs simultaneously agreed, as a bundle. Near date + far date.

spot – usually one of the 2 legs is a spot trade, but fwd-fwd FX swap is also common

repo – one way to understand the economic rationale (which is a bit convoluted) of FXSwap relies on an understanding of repo (i.e. overnight lending) assuming you find repo less convoluted than FXSwap. A borrower may need a mio USD for 24 hours and have no problem repaying. To demonstrate her repayment capability and to address lender’s concern, she pledges something as a collateral. This something could be a T-bond or some surplus JPY. Therefore, she _borrows_ USD by _buying_ USDJPY on near date, then on far date repays by selling USDJPY.

http://en.wikipedia.org/wiki/Overnight_market is a good intro to the rationale of short-term loans.

bridge-loan — is another way to understand why people need short term loans. FXSwap is similar to a short term loan.

interest calculation – Only after you grasp the rationale above, should you look into the interest implication — even the tiniest amount of math can be hard for some beginners (like me). Both currencies accrue interest between near date and far date.

trading losses at i-banks — vastly different natures

A $1billion trading loss can mean a lot or mean nothing to an investment bank. Let’s assume a hypothetical full-service investment bank named SS.

$1b trading loss in a SS hedge fund (a subsidiary buy-side run by SS) — assuming SS house money is not invested in the fund(which is rare), then the $1b hit the fund’s clients only. If they start to withdraw, SS will lose management fee income at the end of the quarter. NOT $1b loss in SS balance sheet!

$1b trading loss in a SS prop trading desk — Simple and clear. $1b House money lost.

$1b trading loss in a structured OTC desk — like prop

$1b trading loss in a bond desk which is always a dealership — like prop. “Dealer” is more accurate than “market-maker” or “agency trader”. See http://bigblog.tanbin.com/2010/11/agencyprop-tradersdealer.html

$1b trading loss in exchange agency trading — In this case, SS is THE counter-party to clients. SS takes positions. SS must carefully hedge its exposure to IR, vol, FX, credit risk, sector concentration etc. The $1b loss is bank’s loss, not client’s loss.

?? $1b trading loss in a pass-through brokerage unit in SS — An article on P40 of [[Bloomberg Markets Dec 2008]] confirmed that such a business does exist in an investment bank, but I doubt the brokers would know client’s PnL. This unit takes no position no risk, so should not suffer any loss. See http://bigblog.tanbin.com/2009/09/adp1-acid-test-for-brokerdealerpropflow.html

how frequently can volatility change?

Remember r-vol is backward-looking while i-vol is forward-looking.

In a top 3 i-bank’s VaR engine, vol is assumed to change once a day. An expert mentioned vol “can change overnight”.

== i-vol based on mid-bid/ask can change by the minute.
== Realized-vol is OFTEN (usually?) measured based on closing prices, in which case it won’t change intra-day. http://en.wikipedia.org/wiki/Volatility_(finance)#Crude_volatility_estimation says “Suppose you notice that a market price index, which has a current value near 10,000, has moved about 100 points a day, on average, for many days. This would constitute a 1% daily movement, up or down.”

trading decisions require human !! just machine intelligence

XR,

(another blog post)

You questioned if so much of trading decision-making is reliably handled by computers, then what special skills would a trader need? If not much, then you and me can also be traders. Well, you have more trading experience than I have (0.000), but here's my 2 cents worth.

There are important pricing decisions beyond pre-trade (PnL check, funding, borrowing…) but I assume your question is about pre-trade esp. pricing decisions. In that space, I feel below are some skills/tasks a machine won't, can't or shouldn't do —

* configuration – trade decision making software offers a bunch of tunable parameters on a per-name basis, name being a cusip, a stock symbol etc. Generally machines don't derive these values as these are inputs to the machines.

** pricing rules – A special type of configuration is a pricing rule. A trader often has to pick one from a pool of rules. Each rule follows some market data to compute prices, which drive pre-trade decisions. A machine won't pick the rule — it applies rules you pick.

* hedging – after (sometimes before) a non-trivial trade, there's usually a need to adjust hedging. I feel often a machine needs guidance from a human. I feel it's dangerous to let machines make hedging decision. Even in a liquid market, machines may pay too high. Hedging is a more complex task than pricing a bid/offer, perhaps too complex for a machine.

* timing – a trader often steps in to change pricing rules, configuration numbers, or stop/start a machine, when she sees some market event

* conflicting signals – most algorithms process tons of market data to pick up signals according to some strategy — strategy chosen by humans, but in a storm, market data can present conflicting signals. One machine will see signals to sell; another in the same desk may see signals to buy. There are basic rules to prevent computers from make self-contradictory trades, but a human may have a better chance making out what's happening in the market. After that, we can put together a coherent view and plan.

** exception is high-frequency trading. I feel HFT algos can tolerate more ambiguity and conflicting signals. They aim to make quick in-and-out trades, so they may not need any view at all.

* RFQ – some RFQ are answered by machines, but other RFQ are large or unique, (or the trader knows the requester well) so traders may step in to review these RFQs.

* news – machines can't understand news and adjust trading.

* trends – machines can spot statistical trends, but how about industry trends and economic trends. I don't have good examples of such trends. Although such insights don't affect everyday trading, they set long term goals.

* information overload — In all financial markets, there is lots of information. The amount of information (sometimes misleading or distracting) makes trading not easier but trickier. Evolution has given human brains special capacity to handle information overload. We discard 99% of the information to focus on critical factors; we see through smoke and mirrors; we question; we debate… That allows us to figure out what's happening. Not for a machine.

* specialization — Quite often, the more complex, the more human insight is required. Many mainstream trading desks are organized by product, so that each trader can specialize and focus on a limited body of information and knowledge so as to gain insight. Similarly, a stock/bond exchange often appoints 1 or 2 traders as specialist market-makers for a particular “name”, so they should know everything about that security.

* mistakes – machines make many stupid trades in terms of timing, pricing, quantity etc. That's my short answer and ultimate answer to your question.

curve-based pricing – briefly

Most non-trivial pricing systems use some curves.

* term structures – usually means time-based curves
* swap curve – closely related to yield curve
* yield curve
* discount curve
* fwd curve
* dividend curve
* vol surface
* credit default curve (hazard rate)

Who don’t use curves? Some pricing systems simply “adopt” bid/ask from the market with minimal validation. Perhaps good enough for mark-to-market, but not pre-trade. Simplistic (almost naive) pre-trade pricing algo gives up our independent thinking and makes our trading engine a blind slave.

A lot of the best bid/ask aren’t _consistent_.
– consistent with historical data
– consistent with other parts of a curve. Outliers.

Therefore, chief challenges in curve-based pricing include
– selecting the most suitable analytical form – polynomial, exponential, piece-wise linear(?) …
– outliers,
– curve-fitting,
– smoothness calculation,
– fitting cost calculation — measures deviation from original points.

skill devaluation in IT^finance

I experienced/witnessed a few waves of skill devaluation in IT sector, but I feel financial skill is different.

– web master, apache admin
– microsoft certified, cisco certified
– unix admin winnt admin, exchange admin
– perl hackers
– ASP, cold fusion
– network security professionals
– EJB
– structs

I think these skills either fell out of fashion or devalued to commodity skill. I feel any young or old techie can pick up each of these in a few months. In-depth knowledge is usually not required on the job.

Now compare with

– complex SQL against lots of tables
– socket
– time-series database
– low latency
– market data
– quant library
– bond math, option greeks, IRS pricing
– monte carlo
– stress test, scenario test
– VaR
– trade booking
– PnL

barrier (knock) option – key words

Cheaper — insurance than vanilla options
FX — barrier options are more common than in eq
Equities — barrier options are much less common than vanilla options

touch-and-go — is considered a “knock” (or “breach” of barrier). Once out, out forever; Once in, in forever.

knock-price — strike-price can be identical or different from Barrier-price aka knock-price

knock-IN — up-and-IN, down-and-IN
knock-OUT — up-and-OUT, down-and-OUT

in-out parity  — only works for European options without rebate.

MBS is a separate PnL from Mortgage lending

MBS is a completely separate PnL from Mortgage lending business. As explained in http://bigblog.tanbin.com/2011/11/buy-sidesell-side-business-units-in.html, a universal bank has commercial banking + security dealing business units. Such a bank often has a mortgage business and a MBS business. Citigroup is an example, where MBS is probably part of Institutional Client Group. It's important to realize the mortgage and MBS businesses have different books and don't necessarily depend on each other.

The mortgage lending business is older and simpler, much like a loan with collateral. The business starts with initial capital and profits by lending at an interest.
– It has realized PnL
– It has a lot of unrealized PnL
– It has significant risk in terms of default
– When housing prices tumble, all hell breaks loose. Borrowers default. Collateral devalues…

MBS business is more like a dealing desk in corp bonds. MBS business starts with its own capital, and profits by buying/selling “assets”. Holding a mortgage “asset” is like holding a coupon-bearing bond with collateral. We need to very clear about the meaning of “asset” before we understand the MBS securitization process, which I will not discuss.
– MBS business can create MBS security from regular mortgage assets (raw material), and sell them
– MBS business can use as raw material mortgage assets by other mortgage lenders, and therefore decoupled from the mortgage department of the parent bank.
– MBS business can buy or sell existing MBS securities, possibly created by other MBS houses.
** Any trader can buy or sell existing MBS securities, but the MBS business probably does it with more purpose.
– MBS business probably should never create a mortgage by lending directly. That's the responsibility of the mortgage department of the parent bank.

MBS can profit while Mortgage business loses money – if the MBS trader is smart
MBS can lose while Mortgage business profits – if the mortgage lending officer is prudent.

send event from EDT to EDT – user update jtable

I feel it’s a very common pattern to (Let’s not worry about how frequently) send event from EDT to EDT.

+ Most (if not all) user edits on jtable are processed on EDT. What if you want to update something else on screen, or translate the raw user input to a different value? Your event listener need to fire events. This action happens on EDT, and generates a new event to be placed at the tail  of the EDT queue.

+ invokeLater() is often included in a method that may run on EDT or non-EDT

+ invokeLater() often calls another invokeLater()

Don’t invokeAndWait() from EDT. Runtime exception. Reason? a fine technical point — Caller of invokeAndWait() must remain on top of its call stack (CS1) throughout, when the runnable’s run() is “Pushed” on EDT call stack, executes and popped off EDT stack. If CS1 is EDT, then the caller can’t remain on top.

buy-side/sell-side business units in a bulge bracket

Most “pure-play” investment banks have an asset management arm, often comprising private wealth + private-equity + in-house hedge fund + regular mutual fund management [1]. Crucially, in all of these, the money under management is not [3] primarily house money. House money could be a small part of the money invested in such a fund, but if a fund is entirely made up of house money, then it’s like a prop trading desk. In a way, this is also similar to sovereign funds like Singapore’s GIC.

This Asset Management business is often largely separated from the main business, and often incorporated into a separate entity. Just how separated? A GS buy-side veteran told me a buy-side trader can bypass the sell-side arm of GS and trade with a Barclays sell-side i.e. a competitor to GS. Doing so is unusual, punishable but allowed.

Within the big investment bank, on the other side of the fence lives a giant cousin — the sell-side arm. In all investment banks this is a much larger arm. Within the sell side there’s a Chinese wall. In practice, it’s hard to separate out the individual components therein, but a Chinese-wall is quite common —

– underwriting
– capital restructuring + always some (huge amount of) financing. These deals include M&A, MBO/LBO, privatization, spinoff…

—– Chinese Wall —–

– agency trading
– dealing, usually inventory based
– prime brokerage – extension of “brokerage” business

A few other business units are hard to categorize —
– research,
– clearing service,

Now, a non-pure-play “universal” bank does all of the above + commercial banking —
* retail banking
** credit cards
** mortgage — Note MBS is strictly in the “dealing” business
** retail loans
* corporate banking

Nowadays, investment banks also operate a private bank. Private bank clients can take loans from the bank, but by and large private banks make money mostly from fee-based business i.e. asset management.

[1] where some big players focus exclusively — BlackRock, Pimco, Vanguard, Fidelity,
[3] sometimes a little bit

profit size(!! market size)determines budget for a trading system

Q: what kind of market potential determines how much (salary and other) budget a bank has for a trading syste?

I don’t know what factors are truly important but I know market size is not. Many people say Forex securities have gigantic market sizes in _notional_. If you hear anyone describing the (growing) importance of IRS, they never fail to mention total outstanding contract value.

If you ask me, global market __profit__ size (in dollar and cents) determines how much budget a bank allocates to given trading desk. (A bank typically aims to capture x% global or regional market share.)

Example — FX options usually get quite a decent budget with much smaller aggregate contract outstanding than FX spot (B) [1], because FX option has fatter margin. FX spot margin is very thin due to competition.

Example, Equity volatility trades have lower aggregate dollar amount than cash equity (B) but fatter margin.

As yet another derivative example, I believe CDS was very lucrative and high-margin, compared to government bond (B) trading.

All of these trading systems get sizable budgets despite small market sizes compared to the bigger markets of (B).

[1] I’m not sure how to measure outstanding in FX spot, but it’s probably fair to compare aggregate transaction amount in spot vs FX options. FX spot markets have large number of large trades.

net positions in a sell-side FX trading account

In large dealer banks, each “dealing operation” has a single home currency as the reporting currency. At end of day, each book needs to report net positions in each foreign currency + its home currency. Each foreign currency can be either

– net long (or “overbought”)
– net short (or “oversold”)
– flat (or square)

That’s the end-of-today net position. Let’s look at end-of-tomorrow net position. If you have entered a forward buy USD/CHF, then you will have incoming cash flows in USD and cash outflow in CHF by end of tomorrow. You should estimate your end-of-tomorrow net position now.

limit^stop order in FX/eq#my take

See also post on stop orders…

2 common order types to let you buy at a specified price — A) limit order B) stop loss order

My CFA book made it clear that a Stop-Loss-Buy@$5.55 will become a market order once the offer side “touches” that point (compare binary options!). (Note You use a SLB after you enter a short position at a LOWER price like $4. It fires when market moves against you — up in this case.)

– if best offer remains at that price, then your SLB will (partially) fill right there.
– if that 5.55 offer is wiped out and market deteriorates further to 5.58, and your order gets to head of the market-order-queue, then you execute at that price. You suffer a bit. This is the “fall-through” scenario. (For our SLB, this is “break-through”. Anything-through is bad!)
– if market quickly recovers (perhaps offer side gets aggressive) and a LOWER offer is in effect when your order is at head of the queue, then you execute at a BETTER price. This is a touch-and-go scenario.
=== In conclusion, a SL order may execute a bit better/worse than your order price. You can’t control that (but you can quickly send cancels). See http://ibkb.interactivebrokers.com/node/255

In contrast, a regular Limit-Buy order let’s you control the worst case scenario. If you are filled you are always filled at $5.55 or better.

Note the abbreviated terminology. Stop-Buy is a Buy order, for the purpose of stop-loss.

Some (Forex, eq etc) people claim that a SL executes at a worse price than specified. I believe that’s assuming touch-and-go is rare in practice, and fall-through is far more likely.

instance fields vs long argument list

One of the “mild” code smells is the habit to convert instance-method params into fields. It complicates code tracing. Much cleaner is a local var – writable only in a local scope. In contrast, a field (or global) can be updated from many places, so it’s harder to visualize data flow.

Practical Scenario – If there are 5 objects I keep passing among a bunch of instance-methods, I would consider converting them to instance fields of the class (so methods receive fewer args). As a middle ground between fields and long signatures, perhaps an immutable method object is acceptable.

going long Libor .. means@@

  • If you are long an instrument, you are longing for it to rise. Your delta is positive i.e. in your favor.
  • If you are short an asset, you have a shortage for it and hope it depreciates. Your delta is negative.

… That’s my new “cheat-sheet”. Now let’s compare important derivatives:

  1. I think the meaning of “long eurodollar futures” is non-intuitive. If I long eurodollar futures, I want the expiration-date Libor number to Drop. Suppose today is a week before expiration and today’s Libor is 222 bps, I would long for the rate to Drop to 180 on my expiration date. That would mean my futures’ final price would be 98.2
    1. If you are long the futures, then I guess you are a fixed-rate lender
  2. FRA — you buy the FRA (go long) by agreeing to pay the fixed rate. You want the fixed rate (loan-start-date Libor rate) to rise.
    1. if you buy a FRA then you are a fixed-rate borrower
  3. IRS — fixed-payer is long a swap. As illustrated in earlier posts, the “oranges” to be delivered to you is the stream of floating interest payments

——–
Q: Look at any financial instrument with a fluctuating price. An instrument not necessarily transferable or tradable, but always bettable. What does it mean if I “long” this instrument?
A:
– i pay a fixed price for it, today or predefined dates. No runaway — i must pay.
– i get the right to demand cash flow from this instrument
– I long this instrument because I benefit from appreciation.

This complicated explanation is needed in the Libor and IRS context.

Simplest example — if I long IBM, i buy the stock and stand to gain if it rises.
Simple example — if I long copper, i buy a copper futures contract at $800 ie I pay this price today, and hope the price at contract expiration is higher.
example — if I long 10-year T bond, i buy a futures contract at $101….

In Libor IRS, I’d say every fixed-payer is long Libor. Let me repeat —

* Fixed rate payer is long Libor.
* You BUY a swap if you are long Libor. [1]
Also
* you buy a swap if you are short the bond-market [2]

[2] because you want bond prices to drop and yield to rise along with Libor.

[1] because the fixed rate agreed today is based on current Libor. If I go long on Libor, say, the 90-day eurodollar deposit rate, then I enter IR swap
– I pay a fixed rate of 222 bps/year — ie the “price”, computed at current Libor
– I receive a yet-unknown floating rate, hopefully above 222 bps
– I am long Libor therefore I stand to gain when Libor rises

empty throw ^ missing throw in c++

Background – all exception specs beside these 2 are deprecated in c++11. Only these 2 forms proved useful. Let’s rephrase the question as “Real difference between 2 otherwise identical functions, one with empty throw() the other without throw”.

Short Answer — wrapping the empty-throw function call in try/catch is useless.

Short answer – empty throw means “should throw Nothing. Nothing expected“;
Short answer – missing throw means the opposite — “all exceptions expected

Long answer — suppose you wrap each function call in a try/catch (…) ie catch-all. For the function without throw, every single exception from it will fall into your catch(…). For the empty-throw function, every single exception always, always triggers unexpected(). Your try/catch is ignored by compiler — could be removed during compilation.

Now we are ready to look at a function with throw(A). According the ARM, if at runtime this function throws unlisted exceptions, it’s seen as a serious design fault, so serious that compiler will *disregard* your try/catch — paper over (huge) cracks.

Here’s a best practice from http://www.gotw.ca/publications/mill22.htm — Moral #1: Never write an exception specification. If you follow this advice, then your try/catch will work, ie won’t be stripped off by compiler

My advice — “Either don’t list the exceptions, or adhere to your list. If you bother to list the expected exceptions, then stick to it. Don’t throw anything else. “

Note unexpected() is called always, always due to an explicit exception-spec i.e. an explicit throw suffix. “Unexpected” means “function author informed compiler to *expect* some exceptions, but something unexpected came out from the function“.

Let’s repeat the message — whenever you notice unexpected() invoked, there’s a function with a broken exception spec — No smoke without fire. No throw suffix then no “unexpected()”.

Further, these 2 conditions always lead to each other —

function has an exception list, but unlisted exceptions generated unexpected() invocation

What about terminate()? It’s somewhat peripheral in the story of exception-spec. I will just describe one of the causes — an expected (i.e. listed) exception is thrown but not caught. Also, unexpected() calls terminate() by default.

polymorphic equals() in java/c# ? NO

A java interviewer quizzed me why my equals() implementation insists on both objects having exactly the same runtime type, and rejecting a derived object. He questioned what if we happen to have

B var1 = new Derived(1,2); B var2 = new B(1);

and the B portion of both objects are identical?

Biggest problem with this type of polymorphic equals() — X === Y === Z doesn’t mean X === Z. Suppose the base sub-object of X/Y/Z are identical. Y is a base object. Therefore Y.equals(X) == true == Y.equals(Z), but X and Z are subtype instances, and different.

I’m a purist with high standard. If my equals() determines 2 objects to be equals, then I “swear” they are indistinguishable and interchangeable carbon copies.

It’s generally safe to be strict writing equals() — insist both objects’ actual types at runtime are identical.

finance tech is non-mainstream in techland (elite)

Update – Si-Valley also need elites – small number of expert developers.

Financial (esp. trading) IT feels like an elite sector – small number of specialists
– with multi-skilled track record
– familiar with rare, specialized tools — JNI, KDB, FIX, tibrv, sockets, sybase
– Also, Many mainstream tools used in finance IT are used to an advanced level — threading, memory, SQL tuning, large complex SQL

If you compare the track record and skills of a finance IT guy with a “mainstream” tech MNC consultant, the finance guy probably appears too specialized.

That’s one psychological resistance facing a strong techie contemplating a move into finance. It appears risky to move from mainstream into a specialized field.

swing topics

table sort/filter – pre-1.5
table sort/filter -post-1.5
layout managers?
custom table cell renders / editors
grid,
tree table – jide docs
tree table – swingx
view factory
editor kits
custom table model
StyledDocument

large data volume, high message rate
design patterns
swing automated test — scripting
large system tests — maybe there’s nothing technical to worry about.
swingx, jide, jgoodies
— fx
timer
swing worker

Does this person have real experience or home projects only?
High-level design and communication — can he?
trouble-shooting, debugging experience. Common traps?
best practices?

retail^institutional FX ECNs

— retail —
Meta Trader
Ninja trader
FXCM

— institutional, professional —
FXCM pro
currenex
hotspot
fxall
flex fx


Difference? I believe institutional ECNs target buy-side –
– Hedge Funds,
– pension, mutual funds,
– insurance
– corporations with FX needs,
– banks not specializing in FX.

The big FX dealer banks (DB, Barcap, UBS, Citi …) are on the other side of the fence, as liquidity providers. In additional, Hedge Funds are often allowed to play liquidity providers.