Columbia Trading

Tuesday, February 2, 2016

Kelly Strategy rebalancing

From Wiki:
    https://en.wikipedia.org/wiki/Kelly_criterion

Kelly rebalance will enhance the Sharpe ratio and reduce the risk.

def kelly_strategy():

        # Import history, we have to adjust for a bug that causes extra columns
        # to show up in history sometimes.

       # need to get price history
        prices = history(200, '1d', 'price')
     
        # remove empty or None fields, compute the percentage of change
        R = prices.pct_change().dropna()
     
        # Select securities by assuming all returns are statistically independent
        # and calculate their Kelly leverage.
        kelly = R.mean() / R.var()
     
        # Drop any Nan values and sort in ascending order
        kelly = kelly.dropna()
        kelly.sort()
     
        # just select port_size number of stocks
        picks = kelly.tail(context.port_size)
     
        # Limit short exposure if the Kelly score is negative
        kelly = picks.apply(lambda x: max(x, context.short_pct * x))
     
        # Adjust result to keep the account leverage constant
        kelly *= (context.leverage / kelly.abs().sum())

        # Place orders and sell off any securities that were dropped.
        for stock in data:
            if stock in kelly.index:              
                 # adjust the percentage of stocks, either buy or sell
                order_target_percent(stock, kelly[stock])
            else:
                # sell all of them
                order_target(stock, 0)
     

How to find pairs

  • What is cointegration?
  • How to test for cointegration?
  • What is pairs trading?
  • How to find cointegrated pairs?
  • How to generate a tradeable signal?

three major algorithms

1) Mean reversion
2) Momentum trading
3) Pair trading

Monday, February 1, 2016

My trading platform

I will used quantopian as my platform, which is easy to use. You just need know Python programming.

The following post shared some highlighted algorithm in Quantopian.

http://blog.quantopian.com/5-basic-quant-strategies-implemented-by-the-quantopian-community/

It is interesting to  see the following composition about the algorithms:


  1. Mean Reversion, 37%
  2. Sentiment 28%
  3. Momentum 18%
  4. Portfolio Risk 6%
  5. Volatility 5%
  6. Technical 3%
  7. Seansonality 3%

Strategy 1 : mean-reverting

mean-reverting strategies

In finance, mean reversion is the assumption that a stock's price will tend to move to the average price over time.[1][2]
Using mean reversion in stock price analysis involves both identifying the trading range for a stock and computing the average price using analytical techniques taking into account considerations such as earnings, etc.
When the current market price is less than the average price, the stock is considered attractive for purchase, with the expectation that the price will rise. When the current market price is above the average price, the market price is expected to fall. In other words, deviations from the average price are expected to revert to the average.
Stock reporting services commonly offer moving averages for periods such as 50 and 100 days. While reporting services provide the averages, identifying the high and low prices for the study period is still necessary.
Mean reversion has the appearance of a more scientific method of choosing stock buy and sell points than charting, because precise numerical values are derived from historical data to identify the buy/sell values, rather than trying to interpret price movements using charts (charting, also known as technical analysis).
Some asset classes, such as exchange rates, are observed to be mean reverting; however, this process may last for years and thus is not of value to an investor.
Mean reversion should demonstrate a form of symmetry since a stock may be above its historical average approximately as often as below.
A historical mean reversion model will not fully incorporate the actual behavior of a security's price. For example, new information may become available that permanently affects the long-term valuation of an underlying stock. In the case of bankruptcy, it may cease to trade completely and never recover to its former historical average.