Changeset 17690 for lang/python
- Timestamp:
- 08/16/08 12:38:18 (3 months ago)
- Location:
- lang/python/option_tools
- Files:
-
- 1 added
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/python/option_tools/alpha.py
r17600 r17690 5 5 import random,math 6 6 7 def effectiveWeight_Call(S0,C0,K,T,DT,R,V1=None,V=None,mu=None,cacheNum= 10000,newtonNum=10,seed=0):7 def effectiveWeight_Call(S0,C0,K,T,DT,R,V1=None,V=None,mu=None,cacheNum=20000,newtonNum=10,seed=0): 8 8 """対数最適戦略に基づいた、無リスク資産とコールオプションのポートフォリオにおける最適比率を求めます。 9 9 … … 31 31 cache = [] 32 32 random.seed(seed) 33 avg = -0.5*V1*V1 if not mu else mu34 vol = BS_Call_IV(S0,K,T,R,C0,HV=0.2,maxNum=200) if not V else V35 vol1 = vol*math.sqrt(DT) if not V1 else V136 33 vol = float(V) if V else BS_Call_IV(S0,K,T,R,C0,HV=0.2,maxNum=200) 34 vol1 = float(V1) if V1 else vol*math.sqrt(DT) 35 avg = float(mu) if mu else -0.5*vol1*vol1 36 37 37 for i in range(cacheNum): 38 38 #対数正規分布に基づいて未来の価格を算出 … … 46 46 47 47 def _newtonsMethod(num,init_alpha,cache,i=1): 48 """ニュートン法を用いて 最適対数成長率αの値を求めます。48 """ニュートン法を用いて対数最適戦略でmを最大にするαの値を求めます。 49 49 """ 50 50 if i > num: 51 51 return init_alpha 52 52 else: 53 #print init_alpha,_m_alpha(init_alpha,cache)54 53 delta = _m_alpha(init_alpha, cache)/_m2_alpha2(init_alpha, cache) 55 54 new_alpha = init_alpha - delta
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)