Saturday, October 29, 2016

EBITDA

Is a good way to value companies. There are several main methods, all producing different value, well, values. This one involves finding similar companies, and averaging over them the ratio of market cap (not sure if that's the right term, but essentially all that company is worth right now not counting the debt) to this EBITDA number of that company. Then one looks at the EBITDA of company of interest, calculate the worth of it using the averaged ratio, and then uses the result -debt/ shares outstanding to get where the stock price should be.

This method does not work for fast-growing tech companies, because for one thing, they don't have anyone to compare to. Sometimes it can be circumvented by splitting a tech company into sectors doing different things, each one of them comparable to existing companies (like Apple can be split into phone company and computer/software company).

This method is more robust than the seemingly more reasonable DCF (Discounted Cash Flow), where the company is valued depending on the cash it generates for the owner. The DCF is very sensitive to internal parameters, for instance the way the discounting is done (without discounting, any company naively generates infinite cash so has infinite worth). It also doesn't work for natural resource- related companies, because then what's important is how much resources is in the land they own, not how much cash they decided to generate this year. Also note that coal mine companies typically have lifespan of about 10 years, whereas "usual" companies effectively stay around forever (except for a few rare cases).

Method #3 is to look up expert opinions. Typically they are either public or available with your broker. Experts are a bit biased in a sense that they prefer to write about companies they think are good to buy, even though the typical company you find on the market is not any good. So if you put together all expert opinions on all companies, there will be 90% of opinions that tell you to buy something, just because the negative opinions do not get written. Nonetheless, when they talk about specific companies they do not lie, and they probably have spent a month of their lives looking into this company's internal workings, so it's good to check with them.

There's another very good method that seems to be more relevant to what's actually going on in the stock market, but unfortunately it's not available unless you're "in the know". It's called LRO or something, I don't seem to find it on the web. The idea is to see what big investors are actually buying. Look at the big transactions, look at how many offers are out there to buy some kind of company. Having that information, one can estimate how much money can be made if the company was to be bought now and resold in a year, or something like this. Maybe in five years. From that, one can figure out what's a good price. But since only big players are involved in such transactions, you really need to know what they are doing to predict like this.


Monday, June 20, 2016

Macroeconomics doesn't make sense

The purpose of this post is to present IS-LM model and also my own made-up model, just to demonstrate how arbitrary are some assumptions made in economics, and how it obscures the truth. The models like IS-LM and the conclusions drawn from them have their criticism within economic community as well, but the criticism is being no less obscure than the models themselves.

So here's a theoretical physicist's take on IS-LM model. We aim to describe a country with a government, a bunch of banks, businesses and people. Their economic activity is exchange of money and goods/services. It is measured by following well-defined quantities:

CPI -  price of a fixed list of goods that are supposedly the most common consumer choices. Is used to adjust for inflation, so all other quantities get the adjective "real": real GDP, real interest rate. We talk about real values without mentioning it from now on.

GDP - every time money is exchanged for goods/services this year, the amount is added to GDP. Buying shares in a company (or stock) is also counted. Taking/paying loan in a bank, and paying taxes are not counted.

r - interest rate. Reflects what kind of loans are available. Is set by either government, or some agreement/competition between banks (depends on a country).

MS - money supply. Counts how much money (how many bills) the government has printed.

I - investment. Part of the GDP that involves buying shares (or stock).

C - consumption. The rest of the GDP. For economists in the room, we ignore export and government spendings.

Then economists write several equations to determine the equilibrium values of these quantities, and also see how they change if some of the internal mechanics of the system changes. First equation follows directly from definitions:

GDP = C + I

Second equation follows from a simple consideration about Investment and interest rate. Supposedly for investors there's a "safe" option to put their money in a savings account that has rate of return that follows the interest rate r. So some of the investment opportunities are not interesting (if their rate of return is smaller than one of savings account). So investment depends on the interest rate with a negative coefficient:

I = Io - a*r

Here Io and a are describing how many investment opportunities are there, They may, and in principle should, depend on what's up in the economy. If people tend to spend more money, there should be bigger investment opportunities, and more profitable ones. But for some reason IS-LM model doesn't consider that, and instead fixes Io and a to be constants.

Consumption, on the other hand, is allowed (in IS-LM model) to depend on how much money people and businesses got. What they got this year is GDP. They probably have paid taxes, so the amount decreased by a bit. Then they have decided which fraction of the rest to spend this year (or possibly overspend and reduce their savings):

C= c0 +c1*GDP

Here c_1<1, or else we can't balance the equation for GDP. If we collect our knowledge so far, we get the IS (investment-savings) part of IS-LM model:

(1-c1)*GDP  = c0 + I0  - a*r

it's a line with \ slope on (GDP,r) axis. Note that somewhat in spite its name, IS equation doesn't actually talk about savings. What's going on is that of total amount of money MS some part have been circulating (possibly several times) to count towards GDP, while other part were people's savings. Some people made money, some people lost this year. GDP by itself does not really tell us anything about savings. We can imagine a year when two monkeys are selling a banana to each other ad infinitum for a dollar, while the rest of MS in never used. In this case, GDP may be arbitrary huge, but at the same time MS-1 dollars never left people's savings.

To describe savings, one needs to involve heavier math. Suppose that MS is split between people according to a distribution m(i) - how much money does i'th person/business have. Everyone wants to consume c(i) and invest I(i). Also this year they earn g(i). In case m(i)+g(i)>c(i)+I(i), this particular individual/business can achieve it's goals. In fact, the quantities c(i) and I(i) should probably depend on m(i) +g(i). But we ignore it for now. If there's not enough money, then an individual can take a loan, or decrease its consumption goals. In the end, we get an inequality:
 m(i)+g(i) + l(i)>c(i)+I(i)
In fact some individuals also need to pay for older loans, so:
 m(i)+g(i) + l(i)>c(i)+I(i)+p(i)
If we sum these inequalities, we don't get anything interesting:
MS+GDP + LOANSissued>GDP+LOANSpayed
Any significant MS will allow this to balance always.

But the breakdown into individual agents has taught us an important lesson: investment and consumption depends on their savings. Economy where people have tons of savings will grow until they start spending most of them every year, but or IS-LM model doesn't capture that.

Finally, the LM ("liquidity preference/money supply")  part of the model describes how the interest rate is set. Looking at the above, intuitively more consumption means more loans (because for more people their savings are not enough). As we noted, this cannot be seen in the aggregates, one actually needs to consider a distribution. Roughly half of the agents will not need loans this year. But how big will be LOANSissued really depends on the economic inequality accumulated from the past, this year's salaries and this year's desire to consume. We assume that both salaries and consumption depends linearly on GDP for those who are in debt. So
LOANSissued = a + b*GDP
Here b>0. We then make a simple assumption about bank operation (that is very far from what they actually do). The global interest rate is set by the following procedure: they look how many loans are requested this year, and think: ok, the bigger the demand, the bigger we can set the "price". The "price" of loans is the interest rate:

r = a' + b'*GDP

Here b'>0. This is the LM part of the IS-LM model. Together these equations can be solved, and if we assume that all the used coefficients except one are constant, then we can find the dependencies between different economical indicators. Like, when we change c0, we observe that if the GDP grows, I  decreases. Other parameters would lead to other relations, so for instance GDP and I can both increase.

What one can do to check that the above makes sense, is to try other things. For instance, one can fix r=0, and instead develop a relationship between I and people's savings. Unfortunately, as soon as savings are involved, the simple line-crossing economists do is not applicable anymore, instead one needs to run numerical simulations. I have run a simple one and observed the relationship between the supply of shares of a specific company (people willing to sell their shares) and the GDP. It turns out that the supply is bigger when GDP is bigger, which would imply that the corresponding stock price is anticorrelated with the GDP.

Saturday, June 4, 2016

Two levels of understanding of the Market

New traders start approaching the market as an object of scientific method. They think it is a black box that is given to us, like in a problem statement in high school. They absorb all the knowledge they can find about it, believe successful people and their models of efficient market and stock price somehow representing the value of the company. They probably learn to avoid scam, but they are sure that the truth is out there. That the market will be operating forever according to yet undiscovered laws. That if they see contradictions in different known results and theories, they should just ignore it. And such optimism pays off - they do find relations in the historic data and utilize them to trade in the future. If the market were a static black box, they would do just fine.

Yet there is one situation where looking at history and black box approach may lead you in trouble. Quite literally, imagine a trail of candies lying on the ground. The above strategy is like picking up the candy without questioning who left it there. One may easily get into trouble at the end of the trail.

But once one starts asking questions like "who left the candy", it's really easy to stop trading and be overwhelmed by the complexity of what's inside the box. During meetings of our local investment club, I rarely say anything at all. Many other people jump into arguments, but to me none of their arguments are convincing at all. There is absolutely no reason to trust or believe into any principle that somebody tells you about the market.

So who left the candy? In fact, people like you did. Other traders who believed in similar things that you believe in made "mistakes", and you are getting their money now (assuming that you win). That is a simple picture. Once one starts to dig deeper, it is even more disturbing.

It will probably not be too far off to say that 90% of the money in the market is managed by people called "portfolio managers". That means this is their full-time job, they often have business and economy background and they are put in charge of large sums of money. It is generally not completely automated, it's more like a machine-human interface. Human still does the steering, and the machine takes care of the details.

Now these guys do not actually take money from you. You don't even have enough money to feed their greed. Most of their wins is money taken from each other. That is, even though these people have lengthy resumes with tons of accomplishment and expertise in the area, roughly 50% of them end up losing every year. Stock market does not "generate" money by itself. The only way for someone to win is for someone to lose.

It's ironic then that all of them were able to convince their rich employers that their portfolio management skills are above average. In fact, they are not even rational players. If one tries to use game theory to this problem, one sees that many of the portfolio managers never really tried to optimize their game strategy against other portfolio managers, like they should optimally. Instead, they have empirically collected a huge body of knowledge about how to do their job, that was based essentially on the first approach described above (black box) plus some evolutionary dynamics that made them slowly abandon the methods that do not play well against other players. They still probably have tons of methods used daily that make absolutely no sense from the point of view of game theory. And they will keep using them for a while.

The problem is how fanatic they are on this erroneous path. An ideal game theory strategy against them involves studying their thought process, however inappropriate for the problem, then modeling them by a few math equations and coming up with optimal strategy. But their thought process is so sophisticated (and probably not even deterministic) that it defies any simple modeling. In this way, even though they are not getting closer to the better 50% of their crowd (the winning one) by indulging in all those economy studies, they somehow protect themselves from bright people who would want to attack them with correct math tools. And as a bonus, they also manage to charm their rich employers with the obscure language of finance.

I find this field to be not in the realm of science, it more resembles alchemy, where you secretly develop outlandish recipes that do not actually work, and make colorful sparks to awe the king so he does not think of beheading you this time. Over the years, alchemists developed some kind of understanding of nature, but they also had tons of misconceptions that held them back. 

Monday, May 23, 2016

Low income strategy

So you have that minimal wage 2k$. You live next to your job and can get by without a car. You share a house with a few roommates so your rent is <1k$. You are healthy so you don't need insurance (or you have subsidized insurance). Your family is all fine so you don't have any financial burden from them. It goes without saying that you don't spend on alcohol and have inexpensive hobbies. Then you're good to go - saving money actually makes sense for you.

You get 1k$ net profit every month. You get credit cards from different banks and accumulate promotions and credit line. You get 0-interest first X month loans and pay them back on time. You hold your money in both liquid and illiquid investments. The amount you loan is equal to twice your current worth that is invested in liquid part of your portfolio. Let's do a calculation:
M is the money that you own. 0.5M of it is in illiquid investments with 5% yearly rate. 0.5M +M owed are in liquid investments - stock market and high rate savings accounts. They say Goldman now has a saving account everybody can open with them. The return rate is 2% for savings, random for stock market, but we assume it is roughly 3% expectation value in the current economy. With a more advanced algorithms small amounts of investment can easily get 20% return rates, but the taxes may be an issue for those ones. So if you don't use our algos, you are stuck at 3% expectation value. If you do, it is let's say 10%.
So over a year you get 12k$ of wages, and (0.025+ 0.045)M= 0.07M of investment income. After taxes it gets reduced to 11k$ and 0.05M. So our new M' = 1.05M + 11k$. The amount of money you save living this way is (for the first 10 years):
00
111
222.55
334.6775
447.411375
560.78194375
674.82104094
789.56209298
8105.0401976
9121.2922075
10138.3568179
One group of people that easily fits the requirements are gradstudents. They stay for 6 years, and then typically get a postdoc for 2, and then forced to leave their field. With this strategy, they can instead retire :) the 5% income from 100k$ is 5k$/year - enough to have a comfortable life in one of those third world countries. They can even keep doing science - their dream job - in their free time.
Seriously, 5k$/ year is not enough. You don't expect to be able to support your family with that. There are also other nice bonuses like promotions from all those credit cards (500$ a year?), and extra 40k$ of postdoc salaries over those 2 years. So you can maybe get to 150k$ by year 8. Or 200k$ if you get a second postdoc. Moving to another country will mess up your loan game, so 5% interest rate will not be available anymore (however, the interest rate in that country may well be comparable). Also if you are a foreigner, you will need to figure out immigration by then.

Now let's consider an idealistic scenario. You use our algorithm and you get 10% yearly returns on it. Then it doesn't really make sense to use illiquid investments - their rate is lower. You may still do it to diversify your portfolio. But let's say you don't, and put all 3M into this algorithm (email us for details, there should be a form on the right). You get 0.3M yearly returns. Lets say you somehow figure out your taxes, so you just pay 1/3 on stock trading income - your returns after taxes are 0.2M. Let's see what the formula M' = 1.2M + 11k$ spits out after 8 years :)))
00
111
224.2
340.04
459.048
581.8576
6109.22912
7142.074944
8181.4899328
9228.7879194
10285.5455032
Now you get 181k$ savings (+44k$ extra from postdoc salary and credit card promos). Also your yearly return is much more noticeable: 45k$/year. That is a decent salary! Our only assumptions are that the algorithm will still be working at 10% yearly returns expectation value, and that the banks will still give out those 0-rate loans as a way to attract you as a customer. If you play the credit card game (see website "dr. credit"), your credit line should be pretty big at year 8, and the banks should be willing to loan you sums like 400k$ with no interest rate for a short amount of time (because they expect you to forget to pay on time). Both assumptions are very feeble. But at least they show that financial stability is possible for those who want to stay in Academia. In the same way they are possible for other low-paying jobs.

Wednesday, March 16, 2016

Installing Python 3.3





So there are two ways of installing python such that the nice Mathematica-like iPython notebook environment works. In the above, it's hardcore console. Here's a related blogpost. Here's a better one. For me I installed Python 2.7 on an older Mac.

I needed to say "pip install ipython[all]" instead of what's in the video.



Then running "ipython notebook" worked. You also need to "pip install" numpy, pandas etc.



Alternatively, and avoiding console for the most part, one may go to Anaconda website. There they have a file you can download for consoleless installation. Ideally "ipython notebook" console command then just gives you what you want.

Wednesday, March 9, 2016

The Big Short, and loans in the modern day

The movie shows how knowing that something for sure is gonna happen, big money players can negotiate instruments that allow them to make much bigger returns than what one would expect. Let's see. Naively, if you know that the price is going to go down or up 5%, you can make 5% returns. If you find a way to borrow money at a rate <5% of interest payments for that period of time, then you can increase your returns. The typical rate for a trustworthy borrower is 5,69% per year. If you know about 5% price move that's gonna happen over 1/2 a year, then you should borrow as much money as they are willing to lend you and get roughly 4% of that after all. Unfortunately, there's not so many places you can borrow big sums of money for stock market purposes. Maybe it changes when you have a lot of money already, and some legal status, Idk. But in essence, one would not expect that a hedge fund can borrow much more money than what investors already gave to it, or else it would do it all the time. So naively you expect that your returns will still be of order 5% of what your investors gave you, even if you are a hedge fund.

But there are plenty of financial instruments that circumvent it, most of which are not available to simple people. One thing would be leverage. As far as I understand, hedge fund can make an agreement with a broker about investing money 1:20 into this opportunity. Then, if the actual price reaches -5% at any point in that 1/2 a year, hedge fund loses everything. But if it actually goes +5% as expected, hedge fund doubles the money, getting +100% out of known 5% change of a given instrument. Another way of thinking about it: hedge fund finds a person who is willing to make a bet on all this money that the price is not gonna go move 5% that direction.


Christian Bale plays Michael Burry in ‘The Big Short.’
 
PARAMOUNT PICTURES


So when one of the main characters (played by Christian Bale?) was drawing numbers on the board: first -119% when the price did something unexpected, but then +440% when it went the way he expected, this is essentially what was happening. The housing prices dropped, say by 60%, after rising by 30%, counting from the moment he shorted the housing market. His bare returns are +30%. If he used the leverage instrument, he needed 1:14 to get his 440%. So he could only afford prices going up by 1/14, or 8%. If they went 9%, he'd lose everything. How could he afford 30% rise on his leveraged short position? And still be only in -119%, not in -440% as the symmetry would suggest?

First of all, he did not put all of his fund's money into shorting the housing market. But that doesn't help: to have 440% returns, he needed to have -440% loss when the price went the opposite direction. Which would bust him. The resolution is that, first, even though the housing market that we see was down by 60%, he shorted some more extreme instruments that were down by almost 100%. Second, to short them, he used Credit Default Swaps, that has been around for decades, just that nobody thought of using them on a housing market.

It is good to note that he made his decision to trade based only only the publicly available information. Using insider's information about upcoming price motions to make money is something you can go to jail for.

Another concept that movie covers are CDO's: a packs of loans that are offered by a bank to investors to provide money for. The movie drives the point home that anyone who was working in the bank on getting those CDO's approved and sold insurance on them was acting completely irresponsible and should go to jail (although almost noone did).

Much blamed CDO's still exist, although in a heavily regulated fashion. Banks still don't do a proper investigation of individual borrowers. However there are web-based platforms Lending club and Prosper that do the bank's job of connecting capital and borrowers without "black boxing" where the money goes. Careful investors can review every single loan app. For big investors, there's even a startup Theorem LP, that's a third party optimization/machine learning that helps quickly scan all the loan requests for reliable ones. They managed to double the return of a naive investment.

Their fees are twofold: there's a 1% fee for putting money into account, and standard hedge fund 10% fee on profits. The minimum account value is 1M$. So essentially what this company is doing is what big banks failed to do during the 2008: carefully review each loan application. It also claims to sometimes provide liquidity to those who want to withdraw (option not available to regular investors on Lending Club), and identify recession years and be even more stringent in the screening during those years. The defaults usually lag 0.5 years behind the economy collapse. Here's a neat data visualization by Bloomberg.

Tuesday, March 1, 2016

Money isn't everything

Once you familiarize yourself with the stock market, it's easy to get caught up in making money frenzy. You won't make too much  - roughly 1% of your current wealth per month is what you can realistically expect. And for most people, they are either in debt, living from a paycheck to paycheck, or having net available wealth of roughly 10 times their monthly salary. So if you do the math, investment gives you only 10% of what your daily job gives you. It's only natural that you commit only 10% of your time to it, not all day every day.

One may argue that if you get really good at it, you can attract other people's money. If you go to a hedge fund - that's exactly what happens, and you are paid relatively big salary. But not everybody would want to have finance as their daily job. There are much better things to do in life. Outside hedge fund, as an independent investor, there's really not many legal ways to manage other people's money. Your uncle can give you 100k$ informally. There are trading competitions online, where you can get to manage up to 1M$ if you win. The conditions are usually that the investment manager gets 10% from the profits. At 1% per month the profits from 1M$ are about 10k$, so you get 1k$ per month - not a salary, but best of what's available. Still doesn't justify spending more than 10% of your time on it. If you are educated enough to invest correctly, you are probably educated enough for one of those manager or software engineer jobs that pays 10 times more. If you want them, that is.

But even if the activity gave you all the money you need, money isn't everything. For what we want to do, usually bottleneck isn't money. Money can be loaned in the worst case. There are other resources that are often a bottleneck: connections, education, achievments on your cv, status, fame, friends and family, relationships, health, and last but not least - time. Managing those resources is somewhat harder that speculating on the stock market. For one thing, they are pretty much illiquid - you cannot exchange them or request them instantly. There are some that come close liquidity, as I will attempt to list below. For another thing, if with money the utility function is clear as a day: more is better, with other things there may not be a single utility function to optimize. Finally, the US society is incredibly focused on independence, providing for yourself. But many of the non-money resources only become available if you let go of that notion that you're optimizing them for yourself alone, and collaborate with other people.

Let's go over a few examples.

  • Education. Oftentimes you find a job you want but don't have a diploma that qualifies for it, or for that matter, the skills. You can easily get a loan and waste another 4 years of your life studying in a college. If you can do it without a loan, you probably should at least once in your life. (again, issues with utility function. Teenagers are incredibly susceptible to feeling included/excluded of whatever everybody else is doing. It is not clear if those feeling persist to adult age in people who did not go for college) A bit more optimal solution is to be self-taught - it only takes about a year of your time and ideally doesn't cost you anything with tons of free resources available. However, it only works for people who already know what they want, and most of the college kids don't, which kind of justifies colleges. Also, there's an extra cost that you now need to prove that you know your stuff every time, instead of just having your diploma speak for you. Are there any other solutions? So far, we only considered purchases of resource "Education" from the standard system. Can one loan education without actually giving the cost? Can a person trade their education for something else? Those are the right questions to ask. The opportunities to circumvent the standard cost usually come with a lot of money. You can hire full-time a person who has this education to do what you wanted to do but needed education. Similarly, a person getting a job is essentially trading his education (and time) for money. So there is certain liquidity for resource called "Education". But it's nowhere near one click of the button liquidity that is available for stocks on the stock market. In a sense, internet can be a way to get educated people to do things for you just one click of the button away. But it probably will cost you again. When I'm talking about "Education" resource, I mean not only the skills to do things, but also the fact that those skills open certain doors in our society. You job choices, salary and locations will strongly depend on what it says under "Education" in your cv. That effect seems to be not liquid at all. It's much like our second example - immigration status:
  • Your job opportunities are severely cut by the immigration status. It takes time and paperwork to have a proper one, and many companies just don't want to bother. So your ability to settle down in certain countries at certain times of your life very much depends on this completely illiquid resource "Im. status". The only way to loan or trade immigration status is to marry someone. Otherwise, it's just one other thing like Education that you either have or not, either get the benefits or not, and you can't easily get those benefits within legal bounds.
  • Social resources like connections, friends and family, relationships are liquid only for people who are good at it. You can let someone else benefit from your social connections as much as you do. However it's typically not done as a transaction, more as a favor, so it's unavailable 90% of times when you actually need it. There may be some markets for the above, but they are all very controversial if it's click-of-a-button. To do it more traditional way, one is expected to invest a lot of time, and the only way to save time on this is to have a lot of money and hire a secretary.
  • Health and time are resources that are given in only limited quantity, and "activated" by money. Time can be purchased by hiring other people, if you want to do something productive with it. If you just want to have fun, you only get 24 hours in a day and that's it. Health can be a huge money dump, and also some people just don't have it. To keep oneself in good health takes time and effort. Some parts of our body are replaceable, but the markets for them are heavily contrained by the law.
By describing the obvious things in life in this kind of structure, we may outline a model for life. Then we can proceed to "solve life". That is, come up with objective function and optimize it given the constraints. This is essentially what we do every day, but sometimes we are pretty bad at it. Because it's a hard problem, and the only data we have is just lives of a few people we know plus our personal experience. Any datasets collected by facebook etc. are too noisy and miss the whole point.

But one can start working in that direction, formulate relevant questions, even if not all of them can be answered at this point.

Wednesday, February 24, 2016

Meeting the school money investors

Private schools are non-profit, but they have a lot of money from undergrads paying tuition, and money from fellowships and grants. Also donations from the alumni. Quite a significant portion of this "profit" is not immediately spent on the needs of the school, but is instead invested. The scale of this investment is billions of dollars times how big the school is and how long has it been around. On the east coast, it is really funny to observe competition between Harvard and Yale - who can make most returns this calendar year, or in a three-year interval? Both have of order 50 billion.

Of course it's not a fair comparison - each school has different needs. There are other indicators they like to compare themselves to. The non-profit part allows them to pay no taxes. What's the most interesting is how the investment decisions are made, and what kind of choices are available on that level. Of course this is not as big as it gets, but it's big enough to open most doors for them. More below.

The people in charge are called something like "board of trustees". They are about 12 people who are old and experienced in investment. Some are professors, some have business background. A few consultants who do not have a say in the final decision making are also present on their meetings, e.g. a consultant on China market. I assume that a lot of paperwork is handled by secretaries or their equivalents. What this organization's daily job is can be described as a lot of paperwork, and some very qualitative analysis of the bigger picture. They do look on quantitative performance measures, but then they are mostly talking to make sense of it. School provides this organization with budget needs (amount to be subtracted from the fund's value at the end of calendar year). There don't seem to be any other constraints.

The actual buy and sell decision are made by money managers, who sign an agreement with the above people. These managers are different companies like hedge funds, and also independent venture capitalists etc. Each one specializes in one or two areas. The board of trustees does not tell them what to do, just asks them what they usually do, and then if their plans align with board of trustees big picture view, they are hired. Then board of trustees monitors their activity, and if it deviates from the expectations, or they just plain lose money. 10% every year get fired, and it leads to a lot of annoying paperwork for the board.

2b/100 = 20m$ per manager. This opens all the doors of hedge funds.


Monday, February 8, 2016

Market is down again

If we believe that investing is still a good idea, then now is the time to move the money there. Of course, one may also be happy about not having investment and keeping the dollars while people who invested are losing money day after day. But this reason to be proud of yourself will disappear as soon as some part of the market shoots up. And it certainly will, problem is, we never know which one. But what do we know?

Under quite a detailed scrutiny, market still looks like a random Markov process. In fact, the more one looks the more indications there are that there are no correlations whatsoever. Correction: you can find correlations, but only such that do not tell you anything about the sign of the price change.

Now, any strategy that can be coded by working with the price data and is a simple looking-back decision making program seems to return essentially random results. There are some that are skewed to perform better, and the dispersion is so big that on some stocks it would seem to perform really well, but it's all just noise. From what we can see, consequence of individual action on the stock market is pretty much 50/50 for most of them, except for particularly stupid ones. In fact, it is hard to find a consistently losing strategy (with 0 fees) because one would invert it (sell instead of buy) and turn it into winning strategy.

The things that are easy algorithmically do not neccessarily coincide with what people actually do while trading by hand. Algorithmically, almost every code that you write makes 100s of operations, while we usually are much more lazy and just want to buy once. So we have confirmed the 50/50 picture for algorithms like trendfollowing and mean-reversion, but these results do not help much in thinking about actually making a trade yourself this one time. So what would be the algorithms that shed some light on the effectiveness of most common trading practices? I hope to list a few things that I have tested here. I have two main interests:


  1. Stop-loss. In B&H strategy, one may take an active position and check how much is the portfolio worth every few days. If he sees that it is down by the last year's earnings, he might impulsively withdraw everything and wait for some time. I'd like to know how it affects the long-term returns (and e.v.) and what wait time and threshold to pick. Also maybe there are stocks that consistently reward traders who use this strategy.
  2. In picking which stocks to invest, one may focus on best performers and worst performers.
  3. The SR is the main instrument in thinking about stock as a random process, but for some of them it does not obey the naive sqrt(Ndays) dependence. In such way one can choose top SR and worst SR stocks, and maybe expect different strategies to work on them.


Thursday, February 4, 2016

Machine learning US investment options

As we remarked in the previous post, assessing the financial promise of a given company or other market instrument is a task for a professional. An amateur may point out one or two obvious things, but will have to guess in pretty much all the major questions. So the natural thought would be to seek out professionals.

There are a few services available with regards to investment:


  1. Portfolio management. There are some calculations based on the past prices and a list of assumptions, which lead to a prescription how much money one should commit to a given type of investment. The central idea is that of diversification: all things cannot fail at once. Or in more mathematical terms, average of N independent random variables will have 1/sqrt(N) smaller standard deviation than each one individually. This slightly improves the performance as compared to s&p 500, and there are plenty of websites that offer this kind of portfolios with formulas hard-coded in: betterment.com, Acorn. Note that such services do not improve the expectation value of your returns, they trade the expectation value for "protection from risk", in other words, apparent reduction in standard deviation of your returns. They save you the nerves during the market crashes. Nobody knows what happens with the actual probability, if that can even be defined (see below). Nice thing about those websites is that they seem to do the rebalancing for you, which also gives a slight improvement over buy&hold of fixed number of shares.
  2. Mutual funds. Those ones will ask you 1$ commission or 0.3%, and attempt to do something that they often do not completely disclose, but possibly more complicated than just portfolio allocation and rebalancing. You can choose the area of the market - there are plenty of mutual funds available for each one. Then the "professionals" who manage the mutual funds decide what to buy and when. Hopefully they can not only improve over blind allocation of portfolio managers, but also time their purchases (or play with the derivatives). However, all of that zoo does not bring them easy victory - as one sees in the websites that show mutual fund's performance, many of them jump like crazy on the scale of 1 year, and it's hard to say conclusively whether their strategy still works. Also, some of them have large barriers to entry (100K$, still not as large as hedge funds)
Most of the intuition in the comparison comes from the simple random process. Such random process would have fixed mean M size of each step, and a much bigger random noise determined by standard deviation S. Let step happen over 1 day. Then after 252 days (roughly 1 year of trading days) the mean/deviation of total returns will be amplified as sqrt(252)*M/S. This number is called Sharpe ratio (roughly). The general logic is that we want to choose a portfolio with the biggest M, but almost all the time the apparent Sharpe ratio of such portfolio will be too small. The mnemonic is that 1/Sharpe^2 is the number of years of data that we need to be confident in our choice. For individual instruments as well as the most of the simple strategies, Sharpe<1, which implies that we need >1 year of uniform data to confirm that our algorithm is working at all. But the problem is, the data on the stock market is strongly non-uniform, especially for B&H strategies. The events every few month strongly influence all the market and change the sentiment about the companies and other instruments. Of course, there are short term changes as well, but the hope is that they repeat often enough so that our training can take them into account. But the month/year scale events tend to be unique and unpredictable. So, in short, our conclusion is that past data alone does not provide sufficient evidence for reliability of any B&H strategy. If that argument was not enough, there's also selection bias that is carefully accounted in Quantopian.com environment, but not in any of the cheesy portfolio allocation formulas.

Still, it's a good sanity check to find out what's your strategy's Sharpe ratio. It's very random, though. Somewhat more stable number is achieved via training-test splitting, optimizing of paramenters on the training and endless crossvalidation on test. We expect that "speculation" strategies can be reliably assessed in this way as they are the ones about timing the purchases, which should be a universal technique largely independent on long-term trends of the market. But B&H strategies are not expected to provide particularly insightful numbers even after the laborious crossvalidation. We will cover a few results for a best performer/worst performer strategies in the next post.

In conclusion, I'd like to note that the above Sharpe ratio analysis relies on the assumption of simple random process, which is in one way definitely not true for the stock market instruments. If the mean M and the dispersion S were as they are measured from the data, typical stock would travel of order S*sqrt(N) from it's origin over N days for N<252/Sharpe^2. But a real stock hardly ever travels that far. If one estimates the anticorrelation coefficient sum(Xi -M) (Xj-M) = sum -0.5(Xi -M)^2 +  0.5(sum Xj- NM)^2 = NS^2, it's almost maximally possible...

Wednesday, February 3, 2016

What to do with the money in US?

A typical choice is either mortgage or retirement fund. Or anything in stock market really. I would like to assess real estate at some point, but currently I don't have enough money to think about it. The low-cost real estate options like REITs don't seem to be very interesting. There's an ongoing REIT in California right now called RichUncles, that seem to be doing some pyramid scheme instead. Its executives spend disproportional amount of money on publicity and high dividends, which makes one suspect they are using their shareholders money for that. Of course, we will only know at their liquidation event that will happen in a few years. They will either be able to pay everybody back, or not. No way to predict. They do publish some sort of financial reports and list of buildings that they buy, but there are not so many figures in those reports, and no plots whatsoever.

Which brings us back to the stock market. Stock market is huge! There are about 7000 instruments on Quantopian.com with  minute data available to analyze: companies, including recent IPOs, and ETFs - a placeholder companies which track some of the government bonds and commodities. What do all of these words mean?
IPO - a moment when company's stock becomes available on the market, as well as the company that recently has done that.
ETF - as explained above.
government bonds - have something to do with the bank interest rates and government borrowing money from citizens.
Commodities - stuff like oil price and gold.

Here's the comparison of all of that stuff over the past year (TLT is bonds, UUP is dollar futures(?), DBC is commodities, S&P 500 is "the market") :
We see that all of them went down, but in somewhat different fashion. Now what investors tend to say is that when the market is low, we need to buy in and hope for it to go up. There are also more advanced talks about rebalancing: one holds a combination of stocks and bonds, and as the stocks go down, buys more stocks and sells more bonds. There are no instructions as to when exactly should one do that. Doing that now sounds like a good idea: bonds are on the uptrend, and the stocks are really cheap. But then, one may argue that waiting for another day, month, year will give one an even better deal as today's trend continues. Nobody really knows when is it gonna revert.

Another direction of work is to try to "outperform the indices". If one carefully picks companies, avoiding the ones with dumb people in the leadership, and the ones with too smart leaders who drain money from stockholders. Avoiding also those that are overpriced, just because every single trader on a stock market wants to buy a bit of Netflix, Google, etc. And avoiding those that have ok leadership, but just not very profitable market (e.g. one-trick companies who only produce one product). After all this avoidance, there's really not much left. Not clear if this is a good strategy as the ability of non-business people to assess financial reports and leadership decisions (as well as the sentiment of institutional investors) is obviously limited. 

Now, in the internet at the end of any such article there's a solution proposed, and a link redirecting the reader to put their money in. I don't have such link at the moment, but I promise that as soon as I set it up I'll share it here. (I hope you see the irony in this paragraph)

So what to do with the money?

There are many many choices available. As I'm a foreigner in US, I always have an option of storing up to 15k$ in a bank account in my home country with about 3% interest rate. Any larger sum will be subject to the risk of bank collapsing (which happens daily in that country), but <15k$ is reimbursed in that case by our government. If you have more money - that just means more paperwork as you need to open more than one account.

Another unique thing about my country is that I can be a venture capitalist there, but not here (here you need to possess 1M$ to become an angel investor). I did not find any good startups there though.

Finally, the currency was doing something very interesting in my home country, and all the savings that I had in my own currency were halved. Bitcoin wasn't doing too bad but it seems to get illegal soon.

So let's discuss US and what one can do here. First, note that I look at three parameters: performance in the past (and here one should mention more than one timescale), risk (how many big jumps up and down are there), and sentiment (is there any impending doom on that financial instrument). Of course that's not enough for complete analysis, only for the first step. I'll try to outline the complete analysis in my further posts. The above three choices are as follows:
1) bank  - performance +3% yr, risk = 0, impending doom = quite substantial since I'm pessimistic about my country. Also, a lot of hassle with actually opening those accounts.
2) startup - performance +50% last yr, risk = ? illiquid, so no data, impending doom = almost certain. Most of the startups don't return on the investment in any way. It only makes sense if you can invest in a 100 of them at once, which I can't as I don't have 1M$ after all.
3) my home currency - performance -50% last yr, risk = 20% (I don't expect bigger jumps than that), impending doom = that's the problem with the currencies, isn't it? Unless you wanna speculate, none of the currencies just grows indefinitely. If I keep my money in dollars in a can for 10 or a 100 years, I don't expect to be rich just because of that. Don't think that ever happened in history. One think that I can do with dollars is to go to the country where the currency is doing really poorly and enjoy my life there. I think the rules of Forex trading allow one to short a currency - that is, try to win money on the assumption that a given country gonna collapse through the floor. That idea seems strangely appealing to a pessimistic person. The fact that I'm holding my money in dollars is already a first step towards that.
4) bitcoin - performance +100% last yr, risk = 30%, impending doom = pretty sure that it will get forbidden by all major governments. It seems that the recent growth was partly due to a Russian con artists' operations in Africa in India.

Wednesday, January 6, 2016

Portfolio managing tools and the true choice you're making

Most of the stock-market related materials use the following argument to convince their clients that the specific investment strategy works: look, it worked in the past, so let's assume the returns and the risk will be the same in the future. That's all good, but then you get in trouble when you need to compare two strategies from, say, two different providers, and decide how much money to allocate to each of them. Even worse, now they offer you more control and ask "what sectors do you believe in?" or "how much risk, on the scale of 1 to 10, are you willing to take?". Behind these questions is some good math, and supposedly you may just answer them as you normally do, and get not a bad result.

But the choice of the index to follow, or individual instruments to include, is way less educated. In fact, the creators of the online tools just followed what's standard, or made a few arbitrary choices. If you start tuning up too much, then you can get good returns, and even seemingly smaller risks, by cherripicking the stocks that performed well in the past. So to be safe, one needs to draw a line somewhere in the sophistication of the portfolio tool. Even though what it does is just optimizes risk and return, we can't let it optimize too deeply. Also, that would lead to longer runtimes, and user wants the website to show you your ideal portfolio immediately.

As you may have guessed, this is not so good. There's a methodology #2, that allows to protect oneself from overfitting, while actually trying every single slider. That methodology will give you something that's closer to an ideal portfolio, but unfortunately, producing that requires work. So most people stick with methodology #1 - just check how it performs on the past and think about those numbers. It's easy, you can do it in Excel. For my first trading competitions, I tried my algorithm against both methodologies. In #1, everything looked fine, in #2 it was not. But I did not have time to produce a better algorithm, so I submitted whatever I've got. And unsurprisingly, I lost. This algorithm still has not recovered even though half a year has passed. Which means that methodology #1 is useless.
(the blue is after the competition started)


Which would imply that all the portfolio management choices should be either made by doing a lot of work using methodology #2, or taken completely at random because it does not actually matter. All the fancy portfolio management tools make you think that you are in control, while in fact before you have done any work, you aren't.

Now, what does the methodology #2 tell us about the ratio of bonds to stocks, about which index to pick, about whether we should care about all the alternative investment opportunities? Unfortunately, I don't have time to fully explore those questions. Let me set a plan for myself:

First of all, if strategy fails Methodology #1 (look how it performs on the past), then it's definitely a bad strategy, so #1 is not useless after all. It's a good sanity check to start with.

There's a problem with #1, though. Depending on how much time you look back, the choices you make may be different. There's a simple way to estimate whether the time you can look back is enough - the Sharpe ratio parameter is made to tell you just that. In fact,
Nyears = 1/Sharpe^2
is the appropriate amount of time to make an reliable choice of what's the trend.  For various indices, we get 2-9years. For individual stocks, it's more like 25 years. Real estate indices, too. If we look at a longer time period, we can determine the trend even better - that given a simple random process model of the stock market has anything to do with reality.

Since some of the stuff we want to trade only existed for 10-20 years, people usually don't go back further. Also there's an idea that somewhere on time scales of 20+ years a change in economic epochs happen, and whatever was true does not have any predictive power for the other. Of course, there changes happening on all time scales, so such distinction is arbitrary. But we need to start somewhere.

So we want to choose among market instruments that have SR>0.25 on the last 20 years, roughly. Individual stocks are not  expected to comply with this requirement - their Sharpe ratio over the past 20 yrs is heavily fluctuating with really small mean, like 0.1. But pretty much any way of adding them up into index will give the desired SR. Also there are other instruments. So, there are a lot of pre-made indices we can allocate our money in. Methodology #1 tells us to chose an appropriate rate of return and risks (total Sharpe ratio). If you know how many years later you want to use the money from your investment for something (like buying a house, paying for the kids' college, retirement), then the Nyears from formula above should be less than your time scale. Of the remaining options, you just maximize returns. So you end up with some proportion of money allocated in different indices, such that it happened to have sufficiently high SR and highest returns on the past 20 yrs. This is what people use. As an option, you can say that "I'm not gonna need this money for anything" and just put them for highest returns available, which is not a bad strategy since we restricted SR to be >0.25 above anyways. So you don't have to know exactly when you gonna have kids :)

This is kind of backwards. Somebody already created an index by choosing which proportions to use for different companies. Now you are choosing which proportions of your money to have in different indices. A lot of work has been swept under the rug - in principle, different indices could have been made for you, and you'd never know. One of the central ideas of methodology #2 is about making it a fair comparison, where every, even seemingly irrational strategy, gets a chance. The parameters of the model would be individual coefficients. The hyper-parameters would be the exact prescriptions to obtain them based on the observed performance. The distinction between parameters and hyperparameters is arbitrary, of course.

For example, methodology #1 is now just one of the possible points in the space of hyperparameters. It's not so much work, but I haven't come with others yet. The numerical tests are also not done yet. Let's see if I have time for this - the difference is between having a verified 3-7% e.v. interest rate and just doing something that has e.v. 0% Probably it won't be negative by this method, just because to make B&H strategy negative, one really needs those stocks that went extinct. Maybe a careful numerical test will show some strategies to be negative. Anyways, it's about 3-7% of my investment yearly if I decide to invest B&H, so it's probably worth my time.

I probably won't be able to test those portfolio managing programs, because they have very many numbers involved. But at least this is a first step of actually making an intelligent choice.