packages feed

hq 0.1.0.6 → 0.1.0.7

raw patch · 5 files changed

+148/−2 lines, 5 files

Files

+ external/include/importexport.h view
@@ -0,0 +1,36 @@+//+// This source code resides at www.jaeckel.org/LetsBeRational.7z .+//+// ======================================================================================+// Copyright © 2013-2014 Peter Jäckel.+// +// Permission to use, copy, modify, and distribute this software is freely granted,+// provided that this notice is preserved.+//+// WARRANTY DISCLAIMER+// The Software is provided "as is" without warranty of any kind, either express or implied,+// including without limitation any implied warranties of condition, uninterrupted use,+// merchantability, fitness for a particular purpose, or non-infringement.+// ======================================================================================+//+#ifndef IMPORTEXPORT_H+#define IMPORTEXPORT_H++#if defined(_WIN32) || defined(_WIN64)+#   define EXPORT __declspec(dllexport)+#   define IMPORT __declspec(dllimport)+# else+#   define EXPORT+#   define IMPORT+#endif++#ifdef __cplusplus+#   define EXTERN_C extern "C"+#else+#   define EXTERN_C+#endif++#   define EXPORT_EXTERN_C EXTERN_C EXPORT+#   define IMPORT_EXTERN_C EXTERN_C IMPORT++#endif // IMPORTEXPORT_H
+ external/include/lets_be_rational.h view
@@ -0,0 +1,36 @@+//+// This source code resides at www.jaeckel.org/LetsBeRational.7z .+//+// ======================================================================================+// Copyright © 2013-2014 Peter Jäckel.+// +// Permission to use, copy, modify, and distribute this software is freely granted,+// provided that this notice is preserved.+//+// WARRANTY DISCLAIMER+// The Software is provided "as is" without warranty of any kind, either express or implied,+// including without limitation any implied warranties of condition, uninterrupted use,+// merchantability, fitness for a particular purpose, or non-infringement.+// ======================================================================================+//+#ifndef   LETS_BE_RATIONAL_H+#define   LETS_BE_RATIONAL_H++#include "importexport.h"++#define ENABLE_SWITCHING_THE_OUTPUT_TO_ITERATION_COUNT+#define ENABLE_CHANGING_THE_HOUSEHOLDER_METHOD_ORDER++EXPORT_EXTERN_C double set_implied_volatility_maximum_iterations(double n);+EXPORT_EXTERN_C double set_implied_volatility_output_type(double k);+EXPORT_EXTERN_C double set_implied_volatility_householder_method_order(double m);+EXPORT_EXTERN_C double normalised_black_call(double x, double s);+EXPORT_EXTERN_C double normalised_vega(double x, double s);+EXPORT_EXTERN_C double normalised_black(double x, double s, double q /* q=±1 */);+EXPORT_EXTERN_C double black(double F, double K, double sigma, double T, double q /* q=±1 */);+EXPORT_EXTERN_C double normalised_implied_volatility_from_a_transformed_rational_guess_with_limited_iterations(double beta, double x, double q /* q=±1 */, int N);+EXPORT_EXTERN_C double normalised_implied_volatility_from_a_transformed_rational_guess(double beta, double x, double q /* q=±1 */);+EXPORT_EXTERN_C double implied_volatility_from_a_transformed_rational_guess_with_limited_iterations(double price, double F, double K, double T, double q /* q=±1 */, int N);+EXPORT_EXTERN_C double implied_volatility_from_a_transformed_rational_guess(double price, double F, double K, double T, double q /* q=±1 */);++#endif // NORMAL_DISTRIBUTION_H
+ external/include/normaldistribution.h view
@@ -0,0 +1,34 @@+//+// This source code resides at www.jaeckel.org/LetsBeRational.7z .+//+// ======================================================================================+// Copyright © 2013-2014 Peter Jäckel.+// +// Permission to use, copy, modify, and distribute this software is freely granted,+// provided that this notice is preserved.+//+// WARRANTY DISCLAIMER+// The Software is provided "as is" without warranty of any kind, either express or implied,+// including without limitation any implied warranties of condition, uninterrupted use,+// merchantability, fitness for a particular purpose, or non-infringement.+// ======================================================================================+//+#ifndef   NORMAL_DISTRIBUTION_H+#define   NORMAL_DISTRIBUTION_H++#include <math.h>+#include <cmath>+#include "importexport.h"++#define ONE_OVER_SQRT_TWO     0.7071067811865475244008443621048490392848359376887+#define ONE_OVER_SQRT_TWO_PI  0.3989422804014326779399460599343818684758586311649+#define SQRT_TWO_PI           2.506628274631000502415765284811045253006986740610++EXPORT_EXTERN_C double erf_cody(double z);+EXPORT_EXTERN_C double erfc_cody(double z);+EXPORT_EXTERN_C double erfcx_cody(double z);+EXPORT_EXTERN_C double norm_cdf(double z);+inline double norm_pdf(double x){ return ONE_OVER_SQRT_TWO_PI*exp(-.5*x*x); }+EXPORT_EXTERN_C double inverse_norm_cdf(double u);++#endif // NORMAL_DISTRIBUTION_H
+ external/include/rationalcubic.h view
@@ -0,0 +1,34 @@+//+// This source code resides at www.jaeckel.org/LetsBeRational.7z .+//+// ======================================================================================+// Copyright © 2013-2014 Peter Jäckel.+// +// Permission to use, copy, modify, and distribute this software is freely granted,+// provided that this notice is preserved.+//+// WARRANTY DISCLAIMER+// The Software is provided "as is" without warranty of any kind, either express or implied,+// including without limitation any implied warranties of condition, uninterrupted use,+// merchantability, fitness for a particular purpose, or non-infringement.+// ======================================================================================+//+#ifndef   RATIONAL_CUBIC_H+#define   RATIONAL_CUBIC_H++// Based on+//+//    “Shape preserving piecewise rational interpolation”, R. Delbourgo, J.A. Gregory - SIAM journal on scientific and statistical computing, 1985 - SIAM.+//    http://dspace.brunel.ac.uk/bitstream/2438/2200/1/TR_10_83.pdf  [caveat emptor: there are some typographical errors in that draft version]+//++#include "importexport.h"++EXPORT_EXTERN_C double rational_cubic_interpolation(double x, double x_l, double x_r, double y_l, double y_r, double d_l, double d_r, double r);+EXPORT_EXTERN_C double rational_cubic_control_parameter_to_fit_second_derivative_at_left_side(double x_l, double x_r, double y_l, double y_r, double d_l, double d_r, double second_derivative_l);+EXPORT_EXTERN_C double rational_cubic_control_parameter_to_fit_second_derivative_at_right_side(double x_l, double x_r, double y_l, double y_r, double d_l, double d_r, double second_derivative_r);+EXPORT_EXTERN_C double minimum_rational_cubic_control_parameter(double d_l, double d_r, double s, bool preferShapePreservationOverSmoothness);+EXPORT_EXTERN_C double convex_rational_cubic_control_parameter_to_fit_second_derivative_at_left_side(double x_l, double x_r, double y_l, double y_r, double d_l, double d_r, double second_derivative_l, bool preferShapePreservationOverSmoothness);+EXPORT_EXTERN_C double convex_rational_cubic_control_parameter_to_fit_second_derivative_at_right_side(double x_l, double x_r, double y_l, double y_r, double d_l, double d_r, double second_derivative_r, bool preferShapePreservationOverSmoothness);++#endif // RATIONAL_CUBIC_H
hq.cabal view
@@ -7,7 +7,7 @@ -- hash: ccfecaab3d1004f03e5a9e851269c0209561044c1b9aa90d587dc93a936394f0  name:           hq-version:        0.1.0.6+version:        0.1.0.7 synopsis:       Quantitative Library category:       Finance description:    Please see the README on GitHub at <https://github.com/ghais/hq#readme>@@ -91,12 +91,18 @@   hs-source-dirs:       src   include-dirs:-      external/src+      external/include+      external   cxx-sources:       external/src/lets_be_rational.cpp       external/src/normaldistribution.cpp       external/src/rationalcubic.cpp       external/src/erf_cody.cpp+  install-includes:+      importexport.h+      lets_be_rational.h+      normaldistribution.h+      rationalcubic.h   build-depends:     , base >=4.12 && <5     , bytestring >=0.10 && <0.11