00001 #pragma once
00002
00003 #ifndef OPTIONSTRATEGY_H
00004 #define OPTIONSTRATEGY_H
00005
00006 #include "BlackScholes.h"
00007 #include "../../common/types.h"
00008
00009 #include <valarray>
00010
00011 using namespace std;
00012
00013 static const Natural maxNbOptions=500;
00014 static const Real defaultshiftRate=0.0001;
00015 static const Real defaultshiftVol=0.0001;
00016 static const Real defaultshiftMat=0.01;
00017 static const Real defaultshiftSpot=0.0001;
00018 static const Real defaultshiftStrike=0.0001;
00019
00020 class OptionStrategy
00021 {
00027 friend ostream& operator << (ostream &os, const OptionStrategy& optionStrategy);
00028 friend ostream& operator << (ostream &os, const OptionStrategy* optionStrategy) {
00029 return os << *optionStrategy;
00030 }
00031
00032 public:
00034 OptionStrategy();
00035 ~OptionStrategy();
00037 void addOneOptionToStrategy(Real spot, Real vol,bool isVol, Real r, Real K, Real T,TypeOptionBS type,Real Quantity);
00038 void addOneBlackScholesObject(BlackScholes* bs,Real Quantity);
00039
00041 void addLongCallSpread(Real spot,Real volStrike1,bool isVol1,Real volStrike2,bool isVol2,Real r, Real K1, Real K2, Real T,Real Quantity);
00043 void addLongStraddle(Real spot,Real vol,bool isVol, Real r, Real K, Real T,Real Quantity);
00045 void addLongStrangle(Real spot,Real volStrike1,bool isVol1,Real volStrike2,bool isVol2,Real r, Real K1, Real K2, Real T,Real Quantity);
00048 void addLongButterflySpread(Real spot,Real volStrike1,bool isVol1,Real volStrike2,bool isVol2,Real volStrike3,bool isVol3, Real r, Real K1, Real K2, Real T,Real Quantity);
00049 void addLongButterflySpread(Real spot,Real volStrike1,bool isVol1,Real volStrike2,bool isVol2,Real volStrike3,bool isVol3, Real r, Real K1, Real K2, Real K3, Real T,Real Quantity);
00051 void addLongRatioCallSpread(Real spot,Real volStrike1,bool isVol1,Real volStrike2,bool isVol2, Real r, Real K1, Real K2, Real T,Real Quantity);
00053 void addLongPutSpread(Real spot,Real volStrike1,bool isVol1,Real volStrike2,bool isVol2,Real r, Real K1, Real K2, Real T,Real Quantity);
00054
00056 Real getGlobalDelta();
00057 Real getGlobalGamma();
00058 Real getGlobalVega();
00059 Real getGlobalTheta();
00060 Real getGlobalRho();
00061
00063 Real returnPrice();
00065 Real recalcPrice();
00067 Natural returnNbOptions() const;
00068
00070 BlackScholes* returnOption(Natural i) const;
00071
00073 Real returnOptionQuantity(Natural i) const;
00074
00076 void changeRate(Real addConstant=defaultshiftRate);
00077
00079 void changeVol(Real addConstant=defaultshiftVol);
00080
00082 void changeMaturity(Real addConstant=defaultshiftMat);
00083
00085 void changeSpot(Real addConstant=defaultshiftSpot);
00086
00088 void changeStrike(Real addConstant=defaultshiftStrike);
00089
00090 private:
00091 Real _price;
00092 Natural _nbOptions;
00093 valarray <BlackScholes*> _insideOptions;
00094 valarray <Real> _insideQuantities;
00095 };
00096
00097 #endif
00098