Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Do I also have to change the function name exported to the cell, e.g.
OPT_BARRIER()?

      My concern here would be that potentially calc function naming is not
always a great match to UNO constraints - and yet those functions are
defined as IDL. Some functions have '.'s in them IIRC, others might want
to have _'s (?) and translating functions is prolly not feasible via the
UNO interface.

Not sure I understand, would you prefer to see no '_' and rather
me to change OPT_BARRIER() to OPTBARRIER() or something?

I've attached a patch to sort out the internal UNO variable/function
naming issue.

Cheers, Tino
From 4e61de11fb73973519d409c39ec66c84d3316f9b Mon Sep 17 00:00:00 2001
From: tino <ttk448@gmail.com>
Date: Tue, 4 Dec 2012 17:26:52 +0000
Subject: [PATCH] changed function names and variables to conform with UNO
 style

Change-Id: I3de884b54083a6916a5baed4d475016aa9d4ddec
---
 .../com/sun/star/sheet/addin/XPricingFunctions.idl | 46 +++++++++++-----------
 scaddins/source/pricing/pricing.cxx                | 20 +++++-----
 scaddins/source/pricing/pricing.hrc                | 34 ++++++++--------
 scaddins/source/pricing/pricing.hxx                |  8 ++--
 scaddins/source/pricing/pricing.src                | 16 ++++----
 5 files changed, 63 insertions(+), 61 deletions(-)

diff --git a/scaddins/idl/com/sun/star/sheet/addin/XPricingFunctions.idl 
b/scaddins/idl/com/sun/star/sheet/addin/XPricingFunctions.idl
index 495891a..12d66d8d 100644
--- a/scaddins/idl/com/sun/star/sheet/addin/XPricingFunctions.idl
+++ b/scaddins/idl/com/sun/star/sheet/addin/XPricingFunctions.idl
@@ -38,34 +38,36 @@ module addin
      */
     interface XPricingFunctions : com::sun::star::uno::XInterface
     {
-        /// opt_barrier()
-        double getOpt_barrier( [in] double spot, [in] double vol,
-            [in] double r, [in] double rf, [in] double T, [in] double strike,
-            [in] double barrier_low, [in] double barrier_up,
-            [in] double rebate,
-            [in] string put_call, [in] string in_out,
-            [in] string continuous, [in] any greek  )
+        /// OPT_BARRIER(), pricing of a barrier option.
+        double getOptBarrier( [in] double Spot, [in] double Vol,
+            [in] double Rate, [in] double RateForeign,
+            [in] double Maturity, [in] double Strike,
+            [in] double BarrierLow, [in] double BarrierUp,
+            [in] double Rebate,
+            [in] string PutCall, [in] string InOut,
+            [in] string Continuous, [in] any Greek  )
             raises( com::sun::star::lang::IllegalArgumentException );
 
-        /// opt_touch()
-        double getOpt_touch( [in] double spot, [in] double vol,
-            [in] double r, [in] double rf, [in] double T,
-            [in] double barrier_low, [in] double barrier_up,
-            [in] string for_dom, [in] string in_out,
-            [in] string continuous, [in] any greek  )
+        /// OPT_TOUCH(), pricing of a touch/no-touch option.
+        double getOptTouch( [in] double Spot, [in] double Vol,
+            [in] double Rate, [in] double RateForeign,
+            [in] double Maturity,
+            [in] double BarrierLow, [in] double BarrierUp,
+            [in] string ForeignDomestic, [in] string InOut,
+            [in] string Continuous, [in] any Greek  )
             raises( com::sun::star::lang::IllegalArgumentException );
 
-        /// opt_prob_hit()
-        double getOpt_prob_hit( [in] double spot, [in] double vol,
-            [in] double mu, [in] double T,
-            [in] double barrier_low, [in] double barrier_up )
+        /// OPT_PROB_HIT(), probability of hitting a barrier.
+        double getOptProbHit( [in] double Spot, [in] double Vol,
+            [in] double Mu, [in] double Maturity,
+            [in] double BarrierLow, [in] double BarrierUp )
             raises( com::sun::star::lang::IllegalArgumentException );
 
-        /// opt_prob_inmoney()
-        double getOpt_prob_inmoney( [in] double spot, [in] double vol,
-            [in] double mu, [in] double T,
-            [in] double barrier_low, [in] double barrier_up,
-            [in] any strike, [in] any put_call )
+        /// OPT_PROB_INMONEY(), probability of ending up in-the-money.
+        double getOptProbInMoney( [in] double Spot, [in] double Vol,
+            [in] double Mu, [in] double Maturity,
+            [in] double BarrierLow, [in] double BarrierUp,
+            [in] any Strike, [in] any PutCall )
             raises( com::sun::star::lang::IllegalArgumentException );
 
     };
diff --git a/scaddins/source/pricing/pricing.cxx b/scaddins/source/pricing/pricing.cxx
index ba4cb31..cf65787 100644
--- a/scaddins/source/pricing/pricing.cxx
+++ b/scaddins/source/pricing/pricing.cxx
@@ -110,10 +110,10 @@ ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) :
 
 const ScaFuncDataBase pFuncDataArr[] =
 {
-   FUNCDATA( Opt_barrier,       13, ScaCat_Finance,    UNIQUE,  STDPAR),
-   FUNCDATA( Opt_touch,         11, ScaCat_Finance,    UNIQUE,  STDPAR),
-   FUNCDATA( Opt_prob_hit,       6, ScaCat_Finance,    UNIQUE,  STDPAR),
-   FUNCDATA( Opt_prob_inmoney,   8, ScaCat_Finance,    UNIQUE,  STDPAR)
+   FUNCDATA( OptBarrier,       13, ScaCat_Finance,    UNIQUE,  STDPAR),
+   FUNCDATA( OptTouch,         11, ScaCat_Finance,    UNIQUE,  STDPAR),
+   FUNCDATA( OptProbHit,        6, ScaCat_Finance,    UNIQUE,  STDPAR),
+   FUNCDATA( OptProbInMoney,    8, ScaCat_Finance,    UNIQUE,  STDPAR)
 };
 
 #undef FUNCDATA
@@ -645,7 +645,7 @@ bool getinput_greek(bs::types::Greeks& greek, const ANY& anyval) {
 
 
 // OPT_BARRIER(...)
-double SAL_CALL ScaPricingAddIn::getOpt_barrier( double spot, double vol,
+double SAL_CALL ScaPricingAddIn::getOptBarrier( double spot, double vol,
             double r, double rf, double T, double strike,
             double barrier_low, double barrier_up, double rebate,
             const STRING& put_call, const STRING& in_out,
@@ -671,7 +671,7 @@ double SAL_CALL ScaPricingAddIn::getOpt_barrier( double spot, double vol,
 }
 
 // OPT_TOUCH(...)
-double SAL_CALL ScaPricingAddIn::getOpt_touch( double spot, double vol,
+double SAL_CALL ScaPricingAddIn::getOptTouch( double spot, double vol,
             double r, double rf, double T,
             double barrier_low, double barrier_up,
             const STRING& for_dom, const STRING& in_out,
@@ -697,7 +697,7 @@ double SAL_CALL ScaPricingAddIn::getOpt_touch( double spot, double vol,
 }
 
 // OPT_PRB_HIT(...)
-double SAL_CALL ScaPricingAddIn::getOpt_prob_hit( double spot, double vol,
+double SAL_CALL ScaPricingAddIn::getOptProbHit( double spot, double vol,
             double mu, double T,
             double barrier_low, double barrier_up ) THROWDEF_RTE_IAE
 {
@@ -711,13 +711,13 @@ double SAL_CALL ScaPricingAddIn::getOpt_prob_hit( double spot, double vol,
     RETURN_FINITE( fRet );
 }
 
-// OPT_PRB_INMONEY(...)
-double SAL_CALL ScaPricingAddIn::getOpt_prob_inmoney( double spot, double vol,
+// OPT_PROB_INMONEY(...)
+double SAL_CALL ScaPricingAddIn::getOptProbInMoney( double spot, double vol,
             double mu, double T,
             double barrier_low, double barrier_up,
             const ANY& strikeval, const ANY& put_call ) THROWDEF_RTE_IAE
 {
-    bs::types::PutCall pc;
+    bs::types::PutCall pc=bs::types::Call;
     double  K;
 
     // read and check input values
diff --git a/scaddins/source/pricing/pricing.hrc b/scaddins/source/pricing/pricing.hrc
index bf4df21..1f7cf3c 100644
--- a/scaddins/source/pricing/pricing.hrc
+++ b/scaddins/source/pricing/pricing.hrc
@@ -22,33 +22,33 @@
 
 #define PRICING_RESOURCE_START                 1000
 
-#define RID_PRICING_FUNCTION_DESCRIPTIONS   PRICING_RESOURCE_START
-#define RID_PRICING_FUNCTION_NAMES          (PRICING_RESOURCE_START+1000)
-#define RID_PRICING_DEFFUNCTION_NAMES       (PRICING_RESOURCE_START+2000)
+#define RID_PRICING_FUNCTION_DESCRIPTIONS  PRICING_RESOURCE_START
+#define RID_PRICING_FUNCTION_NAMES         (PRICING_RESOURCE_START+1000)
+#define RID_PRICING_DEFFUNCTION_NAMES      (PRICING_RESOURCE_START+2000)
 
 
-#define PRICING_FUNCDESC_START              (RID_PRICING_FUNCTION_DESCRIPTIONS+1)
+#define PRICING_FUNCDESC_START             (RID_PRICING_FUNCTION_DESCRIPTIONS+1)
 
-#define PRICING_FUNCDESC_Opt_barrier        (PRICING_FUNCDESC_START)
-#define PRICING_FUNCDESC_Opt_touch          (PRICING_FUNCDESC_START+1)
-#define PRICING_FUNCDESC_Opt_prob_hit       (PRICING_FUNCDESC_START+2)
-#define PRICING_FUNCDESC_Opt_prob_inmoney   (PRICING_FUNCDESC_START+3)
+#define PRICING_FUNCDESC_OptBarrier        (PRICING_FUNCDESC_START)
+#define PRICING_FUNCDESC_OptTouch          (PRICING_FUNCDESC_START+1)
+#define PRICING_FUNCDESC_OptProbHit        (PRICING_FUNCDESC_START+2)
+#define PRICING_FUNCDESC_OptProbInMoney    (PRICING_FUNCDESC_START+3)
 
 
-#define PRICING_FUNCNAME_START              (RID_PRICING_FUNCTION_NAMES+1)
+#define PRICING_FUNCNAME_START             (RID_PRICING_FUNCTION_NAMES+1)
 
-#define PRICING_FUNCNAME_Opt_barrier        (PRICING_FUNCNAME_START)
-#define PRICING_FUNCNAME_Opt_touch          (PRICING_FUNCNAME_START+1)
-#define PRICING_FUNCNAME_Opt_prob_hit       (PRICING_FUNCNAME_START+2)
-#define PRICING_FUNCNAME_Opt_prob_inmoney   (PRICING_FUNCNAME_START+3)
+#define PRICING_FUNCNAME_OptBarrier        (PRICING_FUNCNAME_START)
+#define PRICING_FUNCNAME_OptTouch          (PRICING_FUNCNAME_START+1)
+#define PRICING_FUNCNAME_OptProbHit        (PRICING_FUNCNAME_START+2)
+#define PRICING_FUNCNAME_OptProbInMoney    (PRICING_FUNCNAME_START+3)
 
 
 #define PRICING_DEFFUNCNAME_START           (RID_PRICING_DEFFUNCTION_NAMES+1)
 
-#define PRICING_DEFFUNCNAME_Opt_barrier      (PRICING_DEFFUNCNAME_START)
-#define PRICING_DEFFUNCNAME_Opt_touch        (PRICING_DEFFUNCNAME_START+1)
-#define PRICING_DEFFUNCNAME_Opt_prob_hit     (PRICING_DEFFUNCNAME_START+2)
-#define PRICING_DEFFUNCNAME_Opt_prob_inmoney (PRICING_DEFFUNCNAME_START+3)
+#define PRICING_DEFFUNCNAME_OptBarrier      (PRICING_DEFFUNCNAME_START)
+#define PRICING_DEFFUNCNAME_OptTouch        (PRICING_DEFFUNCNAME_START+1)
+#define PRICING_DEFFUNCNAME_OptProbHit      (PRICING_DEFFUNCNAME_START+2)
+#define PRICING_DEFFUNCNAME_OptProbInMoney  (PRICING_DEFFUNCNAME_START+3)
 
 
 #endif
diff --git a/scaddins/source/pricing/pricing.hxx b/scaddins/source/pricing/pricing.hxx
index 66d2d26..ca02f9c 100644
--- a/scaddins/source/pricing/pricing.hxx
+++ b/scaddins/source/pricing/pricing.hxx
@@ -389,23 +389,23 @@ public:
     //  methods from own interfaces start here
     // ----------------------------------------
 
-    virtual double SAL_CALL getOpt_barrier( double spot, double vol,
+    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 STRING& put_call, const STRING& in_out,
             const STRING& continuous, const ANY& greek ) THROWDEF_RTE_IAE;
 
-   virtual double SAL_CALL getOpt_touch( double spot, double vol,
+   virtual double SAL_CALL getOptTouch( double spot, double vol,
             double r, double rf, double T,
             double barrier_low, double barrier_up,
             const STRING& for_dom, const STRING& in_out,
             const STRING& barriercont, const ANY& greekstr ) THROWDEF_RTE_IAE;
 
-   virtual double SAL_CALL getOpt_prob_hit( double spot, double vol,
+   virtual double SAL_CALL getOptProbHit( double spot, double vol,
             double mu, double T,
             double barrier_low, double barrier_up ) THROWDEF_RTE_IAE;
 
-   virtual double SAL_CALL getOpt_prob_inmoney( double spot, double vol,
+   virtual double SAL_CALL getOptProbInMoney( double spot, double vol,
             double mu, double T,
             double barrier_low, double barrier_up,
             const ANY& strikeval, const ANY& put_call ) THROWDEF_RTE_IAE;
diff --git a/scaddins/source/pricing/pricing.src b/scaddins/source/pricing/pricing.src
index c85a5d5..6aa1675 100644
--- a/scaddins/source/pricing/pricing.src
+++ b/scaddins/source/pricing/pricing.src
@@ -23,7 +23,7 @@
 // function and parameter description
 Resource RID_PRICING_FUNCTION_DESCRIPTIONS
 {
-    Resource PRICING_FUNCDESC_Opt_barrier
+    Resource PRICING_FUNCDESC_OptBarrier
     {
         String 1    // description
         {
@@ -150,7 +150,7 @@ Resource RID_PRICING_FUNCTION_DESCRIPTIONS
 
 
 
-    Resource PRICING_FUNCDESC_Opt_touch
+    Resource PRICING_FUNCDESC_OptTouch
     {
         String 1    // description
         {
@@ -258,7 +258,7 @@ Resource RID_PRICING_FUNCTION_DESCRIPTIONS
     };
 
 
-    Resource PRICING_FUNCDESC_Opt_prob_hit
+    Resource PRICING_FUNCDESC_OptProbHit
     {
         String 1    // description
         {
@@ -321,7 +321,7 @@ Resource RID_PRICING_FUNCTION_DESCRIPTIONS
     };
 
 
-    Resource PRICING_FUNCDESC_Opt_prob_inmoney
+    Resource PRICING_FUNCDESC_OptProbInMoney
     {
         String 1    // description
         {
@@ -410,19 +410,19 @@ Resource RID_PRICING_FUNCTION_DESCRIPTIONS
 // function names as accessible from cells
 Resource RID_PRICING_FUNCTION_NAMES
 {
-    String PRICING_FUNCNAME_Opt_barrier
+    String PRICING_FUNCNAME_OptBarrier
     {
         Text [ en-US ] = "OPT_BARRIER";
     };
-    String PRICING_FUNCNAME_Opt_touch
+    String PRICING_FUNCNAME_OptTouch
     {
         Text [ en-US ] = "OPT_TOUCH";
     };
-    String PRICING_FUNCNAME_Opt_prob_hit
+    String PRICING_FUNCNAME_OptProbHit
     {
         Text [ en-US ] = "OPT_PROB_HIT";
     };
-    String PRICING_FUNCNAME_Opt_prob_inmoney
+    String PRICING_FUNCNAME_OptProbInMoney
     {
         Text [ en-US ] = "OPT_PROB_INMONEY";
     };
-- 
1.7.11.2


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.