/*@@@@@@@@@@@@@@@@@@@@@@ LookBack.h @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 Random Option Pricing
 Summer 2002
 Authors: A. Korobchevsky
          S. Ferrando
 Ryerson University ALL RIGHTS RESERVED
 
 Purpose: Implements the European Average Strike option 

 Instance variables:
	  sum_St - total stock price for all timesteps
	       N - number of timesteps
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#ifndef LOOK_BACK_H__
#define LOOK_BACK_H__

struct LookBack : Derivative
{ 



  /******************************* LookBack ***************************
   * Function: LookBack
   * Purpose: Constructor
   * Param: Starting asset value
   * Returns: N/A
   ********************************************************************/
  LookBack()
  { min_St = this->S0 = 2000000000000000.0;
  }




  /*********************** init ***************************************
   * Function: init
   * Purpose: Initialises sum_St utility parameter
   * Param: N/A
   * Returns: N/A
   * Note: Empty for path independent derivatives
   ********************************************************************/
  void init()
  { min_St = this->S0;
  }




  /********************* payOff ****************************************
   * Function: payOff
   * Purpose: Returns the option payoff
   * Param: Final stock price
   * Returns: option payoff
   * Precondiion: Underlying and derivative parameter must be initialized
   * Note: Call only after all timesteps are completed
   ********************************************************************/
  double payOff(double St)
  { return St - min_St;
  }




  /*********************** update *************************************
   * Function: update
   * Purpose: Updates the sum values between timesteps
   * Param: Stock value at any given point
   * Returns: N/A
   * Note: Empty for path independent derivatives
   ********************************************************************/
  void update(double St)
  { if (min_St > St) min_St = St;
  }




  private:
    double S0;
};

#endif
