2013-03-07 5 views
5

私は、Pythonの非常に基本的な変動金利ボンドの価格を、Quantlib(v1.2)SWIGラッパーを使用して評価しようとしています。私はドキュメントに含まれている例を変更しました。Pythonを使用しているquantlibの価格設定

私の債券は4年満期です。 liborは10%に設定され、債券のスプレッドは0です。私の質問は、私が10%の利率で割り引いている場合、なぜ債券100のPVがないのですか?私は99.54の値を得ています。

ありがとうございます!あなたは(30/360)を提供し、支払日カウンタと一致していません

from QuantLib import * 

frequency_enum, settle_date = 4, Date(5, 1, 2010) 
maturity_date = Date(5, 1, 2014) 
face_amount = 100.0 
settlement_days = 0 
fixing_days = 0 

calendar = NullCalendar() 
settle_date = calendar.adjust(settle_date) 
todays_date = calendar.advance(settle_date, -fixing_days, Days) 
Settings.instance().evaluationDate = todays_date 

rate = 10.0/100.0 

flat_forward = FlatForward(settle_date, 
          rate, 
          Thirty360(), 
          Compounded, 
          frequency_enum) 

discounting_term_structure = RelinkableYieldTermStructureHandle(flat_forward) 
index_term_structure = RelinkableYieldTermStructureHandle(flat_forward) 

index = USDLibor(Period(3, Months), index_term_structure) 

schedule = Schedule(settle_date, 
        maturity_date, Period(frequency_enum), 
        NullCalendar(), 
        Unadjusted, Unadjusted, 
        DateGeneration.Forward, False) 

floating_bond = FloatingRateBond(settlement_days, 
           face_amount, 
           schedule, 
           index, 
           Thirty360(), 
           Unadjusted, 
           fixing_days, 
           [], # Gearings 
           [0], # Spreads 
           [],  # Caps 
           [],  # Floors 
           False, # Fixing in arrears 
           face_amount, 
           settle_date) 

bond_engine = DiscountingBondEngine(discounting_term_structure) 
floating_bond.setPricingEngine(bond_engine) 

# coupon pricers 
pricer = BlackIborCouponPricer() 

volatility = 0.0 
vol = ConstantOptionletVolatility(settlement_days, 
            calendar, 
            Unadjusted, 
            volatility, 
            Thirty360()) 

pricer.setCapletVolatility(OptionletVolatilityStructureHandle(vol)) 
setCouponPricer(floating_bond.cashflows(), pricer) 

print floating_bond.NPV(), floating_bond.cleanPrice(), floating_bond.dirtyPrice() 

答えて

4

クーポン・レートがUSDLiborの日カウンタを使用して固定されている(つまり、360 /実です)。あなたはクーポンを検査することによってそれを見ることができます:Tはすべてのクーポン0.25 =が、10%よりも金利が低くあなたを与える

cfs = floating_bond.cashflows() 
coupons = [ as_coupon(c) for c in cfs[:-1] ] # the last one is the redemption 
print [ (c.rate(), c.accrualPeriod()) for c in coupons ] 

を。

希望する価格を取得するには、レートと発生期間を一致させる必要があります。 1つの方法は、Actual360()を私のマシンに100.002の価格を与える債券の日のカウンタとして渡すことです(私はこれ以上調査しませんでしたが、不一致はLIBOR固定の終了日に起因する可能性があります。 USDのカレンダーで、クーポンの最後と正確に一致しない可能性があります)。もう1つの方法は、内部の30/360日カウンタを使用してカスタムLIBORインデックスを作成することです。私はこれを自分で試したことはありませんが、IborIndexクラスの適切なインスタンスを作成することでそれを行うことができます。

+2

ありがとうございました。私はカスタムインデックスを作成し、私は100.0の正確な結果を得ました!カスタムインデックスは次のとおりです: 'index = IborIndex( 'USD Libor'、期間(3ヶ月)、決済日、USDCurrency()、NullCalendar()、未調整、False、Thirty360()、index_term_structure)' – ducky

関連する問題