quantlib | The idiomatic rust implementation of the QuantLib C++ | Cryptocurrency library
kandi X-RAY | quantlib Summary
kandi X-RAY | quantlib Summary
The QuantLib project (is aimed at providing a comprehensive software framework for quantitative finance. QuantLib is a free/open-source library for modeling, trading, and risk management in real-life. Appreciated by quantitative analysts and developers, it is intended for academics and practitioners alike, eventually promoting a stronger interaction between them. QuantLib offers tools that are useful both for practical implementation and for advanced modeling, with features such as market conventions, yield curve models, solvers, PDEs, Monte Carlo (low-discrepancy included), exotic options, VAR, and so on.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of quantlib
quantlib Key Features
quantlib Examples and Code Snippets
Community Discussions
Trending Discussions on quantlib
QUESTION
In a code review recently, I had some less than kind words for something I thought awful. It turns out that it was obviously inspired by the QuantLib::Error class, which looks like this:
...ANSWER
Answered 2022-Mar-11 at 02:18This is following the behavior of standard library exception types.
They are supposed to be copyable without throwing exceptions, since throwing an exception during construction of an exception handler parameter would cause a call to std::terminate
(and possibly in some other situations requiring a copy of the exception as well).
If std::string
was used directly, copying the exception could cause for example a std::bad_alloc
to be thrown. Using a reference-counted pointer instead avoids that.
QUESTION
I'm new to classes in Python and could use some assistance.
I have the following (admittedly poorly-written) class:
...ANSWER
Answered 2022-Jan-26 at 23:39I recommend a reading of the Python documentation about classes.
Q1. What is causing the NameError: name 'self' is not defined
error in the class above?
A: self
refers to an object of a class. You cannot reference an object before you create one.
Q2. Would someone kindly show me the correct (i.e. canonical) way to write this class?
A: You could add the class properties you defined to the __init__
method, as you did with some properties.
QUESTION
I calculated bond price and stressed bond price (shocking up yield) in both Excel and Python Quantlib. As the following table shows, weird results were generated: base bond price matches well between Excel and Quantlib but the stressed bond prices have more gaps (1.5% relative difference). Yields also show some gaps. Can you please provide some comments?
Excel Code:
...ANSWER
Answered 2021-Nov-23 at 08:29You need to add
QUESTION
I have the following old code that used to work on "older" combinations/versions of C++, QuantLib and Boost.
While was playing around with the idea of upgrading to newer versions ie C++11, QuantLib >= 1.76, boost >= 1_71 building now throws the following "conversion" error(s).
I am using [options] g++ -std=gnu++11
ANSWER
Answered 2021-Sep-29 at 18:58The errors are narrowing conversions, which are never allowed in uniform initializers.
That's relevant because aggregate initialization existed all along and did not have that restriction. Now in C++11 world, aggregate initialization is just a form of uniform initialization, with ditto narrowing rules.
You should explicitly convert the respective values (checking that the conversion is safe!)
E.g.
QUESTION
Can someone please help with the pricing of the following forward rate agreement using QuantLib Python?
A 3x6 forward rate agreement, with a notional of $100,000, the FRA rate being 6%, The FRA settlement date is after 3 months (90 days) and the settlement is based on a 90-day USDLIBOR.
My valuation date is 30 June 2020.
This is my attempt:
...ANSWER
Answered 2021-Sep-07 at 14:13First off (for accuracy) the daycount for USD FRAs is Act/360, ie ql.Actual360()
. Also bear in mind that the fixing calendar for FRAs is based on the UK calendar (BBA Libor), which may be different from the settlement calendar (so 4th July is not a fixing holiday, but is a settlement holiday).
The main issue with the OP code is that the FRA start date is the same as the evaluation date. Once you know the fixing, then the FRA is effectively settled, so has a NPV of zero and a cashflow.
The first parameter of ForwardRateAgreement()
is the settle date of the FRA. The second, maturity, is the end date. So for a spot 3x6, the start date is 3m from now, and the maturity is 6m from now.
Amending this line to:
dayConvention = ql.Actual360()
and
fra = ql.ForwardRateAgreement(calendar.advance(startDate,ql.Period(3,ql.Months)), calendar.advance(startDate,ql.Period(6,ql.Months)), ql.Position.Long, rate, notional, index, spotCurveHandle)
will give you the dates for a spot 3x6 FRA (30-Sep-20 -> 30-Dec-20).
Output:
NPV: -262.08622386063985
NB. In the QuantLib example for FRA's, they use a selection of FRA market rates to build a PiecewiseLogLinearDiscount
curve to value the FRA, rather than a zero curve, and I guess it is the subtle differences between the two which is leading to the slight change in forward rate (and hence NPV). The implied forward rate for the FRA comes out at 4.937% ... ie not 5%, which also increases the NPV. In practice, if you are trying to price FRAs then build a curve using market FRA quotes.
QUESTION
I am trying to compile some C++ that depends on QuantLib, which in turn depends on Boost. I am working on a MacBook Pro M1 (ARM architecture). I installed Boost and QuantLib using the instructions on this page: https://www.quantlib.org/install/macosx.shtml. I then tried to compile the following source code:
...ANSWER
Answered 2021-Aug-09 at 13:33I think you're missing a -lQuantLib
in your command line? You're telling the compiler where to look for the libraries (the -L
switches`) but not which libraries to link.
Also, check whether homebrew also installed a quantlib-config
script on your computer. If so, it should provide the switches you need; try running
QUESTION
What's wrong with my code? I wanted to make a new xts object to store data from the first loop and to be used in subsequent loops but I got this error message:
...ANSWER
Answered 2021-Aug-05 at 10:30if(i < 1){
fund_table_xts_fin <- fund_table_xts
} else {
fund_table_xts_fin <- merge(fund_table_xts, fund_table_xts_fin)
}
In the above section when i = 1 then you are in the else block but there is no 'fund_table_xts_fin' object created yet. You can try this:
`if(i == 1){
fund_table_xts_fin <- fund_table_xts
} else {
fund_table_xts_fin <- merge(fund_table_xts, fund_table_xts_fin)
}`
QUESTION
I have pip installed newest QuantLib
for python 1.23 for Windows.
ql.Callability()
is available but ql.CallabilityPrice
is not provided.
Is there any issue?
ANSWER
Answered 2021-Aug-01 at 06:07CallabilityPrice
was renamed to BondPrice
in the underlying C++ library a couple of versions ago. The Python module kept the old version for a while but eventually did the same.
QUESTION
I have the following code. However i am having error when executing same. I want the function to calculate the schedule date and ouput same to a new dataframe. It seems the error is in the for loop. I am new to this so just trying to figure out
...ANSWER
Answered 2021-Jun-11 at 16:14I assume what you are wanting to do is to modify a dataframe row by row (if there is more to it there may be a better solution) :
QUESTION
I want to calculate days difference between the dates using 360 days basis .Code is as per below but is not working
...ANSWER
Answered 2021-May-14 at 22:01For example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install quantlib
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page