Changeset 17527
- Timestamp:
- 08/12/08 17:42:38 (5 months ago)
- Location:
- lang/python/option_tools
- Files:
-
- 1 added
- 1 modified
-
__init__.py (added)
-
alpha.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/python/option_tools/alpha.py
r17522 r17527 6 6 7 7 def effectiveWeight_Call(S0,C0,K,T,R,V,V1,mu=None,cacheNum=10000,newtonNum=10,seed=0): 8 """ 9 対数効用関数に基づいた、無リスク資産とコールオプションの最適成長比率を求めます。 8 """対数効用関数に基づいた、無リスク資産とコールオプションの対数最適成長比率を求めます。 10 9 11 10 引数: … … 26 25 cache = [] 27 26 random.seed(seed) 28 avg = -0.5*V1*V1 if not mu else mu 27 avg = -0.5*V1*V1 if not mu else mu #指定されなかったらマルチンゲールにする。 29 28 30 29 for i in range(cacheNum): 31 #対数正規分布に基づいて未来の 値を算出30 #対数正規分布に基づいて未来の価格を算出 32 31 S = S0*random.lognormvariate(avg, V1) 33 32 cnd = C0 / (BS_Call(S,K,T,R,V)-C0) … … 39 38 40 39 def _newtonsMethod(num,init_alpha,cache,i=1): 40 """ニュートン法を用いて最適対数成長率αの値を求めます。 41 """ 41 42 if i > num: 42 43 return init_alpha … … 48 49 49 50 def _m(alpha,cache): 51 """対数成長率mの値を求めます。 52 """ 50 53 total = sum([math.log( (alpha/x) + 1 ) for x in cache]) 51 54 return total / len(cache) 52 55 53 56 def _m_alpha(alpha,cache): 57 """mをαで偏微分した関数です。 58 """ 54 59 total = sum([1.0/(alpha + x) for x in cache]) 55 60 return total / len(cache) 56 61 57 62 def _m2_alpha2(alpha,cache): 63 """mの2階偏微分関数です。 64 """ 58 65 total = sum([-1.0/((alpha + x)**2) for x in cache]) 59 66 return total / len(cache)
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)