风险因素模型库python风格。
shortrate的Python项目详细描述
风险因素模型库python风格。
示例用法
frombusinessdateimportBusinessDate,BusinessRangefromdcfimportZeroRateCurve,FxCurvefromtimewaveimportConsumer,EnginefromshortrateimportRiskFactorProducer,GBMFxCurve,HullWhiteCurve,HullWhiteFxCurve,HullWhiteMultiCurrencyCurves=BusinessDate()t=s+'10y'g=BusinessRange(s,t,'6M')d=ZeroRateCurve([s],[0.05])f=ZeroRateCurve([s],[0.04])x=FxCurve([s],[.8],domestic_curve=d,foreign_curve=f)r=GBMFxCurve.cast(x,volatility=0.2)printr.evolve(1.,s,s+'1y',0.01)printr.get_fx_rate(s+'3y'),r._factor_dateprintr.evolve(1.,s+'1y',s+'5y',0.1)printr.get_fx_rate(s+'7y'),r._factor_datehwd=HullWhiteCurve.cast(d,mean_reversion=0.01,volatility=0.03,terminal_date=t)hwf=HullWhiteCurve.cast(f,mean_reversion=0.01,volatility=0.03,terminal_date=t)hwx=HullWhiteFxCurve.cast(r,hwd,hwf)hwxf=HullWhiteMultiCurrencyCurve.cast(hwf,hwd,hwx)printhwd.evolve(1.,s,s+'1y',0.01)printhwf.evolve(1.,s,s+'1y',0.02)printhwx.evolve(1.,s,s+'1y',(0.01,0.02,0.01))printhwxf.evolve(1.,s,s+'1y',0.02)func=(lambdax:hwd.get_cash_rate(t-'1y'))c=Consumer(lambdax:func(x.date))res=Engine(RiskFactorProducer(hwd),c).run(g,100)printres
安装
最新的稳定版本始终可以通过pip安装或更新:
$ pip install shortrate
如果上述操作失败,请尝试轻松安装:
$ easy_install shortrate
开发版本
最新的开发版本可以直接从github安装:
$ pip install --upgrade git+https://github.com/pbrisk/shortrate.git
贡献
Issues和Pull Requests总是受欢迎的。
许可证
根据apache软件许可证提供了代码和文档(请参见LICENSE)。