How to use the quantlib.time.api.NullCalendar function in QuantLib

To help you get started, we’ve selected a few QuantLib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enthought / pyql / examples / test_process.py View on Github external
def flat_rate(forward, daycounter):
    return FlatForward(
        quote           = SimpleQuote(forward),
        settlement_days = 0,
        calendar        = NullCalendar(),
        daycounter      = daycounter
    )

DtSettlement = today()

settings = Settings()
settings.evaluation_date = DtSettlement

daycounter = ActualActual()
calendar = NullCalendar()

iRate = .1
iDiv = .04

risk_free_ts = flat_rate(iRate, daycounter)
dividend_ts = flat_rate(iDiv, daycounter)

s0 = SimpleQuote(32.0)

# Bates model

v0 = 0.05
kappa = 5.0;
theta = 0.05;
sigma = 1.0e-4;
rho = 0.0;
github enthought / pyql / examples / test_process.py View on Github external
def flat_rate(forward, daycounter):
    return FlatForward(
        quote           = SimpleQuote(forward),
        settlement_days = 0,
        calendar        = NullCalendar(),
        daycounter      = daycounter
    )
github enthought / pyql / quantlib / mlab / option_pricing.py View on Github external
def _blsimpv(price, spot, strike, risk_free_rate, time,
             option_type='Call', dividend=0.0):

    spot = SimpleQuote(spot)
    daycounter = ActualActual()
    risk_free_ts = FlatForward(today(), risk_free_rate, daycounter)
    dividend_ts = FlatForward(today(), dividend, daycounter)
    volatility_ts = BlackConstantVol(today(), NullCalendar(),
                                     .3, daycounter)

    process = BlackScholesMertonProcess(spot, dividend_ts,
                                        risk_free_ts, volatility_ts)

    exercise_date = today() + Period(time * 365, Days)
    exercise = EuropeanExercise(exercise_date)

    payoff = PlainVanillaPayoff(option_type, strike)

    option = EuropeanOption(payoff, exercise)
    engine = AnalyticEuropeanEngine(process)
    option.set_pricing_engine(engine)

    accuracy = 0.001
    max_evaluations = 1000
github enthought / pyql / examples / settings_with_QL_error.py View on Github external
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

calendar = TARGET()

date_today      = Date(6,9,2011)
date_payment    = Date(6,12,2000)
settlement_days = 2

quote = SimpleQuote(value=0.03)

term_structure = FlatForward(
    settlement_days = settlement_days,
    quote           = quote,
    calendar        = NullCalendar(),
    daycounter      = Actual360()
)

try:
    df_1 = term_structure.discount(date_payment)
    print('rate: %f df_1: %f' % (quote.value, df_1))
except RuntimeError as exc:
    logger.error('Evaluation date and discount date issue.')
    logger.exception(exc)
github enthought / pyql / examples / scripts / HestonSimulation-2.py View on Github external
def flat_rate(forward, daycounter):
    return FlatForward(
        quote           = SimpleQuote(forward),
        settlement_days = 0,
        calendar        = NullCalendar(),
        daycounter      = daycounter
    )

settings = Settings.instance()
settlement_date = today()
settings.evaluation_date = settlement_date

daycounter = ActualActual()
calendar = NullCalendar()

interest_rate = .1
dividend_yield = .04

risk_free_ts = flat_rate(interest_rate, daycounter)
dividend_ts = flat_rate(dividend_yield, daycounter)

s0 = SimpleQuote(100.0)

# Heston model

v0 = 0.05
kappa = 5.0;
theta = 0.05;
sigma = 1.0e-4;
rho = -0.5;
github enthought / pyql / quantlib / util / rates.py View on Github external
def flat_rate(forward, daycounter):
    """
    Create a flat yield curve, with rate defined according
    to the specified day-count convention.
    Used mostly for unit tests and simple illustrations.
    """

    return FlatForward(
        forward=SimpleQuote(forward),
        settlement_days=0,
        calendar=NullCalendar(),
        daycounter=daycounter
    )
github enthought / pyql / examples / bonds.py View on Github external
bond = FixedRateBond(
    settlement_days,
    face_amount,
    fixed_bond_schedule,
    [coupon_rate],
    ActualActual(ISMA),
    Following,
    redemption,
    issue_date
)

discounting_term_structure = YieldTermStructure(relinkable=True)
flat_term_structure = FlatForward(
    settlement_days = 1,
    forward         = 0.044,
    calendar        = NullCalendar(),
    daycounter      = Actual365Fixed(),
    compounding     = Continuous,
    frequency       = Annual)
discounting_term_structure.link_to(flat_term_structure)
pricing_engine = DiscountingBondEngine(discounting_term_structure)
bond.set_pricing_engine(pricing_engine)


print('Settlement date: ', bond.settlement_date())
print('Maturity date:', bond.maturity_date)
print('Accrued amount: ', bond.accrued_amount(bond.settlement_date()))
print('Clean price:', bond.clean_price)
github enthought / pyql / examples / simulate_example.py View on Github external
def flat_rate(forward, daycounter):
    return FlatForward(
        forward         = SimpleQuote(forward),
        settlement_days = 0,
        calendar        = NullCalendar(),
        daycounter      = daycounter
    )
github enthought / pyql / examples / simulate_example.py View on Github external
def flat_rate(forward, daycounter):
    return FlatForward(
        forward         = SimpleQuote(forward),
        settlement_days = 0,
        calendar        = NullCalendar(),
        daycounter      = daycounter
    )

settings = Settings.instance()
settlement_date = today()
settings.evaluation_date = settlement_date

daycounter = ActualActual()
calendar = NullCalendar()

interest_rate = .1
dividend_yield = .04

risk_free_ts = flat_rate(interest_rate, daycounter)
dividend_ts = flat_rate(dividend_yield, daycounter)

s0 = SimpleQuote(32.0)

# Heston model

v0 = 0.05
kappa = 5.0
theta = 0.05
sigma = 1.0e-4
rho = -0.5