Kaydet (Commit) e9f31eaa authored tarafından tino's avatar tino Kaydeden (comit) Fridrich Strba

adding calc add-in for option pricing

Change-Id: Ica4b621a7ae7e5ab447192ae3fe7b8911295bef2
Reviewed-on: https://gerrit.libreoffice.org/1232Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst 4feaf5a8
......@@ -323,6 +323,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
pcr \
pdffilter \
placeware \
pricing \
protocolhandler \
qstart_gtk \
res \
......
......@@ -77,6 +77,7 @@ my_components = \
component/sc/util/scfilt \
component/scaddins/source/analysis/analysis \
component/scaddins/source/datefunc/date \
component/scaddins/source/pricing/pricing \
component/sd/util/sd \
component/sd/util/sdd \
component/sd/util/sdfilt \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2011 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
$(eval $(call gb_AllLangResTarget_AllLangResTarget,pricing))
$(eval $(call gb_AllLangResTarget_add_srs,pricing,\
scaddins/pricing \
))
$(eval $(call gb_SrsTarget_SrsTarget,scaddins/pricing))
$(eval $(call gb_SrsTarget_set_include,scaddins/pricing,\
$$(INCLUDE) \
-I$(SRCDIR)/scaddins/source/pricing \
))
$(eval $(call gb_SrsTarget_add_files,scaddins/pricing,\
scaddins/source/pricing/pricing.src \
))
# vim: set noet sw=4 ts=4:
......@@ -45,9 +45,11 @@ $(eval $(call gb_InternalUnoApi_set_include,scaddins,\
$(eval $(call gb_InternalUnoApi_add_idlfiles,scaddins,scaddins/idl/com/sun/star/sheet/addin,\
Analysis \
DateFunctions \
PricingFunctions \
XAnalysis \
XCompatibilityNames \
XDateFunctions \
XPricingFunctions \
XMiscFunctions \
))
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2011 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
$(eval $(call gb_Library_Library,pricing))
$(eval $(call gb_Library_set_componentfile,pricing,scaddins/source/pricing/pricing))
$(eval $(call gb_Library_use_internal_comprehensive_api,pricing,\
offapi \
scaddins \
udkapi \
))
$(eval $(call gb_Library_use_libraries,pricing,\
cppu \
cppuhelper \
sal \
tl \
$(gb_UWINAPI) \
))
$(eval $(call gb_Library_add_exception_objects,pricing,\
scaddins/source/pricing/pricing \
scaddins/source/pricing/black_scholes \
))
# Runtime dependency for unit-tests
$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktargetname,pricing)) :| \
$(call gb_AllLangResTarget_get_target,pricing)
# vim: set noet sw=4 ts=4:
......@@ -31,9 +31,11 @@ $(eval $(call gb_Module_Module,scaddins))
$(eval $(call gb_Module_add_targets,scaddins,\
AllLangResTarget_analysis \
AllLangResTarget_date \
AllLangResTarget_pricing \
InternalUnoApi_scaddins \
Library_analysis \
Library_date \
Library_pricing \
))
# vim: set noet sw=4 ts=4:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef com_sun_star_sheet_addin_PricingFunctions_idl
#define com_sun_star_sheet_addin_PricingFunctions_idl
#include <com/sun/star/sheet/addin/XPricingFunctions.idl>
module com
{
module sun
{
module star
{
module sheet
{
module addin
{
service PricingFunctions
{
// exported interfaces:
interface XPricingFunctions;
};
};
};
};
};
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef com_sun_star_sheet_addin_XPricingFunctions_idl
#define com_sun_star_sheet_addin_XPricingFunctions_idl
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/beans/XPropertySet.idl>
module com
{
module sun
{
module star
{
module sheet
{
module addin
{
/**
* Interface with pricing functions.
*/
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 )
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 )
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 )
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 )
raises( com::sun::star::lang::IllegalArgumentException );
};
};
};
};
};
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (C) 2012 Tino Kluge <tino.kluge@hrz.tu-chemnitz.de>
*
*/
#ifndef BLACK_SCHOLES_HXX
#define BLACK_SCHOLES_HXX
// options prices and greeks in the Black-Scholes model
// also known as TV (theoretical value)
namespace sca {
namespace pricing {
namespace bs {
namespace types {
enum Greeks {
Value = 0, //
Delta = 1, // d/dS
Gamma = 2, // d^2/dS^2
Theta = 3, // d/dt
Vega = 4, // d/dsigma
Volga = 5, // d^2/dsigma^2
Vanna = 6, // d^2/dsigma dS
Rho_d = 7, // d/dr_d
Rho_f = 8 // d/dr_f
};
enum PutCall {
Call = 1,
Put = -1
};
enum KOType {
Regular = 0,
Reverse = 1
};
enum BarrierKIO {
KnockIn = -1,
KnockOut = 1
};
// barrier observed continuously or just at maturity (truncated payoff)
enum BarrierActive {
Continuous = 0,
Maturity = 1
};
enum ForDom {
Domestic = 0,
Foreign = 1
};
} // namespace types
// binary option cash (domestic)
// call - pays 1 if S_T is above strike K
// put - pays 1 if S_T is below strike K
double bincash(double S, double vol, double rd, double rf,
double tau, double K,
types::PutCall pc, types::Greeks greeks);
// binary option asset (foreign)
// call - pays S_T if S_T is above strike K
// put - pays S_T if S_T is below strike K
double binasset(double S, double vol, double rd, double rf,
double tau, double K,
types::PutCall pc, types::Greeks greeks);
// vanilla put/call option
// call pays (S_T-K)^+
// put pays (K-S_T)^+
// this is the same as: +/- (binasset - K*bincash)
double putcall(double S, double vol, double rd, double rf,
double tau, double K,
types::PutCall putcall, types::Greeks greeks);
// truncated put/call option, single barrier
// need to specify whether it's down-and-out or up-and-out
// regular (keeps monotonicity): down-and-out for call, up-and-out for put
// reverse (destroys monoton): up-and-out for call, down-and-out for put
// call pays (S_T-K)^+
// put pays (K-S_T)^+
double putcalltrunc(double S, double vol, double rd, double rf,
double tau, double K, double B,
types::PutCall pc, types::KOType kotype,
types::Greeks greeks);
// wrapper function for put/call option which combines
// double/single/no truncation barrier
// B1<=0 - assume no lower barrier
// B2<=0 - assume no upper barrier
double putcalltrunc(double S, double vol, double rd, double rf,
double tau, double K, double B1, double B2,
types::PutCall pc, types::Greeks greek);
// barrier
// touch/no-touch options (cash/asset or nothing payoff profile)
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);
// barrier
// barrier option (put/call payoff profile)
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);
// probability of hitting a barrier
double prob_hit(double S, double vol, double mu,
double tau, double B1, double B2);
// probability of being in-the-money, ie payoff is greater zero,
// assuming payoff(S_T) > 0 iff S_T in [B1, B2]
double prob_in_money(double S, double vol, double mu,
double tau, double B1, double B2);
double prob_in_money(double S, double vol, double mu,
double tau, double K, double B1, double B2,
types::PutCall pc);
} // namespace bs
} // namespace pricing
} // namespace sca
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<component loader="com.sun.star.loader.SharedLibrary" prefix="pricing"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.sheet.addin.PricingFunctionsImpl">
<service name="com.sun.star.sheet.AddIn"/>
<service name="com.sun.star.sheet.addin.PricingFunctions"/>
</implementation>
</component>
This diff is collapsed.
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _SCA_PRICING_HRC
#define _SCA_PRICING_HRC
#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 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_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_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)
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -38,6 +38,8 @@ End
STD_LIB_FILE( gid_File_Lib_Analysis, analysis)
STD_LIB_FILE( gid_File_Lib_Pricing, pricing)
File gid_File_Share_Registry_Calc_Xcd
TXT_FILE_BODY;
Styles = (PACKED);
......@@ -63,6 +65,8 @@ STD_RES_FILE( gid_File_Res_Analysis, analysis)
STD_RES_FILE( gid_File_Res_Date, date)
STD_RES_FILE( gid_File_Res_Pricing, pricing)
STD_RES_FILE( gid_File_Res_Sc, sc )
#if defined WITH_HELP
......
......@@ -54,7 +54,7 @@ Module gid_Module_Prg_Calc_Addins
ParentID = gid_Module_Prg_Calc_Bin;
Sortkey = "700";
Default = YES;
Files = (gid_File_Lib_Date,gid_File_Zip_Addin,gid_File_Lib_Rot,gid_File_Lib_Dfa,gid_File_Lib_Analysis);
Files = (gid_File_Lib_Date,gid_File_Zip_Addin,gid_File_Lib_Rot,gid_File_Lib_Dfa,gid_File_Lib_Analysis,gid_File_Lib_Pricing);
End
Module gid_Module_Brand_Prg_Calc
......@@ -77,6 +77,7 @@ Module gid_Module_Langpack_Calc_Template
Styles = (TEMPLATEMODULE);
Files = (gid_File_Res_Analysis,
gid_File_Res_Date,
gid_File_Res_Pricing,
gid_File_Res_Sc,
gid_File_Res_Solver);
End
......
......@@ -84,6 +84,7 @@ gb_MERGEDLIBS += \
hwp \
hyphen \
lnth \
pricing \
spell \
xstor \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment