Sunday, 6 September 2009

Work smarter not harder

I like genuine ideas. I am a stronger believer that the solution to all the worlds problems lies in the "work smarter not harder" realm. Of course Thomas Edisson said that "there is no substitute for hard work" and I strongly believe that also, but the point is that working hard on old brick and mortar mundane solution doesn't always translate into success, when sometimes, working a little less harder (but still hard enough) and taking the time to look at other things, or what buzz word experts would call "out of the box" thinking, more creative and innovative solutions could be reach, often yielding a better, faster and easier solution to our problems.
One walid s. Saba once told me that sometimes humans tend to look at the worst case solution because it looks simplerm and sometimes we don't bother looking beyond our noses because a solution is reached and work can be started. I.e. the more efficient solution may not necessary be the obvious one. (His literally words was that heap sort was just an instance of merge sort, just a little less obvious, and if we go up the complexity we may be onto something - I am yet to find out if he found that something but should get back in touch soon enough.....)

A cool example I found out about in time magazine was something called dial4light which is a system that allows u to switch on street lights urself. This was inventrd in a village called dorentrup in germany, where the municipality was running high energy bills and had to switch off lights in seldom used streets at night. Some villagers complained as their kids were having trouble walking home in the dark. They contacted a company called lemgo that created a modem and software dialup system that u could ring a number, enter the area code or street name and the lights would switch on for that street, and so on and so forth. That solved the kids problem, reduced the energy bills and reduced the village carbon emissions as well.

Of course like all systems that can be abused and would never work in big cities such as london (am sure some gangs in hackney would relish the idea of darker streets and useless cctv cameras), but can be pretty useful in somewhere like west stevenage, population 81.

I like it- that's thinking smarter, rather than splashing out on wind farms to generate energy that is just going to waste.

Friday, 17 July 2009

C++ Interview Questions - Finance

Finance is a bitch of an environment to work in, especially if you are coding in C++! You can end up spending endless hours staring at tiny bits of strings and numbers, wondering what the hell is happening. It can get to be quite a bit of a pain, as the problem is compounded with real time data, and if you are working with something like NASDAQ, you can be looking at 27 GB of data a day! That's pretty much alot of trades, but NASDAQ is pretty much as big as the whole of Europe combined in the number of trades that go on during the day (So whomever said the USA is declining as a superpower, please get a clue - far from it).

Anyway, I've always had issues finding any conclusive interview preparation when it came to programming and finance, because what I think that there is a critical gap between the developers and the bankers, a sort of digital divide, that the bankers are pretty much idiots when it comes to technology, and all us developers have taken jobs with NO FINANCE EXPERIENCE REQUIRED at the bottom of the job description........ I don't know what can be done to fix that, and i dont really care because I've done my own homework when it comes to finance. So maybe some time when am not stressed about that damn feed handler, I'll propose a new recruitment philosophy and arrogantly blog about it.

So to the meat. Here are some questions (and answers mind you) I have encountered, whether through being interviewed or interviewing, or just plain day-to-day issues I came across.

In no particular order:

1) How many vtables do you have in any particular program?

A: C++ maintains a virtual table for each class within your program.

2) What is the difference between allocating memory using new and malloc ? What are the disadvantages of malloc?

A: New allocated memory on the heap, while malloc allocates memory on the stack. Memory allocated using the heap will live throughout the lifetime of the program, while malloc goes out of scope as soon as the method/class it is contained in returns. Malloc is also bad as it can lead to memory leaks, and running out of memory if we do not free the memory we allocate. In addition, malloc will allocate a fixed chunk of memory that is static and must be set by the user, while that is left up to the system when you use new. New also invokes the destructor automatically

4) What is the difference between free and realloc ?

5) What are the four methods that are provided for you with by default when a class is invoked?

A: Constructor, destructor, copy constructor and assignment

6) How many bits in a byte? Give an example of where you would want to use bit manipulation in a financial context.

A: 8 bits in a byte. If you are receiving messages from a trade, you may want to move pointers around the bits and bytes to read through them.

7) So you are receiving messages from an exchange - in a tag->value format. What would be a suitable data structure to use ?

A: A map.

8) So you are using a map, what is the disadvantage of using erase()

A: when u erase an element from a map, the map reshuffles, and ur pointer may either be pointing to null, or to a different location in the map.

9) What is the size of a pointer?

10) What is the difference between a shared pointer, an auto pointer and a regular pointer.

share and auto pointers are smart pointers. Smart pointers own the object they point to, and thus are responsible for deleting it (calls delete on itself). An auto pointer is a regular pointer wrapped by an object that owns this pointer, and deletes it when that object goes out of scope. Shared pointers compliment auto pointers, and you don't need to know who owns it. When the last shared pointer for an object in memory is destructed, the wrapped pointer will also be deleted.

11) What is a pure virtual function? What would be a scenario when u would need to declare a virtual function as pure?

A: A pure virtual function has no implementation and it usually belongs to a parent in a parent-child class hierarchy. Rather the implementation is left to the inherited class- yet pure virtual functions force inherited classes to implement that function, yet when that method is not pure, the child class does not need to implement it. (Although it can).

12) What is the difference between overloading and overriding?

A: Overriding is usually in inheritance, that u override a function in the base class by re-implementing it in the child class, usually by having the same function with a different implementation, while you overload operators or functions that have the same name but different signatures are thus overloaded. Another flavor of overloading would be operator overloading, where u can use the + operator to add an integer to a pointer for example.

12) What is the recommended maximum level of inheritance in any number of classes?

A: Try to restrict your parent child relationship to 3 levels : parent-child-grandchild. Deeper levels can lead to circular references and confusion.

13) Assume you have a child class, and you declare an object of type of the base class in the child class. That object is pointing to a method in the child class. What happens when you delete the pointer? (An asshole in New York asked me this during an interview)

A: (This one still escapes me, if anyone has an answer or better explanation, give me a shout).

14) What is the difference between private and protected?

A: Private functions are private to the class itself, and its children, but none else. Methods declared as protected are accessible by friend classes.

15) What are forward declarations?

A: Forward declarations allow us to declare objects before providing definitions for them. That's probably why you would need to declare ur methods in ur header files first. You can use them in ur program and it would compile even before u implement them (or just have an empty { } implementation).

16) What is an abstract class?

A: An abstract class is a class containing at least one abstract method - an abstract method is a method declaration without any implementation.

17) What is the difference between a copy constructor and constructor ?

A: A copy constructor is a constructor that takes an object of itself as an argument:

class MyObject (MyObject A);

18) What is the lookup time of a hash table? How about sorting it? What can be the worst case scenario?

A: O(1) for lookup, O(logn) for sorting. The worst case scenario for hash table sorting is O(n) if heavy chaining occurs - i.e. lots of collisions with all elements having the same hash value.

19) What is the lookup time for a Binary Search Tree? How about sorting it?

A: O(logn) for lookup, O(nlogn) for sorting.

20) What is the reference of a null pointer?

A: Null pointers always point to reference 0 (zero).

21) What is a vector?

A vector is a dynamic array of any data type. The associated methods are pop(), push_back(element), size()

22) What is the difference between string messages and packets?

A: That depends on what your packet looks like, but the general idea is that packets have a header and a trailer, with checksums and CRCs that could allow you to reconstruct lost or partially received messages.

23) What are the advantages and disadvantages of using a TCP-based connection? How about UDP?

24) Can you implement a queue with two stacks? How about a stack with two queues?

25) Which of these tuples are alike? Why?

AABBCCDEE - 11233445566 - EEFFGGHII ,


11375500 - 09455901


Answer: In fact, all the above are alike except AAABBBDDD- AAABBBCCC - CCCDDDEEE because there is not enough information to make an assumption.

a - AABBCCDEE - 11233445566 - EEFFGGHII are alike because if there is only one byte that is alternating its position. For alphabetics based strings, the 3rd bit from the right-most side is a single digit and its alternating position to become the 3rd byte from the left most position for numeric based strings.

b-113755900 - 094559001 , this is a time indication. 11:37:55:900 (hours, minutes, seconds, milliseconds

c-ABCAABC - XXXYZZZ : these are palindroms from the look of it.

27) Give an example where u would need to use bit shifting.

28) In Finance, time and timezones are of essence.

29) What is multiple inheritance? What are its advantages and disadvantages?

Multiple inheritance is mainly a C++ charachteristic, that allows classes to inherit from more than one class (disallowed in Java). The disadvantage is that it may lead to ambiguity.

29) In binary trees, describe preorder, postorder and inorder traversal.

More questions to come.

Monday, 27 April 2009

I left facebook

I feel really crap at the moment, as I battle a cold. I have taken ill, hangovers dont feel like they used to, and I am battle to rid myself of that disgusting cigarette.

Thing is, I had a friends' gathering in my back yard yesterday. While I was battling with that hamburger on the grill, an old friend of mine threw the word that she saw my "Leaving facebook" message. My other friend who battled for years to stay away from facebook and finally had to join because of her phd study group, said that she laughed when she saw my message. I had to be philosophical about everything as usual.

Maybe I am.

But, I left facebook for many reasons. As everything, there is one main reason I left, but I am also convinced by many other reasons why facebook is not for me.

First, I just like to say that social networking is a tool to be reckoned with, and I am not against it. I remain (for now) on LinkedIn. With this out of the way, the reasons for quiting fall into two categories, the first being purely socio-technical, while the second is really personal.

As I was a taught at the Information Systems and Innovation group at the LSE, that information systems are social systems, and I realized that :

1) Digital footprint: The growth of information we generate both voluntarily and involuntarily is exponential in growth, and our attempt in controling that growth through settings and privacy control, can only be linear, because most of the time, we are unaware of our own "data generating activities" if you want to call it that. i.e. do you really can guarrantee that you won't update your status when you are drunk, or upload a photo of you in a leather jacket on a bike when your adrenaline pumped or think it will impress a girl. Really, we do some stupid things sometimes and say stupid things that we often regret, but these are often "gone with the wind", but when facebook takes on a life of it's own, these stupid things come with it, which brings me to my next point

2) Data Mirroring: if you upload a photo on the internet, you have to realize that it's going to be there for a while....and I mean decades, not years. Not only that, is that once you upload it, you can't really fully delete it. With the growth of the internet, and its integration in business, as well as government laws, forced data to be backed up and mirrored to different servers, often in different location. For example: If you upload a photo to facebook server1, it will be backed up to facebook server2, which in turn is backed up to an external vendor, storage provider or data centre. That means A is connected to B which is connected to C. Now, if for some reason, A looses its connection to B, A can no longer access what is on C. Hence some data is sitting on C, but if you delete that picture from A, doesn't necessarily mean it will be delted from C, coz it can really get quite tangled, with backups to backups to backups. Loose a connection somewhere along the way, and that data is lost forever, but not deleted! So, If I delete my pictures from FB, that doesnt necessarily mean when I am 50, I may find in a google hit a picture of me on a motor bike in a leather jacket, I took 20 years ago.... So I figured that kind of digital footprint, isn't really needed.

There is a fine line between a digital footprint, and plastering ur private life all over the web. I am sure you know how data is mirrored over and over again , and well, one has to think twice before uploading a picture on the web, because well, it's going to be there for a really long time, and even still that the initial source of data may loose its connection to its mirror, there is no way you can control the data once its on the web. Controling a facebook account privacy is futile, and its better to leave now before it's too late.

I perfectly agree that a virtual existance is bullshit, and we are NOT what we put on the internet. Like the people who spend hours picking out their best picture to choose as a profile picture, this is not really them! So on and so forth for pictures, notes, posts, quotes, etc.... its all what we think we are, and we only usually focus on the good things and never the bad things, thats just human nature.

So, and this is cliche, but resistance is futile. The only difference between, lets say the government, taking ur information (reading ur emails, chats etc) without your consent, and making it let loose on the web in things like facebook, for anyone to have, is well, we only hope that there will be laws to protect us from the former, but the latter, well.... like Einstein said "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe."

Saturday, 18 April 2009

Soros and Sterling

Yesterday I was walking back from my lunch break, and I stopped to pick up a coffee. Having no cash I nipped to the adjacent ATM machine to withdraw a 10 pound note. Disintrested and my mind completely elsewhere I put my card and followed the all too slow process of withdrawing cash. In automatic motion I clicked the buttons and saw some thing yet my fingers were still pressing and I had my cash before I vould realize that this ATM machine gave me the option to withdraw euros. Now I found that rather strange. It was Liverpool Street station and Stansted airport is on the route but I I had just finished George Soros' book, and a few thoughts came to mind. The dollar is looosing ground, but is it thathappening THAT fast?

Soros, in his book, The New Paradigm for Financial Markets : The Credit Crisis of 2008 and What it Means, talks about how the dollar is loosing ground. Now what I like about Soros, that he acknowledges some important events and if he was not a financier, I bet he would have made a good historian. He talks about the Arab Oil Embargo of 1973, when the recycling of Petrodollars by the banks pushed the dollar to become the world's currency. (Funny how the oil embargo served rather than tarnished Western domination - well, it did negate Keynsian economic theory though, so Arabs did have some effect on the 20th century). Countries with weaker currencies, with weaker currencies and unstable economies, either used the dollar as a reserver currency, pegged there currency to the dollar, or those going the distance, dollarised their currency.

According to Mr. Soros, who, for the sake of entertainment, graduated from LSE the same year Paul Volker, the ex-Fed chairman and now heads Obama's Economic Advisory board (they graduated in 1952), thinks that the days of the dollar as the world currency are numbered, if not over.

According to Soros, the international financial system is under the control of number of financial authorities representing the developed countries, mainly the IMF, the World Bank, and if I will allow my self to add to that the SEC and the FSA, which both are watchdogs for the financial centers of New York and London respectively. These institutions, as he says, are "more equal than others". They constitute the Washington Consensus. The Washington Consensus is a set of "10 commandments" for countries to adopt as policies for economic development (such as privatization , free trade, tax reform and similar neo-liberal guidlines, and of course, deregulation), and in exchnage they receive aid from the Bretton Woods institutions. This leads to a globalized economy, and the way the system is structured, the United States, and to decreasing decrease the UK and the world's biggest economies enjoy veto power.

This structure, and specifically the deregulation that was so strongly encouraged, looks great when its working, yet when a sever crisis such as the current one comes a long, it shows how fragile the system is, and it all comes crashing down. With the car industry failing, the banking in shambles, and the housing market crashing, the US will be forced to into converting some of its reserves held in bonds , and some of its assets into cash to finance all these rescue packages and TARP funds.

The dollar is loosing ground.

"The invasion of Iran has much to do with the rise in the price of oil and the unwillingness of the rest of the world to hold dollars. This will reinforce and extend the current commodity boom and create inflationary pressures. The decline of the dollar as the generally accepted reserve currency will have far reaching political consequences and raise the specter of a breakdown in the prevailing world order. Generally speaking, we are liable to pass through a period of great uncertainty and destruction of financail wealth before a new order emergrs." (Soros 2008).

Soros should know a thing or two about currencies. He sure knows about the sterling, as he almost single handedly broke the Bank of England in Black Wednesday in 1987, when the BoE withdrew the pound from circulation before the markets closed. He should know about the dollar as well I guess, he did co-author a book with Paul Volcker !

Which brings us back to the ATM machine in Liverpool Street. Is the Euro the new currency? Or is it just the bank being clever, trying to get customers, or is it the customers demanding euros in atm machines? I talked about the Amero and the Khaleeji in a previous post, but, all these are pretty much either in the not-so-near future, or may never even materialize, but with the sterling at just 1.1 against the euro, I am thinking, is this the end of the Pound?

Probably not, but this ATM sure yanked my chain....or did it?

Monday, 9 February 2009

The Return of the Bankers

I want to become a financier. Not a banker. There is a big difference.

Personally, I don't really like bankers, even though one day I'll probably be one (briefly I hope). But for me, a banker is someone who juggles alot of numbers. I dislike numbers, even though, I can sometimes be quite good with them. But numbers are like people, torture them enough, and they will tell you anything. Just like the half empty/half full glass analogy. What I am really interested in is the true investing activity, know thy product, invest because you believe in something, not because you can shave off a 20bps profit here, and a 30bps there. That's just like a headless chicken running across financial markets.

Although those headless chickens, can have alot of sway when it comes to making, and wasting, money. After the credit crunch, everyone hates those greedy bankers who fucked us all.

But they will be back.

The credit squeeze started back in 2007, and here we are in 2009, and everyone is still talking about those bankers. Even with high levels of redundancy, losses and enough crap to last a lifetime, if you switch on the radio or the television, on the news, talk shows, comedy shows, theatre plays, you name it, everyone is either dissing or making fun of the bankers. [sarcasm ensues] . Today's world is a media world, and whoever can sell newspapers (or drive internet traffic- don't give me that Rupert Murdoch paid news argument - am for paying for content) will be in the news. The bankers, with their casino or wealth creation activity (depending on personal definition) are media darlings (no Alistair not you) - everyone loves money, and they are in the midst of it, so they are always in the news.

And they want to be.

It's like movie stars with a twist- the media easily makes and breaks stars, and these stars with brains of peanuts (exhibit A: Katie Price) are constantly pulling some shit- divorces, cheating, adoption- some crap like that its sole purpose is to keep them in the media, because bad or good publicity, it sells- and they make a bundle. Now with the bankers, its a twist because it creates a positive feedback loop - and the air of mystic that the Goldmans and the Hedgies like to create an aura around them - sure u can hate the big bonuses - but thats part of the game. Sure everyone may think ur the scum of the universe, but a master of the universe at the same time. I steal this line from an all time great movie, The Full Monty :"People don't look at u funny when u have a thousand quid in ur back pocket" and its the same with the bankers everyone loves to hate- but everyone wants to be, and they can pitch it as a way to "attract the best talent" bullocks, but the real trick behind that is that the way people with serious money when they see in "Young banker offers prostitute million dollars" is that they dont care about his morals, the silver linning is that such a young kid from mediocre background can have that much money, means that he must be making his employer a hell of alot, and putting a sweet 10 mill with them may not be a bad idea. Morals are negotiable when you are an ultra high net worth individual (excess of 30million that is).

So as long as we are hating bankers, as long as they are loving it- and so is the media.

I like financiers, they are the ones in the back. Reasons to follow.

Thursday, 15 January 2009

Finance for Engineers - The Advanced Stuff

Some more finance terms for the engineer..... With time working in a financial software house, you learn alot about finance, although at some point you decide that you have to do your own homework, and piece things together because, the future may take you to a trading desk, and you find yourself working on the Monte Carlo algorithm....
  • Splits : Companies can "split" their stocks. i.e. If the value of 1 share is £100 and the company issues a 2:1 split, this means every share will become 2 shares, and the value of the individual share is adjusted accordingly, i.e. each share will be now valued at £50. The shareholders themselves still maintain the same stake valued at £100, but instead of owning one share, they now own two (neat!). This gives them more flexibility. Also, once a split occurs, this will affect the stock price (up/down increasing trading activity) , and there can be all kinds of splits with ratios such as 10:9 , giving leeway for financial (mathematical) modelling! Another issue is that the more a company has in number of stocks, i.e. volume, the more possible shareholders it can have, and the more shareholders it has, the more complicated hostile takeovers become.

  • S&P500, FTSE 100: The index of the top 100 or 500 companies/stocks (depending on geographic location) and their performance which is used as a benchmark for measuring market performance. (See my post about The New Barbarians, in reference to the power of these ranking institutions. They even rank countries! )

  • Dow Jones Average Basically to measure the performance of the stock market. It's measured in points, or dollar per share. Simply enough (I think) is the total number of points traded on the market that day, compared to the previous day. If greater than one, market is up, if less than one, market is down. A value of one means the stock market performed exactly the same (hardly ever the case).

  • Basis Points: 1/100 of a percent, or 0.01%, which is used either to measure the yield of (fixed income) securities, or commission some traders may be basing their deals on.

  • IPOs: When a company decides to go public, it will have an Initial Public Offering, which is when it first issues it stock to be traded on the stock exchange(s). Usually, one (or more) of the investment banks would be the advisers of the company on how to handle the IPO and how to price the stock, based on initial asking price.

  • Spreads: Stocks can be volatile i.e. have a given amount of risk. The spread is the measure of risk between investing in government bonds (risk free) to investing in stocks (risk avert).

  • Arbitrage: This is a tough one. Arbitrage is basically betting on two different trades in different industries/domains that are usually (but not necessarily) different (or in a sense arbitrage sense- opposite). Hence if one trade (or the dependent market) performs badly, means the other is performing well, and vice versa, so one will make profit, and the other won't, therefore, exploiting the difference, the trader would make a profit. Of course, the trick, is to have it pay off significantly to cancel out the loss, and make a profit. Nothing is about breaking even and its not a zero sum game. (hardly) * Volatility: The measure of how much the security price fluctuates, and how varied the fluctuations are. i.e. a highly volatile stock is a stock that can go up and down 25% on day-to-day trades.

    * Exposure: Is the risk to which a given asset is threatened by. i.e. if a company has an asset worth one billion, and its exposure is 5 billion, means that its trades are valued at 5 billion, except it only has assets worth 1 billion. The importance of exposure is that if the company goes bust, it looses its assets, but the loss is much more than the worth of the assets.

  • Bear Market : When a market is said to be a "bear market" means that its going down. When a trader is said to be "bearish" refers to him being pessimistic about the market

  • Bull Market : When a market is said to be a "bull market" means that its going up. When a trader is said to be "bullish" refers to him being optimistic about the market

  • Hedging : When a fund hedges, it makes certain investments to reduce risk on a given security.

  • Models: Usually mathematical, quants create algorithms and models to simulate and predicate market behavior and/or the future of a security or market (by quantifying market factors)

  • Trades: The transaction of selling or buying a security.

  • Hostile Takeovers: Is when a company or fund takes over another company through a majority stock buyout, against the will of the stakeholders. Splits are one way of increasing the volume of stokes and thus increasing the number of shareholders, making a hostile takeover more difficult.

  • Leveraged Buy-outs: This is a scary one. A leveraged buy-out is when a company or investor begins on issuing bonds based on the assets of the company to be taken over. Imagine! You are issuing bonds whose underlying assets are the company you "will" buy-out. i.e. if the buy out fails, those bonds are worthless- but, well, the acrobatics about this, is that you issue bonds as a way of raising enough cash to force the buy-out and make the company's assets as your own, and be able to backup your bonds! (financiers are crazy!)
  • Buy Backs: Is when a company buys back a number of its own shares, to reduce the number of shares, and giving its current shareholders a bigger stake, thus raising the value of its stock. This is opposite (not quite though) to a split. This is a positive sign that the management is optimistic about the future of the company and think its current stock price is undervalued

  • Premium: When a bond is purchased before its interest or is due.

  • Short Selling: (complicated) This is basically when someone is selling stocks he does not own.
  • Liquidity: Th ability of transforming assets into cash (liquid money) without any loss to its value. Usually the root problem for leverage and exposure

  • Overvaluation:when a stock is mis-priced, and analysts give it an estimated price that is unrealistic and higher than it actually is worth. The trick is that overvaluation only is exposed as over-valuation when the stock price goes the other way, and people end up paying more for it. (This is sometimes picked up by traders as a misprice, and they go back-to-back on the stock. Serious shit I am too young in the business to figure out)

  • Undervaluation: the inverse of overvaluation - usually a bargain for the buyer, a loss for the seller.

  • Default: When a company defaults, usually on a bond or loan, means it has declared that it cannot and will not be re-paying the holders of the bonds or debtors for the money they paid for this bond. (related to bankruptcy, but not quite).

  • FSA: Financial Services Authority. Is the governing body of the Financial industry in the UK. It's a non-governmental, independent organization whose primary function is to insure efficient, fair and good business operation in the finance industry. i.e. it regulates the operation of financial institutions and individuals and prevents illegal practices such as insider trading, fraud, unfair advantage, etc...

  • SEC US Security and Exchange Committee. The US equivalent of the FSA.

  • Black Wednesday: September 16, 1992 in the UK when the British government had to withdraw the pound from the European Exchange mechanism.

  • Black Monday: October 19,1987. When the Dow Jones dropped 508 points, with markets crashing anywhere between 20 and 45% around the world. It was the largest one day percentage decline in stock market history.

  • Russell Index : The Russell Index is a capitalization-weighted index designed to measure the performance of a market consisting of the 2,000 smallest publicly traded U.S. companies (in terms of market capitalization).

So what is actually traded?

Need not get into Economics or philosophy on currencies, market behaviors etc. The bulk of trade is commodities (money itself is a commodity), and their derivatives.

Note: These are notes I made myself, and I hold the nominal copyright. I have passed them over to work colleagues but I am the originator, just in case somebody is wondering.