45constexpr OUStringLiteral
MY_SERVICE =
u"com.sun.star.sheet.addin.PricingFunctions";
46constexpr OUStringLiteral
MY_IMPLNAME =
u"com.sun.star.sheet.addin.PricingFunctionsImpl";
50 {
"getOptBarrier", PRICING_FUNCNAME_OptBarrier, PRICING_FUNCDESC_OptBarrier,
"OPT_BARRIER", 13,
ScaCategory::Finance,
false,
false },
51 {
"getOptTouch", PRICING_FUNCNAME_OptTouch, PRICING_FUNCDESC_OptTouch,
"OPT_TOUCH", 11,
ScaCategory::Finance,
false,
false },
52 {
"getOptProbHit", PRICING_FUNCNAME_OptProbHit, PRICING_FUNCDESC_OptProbHit,
"OPT_PROB_HIT", 6,
ScaCategory::Finance,
false,
false },
53 {
"getOptProbInMoney", PRICING_FUNCNAME_OptProbInMoney, PRICING_FUNCDESC_OptProbInMoney,
"OPT_PROB_INMONEY", 8,
ScaCategory::Finance,
false,
false },
57 aIntName( OUString::createFromAscii( rBaseData.pIntName ) ),
58 pUINameID( rBaseData.pUINameID ),
59 pDescrID( rBaseData.pDescrID ),
60 nParamCount( rBaseData.nParamCount ),
61 eCat( rBaseData.eCat ),
62 bDouble( rBaseData.bDouble ),
63 bWithOpt( rBaseData.bWithOpt )
83extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
85 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const&)
99static const char*
pLang[] = {
"en" };
100static const char*
pCoun[] = {
"US" };
105 pDefLocales.reset(
new lang::Locale[
nNumOfLoc ] );
132 return ScaResId(pResId[nStrIndex - 1]);
183 auto fDataIt = std::find_if(pFuncDataList->begin(), pFuncDataList->end(),
185 if (fDataIt != pFuncDataList->end() )
187 aRet = ScaResId(fDataIt->GetUINameID());
188 if( fDataIt->IsDouble() )
193 aRet =
"UNKNOWNFUNC_" + aProgrammaticName;
203 auto fDataIt = std::find_if( pFuncDataList->begin(), pFuncDataList->end(),
205 if( fDataIt != pFuncDataList->end() )
206 aRet = GetFuncDescrStr( fDataIt->GetDescrID(), 1 );
212 const OUString& aProgrammaticName, sal_Int32 nArgument )
216 auto fDataIt = std::find_if( pFuncDataList->begin(), pFuncDataList->end(),
218 if( fDataIt != pFuncDataList->end() && (nArgument <= 0xFFFF) )
220 sal_uInt16 nStr = fDataIt->GetStrIndex(
static_cast< sal_uInt16
>( nArgument ) );
222 aRet = GetFuncDescrStr( fDataIt->GetDescrID(), nStr );
231 const OUString& aProgrammaticName, sal_Int32 nArgument )
235 auto fDataIt = std::find_if( pFuncDataList->begin(), pFuncDataList->end(),
237 if( fDataIt != pFuncDataList->end() && (nArgument <= 0xFFFF) )
239 sal_uInt16 nStr = fDataIt->GetStrIndex(
static_cast< sal_uInt16
>( nArgument ) );
241 aRet = GetFuncDescrStr( fDataIt->GetDescrID(), nStr + 1 );
243 aRet =
"for internal use only";
250 const OUString& aProgrammaticName )
254 auto fDataIt = std::find_if( pFuncDataList->begin(), pFuncDataList->end(),
256 if( fDataIt != pFuncDataList->end() )
258 switch( fDataIt->GetCategory() )
275 const OUString& aProgrammaticName )
277 return getProgrammaticCategoryName( aProgrammaticName );
282 const OUString& aProgrammaticName )
284 auto fDataIt = std::find_if( pFuncDataList->begin(), pFuncDataList->end(),
286 if( fDataIt == pFuncDataList->end() )
287 return uno::Sequence< sheet::LocalizedName >( 0 );
289 const std::vector<OUString>& rStrList = fDataIt->GetCompNameList();
290 sal_uInt32
nCount = rStrList.size();
292 uno::Sequence< sheet::LocalizedName > aRet(
nCount );
293 sheet::LocalizedName* pArray = aRet.getArray();
318 if(anyval.getValueTypeClass() == uno::TypeClass_STRING) {
320 }
else if(anyval.getValueTypeClass() == uno::TypeClass_VOID) {
325 return getinput_putcall(pc, str);
328bool getinput_strike(
double& strike,
const uno::Any& anyval) {
329 if(anyval.getValueTypeClass() == uno::TypeClass_DOUBLE) {
331 }
else if(anyval.getValueTypeClass() == uno::TypeClass_VOID) {
374 if(anyval.getValueTypeClass() == uno::TypeClass_STRING) {
376 }
else if(anyval.getValueTypeClass() == uno::TypeClass_VOID) {
382 if(str ==
"value" || str ==
"price" || str ==
"v" || str ==
"p") {
384 }
else if(str ==
"delta" || str ==
"d") {
386 }
else if(str ==
"gamma" || str ==
"g") {
388 }
else if(str ==
"theta" || str ==
"t") {
390 }
else if(str ==
"vega" || str ==
"e") {
392 }
else if(str ==
"volga" || str ==
"o") {
394 }
else if(str ==
"vanna" || str ==
"a") {
396 }
else if(str ==
"rho" || str ==
"r") {
398 }
else if(str ==
"rhof" || str ==
"f") {
410 double r,
double rf,
double T,
double strike,
411 double barrier_low,
double barrier_up,
double rebate,
412 const OUString& put_call,
const OUString& in_out,
413 const OUString& barriercont,
const uno::Any& greekstr )
420 if( spot<=0.0 || vol<=0.0 || T<0.0 || strike<0.0 ||
421 !getinput_putcall(
pc,put_call) ||
422 !getinput_inout(kio,in_out) ||
423 !getinput_barrier(bcont,barriercont) ||
424 !getinput_greek(greek,greekstr) ){
425 throw lang::IllegalArgumentException();
428 double fRet=
bs::barrier(spot,vol,r,rf,T,strike, barrier_low,barrier_up,
429 rebate,
pc,kio,bcont,greek);
431 if (!std::isfinite(fRet))
432 throw css::lang::IllegalArgumentException();
438 double r,
double rf,
double T,
439 double barrier_low,
double barrier_up,
440 const OUString& for_dom,
const OUString& in_out,
441 const OUString& barriercont,
const uno::Any& greekstr )
448 if( spot<=0.0 || vol<=0.0 || T<0.0 ||
449 !getinput_fordom(fd,for_dom) ||
450 !getinput_inout(kio,in_out) ||
451 !getinput_barrier(bcont,barriercont) ||
452 !getinput_greek(greek,greekstr) ){
453 throw lang::IllegalArgumentException();
456 double fRet=
bs::touch(spot,vol,r,rf,T,barrier_low,barrier_up,
459 if (!std::isfinite(fRet))
460 throw css::lang::IllegalArgumentException();
467 double barrier_low,
double barrier_up )
470 if( spot<=0.0 || vol<=0.0 || T<0.0 ) {
471 throw lang::IllegalArgumentException();
474 double fRet=
bs::prob_hit(spot,vol,mu,T,barrier_low,barrier_up);
476 if (!std::isfinite(fRet))
477 throw css::lang::IllegalArgumentException();
484 double barrier_low,
double barrier_up,
491 if( spot<=0.0 || vol<=0.0 || T<0.0 ||
492 !getinput_putcall(
pc,put_call) ||
493 !getinput_strike(K,strikeval) ) {
494 throw lang::IllegalArgumentException();
499 if (!std::isfinite(fRet))
500 throw css::lang::IllegalArgumentException();
ScaFuncData(const ScaFuncDataBase &rBaseData)
virtual css::uno::Sequence< css::sheet::LocalizedName > SAL_CALL getCompatibilityNames(const OUString &aProgrammaticName) override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getProgrammaticFuntionName(const OUString &aDisplayName) override
virtual OUString SAL_CALL getProgrammaticCategoryName(const OUString &aProgrammaticName) override
virtual OUString SAL_CALL getFunctionDescription(const OUString &aProgrammaticName) override
virtual OUString SAL_CALL getDisplayFunctionName(const OUString &aProgrammaticName) override
virtual double SAL_CALL getOptBarrier(double spot, double vol, double r, double rf, double T, double strike, double barrier_low, double barrier_up, double rebate, const OUString &put_call, const OUString &in_out, const OUString &continuous, const css::uno::Any &greek) override
virtual OUString SAL_CALL getDisplayCategoryName(const OUString &aProgrammaticName) override
OUString GetFuncDescrStr(const TranslateId *pResId, sal_uInt16 nStrIndex)
virtual double SAL_CALL getOptTouch(double spot, double vol, double r, double rf, double T, double barrier_low, double barrier_up, const OUString &for_dom, const OUString &in_out, const OUString &barriercont, const css::uno::Any &greekstr) override
virtual OUString SAL_CALL getServiceName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual double SAL_CALL getOptProbHit(double spot, double vol, double mu, double T, double barrier_low, double barrier_up) override
virtual OUString SAL_CALL getDisplayArgumentName(const OUString &aProgrammaticName, sal_Int32 nArgument) override
const css::lang::Locale & GetLocale(sal_uInt32 nIndex)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getArgumentDescription(const OUString &aProgrammaticName, sal_Int32 nArgument) override
virtual css::lang::Locale SAL_CALL getLocale() override
OUString ScaResId(TranslateId aResId)
virtual ~ScaPricingAddIn() override
virtual double SAL_CALL getOptProbInMoney(double spot, double vol, double mu, double T, double barrier_low, double barrier_up, const css::uno::Any &strikeval, const css::uno::Any &put_call) override
virtual void SAL_CALL setLocale(const css::lang::Locale &eLocale) override
std::vector< OUString > aCompList
sal_uInt16 GetStrIndex(sal_uInt16 nParam) const
std::vector< ScaFuncData > ScaFuncDataList
#define SAL_N_ELEMENTS(arr)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
double touch(double S, double vol, double rd, double rf, double tau, double B1, double B2, types::ForDom fd, types::BarrierKIO kio, types::BarrierActive bcont, types::Greeks greek)
double prob_in_money(double S, double vol, double mu, double tau, double B1, double B2)
double barrier(double S, double vol, double rd, double rf, double tau, double K, double B1, double B2, double rebate, types::PutCall pc, types::BarrierKIO kio, types::BarrierActive bcont, types::Greeks greek)
double prob_hit(double S, double vol, double mu, double tau, double B1, double B2)
std::vector< ScaFuncData > ScaFuncDataList
void InitScaFuncDataList(ScaFuncDataList &rMap)
const ScaFuncDataBase pFuncDataArr[]
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * scaddins_ScaPricingAddIn_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static const char * pCoun[]
const sal_uInt32 nNumOfLoc
constexpr OUStringLiteral MY_IMPLNAME
static const char * pLang[]
constexpr OUStringLiteral ADDIN_SERVICE
constexpr OUStringLiteral MY_SERVICE