Friday, April 19, 2013

Choosing which investment to liquidate

I needed cash recently and had to figure out whether to take it out of savings or liquidate some investments. I came up with the following logic for deciding the investment liquidation order. Please let me know if you see any flaws in my reasoning!

Suppose you have $100 in savings (S), and stocks A and B are selling at $100, and you need $100 in cash now. Do you liquidate A, B, or S? You should liquidate the investment you expect will drop in "effective price."

Effective Price
I call "effective price" (I don't know what the real name is) the price of a stock after taxes. Suppose you bought a stock at $1 this year and it's current price is $100. You can sell the stock for $100 to meet your cash flow needs but your $99 gain will be taxed at the short term capital gains rate of, say, 25% = $24.75. So although you receive $100 today for the stock, you'll have to pay the IRS $24.75 come tax day so the effective price is $100-$24.75=$75.25.

A capital loss increases the effective price since it can be used to offset the capital gains of some other sale. Suppose you bought a stock at $100 and it's current price is $75. Selling the stock causes a short term capital loss of $25. You can later subtract that loss from the capital gains of a sale of another stock, effectively reducing the tax for that second sale by $25*25%=$6.25. Therefore the effective price is $75+$6.75=$81.25.

For Identical Securities, Sell The One With The Highest Effective Price
Suppose A and B are the same stock and are both selling at $100, but you bought A at $1 and B at $10 this year. Thus the effective price of A is $75.25 and B is $77.50. For simplicity assume we only need $75. Its better to sell B since your after tax profit (eg net profit) is higher. If you sell B today for the effective price of $77.50 and A tomorrow for $75.25 (assuming the price doesn't change), your net would be $152.75.
(Apparently this is standard practice: see Page 3, Paragraph 2, http://www.invescopowershares.com
/pdf/P-TES-WP-1-E.pdf)


If both stocks are selling at a capital loss it's better to sell the stock with the highest loss since the loss can be used to reduce your net taxable gains. For example, suppose A and B are the same stock selling at $100, but you bought A at $125 and B at $150 this year, which means selling A creates a $25 short term capital loss and selling B generates a $50 loss. As explained earlier the loss increases the effective price: A's effective price become $100+($25*25%)=$106.25 and B's is $100+(50*.25)=$112.50. Therefore we should sell B since it's effective price is higher.


For Different Securities With The Same Price, Sell The One Whose Price Is Expected To Drop or Stay The Same
Now take the exact same scenario except A and B are different stocks. The effective price of A and B is still $75.25 and $77.50, respectively. However, a careful analysis of the companies suggests that A is overvalued at $100 and the price is expected to fall tomorrow to, say, $50 ($37.75 effective price). If you just sold the one with the highest effective price today, B, and A tomorrow your net would be $115.25. However if you sold A because you felt it was overvalued and expected it to fall, then sold B, your net would be $152.75. So for different securities its better to sell the one whose price is expected to drop.

However if we expect the effective prices of A and B to increase then its better to obtain the $75 from savings so we can hopefully capture A and B's gains at a later date.

We don't have to care about the future when the securities are identical (eg stock in the same company) since price changes will effect those securities identically. In other words if A and B are the same stock and the price of the stock go up $10, both A and B will have the same price and their effective prices will change proportionally with the price change. So you want to sell the one with the highest effective price.

Not So Simple
Of course real situations are never this black and white. We don't really know what's going to happen to A and B, and their effective prices may influence the decision:

"If the pursuit of lower taxes affects the pre-tax return potential, then it's not clear that such an approach enhances after-tax return."
https://advisors.vanguard.com/VGApp/iip/site/advisor/researchcommentary/article/IWE_InvComETFTaxEfficiency

Thursday, February 23, 2012

Being true to yourself

I subscribe to the philosophy that there is no absolute right and wrong. Stealing is considered an absolute wrong if you believe Thou Shalt Not Steal. However, in some cases stealing is completely justified (stealing drugs for your sick wife, for example). If you reject the absolutes mandated by religion, right and wrong are relative not absolute.

But relative to what? Relative to some societal norm? I believe right and wrong should be relative to your "true nature," whatever that is. Wolf Larsen's character in the Sea Wolf by Jack London was a monster; however, I agree with his belief that a person should live in accordance with his true nature. Not following your true nature is cowardice.

Happiness only comes when you follow your true nature.

For example, if in your heart you believe you should help someone who has an accident, but you don't because you are afraid to be hurt or sued, you are denying your true nature and are a coward.

I don't steal because some book or priest told me I shouldn't. I don't steal because it's against my true nature.

The same action may be labeled cowardly or not depending on the persons' true nature. If a man insults your wife and you know the right thing is to hit him but you don't because you're afraid, you're a coward. However, if you believe in nonviolence then not hitting is brave not cowardly; in fact, hitting would be cowardly! This is what I mean by relative. The same reaction is cowardly or not depending on the persons' true nature.

The great thing about this philosophy is that if you know your true nature you can ignore everything and everyone when deciding how to live. You don't have to confuse your thoughts with other peoples' beliefs about how you should live. Decisions are hard enough without this noise.

Of course, the hard part is knowing your true nature; separating it from other peoples' perceptions and expectations. Unfortunately I have no advice on discovering your true nature. However, everyone has a true nature--a moral compass. Discovering ones' own true nature by trial-and-error is perhaps what life is all about.

Thursday, April 28, 2011

Sugar: The Bitter Truth

The "Sugar: The Bitter Truth" lecture taught me that most of the fructose (sucrose is fructose+glucose) and alcohol (ethanol) we consume is metabolized as fat, whereas only a little of the glucose we consume is metabolized as fat. The reason is that fructose and ethanol don't trigger insulin production. Since no insulin is produced the brain doesn't shut off the hunger feeling, so want to eat more. This is why high-fructose corn syrup and heavy drinking are bad for you. As the lecturer put it, "fructose is fat, sugar is fat." The reason why God couples fructose and fiber (e.g., sugar cane) is that this naturally limits our fructose intake. Interestingly, HFCS became popular when the FDA recommended a low-fat diet; however, dietary fat isn't the only thing that makes us fat, fructose does too.

I learned to avoid sugared drinks. Since The China Study suggests milk can cause cancer, I'm sticking to water and Vitamin Water Zero. I'll try to eat my carbohydrates with fiber. I'll wait 20 mins before getting a second portion.

Wednesday, April 27, 2011

My weight loss journey

In 2009 I was overweight and looked it. I hit 223 lbs, which is 24 lbs more than the ideal weight for my 6'2" height. I decided to lose weight, eliminate my love handles, and improve my health.

Phase 1: Reduce Caloric Intake, Exercise More
I started a reduced calorie diet. I ordered "reduced portion" lunches and used a small plate for dinner. I reduced or eliminated fast food, soda, unhealthy snacks (e.g., candy, chips, ice cream), and dessert. After reading that people who eat breakfast tend to be more slender, I started eating a 100 calorie breakfast bar for breakfast. I started eating 2-3 pieces of fruit a day.

Snacking at night is a major problem for me. I do it for emotional reasons not hunger. It's very relaxing to snack while reading a book. I replaced unhealthy snacks (e.g., chips) with healthier snacks (e.g., nuts, pretzels), but I still consumed too many calories at the worse possible time--right before bed.

My workout routine at the gym involved 30 mins on the treadmill and 1-1.5 hrs of weight lifting and Nautilus machines. I lost ~5 lbs but I hated it. My company's gym is dreary and simple and usually empty. The treadmill was torture. While I enjoyed weightlifting, my weight and strength had plateaued.

One day I realized that I didn't have to torture myself. Instead, I should just pursue a physical activity I actually enjoyed. So I began taking kung fu classes in Summer 2010.

Phase 2: Kung Fu
I lost 8 pounds (215), reduced my waist size from 35" to 34", reduced body fat from 22.7% to 21.3%, reduced bad cholesterol (LDL) from 172 to 116, and increased good cholesterol (HDL) from 47 to 50. I gained endurance, strength, flexibility, confidence, and fighting ability.

Phase 3: Eat the Right Calories
The "Ultrametabolism" book taught me that some calories--such as those from soda and processed foods--are worse than others--such as those from whole foods. Bad calories slow metabolism and actually make you more hungry. Refined carbohydrates (e.g., high fructose corn syrup) are metabolized into sugar quickly by the body, causing excess insulin production, which leads to insulin resistance--a precursor to Type II diabetes, and causing the body to store the unused energy as body fat. The author advised avoiding foods that have labels (e.g., processed foods) or that our great-grandparents wouldn't recognize (e.g., twinkies). Instead he advised eating whole foods. I also read that sugar and fat cause reactions in our bodies akin to drug addictions.

I stopped eating my 100 calorie breakfast bars for breakfast since they are processed foods. Instead I eat fruit for breakfast.

I lost an additional 10 pounds (205) and reduced my waist size from 34" to 33" by preferring good calories and continuing kung fu. However, I was unable to reach my ideal weight of 199. After slacking off and gaining back 6 pounds (211), I realized more changes were necessary.

Phase 4: Forks Over Knives, Increase Daily Physical Activity, Drink Less Alcohol
"The China Study" book reaffirmed that processed carbohydrates (e.g., white bread, pasta) increase body fat as opposed to complex carbohydrates found in whole foods. Whole plant-based foods are less energy-dense than animal-based foods and contain more water and fiber, which makes your body feel fuller sooner. With a plant-based diet, you don't have to count calories because even though you may actually eat more calories, your metabolism is higher and more calories are expended as heat. The author even suggested we can eat as much plant-based food as we want. However, the author advised against eating excessive nuts if your LDL is over 100 (mine is 116).

The book also provides convincing evidence that plant-based diets decrease risks of cancer, heart disease, diabetes, and obesity.

The "Is Sitting a Lethal Activity?" NY Times article made me realize that sitting at my desk at work for 8 hours/day, 5 days/week was bad because when sitting we expend only 1 calorie/min vs 3 calories/min when walking, our insulin effectiveness and good cholesterol is reduced, and our life expectancy is reduced a few years. Regular exercise (e.g., kung fu) doesn't compensate for a sedentary lifestyle; just like jogging doesn't compensate for smoking. I decided to try to walk and take the stairs more.

I reduced my dinner portions even more to allow me the caloric room to eat healthy snacks at night. However, I'm still trying to reduce snacking.

Update 8/8/11: I achieved my target ideal weight of 199 pounds! So far I've lost 24 pounds and 3 pant sizes (35" -> 32"). My body fat percentage and body mass index are the lowest in 4 years. I celebrated by buying size 32" jeans, which I haven't been able to wear since high school.

Now my goal is to eliminate the remaining belly fat by reducing my weight to 195 and exercising my abs.

Saturday, February 14, 2009

On The Nature Of Happiness

Too much freedom and too many choices--a by-product of modern civilization--cause dissatisfaction, regret, and unhappiness. On the other hand, this allows us to tailor our choices to match our individual preferences.

People incorrectly believe that they will only be happy if they get what they want. They overestimate how much individual decisions and outcomes affect their long-term happiness. This belief is what drives people to be ambitious, productive, industrious, but can also drive people to make moral and ethical compromises. In reality, happiness is relatively fixed regardless of situation (baring extremes like poverty, abuse, sickness).

Tuesday, June 24, 2008

Sending Email Via Wireless

Normally, my Outlook is setup to send email via SMTP (port 25) using SSL encryption to send.columbia.edu. Oftentimes when I connect via a wireless access point, for example, at a hotel or conference, I get the error "Your server does not support the connection encryption type you specified." After troubleshooting using telnet, I found that port 25 was hijacked by the ISP's email server not to send.columbia.edu. The workaround is to use TLS and port 587, which the ISP does not hijack.

Friday, April 25, 2008

Advice for a New PhD Student

To succeed as a PhD student you must publish several papers in the best conferences and journals and become a world-renowned expert in your research area. For the first 2-3 years, classes and teaching will limit the amount of research you can do, so you should:

  • Review research literature - Before you can contribute, you must be an expert on the current state of research in your and peripheral areas.
    • Read lots of papers (IEEE, ACM, CiteSeer).
    • Take notes for each paper you read because you will forget! Write a Related Work-style paragraph. Write notes directly on the paper indicating the overall paper quality, whether it should be cited, tools mentioned that you can use, and important points.
    • Hint: References are valuable for finding relevant papers and conferences.

  • Start by publishing workshop papers - Don't make the mistake I did and submit to a top-tier conference like PLDI from the get go. You'll just waste a lot of time and have nothing to show for it but rejection letters. Make sure you vet your ideas by communicating extensively with your research peers and by publishing workshop papers. The benefits of publishing workshop papers are:
    • You can publish preliminary results and unfinished ideas to determine if your ideas are worth pursuing, find flaws in your logic/arguments, and learn what the main sticking points are and the common questions people ask.
    • Allows your paper/ideas to be peer reviewed so the workshop paper is really just a rough draft for a future conference paper
    • Meet people in your community
    • Pad your publication record
    • You gain practice giving talks. Hint: Practice your talk 2-3 times and make sure you don't exceed the alotted time.

  • Attend conferences and workshops - In the beginning of your PhD program, you should go to conferences and workshops even if you don't have a paper there. This helps to:
    • Make your name known. Remember, by the time you finish your PhD you should be "world renowned." This requires both publications and networking.
    • Find future co-authors
    • Get on future program committees

  • Learn your venues
    • Find out the best conferences and journals in your field (for Software Engineering, look here). Find out where important people in your field publish papers. Subscribe to the SEWORLD and ECOOP Info lists to find out about calls for papers.
    • Create a publication schedule that shows all the conferences and workshops in your area along with their deadlines. Eventually, your life will be structured around these deadlines. Periodically update the schedule so that you are always aware of upcoming deadlines.
    • When considering publishing at a venue, become familar with the papers published in previous years. Is it easy to obtain the papers? Do the papers show up on searches like Google, ACM, IEEE? If the answers are no, publishing at this venue may lessen your paper's impact.

  • Get a summer research internship
    • Line up post-PhD career - Summer internships are really just a recruiting vehicle. The company uses them to determine if they should hire you; for example, to determine if you can do great research. You should knock their socks off so they'll want to hire you after you graduate. Make sure you publish a paper.
    • Fun and profit - Internships are usually great fun, you meet a ton of other interns and contacts, and you make a lot more money than if you stayed at school.
    • Publish a paper - The best indicator of success for an internship is publishing a paper, either at the end of the internship or shortly after. This also communicates to the company that you can do research.
    • Make contacts
    • Hint:Apply in January
The last few years of your PhD should be devoted to research. You should be cranking out high-quality papers during this period and establishing a reputation for high-quality research.
  • Publish, publish, publish - My advisor (Al Aho) requires his PhD students to have "2 good ideas." This translates into 2 papers published in the best conferences (PLDI, POPL, ICSE, FSE, ECOOP, OOPSLA, etc.) and journals (TSE, etc.).
  • Participate - Try to serve on several program committees, serve on an organizing committee, and organize a workshop.
  • Find a job - You should be looking for a job now, not after you graduate.
    • Talk to people at conferences, etc. When these people are deciding who to hire, it will help tremendously that they know you.
    • Subscribe to job postings (CRA, Chronicle, SEWORLD)
    • Try to graduate in May since universities and research labs typically hire on a regular academic schedule. Assistant professor positions for Sept are usually posted in Oct and Sept of the previous year, application deadlines are usually in Jan and Feb, interviews are in Feb and Apr, and offers are made in Feb-May. Labs usually use the same schedule although the start date is immediate.

More advice:

  • Ruthlessly eliminate activities from your life that do not get you closer to finishing your PhD. Throughout your PhD, and especially before embarking on time-consuming activities, ask yourself, "Will this be in my thesis?" If you're spending most of your time coding, there's something wrong. No one cares how much code you write and the elaborate tools and systems you create. They only care about how many good papers you author. For example, I wasted several semesters creating an elaborate system for dynamic aspect-oriented programming and it never produced any publications and was not even mentioned in my thesis. Of course, all research requires some coding. However, rarely does the code see the light of day after you graduate. So keep it simple, quick, and dirty (e.g., PERL is fine). Also, use off-the-shelf software or get someone else to write it (see below). Research papers are a great source for finding out about tools that you can use such as metrics, profilers, compilers, static analyzers, etc.
    The only exception to this is if you are building something that many people will use, thus increasing your reputation. Your dissertation defense committee will appreciate this kind of research contribution. Companies also appreciate this kind of practical work. However, you'll need to develop, support, and market the software, which can be a huge time waster, especially if you don't have any help.

    The same caution about coding goes for teaching, reading, reviewing, meetings, demos, administrivia, etc.

  • Mentoring - Undergrads and master's students can help shoulder some of the coding burden. However, they can also be a huge waste of time and result in a negative net gain.
    • Experience - I like excellent programmers with industrial experience. Industrial experience means they are more likely to produce quality code, are good at collaborating and taking direction, and are likely to be familiar with source control. The more the student needs to learn (programming language, OS, source control, etc.), the more of your time they'll require, and the longer it will take for them to be productive (if ever). For this reason, I eschew undergrads, since they usually have very little programming or industrial experience.
    • Time constraints - I required all students to commit to at least 8 hours a week to working on my project. If the student is taking more than 2 other classes, it is likely they won't be able to meet this. This is another reason why I eschew undergrads, since they usually take a full course load and give the project low priority.
    • Management - You want self-motivated and self-managing students, otherwise you'll spend alot of time managing them. Create a project roadmap that provides enough detail for them to go complete the project. It should include an overview, requirements (checklist of things they need to do), use cases (concrete examples of scenarios they must support), and milestone dates. They should agree to the roadmap before signing up for the class. If you have the time, a good technique is to meet with the students in-person once a week for a combined status meeting and coding session. Create an agenda for student meetings to ensure all issues are addressed
  • Go deep - My mentor at Microsoft Research told me to find a concrete problem and "go deep." Don't try to solve a problem in the abstract. What do you want other people to consider you to be an expert on? Decide what that is and then know that thing better than anyone else in the world. While it may be fun to learn about tangential research areas, you want to be a world renowned expert in one thing not a jack-of-all-trades.
  • Focus on the hard problems - What's the point of getting a PhD if your work has no impact. Your success is measured by your contribution. If you're not working on the most important and hardest problems in your field, then you're contribution is muted. My advisor liked to ask, "Is this a $1000 problem or a $1B problem?"