10 #ifndef _QUANTLIBPLUGIN_H_
11 #define _QUANTLIBPLUGIN_H_
14 #include <ql/quantlib.hpp>
15 #include <ql/math/statistics/generalstatistics.hpp>
28 #include <epl_plugin.hpp>
29 #include <boost/timer.hpp>
30 #include <boost/unordered_map.hpp>
36 #if defined(QL_ENABLE_SESSIONS)
39 Integer sessionId() {
return 0; }
45 #define BOND_COMPARE_EQUAL 0
46 #define BOND_MATURITYDATE_ERROR 1
47 #define BOND_ISSUEDATE_ERROR 2
48 #define BOND_SETTLEMENTDATE_ERROR 4
49 #define BOND_RATE_ERROR 8
50 #define BOND_FREQUENCY_ERROR 16
51 #define BOND_CREATED_NEW 255
53 #define NO_UPDATE_BOND false
54 #define UPDATE_BOND true
57 typedef boost::shared_ptr<FixedRateBond> bond_ptr;
72 const char* issueDate,
const char* maturityDate,
const char* settlementDate,
73 const Rate rate,
const Frequency frequency,
bool takeCopies =
true);
86 const char *toString();
114 char* settlementDate;
123 friend std::size_t hash_value(
const BondKey& x) {
136 YieldKey(bond_ptr& bond, Real price,
const char* settlementDate,
bool takeCopies =
true);
152 char* settlementDate;
158 friend std::size_t hash_value(
const YieldKey& x) {
167 typedef std::map< std::string, bond_ptr> stringbond_map;
169 typedef boost::unordered_map< const char *, bond_ptr > bond_map;
170 typedef boost::unordered_map< const char *, BondKey > bondspec_map;
171 typedef boost::unordered_map< YieldKey, Real > yield_map;
182 OptionResultsChunk(int32_t errorNum,
double npv,
double implVol,
double delta,
double gamma,
double theta,
double vega,
double rho,
char* error);
241 static void initialize(base_plugin_t::method_data_t &md);
256 custom_t<OptionResultsChunk>
257 modelPrice(
double _underlying,
double _strike,
const char* _currentBussinessDate,
258 const char* _maturity,
double _riskFreeRate,
double _volatility,
259 double _dividendYield,
const char* _t,
const char* _modelName);
274 custom_t<OptionResultsChunk>
275 modelImplVol(
double _price,
double _underlying,
double _strike,
276 const char* _currentBussinessDate,
const char* _maturityDate,
277 double _riskFreeRate,
double _dividendYield,
const char* _t,
278 const char* _modelName);
293 custom_t<OptionResultsChunk>
294 modelGreeks(
double _underlying,
double _strike,
const char* _currentBussinessDate,
295 const char* _maturity,
double _riskFreeRate,
double _volatility,
296 double _dividendYield,
const char* _t,
const char* _modelName);
312 custom_t<OptionResultsChunk>
313 btcoxrossrubinsteinGreeks(
double _underlying,
double _strike,
const char* _currentBussinessDate,
314 const char* _maturity,
double _riskFreeRate,
double _volatility,
315 double _dividendYield, int64_t _timeSteps,
const char* _t);
330 custom_t<OptionResultsChunk>
331 btcoxrossrubinsteinPrice(
double _underlying,
double _strike,
const char* _currentBussinessDate,
332 const char* _maturity,
double _riskFreeRate,
double _volatility,
333 double _dividendYield, int64_t _timeSteps,
const char* _t);
348 custom_t<OptionResultsChunk>
349 btcoxrossrubinsteinImplVol(
double _price,
double _underlying,
double _strike,
350 const char* _currentBussinessDate,
const char* _maturity,
351 double _riskFreeRate,
double _dividendYield, int64_t _timeSteps,
359 const char* error(
const custom_t<OptionResultsChunk> &results);
366 double npv(
const custom_t<OptionResultsChunk> &results);
373 double delta(
const custom_t<OptionResultsChunk> &results);
380 double gamma(
const custom_t<OptionResultsChunk> &results);
387 double theta(
const custom_t<OptionResultsChunk> &results);
394 double vega(
const custom_t<OptionResultsChunk> &results);
401 double rho(
const custom_t<OptionResultsChunk> &results);
408 double implVol(
const custom_t<OptionResultsChunk> &results);
421 double yield(
const char* _symbol,
double _price,
const char* _issueDate,
422 const char* _maturityDate,
const char* _settlementDate,
double _rate,
437 double dv01(
const char* _symbol,
double _yield,
const char* _issueDate,
438 const char* _maturityDate,
const char* _settlementDate,
double _rate,
452 double price(
const char* _symbol,
double _yield,
const char* _issueDate,
453 const char* _maturityDate,
const char* _settlementDate,
double _rate,
468 int64_t createBond(
const char* _symbol,
const char* _issueDate,
469 const char* _maturityDate,
const char* _settlementDate,
470 double _rate, int64_t _frequency,
bool _updateFlag);
477 void addToDataset(
double _value,
double _weight);
517 int64_t numSamples();
527 static bond_ptr _getBond(
528 const char* symbol,
const char* issueDate,
529 const char* maturityDate,
const char* settlementDate,
530 Rate rate, Frequency frequency,
bool updateFlag,
int &ouputValue, std::string &discrepancyMessage);
535 bond_ptr bond,
const Real& price,
const char* settlementDate);
540 bond_ptr bond,
const Rate& yield,
const char* settlementDate);
545 bond_ptr bond,
const Rate& yield,
const char* settlementDate);
549 static std::string getDiscrepancyErrorMessage(
int outputValue,
BondKey cachedBondKey,
BondKey inputBondKey);
553 static void dumpCaches();
556 static bond_ptr _createBond(
557 const char* issueDate,
const char* maturityDate,
const char* settlementDate,
558 const Rate& rate,
const Frequency& frequency);
double npv
Definition: QuantlibPlugin.hpp:198
Rate getRate()
Definition: QuantlibPlugin.hpp:102
double implVol
Definition: QuantlibPlugin.hpp:202
char * error
Definition: QuantlibPlugin.hpp:226
static Logger * _logger
Definition: QuantlibPlugin.hpp:519
Definition: QuantlibPlugin.hpp:66
Definition: QuantlibPlugin.hpp:131
Definition: QuantlibPlugin.hpp:230
const char * getMaturityDate()
Definition: QuantlibPlugin.hpp:94
double gamma
Definition: QuantlibPlugin.hpp:210
Definition: QuantlibPlugin.hpp:176
double delta
Definition: QuantlibPlugin.hpp:206
Frequency getFrequency()
Definition: QuantlibPlugin.hpp:106
double vega
Definition: QuantlibPlugin.hpp:218
double theta
Definition: QuantlibPlugin.hpp:214
int32_t errNum
Definition: QuantlibPlugin.hpp:194
QuantlibPlugin()
Definition: QuantlibPlugin.hpp:236
const char * getSettlementDate()
Definition: QuantlibPlugin.hpp:98
const char * getIssueDate()
Definition: QuantlibPlugin.hpp:90
double rho
Definition: QuantlibPlugin.hpp:222