Portfolio Insurance (concept)
//////////////////////////////////////
From CAPM (Capital Asset Pricing Model), 
      
           R(portfolio)= alpha + beta (Rmkt-Rf) 

  We know that most portfolio has a positive beta. 

  This means that if we expect the market would fall, 
    our portfolio value would fall as well. 

  How to protect our portfolio?
   1) sell our portfolio 
   2) reduce our beta
   3) others 

  We could short the S&P500 futures
                              Value of our portfolio 
       n = (beta* - beta) * -------------------------     
                           value of one S&P500 futures contract 

     where n is the number of the S&P500 futures contract 
           n >0 we long 
           n <0 we short the 
//////////////////////////////////////

Portfolio Insurance (implementation)
//////////////////////////////////////
Portfolio insurance is a method of hedging a portfolio of stocks against the 
market risk by short selling stock index futures. This hedging technique is 
frequently used by institutional investors when the market direction is uncertain 
or volatile.

Assume that we manage a portfolio with a current valued of $5 million today. 
Its beta is 1.25. If we expect the whole market would be quite volatility 
in next 3 months. In other words, the market might go down significantly. 

What might be our choices at the moment?

    Alternative #1: Sell stocks right now and buy them back in a few months
    Alternative #2: Sell S&P500 index futures

 Alternative #1 is costly because of the transaction cost. 
 Let see what happen when the market is down 1 point. Below is today s S&P500 level. 
 
  If the market goes down one point, the long position (S&P500 futures contract) 
  would lose $250, while the short position would gain $250. 

  The size of one futures contract on S&P500 is:    index level *250
  If we what to hedge our $5mportfolio, we should short n futures contracts 
                                  5,000,000
         n    =(beta* - beta)  * ------------------- 
                                (index level *250) 		
     Where, beta* is our target beta
            beta  is the portfolio beta
           index level is the S&P500 index level
    Assume that we plan to reduce our beta from 1.25 to 0.5
    Applying the above formula,https://finance.yahoo.com/
         we should short 6 futures contracts. 
      > (0.5-1.25)*5000000/(2736.27*250)
       [1] -5.481915
   Assume, in three months, it is 2636.27, i.e., 100 points down. 
           What is the loss of your portfolio?
           What is the gain is you short one future contract of S&P500 future?
//////////////////////////////////////