Exemple #1
0
SEQSEQ(ANY) SAL_CALL CalcAddins_impl::qlRangeAccrualFloatersCouponSetPricer(
        const ANY &ObjectId,
        const ANY &RangeAccrualPricer,
        const ANY &Trigger) throw(RuntimeException) {
    try {

        // convert input datatypes to C++ datatypes

        std::string ObjectIdCpp;
        calcToScalar(ObjectIdCpp, ObjectId);

        std::string RangeAccrualPricerCpp;
        calcToScalar(RangeAccrualPricerCpp, RangeAccrualPricer);

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectIdCpp,
            QuantLibAddin::RangeAccrualFloatersCoupon, QuantLib::RangeAccrualFloatersCoupon)

        OH_GET_REFERENCE(RangeAccrualPricerLibObjPtr, RangeAccrualPricerCpp,
            QuantLibAddin::RangeAccrualPricer, QuantLib::RangeAccrualPricer)

        // invoke the member function

        static bool returnValue = true;
        ObjectIdLibObjPtr->setPricer(
                RangeAccrualPricerLibObjPtr);

        // convert and return the return value



        SEQSEQ(ANY) retAnyArray;
        retAnyArray.realloc(1);
        SEQ(ANY) retAnyVector(1);
        STRING s = STRFROMASCII( std::string("VOID").c_str() );    
        retAnyVector[0] = CSS::uno::makeAny( s );
        retAnyArray[0] = retAnyVector;        
        return retAnyArray;

    } catch (const std::exception &e) {
        do { 
            std::ostringstream errorMsg; 
            errorMsg << "ERROR: qlRangeAccrualFloatersCouponSetPricer: " << e.what(); 
            OH_LOG_MESSAGE(errorMsg.str());
        
            SEQSEQ(ANY) retAnyArray;
            retAnyArray.realloc(1);
            SEQ(ANY) retAnyVector(1);
            STRING s = STRFROMASCII( errorMsg.str().c_str() );    
            retAnyVector[0] = CSS::uno::makeAny( s );
            retAnyArray[0] = retAnyVector;	    
            return retAnyArray;
        } while (false);
    }
}
Exemple #2
0
    std::string CALVanillaOption(
            const std::string &ObjectId,
            const std::string &Payoff,
            const std::string &Exercise,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert object IDs into library objects

        OH_GET_REFERENCE(PayoffLibObjPtr, Payoff,
            QuantLibAddin::StrikedTypePayoff, QuantLib::StrikedTypePayoff)

        OH_GET_REFERENCE(ExerciseLibObjPtr, Exercise,
            QuantLibAddin::Exercise, QuantLib::Exercise)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::CALVanillaOption(
                ObjectId,
                Payoff,
                Exercise,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::VanillaOption(
                valueObject,
                PayoffLibObjPtr,
                ExerciseLibObjPtr,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function CALVanillaOption : " << e.what());
        }
    }
Exemple #3
0
XLL_DEC bool *qlRangeAccrualFloatersCouponSetPricer(
        char *ObjectId,
        char *RangeAccrualPricer,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlRangeAccrualFloatersCouponSetPricer"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::RangeAccrualFloatersCoupon, QuantLib::RangeAccrualFloatersCoupon)

        OH_GET_REFERENCE(RangeAccrualPricerLibObjPtr, RangeAccrualPricer,
            QuantLibAddin::RangeAccrualPricer, QuantLib::RangeAccrualPricer)

        // invoke the member function

        static bool returnValue = true;
        ObjectIdLibObjPtr->setPricer(
                RangeAccrualPricerLibObjPtr);

        // convert and return the return value

        return &returnValue;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
    boost::shared_ptr<ObjectHandler::Object> create_qlFwdToCotSwapAdapter(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string ForwardModel =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("ForwardModel"));

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(ForwardModelLibObjPtr, ForwardModel,
            QuantLibAddin::MarketModel, QuantLib::MarketModel)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(ForwardModel);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::FwdToCotSwapAdapter(
                valueObject,
                ForwardModelLibObjPtr,
                Permanent));
        return object;
    }
    boost::shared_ptr<ObjectHandler::Object> create_qlPseudoRootFacade(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string Calibrator =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("Calibrator"));

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(CalibratorLibObjPtr, Calibrator,
            QuantLibAddin::CTSMMCapletCalibration, QuantLib::CTSMMCapletCalibration)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(Calibrator);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::PseudoRootFacade(
                valueObject,
                CalibratorLibObjPtr,
                Permanent));
        return object;
    }
    boost::shared_ptr<ObjectHandler::Object> create_qlVanillaSwapFromSwapRateHelper(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string SwapRateHelper =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("SwapRateHelper"));

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(SwapRateHelperLibObjPtr, SwapRateHelper,
            QuantLibAddin::SwapRateHelper, QuantLib::SwapRateHelper)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(SwapRateHelper);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::VanillaSwap(
                valueObject,
                SwapRateHelperLibObjPtr,
                Permanent));
        return object;
    }
    boost::shared_ptr<ObjectHandler::Object> create_qlGaussianDefaultProbLM(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string Basket =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("Basket"));

        std::vector<std::vector<double> > Factors =
            ObjectHandler::matrix::convert2<double>(valueObject->getProperty("Factors"), "Factors");

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(BasketLibObjPtr, Basket,
            QuantLibAddin::Basket, QuantLib::Basket)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(Basket);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::GaussianDefProbLM(
                valueObject,
                BasketLibObjPtr,
                Factors,
                Permanent));
        return object;
    }
Exemple #8
0
XLL_DEC OPER *qlAbcdCalibrationK(
        char *ObjectId,
        OPER *Times,
        OPER *BlackVols,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlAbcdCalibrationK"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert input datatypes to C++ datatypes

        std::vector<double> TimesCpp =
            ObjectHandler::operToVector<double>(*Times, "Times");

        std::vector<double> BlackVolsCpp =
            ObjectHandler::operToVector<double>(*BlackVols, "BlackVols");

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::AbcdCalibration, QuantLib::AbcdCalibration)

        // invoke the member function

        std::vector<double> returnValue = ObjectIdLibObjPtr->k(
                TimesCpp,
                BlackVolsCpp);

        // convert and return the return value

        static OPER xRet;
        ObjectHandler::vectorToOper(returnValue, xRet);
        return &xRet;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
Exemple #9
0
    std::string qlIssuer(
            const std::string &ObjectId,
            const ObjectHandler::property_t &DefaultCurves,
            const std::string &DefaultEvents,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        std::string DefaultCurvesCpp = ObjectHandler::convert2<std::string>(
            DefaultCurves, "DefaultCurves", "");

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert object IDs into library objects

        OH_GET_REFERENCE_DEFAULT(DefaultCurvesLibObjPtr, DefaultCurvesCpp,
            QuantLibAddin::DefaultProbabilityTermStructure, QuantLib::DefaultProbabilityTermStructure)

        OH_GET_REFERENCE(DefaultEventsLibObjPtr, DefaultEvents,
            QuantLibAddin::DefaultEventSet, QuantLib::DefaultEventSet)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlIssuer(
                ObjectId,
                DefaultCurvesCpp,
                DefaultEvents,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::Issuer(
                valueObject,
                DefaultCurvesLibObjPtr,
                DefaultEventsLibObjPtr,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlIssuer : " << e.what());
        }
    }
Exemple #10
0
    std::string qlScheduleTruncated(
            const std::string &ObjectId,
            const std::string &OriginalSchedule,
            const ObjectHandler::property_t &TruncationDate,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Date TruncationDateLib = ObjectHandler::convert2<QuantLib::Date>(
            TruncationDate, "TruncationDate");

        // convert object IDs into library objects

        OH_GET_REFERENCE(OriginalScheduleLibObjPtr, OriginalSchedule,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlScheduleTruncated(
                ObjectId,
                OriginalSchedule,
                TruncationDate,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::Schedule(
                valueObject,
                OriginalScheduleLibObjPtr,
                TruncationDateLib,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlScheduleTruncated : " << e.what());
        }
    }
Exemple #11
0
    std::string qlVanillaSwapFromSwapIndex(
            const std::string &ObjectId,
            const std::string &SwapIndex,
            const ObjectHandler::property_t &FixingDate,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Date FixingDateLib = ObjectHandler::convert2<QuantLib::Date>(
            FixingDate, "FixingDate");

        // convert object IDs into library objects

        OH_GET_REFERENCE(SwapIndexLibObjPtr, SwapIndex,
            QuantLibAddin::SwapIndex, QuantLib::SwapIndex)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlVanillaSwapFromSwapIndex(
                ObjectId,
                SwapIndex,
                FixingDate,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::VanillaSwap(
                valueObject,
                SwapIndexLibObjPtr,
                FixingDateLib,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlVanillaSwapFromSwapIndex : " << e.what());
        }
    }
Exemple #12
0
XLL_DEC double *qlSimpleFloaterPrice(
        char *ObjectId,
        char *YieldCurve,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlSimpleFloaterPrice"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::RangeAccrualFloatersCoupon, QuantLib::RangeAccrualFloatersCoupon)

        OH_GET_OBJECT(YieldCurveCoerce, YieldCurve, ObjectHandler::Object)
        QuantLib::Handle<QuantLib::YieldTermStructure> YieldCurveLibObj =
            QuantLibAddin::CoerceHandle<
                QuantLibAddin::YieldTermStructure,
                QuantLib::YieldTermStructure>()(
                    YieldCurveCoerce);

        // invoke the member function

        static double returnValue;
        returnValue = ObjectIdLibObjPtr->priceWithoutOptionality(
                YieldCurveLibObj);

        // convert and return the return value

        return &returnValue;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
    boost::shared_ptr<ObjectHandler::Object> create_qlFlatVol(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::vector<double> Volatilities =
            ObjectHandler::vector::convert2<double>(valueObject->getProperty("Volatilities"), "Volatilities");

        std::string Correlations =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("Correlations"));

        std::string EvolutionDescription =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("EvolutionDescription"));

        long Factors =
            ObjectHandler::convert2<long>(valueObject->getProperty("Factors"));

        std::vector<double> InitialRates =
            ObjectHandler::vector::convert2<double>(valueObject->getProperty("InitialRates"), "InitialRates");

        std::vector<double> Displacements =
            ObjectHandler::vector::convert2<double>(valueObject->getProperty("Displacements"), "Displacements");

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(CorrelationsLibObjPtr, Correlations,
            QuantLibAddin::PiecewiseConstantCorrelation, QuantLib::PiecewiseConstantCorrelation)

        OH_GET_UNDERLYING(EvolutionDescriptionLibObj, EvolutionDescription,
            QuantLibAddin::EvolutionDescription, QuantLib::EvolutionDescription)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(Correlations);
        valueObject->processPrecedentID(EvolutionDescription);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::FlatVol(
                valueObject,
                Volatilities,
                CorrelationsLibObjPtr,
                EvolutionDescriptionLibObj,
                Factors,
                InitialRates,
                Displacements,
                Permanent));
        return object;
    }
Exemple #14
0
SEQSEQ(ANY) SAL_CALL CalcAddins_impl::qlIndexName(
        const ANY &ObjectId,
        const ANY &Trigger) throw(RuntimeException) {
    try {

        // convert input datatypes to C++ datatypes

        std::string ObjectIdCpp;
        calcToScalar(ObjectIdCpp, ObjectId);

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectIdCpp,
            QuantLibAddin::Index, QuantLib::Index)

        // invoke the member function

        std::string returnValue = ObjectIdLibObjPtr->name();

        // convert and return the return value



        ANY returnValueCalc;
        scalarToCalc(returnValueCalc, returnValue);

        SEQSEQ(ANY) retAnyArray;
        retAnyArray.realloc(1);
        SEQ(ANY) retAnyVector(1);
        retAnyVector[0] = returnValueCalc;
        retAnyArray[0] = retAnyVector;        
        return retAnyArray;

    } catch (const std::exception &e) {
        do { 
            std::ostringstream errorMsg; 
            errorMsg << "ERROR: qlIndexName: " << e.what(); 
            OH_LOG_MESSAGE(errorMsg.str());
        
            SEQSEQ(ANY) retAnyArray;
            retAnyArray.realloc(1);
            SEQ(ANY) retAnyVector(1);
            STRING s = STRFROMASCII( errorMsg.str().c_str() );    
            retAnyVector[0] = CSS::uno::makeAny( s );
            retAnyArray[0] = retAnyVector;	    
            return retAnyArray;
        } while (false);
    }
}
XLL_DEC OPER *qlEvolutionDescriptionFirstAliveRate(
        char *ObjectId,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlEvolutionDescriptionFirstAliveRate"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::EvolutionDescription, QuantLib::EvolutionDescription)

        // invoke the member function

        std::vector<QuantLib::Size> returnValue = ObjectIdLibObjPtr->firstAliveRate();

        // convert and return the return value

        std::vector<long> returnValVec =
            QuantLibAddin::convertVector<QuantLib::Size, long>(returnValue);
        static OPER xRet;
        ObjectHandler::vectorToOper(returnValVec, xRet);
        return &xRet;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
Exemple #16
0
XLL_DEC char *qlSwaptionType(
        char *ObjectId,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlSwaptionType"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::Swaption, QuantLib::Swaption)

        // invoke the member function

        QuantLib::VanillaSwap::Type returnValue = ObjectIdLibObjPtr->type();

        // convert and return the return value

        std::ostringstream os;
        os << returnValue;
        static char ret[XL_MAX_STR_LEN];
        ObjectHandler::stringToChar(os.str(), ret);
        return ret;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
Exemple #17
0
XLL_DEC OPER *qlPiecewiseConstantVarianceVolatilities(
        char *ObjectId,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlPiecewiseConstantVarianceVolatilities"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::PiecewiseConstantVariance, QuantLib::PiecewiseConstantVariance)

        // invoke the member function

        std::vector<double> returnValue = ObjectIdLibObjPtr->volatilities();

        // convert and return the return value

        static OPER xRet;
        ObjectHandler::vectorToOper(returnValue, xRet);
        return &xRet;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
Exemple #18
0
XLL_DEC long *qlExerciseLastDate(
        char *ObjectId,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlExerciseLastDate"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::Exercise, QuantLib::Exercise)

        // invoke the member function

        QuantLib::Date returnValue = ObjectIdLibObjPtr->lastDate();

        // convert and return the return value

        static long returnValueXL;
        returnValueXL = static_cast<long>(QuantLibAddin::libraryToScalar(returnValue));
        return &returnValueXL;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
    boost::shared_ptr<ObjectHandler::Object> create_qlFwdPeriodAdapter(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string LargeModel =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("LargeModel"));

        long Period =
            ObjectHandler::convert2<long>(valueObject->getProperty("Period"));

        long Offset =
            ObjectHandler::convert2<long>(valueObject->getProperty("Offset"));

        std::vector<double> Displacements =
            ObjectHandler::vector::convert2<double>(valueObject->getProperty("Displacements"), "Displacements");

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(LargeModelLibObjPtr, LargeModel,
            QuantLibAddin::MarketModel, QuantLib::MarketModel)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(LargeModel);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::FwdPeriodAdapter(
                valueObject,
                LargeModelLibObjPtr,
                Period,
                Offset,
                Displacements,
                Permanent));
        return object;
    }
    boost::shared_ptr<ObjectHandler::Object> create_qlAccountingEngine(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string MarketModelEvolver =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("MarketModelEvolver"));

        std::string Product =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("Product"));

        double InitialNumeraireValue =
            ObjectHandler::convert2<double>(valueObject->getProperty("InitialNumeraireValue"));

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert object IDs into library objects

        OH_GET_REFERENCE(MarketModelEvolverLibObjPtr, MarketModelEvolver,
            QuantLibAddin::MarketModelEvolver, QuantLib::MarketModelEvolver)

        OH_GET_UNDERLYING(ProductLibObj, Product,
            QuantLibAddin::MarketModelMultiProduct, QuantLib::MarketModelMultiProduct)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(MarketModelEvolver);
        valueObject->processPrecedentID(Product);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::AccountingEngine(
                valueObject,
                MarketModelEvolverLibObjPtr,
                ProductLibObj,
                InitialNumeraireValue,
                Permanent));
        return object;
    }
        /* Fonction de calcul de l'accrued des instruments */
DLLEXPORT xloper * xlSwapConvexity (const char * instrumentId_,
                                    const char * curveId_,
                                    xloper * trigger_) {


         boost::shared_ptr<ObjectHandler::FunctionCall> functionCall(
            new ObjectHandler::FunctionCall("xlSwapConvexity")) ;

         try {

                QL_ENSURE(! functionCall->calledByFunctionWizard(), "") ;

                    // trigger pour provoquer le recalcul
                ObjectHandler::validateRange(trigger_, "trigger") ;
                QuantLib::Real returnValue ;

                OH_GET_REFERENCE(instrumentPtr, 
								 instrumentId_, 
								 QuantLibAddin::interestRateSwapObject, 
								 QuantLib::vanillaSwap2)

				//returnValue = instrumentPtr->dv01();
				returnValue = 0;

                static XLOPER returnOper ;
                ObjectHandler::scalarToOper(returnValue, returnOper) ;
                return & returnOper ;

        } catch (std::exception & e) {

                ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall) ;
                static XLOPER returnOper ;
                returnOper.xltype = xltypeErr ;
                returnOper.val.err = xlerrValue ;

                return & returnOper ;

        }

} ;
Exemple #22
0
DLLEXPORT double *qlSimpleQuoteValue(char *objectID) {

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>
            (new ObjectHandler::FunctionCall("qlSimpleQuoteValue"));

        OH_GET_REFERENCE(x, objectID, QuantLibAddin::SimpleQuote, QuantLib::SimpleQuote);

        static double ret;
        ret = x->value();
        return &ret;

    } catch (const std::exception &e) {

        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;

    }
}
Exemple #23
0
    boost::shared_ptr<ObjectHandler::Object> create_qlScheduleTruncated(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string OriginalSchedule =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("OriginalSchedule"));

        ObjectHandler::property_t TruncationDate =
            valueObject->getProperty("TruncationDate");

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert input datatypes to QuantLib datatypes

        QuantLib::Date TruncationDateLib = ObjectHandler::convert2<QuantLib::Date>(
            valueObject->getProperty("TruncationDate"), "TruncationDate");

        // convert object IDs into library objects

        OH_GET_REFERENCE(OriginalScheduleLibObjPtr, OriginalSchedule,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(OriginalSchedule);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::Schedule(
                valueObject,
                OriginalScheduleLibObjPtr,
                TruncationDateLib,
                Permanent));
        return object;
    }
    boost::shared_ptr<ObjectHandler::Object> create_qlVanillaSwapFromSwapIndex(
        const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) {

        // convert input datatypes to C++ datatypes

        std::string SwapIndex =
            ObjectHandler::convert2<std::string>(valueObject->getProperty("SwapIndex"));

        ObjectHandler::property_t FixingDate =
            valueObject->getProperty("FixingDate");

        bool Permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));

        // convert input datatypes to QuantLib datatypes

        QuantLib::Date FixingDateLib = ObjectHandler::convert2<QuantLib::Date>(
            valueObject->getProperty("FixingDate"), "FixingDate");

        // convert object IDs into library objects

        OH_GET_REFERENCE(SwapIndexLibObjPtr, SwapIndex,
            QuantLibAddin::SwapIndex, QuantLib::SwapIndex)

        // update value object precedent IDs (if any)

        valueObject->processPrecedentID(SwapIndex);

        // construct and return the object

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::VanillaSwap(
                valueObject,
                SwapIndexLibObjPtr,
                FixingDateLib,
                Permanent));
        return object;
    }
	// register an interpolated curve object
DLLEXPORT char * xlInitiateInterpolatedCurve(const char * objectID_       ,
                                             xloper     * calculationDate_,
                                             const char * curveCalendarId_,
                                             xloper     * helperId_       ,
                                             xloper     * trigger_         ) {
    
    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall(
        new ObjectHandler::FunctionCall("xlInitiateInterpolatedCurve")) ;

    try {

        QL_ENSURE(! functionCall->calledByFunctionWizard(), "") ;

            // range validation
        ObjectHandler::validateRange(trigger_        , "trigger"         );
        ObjectHandler::validateRange(helperId_       , "helper Id"       );
        ObjectHandler::validateRange(calculationDate_, "calculation Date");
            
        ObjectHandler::ConvertOper myOper1(* calculationDate_) ;	// xlopers

        std::vector<std::string> helperId = ObjectHandler::operToVector<std::string>(
            * helperId_, "helper Id") ;

        QuantLib::Date currentDate(									// initiate pricing date
            myOper1.missing() ? 
            QuantLib::Date() : 
            QuantLib::Date(static_cast<QuantLib::BigInteger>(myOper1)));

        std::vector<boost::shared_ptr<QuantLib::BootstrapHelper<	// the helpers
			QuantLib::YieldTermStructure> > > helpers;

        for (std::vector<std::string>::const_iterator It = helperId.begin();
			It != helperId.end(); ++It) {

            OH_GET_REFERENCE(helperPtr, * It,						// get helper references
                             QuantLibAddin::RateHelper, 
                             QuantLib::RateHelper);

			helpers.push_back(helperPtr);

        }

            // Construction du value object
        boost::shared_ptr<QuantLibAddin::ValueObjects::interpolatedCurveValueObject> curveValueObject(
            new QuantLibAddin::ValueObjects::interpolatedCurveValueObject(
                objectID_,
                currentDate.serialNumber(),
                true)) ;

            // creates the curve
        boost::shared_ptr<ObjectHandler::Object> myCurve(
            new QuantLibAddin::interpolatedCurveObject(
				curveValueObject,
                currentDate,
				helpers, true,
                std::vector<QuantLib::Handle<QuantLib::Quote> >(),	// empty jump date
                std::vector<QuantLib::Date>(),
                CURVE_DEFAULT_ACCURACY));

		    // object storage
	    std::string returnValue =
            ObjectHandler::RepositoryXL::instance().storeObject(objectID_, 
                                                                myCurve, 
                                                                true);

        static char ret[XL_MAX_STR_LEN] ;
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;

    } catch (std::exception & e) {

        static char ret[XL_MAX_STR_LEN];
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        ObjectHandler::stringToChar(e.what(), ret);
        return ret;

    }

} ;
    /* Fonction de calcul du carry d'un bond */
DLLEXPORT xloper * xlInstrumentCarry (const char * instrumentId_,
                                      const double * startAccruedDate_,
                                      const double * endAccruedDate_,
                                      const double * instrumentYield_,
                                      const char * conventionId_,
                                      xloper * trigger_) {

     boost::shared_ptr<ObjectHandler::FunctionCall> functionCall(
        new ObjectHandler::FunctionCall("xlInstrumentCarry")) ;

     try {

        QL_ENSURE(! functionCall->calledByFunctionWizard(), "") ;

        double returnValue ;

            // trigger pour provoquer le recalcul
        ObjectHandler::validateRange(trigger_, "trigger") ;

            // on récupère la convention
        OH_GET_REFERENCE(conventionPtr, 
                         conventionId_, 
                         QuantLibAddin::interestRateConventionObject,
						 QuantLib::InterestRate)

            // on récupère l'instrument
        OH_GET_UNDERLYING(myBond, 
                          instrumentId_, 
                          QuantLibAddin::Bond,
                          QuantLib::Bond)

        returnValue = myBond.cleanPrice(* instrumentYield_,
                                        conventionPtr->dayCounter(),
                                        conventionPtr->compounding(),
                                        conventionPtr->frequency(),
                                        conventionPtr->businessDayConvention(),
                                        myBond.settlementDate(
                                            QuantLib::Date(static_cast<QuantLib::BigInteger>(* endAccruedDate_)))) ;

        returnValue -= myBond.cleanPrice(* instrumentYield_,
                                         conventionPtr->dayCounter(),
                                         conventionPtr->compounding(),
                                         conventionPtr->frequency(),
                                         conventionPtr->businessDayConvention(),
                                         myBond.settlementDate(
                                            QuantLib::Date(static_cast<QuantLib::BigInteger>(* startAccruedDate_)))) ;

            // variable de retour
        static XLOPER returnOper ;
        ObjectHandler::scalarToOper(returnValue, returnOper) ;
        return & returnOper ;

    } catch (std::exception & e) {

                ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
                static XLOPER returnOper;
                returnOper.xltype = xltypeErr;
                returnOper.val.err = xlerrValue;
                return & returnOper;

    }

}
Exemple #27
0
    std::string qlRiskyFixedBond(
            const std::string &ObjectId,
            const std::string &Bondname,
            const std::string &Currency,
            const double &Recovery,
            const std::string &DefaultCurve,
            const std::string &Schedule,
            const double &Rate,
            const std::string &DayCounter,
            const ObjectHandler::property_t &PaymentConvention,
            const double &Notional,
            const std::string &DiscountingCurve,
            const ObjectHandler::property_t &PricingDate,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        std::string PaymentConventionCpp = ObjectHandler::convert2<std::string>(
            PaymentConvention, "PaymentConvention", "Following");

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Date PricingDateLib = ObjectHandler::convert2<QuantLib::Date>(
            PricingDate, "PricingDate");

        // convert input datatypes to QuantLib enumerated datatypes

        QuantLib::Currency CurrencyEnum =
            ObjectHandler::Create<QuantLib::Currency>()(Currency);

        QuantLib::DayCounter DayCounterEnum =
            ObjectHandler::Create<QuantLib::DayCounter>()(DayCounter);

        QuantLib::BusinessDayConvention PaymentConventionEnum =
            ObjectHandler::Create<QuantLib::BusinessDayConvention>()(PaymentConventionCpp);

        // convert object IDs into library objects

        OH_GET_OBJECT(DefaultCurveCoerce, DefaultCurve, ObjectHandler::Object)
        QuantLib::Handle<QuantLib::DefaultProbabilityTermStructure> DefaultCurveLibObj =
            QuantLibAddin::CoerceHandle<
                QuantLibAddin::DefaultProbabilityTermStructure,
                QuantLib::DefaultProbabilityTermStructure>()(
                    DefaultCurveCoerce);

        OH_GET_REFERENCE(ScheduleLibObjPtr, Schedule,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        OH_GET_OBJECT(DiscountingCurveCoerce, DiscountingCurve, ObjectHandler::Object)
        QuantLib::Handle<QuantLib::YieldTermStructure> DiscountingCurveLibObj =
            QuantLibAddin::CoerceHandle<
                QuantLibAddin::YieldTermStructure,
                QuantLib::YieldTermStructure>()(
                    DiscountingCurveCoerce);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlRiskyFixedBond(
                ObjectId,
                Bondname,
                Currency,
                Recovery,
                DefaultCurve,
                Schedule,
                Rate,
                DayCounter,
                PaymentConventionCpp,
                Notional,
                DiscountingCurve,
                PricingDate,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::RiskyFixedBond(
                valueObject,
                Bondname,
                CurrencyEnum,
                Recovery,
                DefaultCurveLibObj,
                ScheduleLibObjPtr,
                Rate,
                DayCounterEnum,
                PaymentConventionEnum,
                Notional,
                DiscountingCurveLibObj,
                PricingDateLib,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlRiskyFixedBond : " << e.what());
        }
    }
Exemple #28
0
    std::string qlNthToDefault(
            const std::string &ObjectId,
            const std::string &Basket,
            const long &Order,
            const ObjectHandler::property_t &BuyerSeller,
            const std::string &PremiumSchedule,
            const double &Upfront,
            const double &Spread,
            const std::string &DayCounter,
            const double &Notional,
            const bool &SettlesAccrual,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        std::string BuyerSellerCpp = ObjectHandler::convert2<std::string>(
            BuyerSeller, "BuyerSeller", "Buyer");

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Size OrderLib;
        QuantLibAddin::cppToLibrary(Order, OrderLib);

        // convert input datatypes to QuantLib enumerated datatypes

        QuantLib::Protection::Side BuyerSellerEnum =
            ObjectHandler::Create<QuantLib::Protection::Side>()(BuyerSellerCpp);

        QuantLib::DayCounter DayCounterEnum =
            ObjectHandler::Create<QuantLib::DayCounter>()(DayCounter);

        // convert object IDs into library objects

        OH_GET_REFERENCE(BasketLibObjPtr, Basket,
            QuantLibAddin::Basket, QuantLib::Basket)

        OH_GET_REFERENCE(PremiumScheduleLibObjPtr, PremiumSchedule,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlNthToDefault(
                ObjectId,
                Basket,
                Order,
                BuyerSellerCpp,
                PremiumSchedule,
                Upfront,
                Spread,
                DayCounter,
                Notional,
                SettlesAccrual,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::NthToDefault(
                valueObject,
                BasketLibObjPtr,
                OrderLib,
                BuyerSellerEnum,
                PremiumScheduleLibObjPtr,
                Upfront,
                Spread,
                DayCounterEnum,
                Notional,
                SettlesAccrual,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlNthToDefault : " << e.what());
        }
    }
Exemple #29
0
XLL_DEC char *qlMakeSwaption(
        char *ObjectId,
        char *SwapIndex,
        char *OptionTenor,
        OPER *Strike,
        char *PricingEngineID,
        OPER *Permanent,
        OPER *Trigger,
        bool *Overwrite) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlMakeSwaption"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert input datatypes to C++ datatypes

        double StrikeCpp = ObjectHandler::convert2<double>(
            ObjectHandler::ConvertOper(*Strike), "Strike", QuantLib::Null<QuantLib::Rate>());

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            ObjectHandler::ConvertOper(*Permanent), "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Period OptionTenorLib;
        QuantLibAddin::cppToLibrary(OptionTenor, OptionTenorLib);

        // convert object IDs into library objects

        OH_GET_REFERENCE(SwapIndexLibObjPtr, SwapIndex,
            QuantLibAddin::SwapIndex, QuantLib::SwapIndex)

        OH_GET_REFERENCE(PricingEngineIDLibObjPtr, PricingEngineID,
            QuantLibAddin::PricingEngine, QuantLib::PricingEngine)

        // Strip the Excel cell update counter suffix from Object IDs
        
        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(ObjectId);
        std::string SwapIndexStrip = ObjectHandler::CallingRange::getStub(SwapIndex);
        std::string PricingEngineIDStrip = ObjectHandler::CallingRange::getStub(PricingEngineID);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlMakeSwaption(
                ObjectIdStrip,
                SwapIndexStrip,
                OptionTenor,
                StrikeCpp,
                PricingEngineIDStrip,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::Swaption(
                valueObject,
                SwapIndexLibObjPtr,
                OptionTenorLib,
                StrikeCpp,
                PricingEngineIDLibObjPtr,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, *Overwrite, valueObject);

        // Convert and return the return value

        static char ret[XL_MAX_STR_LEN];
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
Exemple #30
0
XLL_DEC double *qlSwaptionImpliedVolatility(
        char *ObjectId,
        double *Price,
        char *YieldCurve,
        OPER *Guess,
        OPER *Accuracy,
        OPER *MaxIter,
        OPER *MinVol,
        OPER *MaxVol,
        OPER *Displacement,
        OPER *Trigger) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlSwaptionImpliedVolatility"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert input datatypes to C++ datatypes

        double GuessCpp = ObjectHandler::convert2<double>(
            ObjectHandler::ConvertOper(*Guess), "Guess", 0.10);

        double AccuracyCpp = ObjectHandler::convert2<double>(
            ObjectHandler::ConvertOper(*Accuracy), "Accuracy", 1.0e-6);

        long MaxIterCpp = ObjectHandler::convert2<long>(
            ObjectHandler::ConvertOper(*MaxIter), "MaxIter", 100);

        double MinVolCpp = ObjectHandler::convert2<double>(
            ObjectHandler::ConvertOper(*MinVol), "MinVol", 1.0e-7);

        double MaxVolCpp = ObjectHandler::convert2<double>(
            ObjectHandler::ConvertOper(*MaxVol), "MaxVol", 4.0);

        double DisplacementCpp = ObjectHandler::convert2<double>(
            ObjectHandler::ConvertOper(*Displacement), "Displacement", 0.0);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Real AccuracyLib = ObjectHandler::convert2<QuantLib::Real>(
            ObjectHandler::ConvertOper(*Accuracy), "Accuracy", 1.0e-6);

        QuantLib::Natural MaxIterLib = ObjectHandler::convert2<QuantLib::Natural>(
            ObjectHandler::ConvertOper(*MaxIter), "MaxIter", 100);

        QuantLib::Real DisplacementLib = ObjectHandler::convert2<QuantLib::Real>(
            ObjectHandler::ConvertOper(*Displacement), "Displacement", 0.0);

        // convert object IDs into library objects

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::Swaption, QuantLib::Swaption)

        OH_GET_OBJECT(YieldCurveCoerce, YieldCurve, ObjectHandler::Object)
        QuantLib::Handle<QuantLib::YieldTermStructure> YieldCurveLibObj =
            QuantLibAddin::CoerceHandle<
                QuantLibAddin::YieldTermStructure,
                QuantLib::YieldTermStructure>()(
                    YieldCurveCoerce);

        // invoke the member function

        static double returnValue;
        returnValue = ObjectIdLibObjPtr->impliedVolatility(
                *Price,
                YieldCurveLibObj,
                GuessCpp,
                AccuracyLib,
                MaxIterLib,
                MinVolCpp,
                MaxVolCpp,
                DisplacementLib);

        // convert and return the return value

        return &returnValue;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}