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>
33using namespace com::apama::epl;
34using 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
57typedef 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);
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) {
167typedef std::map< std::string, bond_ptr> stringbond_map;
169typedef boost::unordered_map< const char *, bond_ptr > bond_map;
170typedef boost::unordered_map< const char *, BondKey > bondspec_map;
171typedef boost::unordered_map< YieldKey, Real > yield_map;
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>
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>
323 const char* _maturity,
double _riskFreeRate,
double _volatility,
324 double _dividendYield, int64_t _timeSteps,
const char* _t);
339 custom_t<OptionResultsChunk>
341 const char* _maturity,
double _riskFreeRate,
double _volatility,
342 double _dividendYield, int64_t _timeSteps,
const char* _t);
357 custom_t<OptionResultsChunk>
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);
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);
572 static bond_ptr _createBond(
573 const char* issueDate,
const char* maturityDate,
const char* settlementDate,
574 const Rate& rate,
const Frequency& frequency);
Definition: QuantlibPlugin.hpp:66
BondKey & operator=(const BondKey &that)
Frequency getFrequency()
Definition: QuantlibPlugin.hpp:106
BondKey(const char *issueDate, const char *maturityDate, const char *settlementDate, const Rate rate, const Frequency frequency, bool takeCopies=true)
BondKey(const BondKey &that)
const char * getMaturityDate()
Definition: QuantlibPlugin.hpp:94
const char * getSettlementDate()
Definition: QuantlibPlugin.hpp:98
Rate getRate()
Definition: QuantlibPlugin.hpp:102
const char * getIssueDate()
Definition: QuantlibPlugin.hpp:90
Definition: QuantlibPlugin.hpp:177
double npv
Definition: QuantlibPlugin.hpp:198
double delta
Definition: QuantlibPlugin.hpp:206
OptionResultsChunk(int32_t errorNum, double npv, double implVol, double delta, double gamma, double theta, double vega, double rho, char *error)
char * error
Definition: QuantlibPlugin.hpp:226
double rho
Definition: QuantlibPlugin.hpp:222
double implVol
Definition: QuantlibPlugin.hpp:202
double gamma
Definition: QuantlibPlugin.hpp:210
double vega
Definition: QuantlibPlugin.hpp:218
double theta
Definition: QuantlibPlugin.hpp:214
int32_t errNum
Definition: QuantlibPlugin.hpp:194
Definition: QuantlibPlugin.hpp:240
void addToDataset(double _value, double _weight)
double price(const char *_symbol, double _yield, const char *_issueDate, const char *_maturityDate, const char *_settlementDate, double _rate, int64_t _freq)
static Real _price(bond_ptr bond, const Rate &yield, const char *settlementDate)
custom_t< OptionResultsChunk > modelImplVol(double _price, double _underlying, double _strike, const char *_currentBussinessDate, const char *_maturityDate, double _riskFreeRate, double _dividendYield, const char *_t, const char *_modelName)
static bond_ptr _getBond(const char *symbol, const char *issueDate, const char *maturityDate, const char *settlementDate, Rate rate, Frequency frequency, bool updateFlag, int &ouputValue, std::string &discrepancyMessage)
int64_t createBond(const char *_symbol, const char *_issueDate, const char *_maturityDate, const char *_settlementDate, double _rate, int64_t _frequency, bool _updateFlag)
static Logger * _logger
Definition: QuantlibPlugin.hpp:535
double theta(const custom_t< OptionResultsChunk > &results)
static Real _dv01(bond_ptr bond, const Rate &yield, const char *settlementDate)
double gamma(const custom_t< OptionResultsChunk > &results)
void removeFromDataset(double _value, double _weight)
custom_t< OptionResultsChunk > btcoxrossrubinsteinGreeks(double _underlying, double _strike, const char *_currentBussinessDate, const char *_maturity, double _riskFreeRate, double _volatility, double _dividendYield, int64_t _timeSteps, const char *_t)
const char * error(const custom_t< OptionResultsChunk > &results)
custom_t< OptionResultsChunk > modelGreeks(double _underlying, double _strike, const char *_currentBussinessDate, const char *_maturity, double _riskFreeRate, double _volatility, double _dividendYield, const char *_t, const char *_modelName)
custom_t< OptionResultsChunk > modelPrice(double _underlying, double _strike, const char *_currentBussinessDate, const char *_maturity, double _riskFreeRate, double _volatility, double _dividendYield, const char *_t, const char *_modelName)
custom_t< OptionResultsChunk > btcoxrossrubinsteinPrice(double _underlying, double _strike, const char *_currentBussinessDate, const char *_maturity, double _riskFreeRate, double _volatility, double _dividendYield, int64_t _timeSteps, const char *_t)
static void initialize(base_plugin_t::method_data_t &md)
double rho(const custom_t< OptionResultsChunk > &results)
double implVol(const custom_t< OptionResultsChunk > &results)
double yield(const char *_symbol, double _price, const char *_issueDate, const char *_maturityDate, const char *_settlementDate, double _rate, int64_t _freq)
double vega(const custom_t< OptionResultsChunk > &results)
double npv(const custom_t< OptionResultsChunk > &results)
custom_t< OptionResultsChunk > btcoxrossrubinsteinImplVol(double _price, double _underlying, double _strike, const char *_currentBussinessDate, const char *_maturity, double _riskFreeRate, double _dividendYield, int64_t _timeSteps, const char *_t)
double delta(const custom_t< OptionResultsChunk > &results)
static Rate _yield(bond_ptr bond, const Real &price, const char *settlementDate)
double dv01(const char *_symbol, double _yield, const char *_issueDate, const char *_maturityDate, const char *_settlementDate, double _rate, int64_t _freq)
QuantlibPlugin()
Definition: QuantlibPlugin.hpp:245
static std::string getDiscrepancyErrorMessage(int outputValue, BondKey cachedBondKey, BondKey inputBondKey)
Definition: QuantlibPlugin.hpp:131
YieldKey(const YieldKey &that)
YieldKey & operator=(const YieldKey &that)
YieldKey(bond_ptr &bond, Real price, const char *settlementDate, bool takeCopies=true)
Definition: QuantlibPlugin.hpp:232
void remove(Real value, Real weight)