Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
logquote.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include "toplevelfixture.hpp"
20#include <boost/test/unit_test.hpp>
21#include <ql/quotes/simplequote.hpp>
23
24using namespace QuantLib;
25using namespace boost::unit_test_framework;
27
28BOOST_FIXTURE_TEST_SUITE(QuantExtTestSuite, qle::test::TopLevelFixture)
29
30BOOST_AUTO_TEST_SUITE(LogQuoteTest)
31
32BOOST_AUTO_TEST_CASE(testLogQuote) {
33
34 BOOST_TEST_MESSAGE("Testing QuantExt::LogQuote...");
35 QuantLib::ext::shared_ptr<SimpleQuote> quote(new QuantLib::SimpleQuote(1.0));
36 Handle<Quote> qh(quote);
37 Handle<Quote> logQuote(QuantLib::ext::shared_ptr<Quote>(new LogQuote(qh)));
38
39 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
40
41 quote->setValue(2.0);
42 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
43
44 quote->setValue(3.0);
45 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
46
47 quote->setValue(123.0);
48 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
49
50 // LogQuote should throw when a negative value is set
51 BOOST_CHECK_THROW(quote->setValue(-1.0), std::exception);
52}
53
54BOOST_AUTO_TEST_SUITE_END()
55
56BOOST_AUTO_TEST_SUITE_END()
Class for storing logs of quotes for log-linear interpolation.
Definition: logquote.hpp:38
stores log of quote for log-linear interpolation
BOOST_AUTO_TEST_CASE(testLogQuote)
Definition: logquote.cpp:32
Fixture that can be used at top level.