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/timer.hpp> 30 #include <boost/unordered_map.hpp> 33 using namespace com::apama::epl;
34 using namespace QuantLib;
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);
235 void remove(Real value, Real weight);
250 static void initialize(base_plugin_t::method_data_t &md);
265 custom_t<OptionResultsChunk>
266 modelPrice(
double _underlying,
double _strike,
const char* _currentBussinessDate,
267 const char* _maturity,
double _riskFreeRate,
double _volatility,
268 double _dividendYield,
const char* _t,
const char* _modelName);
283 custom_t<OptionResultsChunk>
284 modelImplVol(
double _price,
double _underlying,
double _strike,
285 const char* _currentBussinessDate,
const char* _maturityDate,
286 double _riskFreeRate,
double _dividendYield,
const char* _t,
287 const char* _modelName);
302 custom_t<OptionResultsChunk>
303 modelGreeks(
double _underlying,
double _strike,
const char* _currentBussinessDate,
304 const char* _maturity,
double _riskFreeRate,
double _volatility,
305 double _dividendYield,
const char* _t,
const char* _modelName);
321 custom_t<OptionResultsChunk>
322 btcoxrossrubinsteinGreeks(
double _underlying,
double _strike,
const char* _currentBussinessDate,
323 const char* _maturity,
double _riskFreeRate,
double _volatility,
324 double _dividendYield, int64_t _timeSteps,
const char* _t);
339 custom_t<OptionResultsChunk>
340 btcoxrossrubinsteinPrice(
double _underlying,
double _strike,
const char* _currentBussinessDate,
341 const char* _maturity,
double _riskFreeRate,
double _volatility,
342 double _dividendYield, int64_t _timeSteps,
const char* _t);
357 custom_t<OptionResultsChunk>
358 btcoxrossrubinsteinImplVol(
double _price,
double _underlying,
double _strike,
359 const char* _currentBussinessDate,
const char* _maturity,
360 double _riskFreeRate,
double _dividendYield, int64_t _timeSteps,
368 const char* error(
const custom_t<OptionResultsChunk> &results);
375 double npv(
const custom_t<OptionResultsChunk> &results);
382 double delta(
const custom_t<OptionResultsChunk> &results);
389 double gamma(
const custom_t<OptionResultsChunk> &results);
396 double theta(
const custom_t<OptionResultsChunk> &results);
403 double vega(
const custom_t<OptionResultsChunk> &results);
410 double rho(
const custom_t<OptionResultsChunk> &results);
417 double implVol(
const custom_t<OptionResultsChunk> &results);
430 double yield(
const char* _symbol,
double _price,
const char* _issueDate,
431 const char* _maturityDate,
const char* _settlementDate,
double _rate,
446 double dv01(
const char* _symbol,
double _yield,
const char* _issueDate,
447 const char* _maturityDate,
const char* _settlementDate,
double _rate,
461 double price(
const char* _symbol,
double _yield,
const char* _issueDate,
462 const char* _maturityDate,
const char* _settlementDate,
double _rate,
477 int64_t createBond(
const char* _symbol,
const char* _issueDate,
478 const char* _maturityDate,
const char* _settlementDate,
479 double _rate, int64_t _frequency,
bool _updateFlag);
486 void addToDataset(
double _value,
double _weight);
493 void removeFromDataset(
double _value,
double _weight);
533 int64_t numSamples();
543 static bond_ptr _getBond(
544 const char* symbol,
const char* issueDate,
545 const char* maturityDate,
const char* settlementDate,
546 Rate rate, Frequency frequency,
bool updateFlag,
int &ouputValue, std::string &discrepancyMessage);
551 bond_ptr bond,
const Real& price,
const char* settlementDate);
556 bond_ptr bond,
const Rate& yield,
const char* settlementDate);
561 bond_ptr bond,
const Rate& yield,
const char* settlementDate);
565 static std::string getDiscrepancyErrorMessage(
int outputValue,
BondKey cachedBondKey,
BondKey inputBondKey);
569 static void dumpCaches();
572 static bond_ptr _createBond(
573 const char* issueDate,
const char* maturityDate,
const char* settlementDate,
574 const Rate& rate,
const Frequency& frequency);
double npv
Definition: QuantlibPlugin.hpp:198
Rate getRate()
Definition: QuantlibPlugin.hpp:102
Definition: QuantlibPlugin.hpp:231
double implVol
Definition: QuantlibPlugin.hpp:202
char * error
Definition: QuantlibPlugin.hpp:226
static Logger * _logger
Definition: QuantlibPlugin.hpp:535
Definition: QuantlibPlugin.hpp:66
Definition: QuantlibPlugin.hpp:131
Definition: QuantlibPlugin.hpp:239
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:245
const char * getSettlementDate()
Definition: QuantlibPlugin.hpp:98
const char * getIssueDate()
Definition: QuantlibPlugin.hpp:90
double rho
Definition: QuantlibPlugin.hpp:222