Monday, August 12, 2013

Emerging Economies Aren't Driving the Recovery - WSJ


Monday, May 6, 2013

Python Snippet - Pearson Correlation function

Here's the code I wrote in Python to calculate the Pearson Correlation. It works just like the Java version.

def get_Pearson_Correlation(dataseries1, dataseries2):
    result = 0.0
    sum_sq_x = 0.0
    sum_sq_y = 0.0
    sum_coproduct = 0.0
    mean_x = dataseries1[0]
    mean_y = dataseries2[0]

    for i in range(2,len(dataseries1)+1):
        sweep = (i-1)/float(i)
        delta_x = dataseries1[i-1]-mean_x
        delta_y = dataseries2[i-1]-mean_y
        sum_sq_x += delta_x * delta_x * sweep
        sum_sq_y += delta_y * delta_y * sweep
        sum_coproduct += delta_x * delta_y * sweep
        mean_x += delta_x / float(i)
        mean_y += delta_y / float(i)

    pop_sd_x = (sum_sq_x / float(len(dataseries1)))**0.5
    pop_sd_y = (sum_sq_y / float(len(dataseries1)))**0.5
    cov_x_y = sum_coproduct / float(len(dataseries1))

    result = cov_x_y / (pop_sd_x*pop_sd_y)

    return result

Java Snippet - Pearson Correlation function

I am not certain the math is completely correct, regardless, this might serve as a good base to build upon or improve. If you encounter errors feel free to comment!

public class PearsonCorrelation {
   
    public static double getPearsonCorrelation(double[] scores1, double[] scores2){
        double result = 0;
        double sum_sq_x = 0;
        double sum_sq_y = 0;
        double sum_coproduct = 0;
        double mean_x = scores1[0];
        double mean_y = scores2[0];
       
        for(int i=2;i<scores1.length+1;i+=1){
            double sweep = Double.valueOf(i-1)/i;
            double delta_x = scores1[i-1]-mean_x;
            double delta_y = scores2[i-1]-mean_y;
            sum_sq_x += delta_x * delta_x * sweep;
            sum_sq_y += delta_y * delta_y * sweep;
            sum_coproduct += delta_x * delta_y * sweep;
            mean_x += delta_x / i;
            mean_y += delta_y / i;
        }
       
        double pop_sd_x = (double) Math.sqrt(sum_sq_x/scores1.length);
        double pop_sd_y = (double) Math.sqrt(sum_sq_y/scores1.length);
        double cov_x_y = sum_coproduct / scores1.length;
       
        result = cov_x_y / (pop_sd_x*pop_sd_y);
       
        return result;
    }
}

Wednesday, April 24, 2013

Monday, January 21, 2013

List of Top 10 Trader Mistakes

  1. Failure to have a trading plan in place before a trade is executed.
  2. Inadequate trading assets or improper money management.
  3. Expectations that are too high, too soon.
  4. Failure to use protective stops.
  5. Lack of “patience” and “discipline.”
  6. Trading against the trend–or trying to pick tops and bottoms in markets.
  7. Letting losing positions ride too long.
  8. “Over-trading.”
  9. Failure to accept complete responsibility for your own actions.
  10. Not getting a bigger-picture perspective on a market.

10 Lessons From the Market Crash of 1987

1. Stay objective when others get emotional
2. Be like Buffett: Buy on the fear, sell on the greed
3. Make a crash shopping list
4. What goes up fast comes down faster
5. There’s no such thing as ‘it can’t happen’
6. Tune out the daily noise
7. Don’t bail
8. Don’t use the calendar to rebalance your portfolio
9. Bet with your head, not over it
10. Investors face greater risk now

Some David Rosenberg Rules to Remember

This list comes from Economist David Rosenberg, formerly Merrill Lynch’s chief dismal scientist, now at Gluskin Sheff:
1. In order for an economic forecast to be relevant, it must be combined with a market call.
2. Never be a slave to the date – they are no substitute for astute observation of the big picture.

3. The consensus rarely gets it right and almost always errs on the side of optimism – except at the bottom.

4. Fall in love with your partner, not your forecast.

5. No two cycles are ever the same.

6. Never hide behind your model.

7. Always seek out corroborating evidence.

8. Have respect for what the markets are telling you.

9. Be constantly aware with your forecast horizon – many clients live in the short run.

10. Of all the market forecasters, Mr. Bond gets it right most often.

11. Highlight the risks to your forecasts.

12. Get the US consumer right and everything else will take care of itself.

13. Expansions are more fun than recessions (straight from Bob Farrell’s quiver!).

Some Warren Buffet quotes on investing and the stock market

Money Management: “In the 20th century, the United States endured two world wars and other traumatic and expensive military conflicts; the Depression; a dozen or so recessions and financial panics; oil shocks; a flu epidemic; and the resignation of a disgraced president. Yet the Dow rose from 66 to 11,497.”

The Business of Investing: “I always knew I was going to be rich. I don’t think I ever doubted it for a minute.”

The Investor Self: “It’s better to hang out with people better than you. Pick out associates whose behavior is better than yours and you’ll drift in that direction.”

Market Analysis: “Risk comes from not knowing what you’re doing.”

Routines: “The business schools reward difficult complex behavior more than simple behavior, but simple behavior is more effective.”

Stalking: “I don’t look to jump over 7-foot bars; I look around for 1-foot bars that I can step over.”

Buying: “Why not invest your assets in the companies you really like? As Mae West said, “Too much of a good thing can be wonderful.”

Monitoring Positions: “Rule No. 1: Never lose money. Rule No. 2: Never forget Rule No. 1.”

Selling: “Should you find yourself in a chronically leaking boat, energy devoted to changing vessels is likely to be more productive than energy devoted to patching leaks.”

Review: “If past history was all there was to the game, the richest people would be librarians.”

May 6th 2010 - Stock market flash crash videos

Here we have a collection of videos of those moments in which the equity market had a huge drop in minutes, called the "flash crash".   CNBC HD clip:  

An euforic guy with his candlestick charts:

  A trader living the flash crash:  

List of 17 General Trading Rules & Investing Lessons

  1. Establish your risk and stop loss before you hit the buy key.
  2. If it's worth trading, it's worth writing it down. Keep a journal.
  3. Embrace the "Law of Probabilities" and execute your system with consistency.
  4. Embrace technology and take it with you to track positions when you travel.
  5. Investing is a competition.  Bring your "A" game mindset to the table every day.
  6. Yesterday's state of mind doesn't matter.  The only thing that matters is today, here and now.
  7. Listen to the market.  Focus on what the market is telling you, and don't concern yourself with trying to figure out why it's happening.
  8. Every trade should yield a key takeaway lesson.
  9. Stay true to your methodology and your system, not your emotions.
  10. Be brutally honest about your personal "enemies within" and deal with them. Know yourself.
  11. Procrastination and denial have no place in a trader's tool kit.
  12. Do not trade when you are discombobulated or out of equilibrium.
  13. Don't focus on the dollars.  Focus instead on the execution of your trading methodology.
  14. Devise both a bullish and a bearish scenario for your equity when the market is closed.
  15. Never give back more than 50% of your profits on an equity.
  16. Selling is a solo inner struggle.  Don't look for company.
  17. Never lose sight of your money management routines.

HFT - High Frequency Trading - Why and how milliseconds matter

HFT High Frequency Trading Milliseconds Matter

Music Video for Traders - Before He Trades song

The high cost of bad buy and sell decisions

The high cost of bad buy sell decisions

Sunday, January 20, 2013