You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(60) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(18) |
Feb
(4) |
Mar
(6) |
Apr
(2) |
May
|
Jun
(12) |
Jul
(48) |
Aug
(6) |
Sep
(3) |
Oct
(24) |
Nov
(15) |
Dec
(18) |
| 2002 |
Jan
(39) |
Feb
(12) |
Mar
(80) |
Apr
(72) |
May
(46) |
Jun
(27) |
Jul
(23) |
Aug
(34) |
Sep
(65) |
Oct
(71) |
Nov
(19) |
Dec
(14) |
| 2003 |
Jan
(44) |
Feb
(59) |
Mar
(18) |
Apr
(62) |
May
(54) |
Jun
(27) |
Jul
(46) |
Aug
(15) |
Sep
(44) |
Oct
(36) |
Nov
(19) |
Dec
(12) |
| 2004 |
Jan
(26) |
Feb
(33) |
Mar
(47) |
Apr
(63) |
May
(36) |
Jun
(65) |
Jul
(80) |
Aug
(163) |
Sep
(65) |
Oct
(39) |
Nov
(36) |
Dec
(39) |
| 2005 |
Jan
(97) |
Feb
(78) |
Mar
(64) |
Apr
(64) |
May
(48) |
Jun
(55) |
Jul
(89) |
Aug
(57) |
Sep
(51) |
Oct
(111) |
Nov
(86) |
Dec
(76) |
| 2006 |
Jan
(84) |
Feb
(103) |
Mar
(143) |
Apr
(92) |
May
(55) |
Jun
(58) |
Jul
(71) |
Aug
(57) |
Sep
(74) |
Oct
(59) |
Nov
(8) |
Dec
(32) |
| 2007 |
Jan
(60) |
Feb
(40) |
Mar
(50) |
Apr
(26) |
May
(61) |
Jun
(120) |
Jul
(119) |
Aug
(48) |
Sep
(121) |
Oct
(66) |
Nov
(103) |
Dec
(43) |
| 2008 |
Jan
(60) |
Feb
(109) |
Mar
(92) |
Apr
(106) |
May
(82) |
Jun
(59) |
Jul
(67) |
Aug
(118) |
Sep
(131) |
Oct
(56) |
Nov
(37) |
Dec
(69) |
| 2009 |
Jan
(75) |
Feb
(76) |
Mar
(103) |
Apr
(78) |
May
(61) |
Jun
(35) |
Jul
(66) |
Aug
(69) |
Sep
(166) |
Oct
(46) |
Nov
(72) |
Dec
(65) |
| 2010 |
Jan
(48) |
Feb
(57) |
Mar
(93) |
Apr
(85) |
May
(123) |
Jun
(82) |
Jul
(98) |
Aug
(121) |
Sep
(146) |
Oct
(86) |
Nov
(72) |
Dec
(34) |
| 2011 |
Jan
(96) |
Feb
(55) |
Mar
(73) |
Apr
(57) |
May
(33) |
Jun
(74) |
Jul
(89) |
Aug
(71) |
Sep
(103) |
Oct
(76) |
Nov
(52) |
Dec
(61) |
| 2012 |
Jan
(48) |
Feb
(54) |
Mar
(78) |
Apr
(60) |
May
(75) |
Jun
(59) |
Jul
(33) |
Aug
(66) |
Sep
(43) |
Oct
(46) |
Nov
(75) |
Dec
(51) |
| 2013 |
Jan
(112) |
Feb
(72) |
Mar
(49) |
Apr
(48) |
May
(42) |
Jun
(44) |
Jul
(80) |
Aug
(19) |
Sep
(33) |
Oct
(37) |
Nov
(38) |
Dec
(98) |
| 2014 |
Jan
(113) |
Feb
(93) |
Mar
(49) |
Apr
(106) |
May
(97) |
Jun
(155) |
Jul
(87) |
Aug
(127) |
Sep
(85) |
Oct
(48) |
Nov
(41) |
Dec
(37) |
| 2015 |
Jan
(34) |
Feb
(50) |
Mar
(104) |
Apr
(80) |
May
(82) |
Jun
(66) |
Jul
(41) |
Aug
(84) |
Sep
(37) |
Oct
(65) |
Nov
(83) |
Dec
(52) |
| 2016 |
Jan
(68) |
Feb
(35) |
Mar
(42) |
Apr
(35) |
May
(54) |
Jun
(75) |
Jul
(45) |
Aug
(52) |
Sep
(60) |
Oct
(52) |
Nov
(36) |
Dec
(64) |
| 2017 |
Jan
(92) |
Feb
(59) |
Mar
(35) |
Apr
(53) |
May
(83) |
Jun
(43) |
Jul
(65) |
Aug
(68) |
Sep
(46) |
Oct
(75) |
Nov
(40) |
Dec
(49) |
| 2018 |
Jan
(68) |
Feb
(54) |
Mar
(48) |
Apr
(58) |
May
(51) |
Jun
(44) |
Jul
(40) |
Aug
(68) |
Sep
(35) |
Oct
(15) |
Nov
(7) |
Dec
(37) |
| 2019 |
Jan
(43) |
Feb
(7) |
Mar
(22) |
Apr
(21) |
May
(31) |
Jun
(39) |
Jul
(73) |
Aug
(45) |
Sep
(47) |
Oct
(89) |
Nov
(19) |
Dec
(69) |
| 2020 |
Jan
(52) |
Feb
(63) |
Mar
(45) |
Apr
(59) |
May
(42) |
Jun
(57) |
Jul
(30) |
Aug
(29) |
Sep
(75) |
Oct
(64) |
Nov
(96) |
Dec
(22) |
| 2021 |
Jan
(14) |
Feb
(24) |
Mar
(35) |
Apr
(58) |
May
(36) |
Jun
(15) |
Jul
(18) |
Aug
(31) |
Sep
(30) |
Oct
(33) |
Nov
(27) |
Dec
(16) |
| 2022 |
Jan
(35) |
Feb
(22) |
Mar
(14) |
Apr
(20) |
May
(44) |
Jun
(53) |
Jul
(25) |
Aug
(56) |
Sep
(11) |
Oct
(47) |
Nov
(22) |
Dec
(36) |
| 2023 |
Jan
(30) |
Feb
(17) |
Mar
(31) |
Apr
(48) |
May
(31) |
Jun
(7) |
Jul
(25) |
Aug
(26) |
Sep
(61) |
Oct
(66) |
Nov
(19) |
Dec
(21) |
| 2024 |
Jan
(37) |
Feb
(29) |
Mar
(26) |
Apr
(26) |
May
(34) |
Jun
(9) |
Jul
(27) |
Aug
(13) |
Sep
(15) |
Oct
(25) |
Nov
(13) |
Dec
(8) |
| 2025 |
Jan
(13) |
Feb
(1) |
Mar
(16) |
Apr
(17) |
May
(8) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(6) |
Oct
(15) |
Nov
(6) |
Dec
|
| 2026 |
Jan
(6) |
Feb
(4) |
Mar
(20) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Luigi B. <lui...@gm...> - 2020-11-23 10:28:53
|
Hi Daniel,
assuming r and q in the formula map into your riskFreeCurve and
yieldCurve, respectively, I'd say your forward price at date d is
spot * yieldCurve.discount(d) / riskFreeCurve.discount(d)
(because, e.g., riskFreeCurve.discount(d) will give you the exp(-r*t) term.)
Luigi
On Sun, Nov 22, 2020 at 1:10 PM Daniel Lobo <dan...@gm...> wrote:
> Upon searching the Internet I found this spec.
>
> https://quantlib-python-docs.readthedocs.io/en/latest/instruments/forwards.html?highlight=forwardRate#ql.ForwardRateAgreement..forwardRate
>
> However this seems to calculate the Forward interest rate implied by
> FRA. This is not what I was looking for. I wanted to calculate the
> Forward price typically calculated by the formula Spot multiplied by
> Cost of carry (https://en.wikipedia.org/wiki/Forward_price)
>
> Any further pointer will be highly appreciated
>
> On Sun, 22 Nov 2020 at 16:45, Amine Ifri <ami...@gm...> wrote:
> >
> > Daniel,
> >
> > I believe Quantlib has class method called forwardRate(date t1, date t2)
> if my memory serves me well.
> >
> >
> >
> > Amine Ifri
> >
> > > On 22 Nov 2020, at 10:47, Daniel Lobo <dan...@gm...> wrote:
> > >
> > > Hi,
> > >
> > > I have below information -
> > >
> > > import QuantLib as ql
> > >
> > > today = ql.Date(7, ql.March, 2014)
> > > ql.Settings.instance().evaluationDate = today
> > > u = ql.SimpleQuote(100.0)
> > > r1 = ql.SimpleQuote(0.01)
> > > yield = ql.SimpleQuote(0.02)
> > > sigma = ql.SimpleQuote(0.20)
> > > riskFreeCurve = ql.FlatForward(
> > > 0,
> > > ql.TARGET(),
> > > ql.QuoteHandle(r1),
> > > ql.Actual360())
> > > yieldCurve = ql.FlatForward(
> > > 0,
> > > ql.TARGET(),
> > > ql.QuoteHandle(yield),
> > > ql.Actual360())
> > >
> > > Given this information, I want to calculate the Term structure of the
> > > Forward quotes for different dates in futures.
> > >
> > > Can you please help me if QuantLib has any method to perform the same?
> > >
> > > Many thanks for your time.
> > >
> > >
> > > _______________________________________________
> > > QuantLib-users mailing list
> > > Qua...@li...
> > > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: David D. <nh...@gm...> - 2020-11-23 10:12:17
|
Hi,
First, the ZeroCurve constructor already expects continuously compounded
rates (and uses linear interpolation), so if you just define it as:
spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar)
you will get the right result.
Second, the way you are inputting the conventions is not correct. The
alternatives for the compounding are:
- Simple
- Compounded
- Continuous
- SimpleThenCompounded
These "objects" in python actually just return an int. To see what I mean,
try:
print(Simple, Compounded, Continuous, SimpleThenCompounded)
# 0 1 2 3
If you specify Compounded, you can then specify the frequency: Annual,
Semiannual, etc (these frequencies also just return an int)
So you where actually building a curve with semiannually compounded rates,
and that's why your calculations were off
You were building the curve as (Compounded = 1, Semiannual = 2):
spotCurve = ZeroCurve(spotDates, spotRates, dayCount,
calendar, interpolation, Compounded, Semiannual)
when what you wanted was (Continuous = 2):
spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar,
interpolation, Continuous)
Hope this helps
David
On Sun, 22 Nov 2020 at 21:22, Brian Smith <bri...@gm...>
wrote:
> Hi,
>
> I use QL to calculate the Rate of Interest between 2 forward dates as
> below -
>
> from QuantLib import *
> import math
>
> # Settings
> todaysDate = Date(1, 9, 2019)
> Settings.instance().evaluationDate = todaysDate
> dayCount = Actual365Fixed()
> calendar = Canada()
> interpolation = Linear()
> compounding = Compounded
> compoundingFrequency = Continuous
>
> # Definitions
> spotDates = [todaysDate, todaysDate + Period("1y"), todaysDate +
> Period("2y"), todaysDate + Period("3y")]
> spotRates = [0, 0.066682, 0.067199, 0.067502]
>
> spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar,
> interpolation, compounding, compoundingFrequency)
> spotCurveHandle = YieldTermStructureHandle(spotCurve)
>
> spotCurveHandle.forwardRate(spotDates[1], spotDates[2], dayCount,
> Continuous).rate() # Forward rate
> # 0.06659636746440421
>
> However when I manually calculate the same, I see visible difference -
> math.log(math.exp(spotRates[2] * dayCount.yearFraction(todaysDate,
> spotDates[2])) / math.exp(spotRates[1] *
> dayCount.yearFraction(todaysDate, spotDates[1]))) /
> dayCount.yearFraction(spotDates[1], spotDates[2])
>
> #0.06771741643835603
>
> Can you please help me to understand what actually attributes that
> difference between QL's number and my calculation?
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: jian Xu <jia...@gm...> - 2020-11-23 04:25:06
|
Aha, Thanks for pointing that out, Peter. After I pass the same compounding and bond coupon frequency to the constructor of the ZeroSpreadedTermStructure, the clean price comes back to be the same as the new_clean_prce. >>> ts_spreaded1 = ql.ZeroSpreadedTermStructure(ts_handle, spread_handle1, ql.Compounded, fixed_rate_bond.frequency()) >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_spreaded1, settle_date) 101.00000001031341 As a side note, I think a better practice is to always specify compounding and frequency, no matter constructing the baseline "ts_yield" or the spread curve "ts_spreaded1". I don't understand why there isn't inspectors like compounding()/frequency() for the FlatForward and the ZeroSpreadedTermStructure class. On Sun, Nov 22, 2020 at 12:37 PM Peter Caspers <pca...@gm...> wrote: > > Hi Jian, this might be due to > > - different compounding conventions for the spread in the z-spread > calculation (compounded in your code) vs. the zero-spreaded term > structure (defaults to continuous, you can change it but I am not sure > if this is this possible in Python) > > - different day count conventions for the z-spread (given by day_count > in your code) and for the spread in the zero-spreaded term structure, > which is always the day counter of the underlying rate curve (your > ts_handle) - again you can overwrite this in the zero-spreaded term > structure constructor, but this is unfortunately ignored (a known bug, > or an open to do as we often like to call it) > > Best regards, > Peter > > On Sun, 22 Nov 2020 at 19:00, jian Xu <jia...@gm...> wrote: > > > > Hi, > > I encountered some inconsistency in ZSpread calculation. Basically, I > > calculate the zspread using the BondFunctions.zSpread. But when I add > > this zspread on top of the yield curve, I cannot recover the clean > > price. Following is what I did: > > > > I used the official notebook example at: > > http://gouthamanbalaraman.com/blog/bonds-with-spreads-quantlib-python.html, > > everything the same up to the part which sets the bond_engine. > > > > Then instead of using the engine, I used BondFunctions: > > >>> settle_date = fixed_rate_bond.settlementDate(calc_date) > > >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_yield, settle_date) > > > > This returns the clean price of 114.09294985282332, which translates > > to the same NPV =114.18461651948999 on the official site (by adding > > the accrued interest). So far so good. > > > > Then I ask if the clean price is 101, what's the zspread: > > >>> new_clean_price = 101 > > >>> zspread = ql.BondFunctions.zSpread(fixed_rate_bond, new_clean_price, ts_yield, day_count, ql.Compounded, fixed_rate_bond.frequency(), settle_date) > > print(zspread) > > > > This shows the zspread=0.02592546532075354. > > > > Then I add this zspread on top of the original yield curve to obtain a > > new yield curve. My understanding is that by using this new yield > > curve to price the bond, I should recover the new_clean_price. But it > > does not: > > > > >>> spread1 = ql.SimpleQuote(zspread) > > >>> spread_handle1 = ql.QuoteHandle(spread1) > > >>> ts_spreaded1 = ql.ZeroSpreadedTermStructure(ts_handle, spread_handle1) > > >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_spreaded1, settle_date) > > > > This resulted clean price is 100.91139815763174, which is about 0.0886 > > different from the new_clean_price. I tried to increase the > > "accuracy" parameter in the ql.BondFunctions.zSpread, but doesn't seem > > to help. > > > > Does anyone know why? Did I misunderstood ZSpread? Or did I pass > > wrong parameters in the zSpread function call? Thanks. > > > > Jian > > > > > > _______________________________________________ > > QuantLib-users mailing list > > Qua...@li... > > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Brian S. <bri...@gm...> - 2020-11-22 21:21:46
|
Hi,
I use QL to calculate the Rate of Interest between 2 forward dates as below -
from QuantLib import *
import math
# Settings
todaysDate = Date(1, 9, 2019)
Settings.instance().evaluationDate = todaysDate
dayCount = Actual365Fixed()
calendar = Canada()
interpolation = Linear()
compounding = Compounded
compoundingFrequency = Continuous
# Definitions
spotDates = [todaysDate, todaysDate + Period("1y"), todaysDate +
Period("2y"), todaysDate + Period("3y")]
spotRates = [0, 0.066682, 0.067199, 0.067502]
spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar,
interpolation, compounding, compoundingFrequency)
spotCurveHandle = YieldTermStructureHandle(spotCurve)
spotCurveHandle.forwardRate(spotDates[1], spotDates[2], dayCount,
Continuous).rate() # Forward rate
# 0.06659636746440421
However when I manually calculate the same, I see visible difference -
math.log(math.exp(spotRates[2] * dayCount.yearFraction(todaysDate,
spotDates[2])) / math.exp(spotRates[1] *
dayCount.yearFraction(todaysDate, spotDates[1]))) /
dayCount.yearFraction(spotDates[1], spotDates[2])
#0.06771741643835603
Can you please help me to understand what actually attributes that
difference between QL's number and my calculation?
|
|
From: Peter C. <pca...@gm...> - 2020-11-22 18:37:26
|
Hi Jian, this might be due to - different compounding conventions for the spread in the z-spread calculation (compounded in your code) vs. the zero-spreaded term structure (defaults to continuous, you can change it but I am not sure if this is this possible in Python) - different day count conventions for the z-spread (given by day_count in your code) and for the spread in the zero-spreaded term structure, which is always the day counter of the underlying rate curve (your ts_handle) - again you can overwrite this in the zero-spreaded term structure constructor, but this is unfortunately ignored (a known bug, or an open to do as we often like to call it) Best regards, Peter On Sun, 22 Nov 2020 at 19:00, jian Xu <jia...@gm...> wrote: > > Hi, > I encountered some inconsistency in ZSpread calculation. Basically, I > calculate the zspread using the BondFunctions.zSpread. But when I add > this zspread on top of the yield curve, I cannot recover the clean > price. Following is what I did: > > I used the official notebook example at: > http://gouthamanbalaraman.com/blog/bonds-with-spreads-quantlib-python.html, > everything the same up to the part which sets the bond_engine. > > Then instead of using the engine, I used BondFunctions: > >>> settle_date = fixed_rate_bond.settlementDate(calc_date) > >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_yield, settle_date) > > This returns the clean price of 114.09294985282332, which translates > to the same NPV =114.18461651948999 on the official site (by adding > the accrued interest). So far so good. > > Then I ask if the clean price is 101, what's the zspread: > >>> new_clean_price = 101 > >>> zspread = ql.BondFunctions.zSpread(fixed_rate_bond, new_clean_price, ts_yield, day_count, ql.Compounded, fixed_rate_bond.frequency(), settle_date) > print(zspread) > > This shows the zspread=0.02592546532075354. > > Then I add this zspread on top of the original yield curve to obtain a > new yield curve. My understanding is that by using this new yield > curve to price the bond, I should recover the new_clean_price. But it > does not: > > >>> spread1 = ql.SimpleQuote(zspread) > >>> spread_handle1 = ql.QuoteHandle(spread1) > >>> ts_spreaded1 = ql.ZeroSpreadedTermStructure(ts_handle, spread_handle1) > >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_spreaded1, settle_date) > > This resulted clean price is 100.91139815763174, which is about 0.0886 > different from the new_clean_price. I tried to increase the > "accuracy" parameter in the ql.BondFunctions.zSpread, but doesn't seem > to help. > > Does anyone know why? Did I misunderstood ZSpread? Or did I pass > wrong parameters in the zSpread function call? Thanks. > > Jian > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: jian Xu <jia...@gm...> - 2020-11-22 17:59:46
|
Hi, I encountered some inconsistency in ZSpread calculation. Basically, I calculate the zspread using the BondFunctions.zSpread. But when I add this zspread on top of the yield curve, I cannot recover the clean price. Following is what I did: I used the official notebook example at: http://gouthamanbalaraman.com/blog/bonds-with-spreads-quantlib-python.html, everything the same up to the part which sets the bond_engine. Then instead of using the engine, I used BondFunctions: >>> settle_date = fixed_rate_bond.settlementDate(calc_date) >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_yield, settle_date) This returns the clean price of 114.09294985282332, which translates to the same NPV =114.18461651948999 on the official site (by adding the accrued interest). So far so good. Then I ask if the clean price is 101, what's the zspread: >>> new_clean_price = 101 >>> zspread = ql.BondFunctions.zSpread(fixed_rate_bond, new_clean_price, ts_yield, day_count, ql.Compounded, fixed_rate_bond.frequency(), settle_date) print(zspread) This shows the zspread=0.02592546532075354. Then I add this zspread on top of the original yield curve to obtain a new yield curve. My understanding is that by using this new yield curve to price the bond, I should recover the new_clean_price. But it does not: >>> spread1 = ql.SimpleQuote(zspread) >>> spread_handle1 = ql.QuoteHandle(spread1) >>> ts_spreaded1 = ql.ZeroSpreadedTermStructure(ts_handle, spread_handle1) >>> ql.BondFunctions.cleanPrice(fixed_rate_bond, ts_spreaded1, settle_date) This resulted clean price is 100.91139815763174, which is about 0.0886 different from the new_clean_price. I tried to increase the "accuracy" parameter in the ql.BondFunctions.zSpread, but doesn't seem to help. Does anyone know why? Did I misunderstood ZSpread? Or did I pass wrong parameters in the zSpread function call? Thanks. Jian |
|
From: Daniel L. <dan...@gm...> - 2020-11-22 12:07:17
|
Upon searching the Internet I found this spec. https://quantlib-python-docs.readthedocs.io/en/latest/instruments/forwards.html?highlight=forwardRate#ql.ForwardRateAgreement..forwardRate However this seems to calculate the Forward interest rate implied by FRA. This is not what I was looking for. I wanted to calculate the Forward price typically calculated by the formula Spot multiplied by Cost of carry (https://en.wikipedia.org/wiki/Forward_price) Any further pointer will be highly appreciated On Sun, 22 Nov 2020 at 16:45, Amine Ifri <ami...@gm...> wrote: > > Daniel, > > I believe Quantlib has class method called forwardRate(date t1, date t2) if my memory serves me well. > > > > Amine Ifri > > > On 22 Nov 2020, at 10:47, Daniel Lobo <dan...@gm...> wrote: > > > > Hi, > > > > I have below information - > > > > import QuantLib as ql > > > > today = ql.Date(7, ql.March, 2014) > > ql.Settings.instance().evaluationDate = today > > u = ql.SimpleQuote(100.0) > > r1 = ql.SimpleQuote(0.01) > > yield = ql.SimpleQuote(0.02) > > sigma = ql.SimpleQuote(0.20) > > riskFreeCurve = ql.FlatForward( > > 0, > > ql.TARGET(), > > ql.QuoteHandle(r1), > > ql.Actual360()) > > yieldCurve = ql.FlatForward( > > 0, > > ql.TARGET(), > > ql.QuoteHandle(yield), > > ql.Actual360()) > > > > Given this information, I want to calculate the Term structure of the > > Forward quotes for different dates in futures. > > > > Can you please help me if QuantLib has any method to perform the same? > > > > Many thanks for your time. > > > > > > _______________________________________________ > > QuantLib-users mailing list > > Qua...@li... > > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Amine I. <ami...@gm...> - 2020-11-22 11:15:32
|
Daniel, I believe Quantlib has class method called forwardRate(date t1, date t2) if my memory serves me well. Amine Ifri > On 22 Nov 2020, at 10:47, Daniel Lobo <dan...@gm...> wrote: > > Hi, > > I have below information - > > import QuantLib as ql > > today = ql.Date(7, ql.March, 2014) > ql.Settings.instance().evaluationDate = today > u = ql.SimpleQuote(100.0) > r1 = ql.SimpleQuote(0.01) > yield = ql.SimpleQuote(0.02) > sigma = ql.SimpleQuote(0.20) > riskFreeCurve = ql.FlatForward( > 0, > ql.TARGET(), > ql.QuoteHandle(r1), > ql.Actual360()) > yieldCurve = ql.FlatForward( > 0, > ql.TARGET(), > ql.QuoteHandle(yield), > ql.Actual360()) > > Given this information, I want to calculate the Term structure of the > Forward quotes for different dates in futures. > > Can you please help me if QuantLib has any method to perform the same? > > Many thanks for your time. > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Daniel L. <dan...@gm...> - 2020-11-22 10:46:39
|
Hi, I have below information - import QuantLib as ql today = ql.Date(7, ql.March, 2014) ql.Settings.instance().evaluationDate = today u = ql.SimpleQuote(100.0) r1 = ql.SimpleQuote(0.01) yield = ql.SimpleQuote(0.02) sigma = ql.SimpleQuote(0.20) riskFreeCurve = ql.FlatForward( 0, ql.TARGET(), ql.QuoteHandle(r1), ql.Actual360()) yieldCurve = ql.FlatForward( 0, ql.TARGET(), ql.QuoteHandle(yield), ql.Actual360()) Given this information, I want to calculate the Term structure of the Forward quotes for different dates in futures. Can you please help me if QuantLib has any method to perform the same? Many thanks for your time. |
|
From: Luigi B. <lui...@gm...> - 2020-11-20 15:07:18
|
Hello David,
if you can do so while keeping backward compatibility (e.g., by adding
new constructors or giving defaults to new parameters) I'd suggest you
modify the existing class.
Thanks,
Luigi
On Fri, Nov 20, 2020 at 2:44 PM <da...@el...> wrote:
> Hi everyone,
>
>
>
> I’ve made some mods for my own use to the ExponentialSplinesFitting class,
> and before I go ahead and submit a pull request, I’d appreciate some
> initial feedback.
>
> The form of the discount function for the exponential spline fit is: df(t)
> = sum( b(i) exp -i.kappa.t ) for i = 1 to N.
>
> Where b(i) and kappa are the variables used to fit the curve.
>
> The current implementation fixes N at 9 (so 9 x b(i) + 1 x kappa = 10
> parameters). If the discount factor is constrained to be 1 at time t=0
> (which is usually is) then one of the b(i)s is constrained, since at t=0,
> sum(b(i)) = 1, reducing the total number of independent parameters to 9. In
> the implementation b(1) is constrained.
>
>
>
> From my experience of using exponential spline fitting over the years, and
> from what I have read, there is no definitive argument for fixing N=9.
> Indeed the number chosen can depend on several considerations: the density
> of bonds across the curve; whether you want to fit the very short end etc.
> You also find that the value of kappa doesn’t make much difference to the
> quality of fit as long as it is in the right range. Other implementations
> fix kappa (it’s akin to the far-forward overnight rate, so something around
> 1% in the current environment), and then optimize over the b(i)s. If you
> extrapolate the spline beyond the last bond (which is probably not a great
> idea) then kappa does have an effect on the shape of that extrapolated part
> but I feel it is simply an artefact of the fitting.
>
>
>
> In my implementation, the number of parameters is a variable and hence a
> class member, and there is also the option to fix kappa and supply a
> non-zero value for that fix (kappa = 0 is a special case as it produces
> df(t) = 1 no matter how much the b(i)s are varied (in the constrained
> model) ).
>
> Initially I had derived my new class, unimaginatively named
> ExponentialSplinesFittingN from ExponentialSplinesFitting, but on
> reflection the inheritance is redundant as I am over-riding every method,
> so perhaps it should also derive directly from the abstract base
> FittedBondDiscountCurve::FittingMethod. I am open to suggestions for a
> decent name!
>
> I wrote it before I had read the QL “style guide” so will need to amend my
> implantation anyway: hence this is a good moment to hear any thoughts!
>
>
> Best wishes
>
> David Sansom
>
>
>
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: <da...@el...> - 2020-11-20 13:41:54
|
Hi everyone, I've made some mods for my own use to the ExponentialSplinesFitting class, and before I go ahead and submit a pull request, I'd appreciate some initial feedback. The form of the discount function for the exponential spline fit is: df(t) = sum( b(i) exp -i.kappa.t ) for i = 1 to N. Where b(i) and kappa are the variables used to fit the curve. The current implementation fixes N at 9 (so 9 x b(i) + 1 x kappa = 10 parameters). If the discount factor is constrained to be 1 at time t=0 (which is usually is) then one of the b(i)s is constrained, since at t=0, sum(b(i)) = 1, reducing the total number of independent parameters to 9. In the implementation b(1) is constrained. >From my experience of using exponential spline fitting over the years, and from what I have read, there is no definitive argument for fixing N=9. Indeed the number chosen can depend on several considerations: the density of bonds across the curve; whether you want to fit the very short end etc. You also find that the value of kappa doesn't make much difference to the quality of fit as long as it is in the right range. Other implementations fix kappa (it's akin to the far-forward overnight rate, so something around 1% in the current environment), and then optimize over the b(i)s. If you extrapolate the spline beyond the last bond (which is probably not a great idea) then kappa does have an effect on the shape of that extrapolated part but I feel it is simply an artefact of the fitting. In my implementation, the number of parameters is a variable and hence a class member, and there is also the option to fix kappa and supply a non-zero value for that fix (kappa = 0 is a special case as it produces df(t) = 1 no matter how much the b(i)s are varied (in the constrained model) ). Initially I had derived my new class, unimaginatively named ExponentialSplinesFittingN from ExponentialSplinesFitting, but on reflection the inheritance is redundant as I am over-riding every method, so perhaps it should also derive directly from the abstract base FittedBondDiscountCurve::FittingMethod. I am open to suggestions for a decent name! I wrote it before I had read the QL "style guide" so will need to amend my implantation anyway: hence this is a good moment to hear any thoughts! Best wishes David Sansom |
|
From: li c. <weg...@ho...> - 2020-11-20 06:14:57
|
So you may have a check about your PATH config, is c:\windows\system32 is in PATH? Below is my screenshot, all is ok: [cid:image003.jpg@01D6BF47.732C61C0] 发件人: Teddy O <tm...@ho...> 发送时间: 2020年11月19日 8:19 收件人: li cheng <weg...@ho...>; Luigi Ballabio <lui...@gm...> 抄送: qua...@li... 主题: Re: [Quantlib-users] DLL Load Failed yes, it installed _QuantLib.cp38-win_amd64.pyd this time instead of 37. I ran another dependency walker that was supposed to get rid of a bunch of false errors. I'm assuming the issue is this VCRUNTIME140_1.dll, but I also see I have it just below it in windows\system32. [cid:image002.png@01D6BF47.73211720] Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648694290%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Grn4yRTEjc0kHKHlPGsHr6SW1H1p1CXL8lIsHWhLHX8%3D&reserved=0> ________________________________ From: li cheng <weg...@ho...<mailto:weg...@ho...>> Sent: Wednesday, November 18, 2020 8:55 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>>; Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: 回复: [Quantlib-users] DLL Load Failed Could you have a try using Dependency Worker to see the dll linking chain about your *.pyd file. http://dependencywalker.com/<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdependencywalker.com%2F&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648694290%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0WYgmzhcM6zQpcq8NRwV0DopMZTPT%2B1wdKY6YbJDows%3D&reserved=0> The error of missing dlls may caused by missing of vc’s redistribution package. Regards, Cheng 发件人: Teddy O <tm...@ho...<mailto:tm...@ho...>> 发送时间: 2020年11月18日 7:46 收件人: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> 抄送: qua...@li...<mailto:qua...@li...> 主题: Re: [Quantlib-users] DLL Load Failed Still no luck. getting the same error when I uninstall and then reinstall using python -m pip install -U QuantLib and python -m pip install -U QuantLib-python Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648704283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=k6U3c%2FhFGA%2FbAg0fbPdSp3Gji61p1jrfPbeakcZfJQo%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 2:09 PM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled for Python 3.7. You probably have multiple versions of Python installed, and the version of pip you used to install QuantLib was the one for 3.7. Instead of calling pip directly (which might give you the wrong version for the Python you want to use), you can try something like python -m pip install -U QuantLib which will use the pip corresponding to the python you're running. Luigi On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: When I run it in the powershell it says 64bit. "Import Quantlib" also gives me the same error when I run it here as well. Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information. Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648704283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=k6U3c%2FhFGA%2FbAg0fbPdSp3Gji61p1jrfPbeakcZfJQo%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 8:09 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed From the file names and paths, it seems you have the 64-bit version of QuantLib installed but spyder is using 32-bit python. May you check that? Luigi On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: I installed quantlib using "pip install QuantLib" and now I'm getting the below error. I'm using windows 10 and Spyder IDE. I don't see any dll file called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . import _QuantLib ImportError: DLL load failed: The specified module could not be found. These are my path variables: C:\Conda\python38.zip C:\Conda\DLLs C:\Conda\lib C:\Conda C:\Conda\lib\site-packages C:\Conda\lib\site-packages\win32 C:\Conda\lib\site-packages\win32\lib C:\Conda\lib\site-packages\Pythonwin C:\Conda\lib\site-packages\IPython\extensions C:\Users\name t\.ipython Has anyone experienced a similar problem? Thanks Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648714277%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Q0w8gWmEh18W%2Bp0ExwTijrWu6togLBd2YmzMJ2wlGjw%3D&reserved=0> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fquantlib-users&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648714277%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=VtsqouqWV%2Bbt5vUzGoifWlwSeUdmUcFXoe5UuBub6N4%3D&reserved=0> |
|
From: Peter C. <pca...@gm...> - 2020-11-19 17:05:13
|
yes, I was only talking about the ql - class
On Thu, 19 Nov 2020 at 17:37, Eric Ehlers <eri...@re...> wrote:
>
> I would guess that Peter is thinking of (a)
> QuantLib/ql/patterns/observable.hpp, and that Philip is using (b)
> ObjectHandler/oh/observable.hpp. I probably copied (a) to (b) a long
> time ago and (a) might have been updated in the meantime.
>
> Regards,
> Eric
>
> On 11/18/20 9:32 PM, Peter Caspers wrote:
> > If we store a shared_ptr to ObservableSettings in Observable instead
> > of the reference, would that work? This would require an extension of
> > Singleton though.
> >
> > On Tue, 17 Nov 2020 at 13:54, SX L <han...@ho...> wrote:
> >> Calling dtor != deleted. As long as nobody is trying to access the deleted instances, it should be fine. I agree the fix is not an ideal solution.
> >>
> >> ________________________________
> >> From: Peter Caspers <pca...@gm...>
> >> Sent: Monday, November 16, 2020 1:37 AM
> >> To: SX L <han...@ho...>
> >> Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
> >> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >>
> >> That makes sense. But then, how does your proposed fix help in this
> >> situation? To me, it looks like the ObservableSettings instance might
> >> still get deleted before the observables?
> >>
> >> On Sun, 15 Nov 2020 at 16:30, SX L <han...@ho...> wrote:
> >>> My guess is that the shared_ptr of those non-static Observables are stored in another static variable such as OH::Repository. So it depends on which dtor between the two static variables will be called first.
> >>>
> >>> ________________________________
> >>> From: Peter Caspers <pca...@gm...>
> >>> Sent: Saturday, November 14, 2020 8:08 PM
> >>> To: SX L <han...@ho...>
> >>> Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
> >>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >>>
> >>> Hi Philip, I am just curious and maybe the question is naive, but if
> >>> the ObservableSettings instance is stored as a
> >>> shared_ptr<ObservableSettings> within a static map, how can that
> >>> instance be destroyed before any non-static Observable instance?
> >>> Thanks, Peter
> >>>
> >>> On Sat, 14 Nov 2020 at 09:27, SX L <han...@ho...> wrote:
> >>>> I don't have a github account yet, and I am an old fashion coder still using svn. However, the change is simple as below. If I were to go into multithread later, I would dump or re-design Singleton pattern, which is notorious for multithread.
> >>>>
> >>>> Index: ql/patterns/singleton.hpp
> >>>> ===================================================================
> >>>> --- ql/patterns/singleton.hpp (revision 130)
> >>>> +++ ql/patterns/singleton.hpp (working copy)
> >>>> @@ -160,7 +160,7 @@
> >>>> T& Singleton<T>::instance() {
> >>>>
> >>>> #if (QL_MANAGED == 0) && !defined(QL_SINGLETON_THREAD_SAFE_INIT)
> >>>> - static std::map<ThreadKey, ext::shared_ptr<T> > instances_;
> >>>> + static T instances_;
> >>>> #endif
> >>>>
> >>>> // thread safe double checked locking pattern with atomic memory calls
> >>>> @@ -185,9 +185,7 @@
> >>>> ThreadKey id = 0;
> >>>> #endif
> >>>>
> >>>> - ext::shared_ptr<T>& instance = instances_[id];
> >>>> - if (!instance)
> >>>> - instance = ext::shared_ptr<T>(new T);
> >>>> + T* instance = &instances_;
> >>>>
> >>>> #endif
> >>>>
> >>>> ________________________________
> >>>> From: Eric Ehlers <eri...@re...>
> >>>> Sent: Wednesday, November 11, 2020 4:35 AM
> >>>> To: SX L <han...@ho...>
> >>>> Cc: qua...@li... <qua...@li...>
> >>>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >>>>
> >>>>
> >>>> Hi Philip,
> >>>>
> >>>> Would you be willing to submit a pull request?
> >>>>
> >>>> Regards,
> >>>> Eric
> >>>>
> >>>> On 11/10/20 5:21 AM, SX L wrote:
> >>>>
> >>>> Hi Eric,
> >>>>
> >>>> Thanks for looking into this issue. Yes, I identified the issue in my windows x64 debug version. The issue could be hard to reproduce since my release version gives me normal exit code. It really depends on the sequence of calling dtors of those shared pointers at exit.
> >>>>
> >>>> So I would suggest moving away from shared pointers in Singletons. Create a singltonDestroyer or use static instances.
> >>>>
> >>>> Get Outlook for Android
> >>>>
> >>>> ________________________________
> >>>> From: Eric Ehlers <eri...@re...>
> >>>> Sent: Monday, November 9, 2020, 11:42 PM
> >>>> To: SX L
> >>>> Cc: qua...@li...
> >>>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >>>>
> >>>> Hi Philip,
> >>>>
> >>>> I tried unsuccessfully to recreate the error. You did not say which operating system you are using but you mention "debug version" which sounds like visual studio so I tested it on Windows - I'm using Visual Studio 2019 on 64-bit WIndows 10. I built it using "Debug (static runtime)" x64 and I ran ClientCppDemo and it behaves as I expected (no access violation). Anything else I can try to recreate the error?
> >>>>
> >>>> I have not examined the code but your remarks sound sensible to me. What resolution would you suggest?
> >>>>
> >>>> Regards,
> >>>> Eric
> >>>>
> >>>> On 10/7/20 6:43 AM, SX L wrote:
> >>>>
> >>>> I was trying the Quantlib Addin. The QLADemo exits abnormally in the debug version with an access violation exception. It turned out to be the case that ObervableSettings is deleted earlier than some observer and observables at exit. So in the dtor of the observer, ObservableSettings is called to check if update is deferred, hence causing the exception. I feel it's unsafe to use shared pointers inside a singleton. Any suggestion? Thanks.
> >>>>
> >>>> Regards,
> >>>>
> >>>> Philip
> >>>>
> >>>>
> >>>> Get Outlook for Android
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> QuantLib-users mailing list
> >>>> Qua...@li...
> >>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> QuantLib-users mailing list
> >>>> Qua...@li...
> >>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Eric E. <eri...@re...> - 2020-11-19 16:37:51
|
I would guess that Peter is thinking of (a)
QuantLib/ql/patterns/observable.hpp, and that Philip is using (b)
ObjectHandler/oh/observable.hpp. I probably copied (a) to (b) a long
time ago and (a) might have been updated in the meantime.
Regards,
Eric
On 11/18/20 9:32 PM, Peter Caspers wrote:
> If we store a shared_ptr to ObservableSettings in Observable instead
> of the reference, would that work? This would require an extension of
> Singleton though.
>
> On Tue, 17 Nov 2020 at 13:54, SX L <han...@ho...> wrote:
>> Calling dtor != deleted. As long as nobody is trying to access the deleted instances, it should be fine. I agree the fix is not an ideal solution.
>>
>> ________________________________
>> From: Peter Caspers <pca...@gm...>
>> Sent: Monday, November 16, 2020 1:37 AM
>> To: SX L <han...@ho...>
>> Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
>>
>> That makes sense. But then, how does your proposed fix help in this
>> situation? To me, it looks like the ObservableSettings instance might
>> still get deleted before the observables?
>>
>> On Sun, 15 Nov 2020 at 16:30, SX L <han...@ho...> wrote:
>>> My guess is that the shared_ptr of those non-static Observables are stored in another static variable such as OH::Repository. So it depends on which dtor between the two static variables will be called first.
>>>
>>> ________________________________
>>> From: Peter Caspers <pca...@gm...>
>>> Sent: Saturday, November 14, 2020 8:08 PM
>>> To: SX L <han...@ho...>
>>> Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
>>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
>>>
>>> Hi Philip, I am just curious and maybe the question is naive, but if
>>> the ObservableSettings instance is stored as a
>>> shared_ptr<ObservableSettings> within a static map, how can that
>>> instance be destroyed before any non-static Observable instance?
>>> Thanks, Peter
>>>
>>> On Sat, 14 Nov 2020 at 09:27, SX L <han...@ho...> wrote:
>>>> I don't have a github account yet, and I am an old fashion coder still using svn. However, the change is simple as below. If I were to go into multithread later, I would dump or re-design Singleton pattern, which is notorious for multithread.
>>>>
>>>> Index: ql/patterns/singleton.hpp
>>>> ===================================================================
>>>> --- ql/patterns/singleton.hpp (revision 130)
>>>> +++ ql/patterns/singleton.hpp (working copy)
>>>> @@ -160,7 +160,7 @@
>>>> T& Singleton<T>::instance() {
>>>>
>>>> #if (QL_MANAGED == 0) && !defined(QL_SINGLETON_THREAD_SAFE_INIT)
>>>> - static std::map<ThreadKey, ext::shared_ptr<T> > instances_;
>>>> + static T instances_;
>>>> #endif
>>>>
>>>> // thread safe double checked locking pattern with atomic memory calls
>>>> @@ -185,9 +185,7 @@
>>>> ThreadKey id = 0;
>>>> #endif
>>>>
>>>> - ext::shared_ptr<T>& instance = instances_[id];
>>>> - if (!instance)
>>>> - instance = ext::shared_ptr<T>(new T);
>>>> + T* instance = &instances_;
>>>>
>>>> #endif
>>>>
>>>> ________________________________
>>>> From: Eric Ehlers <eri...@re...>
>>>> Sent: Wednesday, November 11, 2020 4:35 AM
>>>> To: SX L <han...@ho...>
>>>> Cc: qua...@li... <qua...@li...>
>>>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
>>>>
>>>>
>>>> Hi Philip,
>>>>
>>>> Would you be willing to submit a pull request?
>>>>
>>>> Regards,
>>>> Eric
>>>>
>>>> On 11/10/20 5:21 AM, SX L wrote:
>>>>
>>>> Hi Eric,
>>>>
>>>> Thanks for looking into this issue. Yes, I identified the issue in my windows x64 debug version. The issue could be hard to reproduce since my release version gives me normal exit code. It really depends on the sequence of calling dtors of those shared pointers at exit.
>>>>
>>>> So I would suggest moving away from shared pointers in Singletons. Create a singltonDestroyer or use static instances.
>>>>
>>>> Get Outlook for Android
>>>>
>>>> ________________________________
>>>> From: Eric Ehlers <eri...@re...>
>>>> Sent: Monday, November 9, 2020, 11:42 PM
>>>> To: SX L
>>>> Cc: qua...@li...
>>>> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
>>>>
>>>> Hi Philip,
>>>>
>>>> I tried unsuccessfully to recreate the error. You did not say which operating system you are using but you mention "debug version" which sounds like visual studio so I tested it on Windows - I'm using Visual Studio 2019 on 64-bit WIndows 10. I built it using "Debug (static runtime)" x64 and I ran ClientCppDemo and it behaves as I expected (no access violation). Anything else I can try to recreate the error?
>>>>
>>>> I have not examined the code but your remarks sound sensible to me. What resolution would you suggest?
>>>>
>>>> Regards,
>>>> Eric
>>>>
>>>> On 10/7/20 6:43 AM, SX L wrote:
>>>>
>>>> I was trying the Quantlib Addin. The QLADemo exits abnormally in the debug version with an access violation exception. It turned out to be the case that ObervableSettings is deleted earlier than some observer and observables at exit. So in the dtor of the observer, ObservableSettings is called to check if update is deferred, hence causing the exception. I feel it's unsafe to use shared pointers inside a singleton. Any suggestion? Thanks.
>>>>
>>>> Regards,
>>>>
>>>> Philip
>>>>
>>>>
>>>> Get Outlook for Android
>>>>
>>>>
>>>> _______________________________________________
>>>> QuantLib-users mailing list
>>>> Qua...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>>
>>>>
>>>> _______________________________________________
>>>> QuantLib-users mailing list
>>>> Qua...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Teddy O <tm...@ho...> - 2020-11-19 00:19:40
|
yes, it installed _QuantLib.cp38-win_amd64.pyd this time instead of 37. I ran another dependency walker that was supposed to get rid of a bunch of false errors. I'm assuming the issue is this VCRUNTIME140_1.dll, but I also see I have it just below it in windows\system32. [cid:399e9869-74a4-4d75-a361-3b855e89f93d] Sent from Outlook<http://aka.ms/weboutlook> ________________________________ From: li cheng <weg...@ho...> Sent: Wednesday, November 18, 2020 8:55 AM To: Teddy O <tm...@ho...>; Luigi Ballabio <lui...@gm...> Cc: qua...@li... <qua...@li...> Subject: 回复: [Quantlib-users] DLL Load Failed Could you have a try using Dependency Worker to see the dll linking chain about your *.pyd file. http://dependencywalker.com/ The error of missing dlls may caused by missing of vc’s redistribution package. Regards, Cheng 发件人: Teddy O <tm...@ho...> 发送时间: 2020年11月18日 7:46 收件人: Luigi Ballabio <lui...@gm...> 抄送: qua...@li... 主题: Re: [Quantlib-users] DLL Load Failed Still no luck. getting the same error when I uninstall and then reinstall using python -m pip install -U QuantLib and python -m pip install -U QuantLib-python Sent from Outlook<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957828188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rRL2PGOp62%2BZcNLPb1culsCFBvN7pMcUUOyWFb37NJk%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 2:09 PM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled for Python 3.7. You probably have multiple versions of Python installed, and the version of pip you used to install QuantLib was the one for 3.7. Instead of calling pip directly (which might give you the wrong version for the Python you want to use), you can try something like python -m pip install -U QuantLib which will use the pip corresponding to the python you're running. Luigi On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: When I run it in the powershell it says 64bit. "Import Quantlib" also gives me the same error when I run it here as well. Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information. Sent from Outlook<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957848177%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=C879UDlLSWBbwADhGes0jgdSx8Z%2FxXZaUJGklYKNc%2BA%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 8:09 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed From the file names and paths, it seems you have the 64-bit version of QuantLib installed but spyder is using 32-bit python. May you check that? Luigi On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: I installed quantlib using "pip install QuantLib" and now I'm getting the below error. I'm using windows 10 and Spyder IDE. I don't see any dll file called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . import _QuantLib ImportError: DLL load failed: The specified module could not be found. These are my path variables: C:\Conda\python38.zip C:\Conda\DLLs C:\Conda\lib C:\Conda C:\Conda\lib\site-packages C:\Conda\lib\site-packages\win32 C:\Conda\lib\site-packages\win32\lib C:\Conda\lib\site-packages\Pythonwin C:\Conda\lib\site-packages\IPython\extensions C:\Users\name t\.ipython Has anyone experienced a similar problem? Thanks Sent from Outlook<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957858171%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=gm4rBJu8LZuINo5nbP08OMoUGYBihmYYAhso0FXMT8o%3D&reserved=0> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fquantlib-users&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957878161%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nZtz2k%2F7pad1Th9WdUNVoapJYSfU4EBmpTaZgGezNZo%3D&reserved=0> |
|
From: Peter C. <pca...@gm...> - 2020-11-18 20:32:42
|
If we store a shared_ptr to ObservableSettings in Observable instead
of the reference, would that work? This would require an extension of
Singleton though.
On Tue, 17 Nov 2020 at 13:54, SX L <han...@ho...> wrote:
>
> Calling dtor != deleted. As long as nobody is trying to access the deleted instances, it should be fine. I agree the fix is not an ideal solution.
>
> ________________________________
> From: Peter Caspers <pca...@gm...>
> Sent: Monday, November 16, 2020 1:37 AM
> To: SX L <han...@ho...>
> Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
>
> That makes sense. But then, how does your proposed fix help in this
> situation? To me, it looks like the ObservableSettings instance might
> still get deleted before the observables?
>
> On Sun, 15 Nov 2020 at 16:30, SX L <han...@ho...> wrote:
> >
> > My guess is that the shared_ptr of those non-static Observables are stored in another static variable such as OH::Repository. So it depends on which dtor between the two static variables will be called first.
> >
> > ________________________________
> > From: Peter Caspers <pca...@gm...>
> > Sent: Saturday, November 14, 2020 8:08 PM
> > To: SX L <han...@ho...>
> > Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
> > Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >
> > Hi Philip, I am just curious and maybe the question is naive, but if
> > the ObservableSettings instance is stored as a
> > shared_ptr<ObservableSettings> within a static map, how can that
> > instance be destroyed before any non-static Observable instance?
> > Thanks, Peter
> >
> > On Sat, 14 Nov 2020 at 09:27, SX L <han...@ho...> wrote:
> > >
> > > I don't have a github account yet, and I am an old fashion coder still using svn. However, the change is simple as below. If I were to go into multithread later, I would dump or re-design Singleton pattern, which is notorious for multithread.
> > >
> > > Index: ql/patterns/singleton.hpp
> > > ===================================================================
> > > --- ql/patterns/singleton.hpp (revision 130)
> > > +++ ql/patterns/singleton.hpp (working copy)
> > > @@ -160,7 +160,7 @@
> > > T& Singleton<T>::instance() {
> > >
> > > #if (QL_MANAGED == 0) && !defined(QL_SINGLETON_THREAD_SAFE_INIT)
> > > - static std::map<ThreadKey, ext::shared_ptr<T> > instances_;
> > > + static T instances_;
> > > #endif
> > >
> > > // thread safe double checked locking pattern with atomic memory calls
> > > @@ -185,9 +185,7 @@
> > > ThreadKey id = 0;
> > > #endif
> > >
> > > - ext::shared_ptr<T>& instance = instances_[id];
> > > - if (!instance)
> > > - instance = ext::shared_ptr<T>(new T);
> > > + T* instance = &instances_;
> > >
> > > #endif
> > >
> > > ________________________________
> > > From: Eric Ehlers <eri...@re...>
> > > Sent: Wednesday, November 11, 2020 4:35 AM
> > > To: SX L <han...@ho...>
> > > Cc: qua...@li... <qua...@li...>
> > > Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> > >
> > >
> > > Hi Philip,
> > >
> > > Would you be willing to submit a pull request?
> > >
> > > Regards,
> > > Eric
> > >
> > > On 11/10/20 5:21 AM, SX L wrote:
> > >
> > > Hi Eric,
> > >
> > > Thanks for looking into this issue. Yes, I identified the issue in my windows x64 debug version. The issue could be hard to reproduce since my release version gives me normal exit code. It really depends on the sequence of calling dtors of those shared pointers at exit.
> > >
> > > So I would suggest moving away from shared pointers in Singletons. Create a singltonDestroyer or use static instances.
> > >
> > > Get Outlook for Android
> > >
> > > ________________________________
> > > From: Eric Ehlers <eri...@re...>
> > > Sent: Monday, November 9, 2020, 11:42 PM
> > > To: SX L
> > > Cc: qua...@li...
> > > Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> > >
> > > Hi Philip,
> > >
> > > I tried unsuccessfully to recreate the error. You did not say which operating system you are using but you mention "debug version" which sounds like visual studio so I tested it on Windows - I'm using Visual Studio 2019 on 64-bit WIndows 10. I built it using "Debug (static runtime)" x64 and I ran ClientCppDemo and it behaves as I expected (no access violation). Anything else I can try to recreate the error?
> > >
> > > I have not examined the code but your remarks sound sensible to me. What resolution would you suggest?
> > >
> > > Regards,
> > > Eric
> > >
> > > On 10/7/20 6:43 AM, SX L wrote:
> > >
> > > I was trying the Quantlib Addin. The QLADemo exits abnormally in the debug version with an access violation exception. It turned out to be the case that ObervableSettings is deleted earlier than some observer and observables at exit. So in the dtor of the observer, ObservableSettings is called to check if update is deferred, hence causing the exception. I feel it's unsafe to use shared pointers inside a singleton. Any suggestion? Thanks.
> > >
> > > Regards,
> > >
> > > Philip
> > >
> > >
> > > Get Outlook for Android
> > >
> > >
> > > _______________________________________________
> > > QuantLib-users mailing list
> > > Qua...@li...
> > > https://lists.sourceforge.net/lists/listinfo/quantlib-users
> > >
> > >
> > > _______________________________________________
> > > QuantLib-users mailing list
> > > Qua...@li...
> > > https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: li c. <weg...@ho...> - 2020-11-18 08:55:50
|
Could you have a try using Dependency Worker to see the dll linking chain about your *.pyd file. http://dependencywalker.com/ The error of missing dlls may caused by missing of vc’s redistribution package. Regards, Cheng 发件人: Teddy O <tm...@ho...> 发送时间: 2020年11月18日 7:46 收件人: Luigi Ballabio <lui...@gm...> 抄送: qua...@li... 主题: Re: [Quantlib-users] DLL Load Failed Still no luck. getting the same error when I uninstall and then reinstall using python -m pip install -U QuantLib and python -m pip install -U QuantLib-python Sent from Outlook<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957828188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rRL2PGOp62%2BZcNLPb1culsCFBvN7pMcUUOyWFb37NJk%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 2:09 PM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled for Python 3.7. You probably have multiple versions of Python installed, and the version of pip you used to install QuantLib was the one for 3.7. Instead of calling pip directly (which might give you the wrong version for the Python you want to use), you can try something like python -m pip install -U QuantLib which will use the pip corresponding to the python you're running. Luigi On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: When I run it in the powershell it says 64bit. "Import Quantlib" also gives me the same error when I run it here as well. Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information. Sent from Outlook<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957848177%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=C879UDlLSWBbwADhGes0jgdSx8Z%2FxXZaUJGklYKNc%2BA%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 8:09 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed From the file names and paths, it seems you have the 64-bit version of QuantLib installed but spyder is using 32-bit python. May you check that? Luigi On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: I installed quantlib using "pip install QuantLib" and now I'm getting the below error. I'm using windows 10 and Spyder IDE. I don't see any dll file called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . import _QuantLib ImportError: DLL load failed: The specified module could not be found. These are my path variables: C:\Conda\python38.zip C:\Conda\DLLs C:\Conda\lib C:\Conda C:\Conda\lib\site-packages C:\Conda\lib\site-packages\win32 C:\Conda\lib\site-packages\win32\lib C:\Conda\lib\site-packages\Pythonwin C:\Conda\lib\site-packages\IPython\extensions C:\Users\name t\.ipython Has anyone experienced a similar problem? Thanks Sent from Outlook<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957858171%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=gm4rBJu8LZuINo5nbP08OMoUGYBihmYYAhso0FXMT8o%3D&reserved=0> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fquantlib-users&data=04%7C01%7C%7Cbcfc6690da464672e88308d88b533f43%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637412536957878161%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nZtz2k%2F7pad1Th9WdUNVoapJYSfU4EBmpTaZgGezNZo%3D&reserved=0> |
|
From: Luigi B. <lui...@gm...> - 2020-11-18 08:07:30
|
Do you at least get a different pyd? On Wed, Nov 18, 2020 at 12:45 AM Teddy O <tm...@ho...> wrote: > Still no luck. getting the same error when I uninstall and then reinstall > using python -m pip install -U QuantLib and python -m pip install -U > QuantLib-python > > Sent from Outlook <http://aka.ms/weboutlook> > ------------------------------ > *From:* Luigi Ballabio <lui...@gm...> > *Sent:* Tuesday, November 17, 2020 2:09 PM > *To:* Teddy O <tm...@ho...> > *Cc:* qua...@li... < > qua...@li...> > *Subject:* Re: [Quantlib-users] DLL Load Failed > > Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled > for Python 3.7. You probably have multiple versions of Python installed, > and the version of pip you used to install QuantLib was the one for 3.7. > > Instead of calling pip directly (which might give you the wrong version > for the Python you want to use), you can try something like > > python -m pip install -U QuantLib > > which will use the pip corresponding to the python you're running. > > Luigi > > > > > > On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...> wrote: > > When I run it in the powershell it says 64bit. "Import Quantlib" also > gives me the same error when I run it here as well. > > Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] > :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" > for more information. > > Sent from Outlook <http://aka.ms/weboutlook> > ------------------------------ > *From:* Luigi Ballabio <lui...@gm...> > *Sent:* Tuesday, November 17, 2020 8:09 AM > *To:* Teddy O <tm...@ho...> > *Cc:* qua...@li... < > qua...@li...> > *Subject:* Re: [Quantlib-users] DLL Load Failed > > From the file names and paths, it seems you have the 64-bit version of > QuantLib installed but spyder is using 32-bit python. May you check that? > > Luigi > > > On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...> wrote: > > I installed quantlib using "pip install QuantLib" and now I'm getting the > below error. I'm using windows 10 and Spyder IDE. I don't see any dll file > called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. > > > File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . > import _QuantLib > > > ImportError: DLL load failed: The specified module could not be found. > > > These are my path variables: > > > C:\Conda\python38.zip > C:\Conda\DLLs > C:\Conda\lib > C:\Conda > > C:\Conda\lib\site-packages > C:\Conda\lib\site-packages\win32 > C:\Conda\lib\site-packages\win32\lib > C:\Conda\lib\site-packages\Pythonwin > C:\Conda\lib\site-packages\IPython\extensions > C:\Users\name t\.ipython > > Has anyone experienced a similar problem? > > Thanks > > > Sent from Outlook <http://aka.ms/weboutlook> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > |
|
From: Teddy O <tm...@ho...> - 2020-11-17 23:45:54
|
Still no luck. getting the same error when I uninstall and then reinstall using python -m pip install -U QuantLib and python -m pip install -U QuantLib-python Sent from Outlook<http://aka.ms/weboutlook> ________________________________ From: Luigi Ballabio <lui...@gm...> Sent: Tuesday, November 17, 2020 2:09 PM To: Teddy O <tm...@ho...> Cc: qua...@li... <qua...@li...> Subject: Re: [Quantlib-users] DLL Load Failed Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled for Python 3.7. You probably have multiple versions of Python installed, and the version of pip you used to install QuantLib was the one for 3.7. Instead of calling pip directly (which might give you the wrong version for the Python you want to use), you can try something like python -m pip install -U QuantLib which will use the pip corresponding to the python you're running. Luigi On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: When I run it in the powershell it says 64bit. "Import Quantlib" also gives me the same error when I run it here as well. Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information. Sent from Outlook<http://aka.ms/weboutlook> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 8:09 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed >From the file names and paths, it seems you have the 64-bit version of QuantLib installed but spyder is using 32-bit python. May you check that? Luigi On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: I installed quantlib using "pip install QuantLib" and now I'm getting the below error. I'm using windows 10 and Spyder IDE. I don't see any dll file called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . import _QuantLib ImportError: DLL load failed: The specified module could not be found. These are my path variables: C:\Conda\python38.zip C:\Conda\DLLs C:\Conda\lib C:\Conda C:\Conda\lib\site-packages C:\Conda\lib\site-packages\win32 C:\Conda\lib\site-packages\win32\lib C:\Conda\lib\site-packages\Pythonwin C:\Conda\lib\site-packages\IPython\extensions C:\Users\name t\.ipython Has anyone experienced a similar problem? Thanks Sent from Outlook<http://aka.ms/weboutlook> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Eric E. <eri...@re...> - 2020-11-17 15:48:50
|
Currently the projects supports bindings to Excel and C++ (PoC). At various points in the past the project has supported bindings to C, Calc (LibreOffice), and maybe one or two other platforms that I can't remember. In order to resurrect the C bindings you would need to get the relevant gensrc module working again, and the QuantLibAddin C project. This would not be a trivial task, you would end up reverse engineering things until you knew them as well as if you had written them yourself. There may be vestiges of the old C project files still kicking around in the QuantLibAddin repo. It might (or might not) be helpful for you to go back and download the very old version of QuantLibAddin that supported C. In your case, rather than generating a raw C API, you would probably want to generate one specifically tailored for Python bindings. Regards, Eric On 11/17/20 1:59 PM, SX L wrote: > Yes. I essentially turned Python to VBA. I tried to load the XLL with > CDLL, no luck. > > As for the C bindings, I want to turn it on. Could you please > elaborate? XLL bindings are actually C ones. C++ bindings won't work > with ctypes. > > ------------------------------------------------------------------------ > *From:* Eric Ehlers <eri...@re...> > *Sent:* Monday, November 16, 2020 6:34 PM > *To:* SX L <han...@ho...> > *Cc:* qua...@li... > <qua...@li...> > *Subject:* Re: [Quantlib-users] How to expose QuantLibAddin to Python? > > > I managed to load QuantLibXLL into Python with win32com. > > > That's an interesting exercise to attempt. An XLL is a DLL so I guess > there is nothing to prevent you from loading it as such into Python. > But the XLL's entry points are designed to be called from Excel so it > would be a hassle at best to use from Python. > > > > However, what about Linux side? SWIG? Can gensrc generate C interfaces similar to XL ones? > > > The idea behind gensrc is that you could autogenerate source code for > the QuantLibAddin interface for any platform, Excel is just one > example. There is a build for C++ but it only supports a subset of the > functionality that QuantLibXL supports. So the C++ build is more of a > proof of concept. It works on Windows and Linux and is documented here: > > > https://www.quantlib.org/quantlibaddin/build_cpp.html > > > Once upon a time, we implemented a gensrc module to export the > QuantLibAddin interface to C, and that facilitated deployment to > platforms such as Python that talk C. However that build has not been > maintained for a long time and it would not be a trivial task to > resurrect it. > > > Regards, > Eric > > > On 11/15/20 5:13 PM, SX L wrote: >> I managed to load QuantLibXLL into Python with win32com. However, >> what about Linux side? SWIG? Can gensrc generate C interfaces similar >> to XL ones? >> >> >> >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... <mailto:Qua...@li...> >> https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Luigi B. <lui...@gm...> - 2020-11-17 14:09:43
|
Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled for
Python 3.7. You probably have multiple versions of Python installed, and
the version of pip you used to install QuantLib was the one for 3.7.
Instead of calling pip directly (which might give you the wrong version for
the Python you want to use), you can try something like
python -m pip install -U QuantLib
which will use the pip corresponding to the python you're running.
Luigi
On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...> wrote:
> When I run it in the powershell it says 64bit. "Import Quantlib" also
> gives me the same error when I run it here as well.
>
> Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
> :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license"
> for more information.
>
> Sent from Outlook <http://aka.ms/weboutlook>
> ------------------------------
> *From:* Luigi Ballabio <lui...@gm...>
> *Sent:* Tuesday, November 17, 2020 8:09 AM
> *To:* Teddy O <tm...@ho...>
> *Cc:* qua...@li... <
> qua...@li...>
> *Subject:* Re: [Quantlib-users] DLL Load Failed
>
> From the file names and paths, it seems you have the 64-bit version of
> QuantLib installed but spyder is using 32-bit python. May you check that?
>
> Luigi
>
>
> On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...> wrote:
>
> I installed quantlib using "pip install QuantLib" and now I'm getting the
> below error. I'm using windows 10 and Spyder IDE. I don't see any dll file
> called _QuantLib, only _QuantLib.cp37-win_amd64.pyd.
>
>
> File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from .
> import _QuantLib
>
>
> ImportError: DLL load failed: The specified module could not be found.
>
>
> These are my path variables:
>
>
> C:\Conda\python38.zip
> C:\Conda\DLLs
> C:\Conda\lib
> C:\Conda
>
> C:\Conda\lib\site-packages
> C:\Conda\lib\site-packages\win32
> C:\Conda\lib\site-packages\win32\lib
> C:\Conda\lib\site-packages\Pythonwin
> C:\Conda\lib\site-packages\IPython\extensions
> C:\Users\name t\.ipython
>
> Has anyone experienced a similar problem?
>
> Thanks
>
>
> Sent from Outlook <http://aka.ms/weboutlook>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
|
|
From: <da...@el...> - 2020-11-17 14:08:50
|
SX_L, I really do think you will entering a world of pain for minimal gain. XLL's are designed to be called from Excel. Yes, the XLL exposes a C-style interface (with no C++ name mangling etc), but the functions expect nearly all parameters to be passed via OPER structures, so getting Python to generate these would be the first hurdle. Second, the OPER structure also provides both Excel and the called XLL with the information on which of them is responsible for the memory allocation and tidy up for any parameters (so you could suffer memory leaks, access violations as the variable has been destroyed unexpectedly, or both). Third, implicit in every call is information (bespoke to Excel) about how the function has been called (in essence like the VBA Application object) so that the XLL can call-back into Excel if needed. And finally, the XLL interface does not currently provide all the objects and functions within QuantLib, and while the Python interface (AFAIK) also doesn't expose every piece of QL functionality, it gives you more than the Excel wrapper, and most importantly Python is being regularly updated. Best DS From: SX L <han...@ho...> Sent: Tuesday, 17 November 2020 13:00 To: Eric Ehlers <eri...@re...> Cc: qua...@li... Subject: Re: [Quantlib-users] How to expose QuantLibAddin to Python? Yes. I essentially turned Python to VBA. I tried to load the XLL with CDLL, no luck. As for the C bindings, I want to turn it on. Could you please elaborate? XLL bindings are actually C ones. C++ bindings won't work with ctypes. _____ From: Eric Ehlers <eri...@re... <mailto:eri...@re...> > Sent: Monday, November 16, 2020 6:34 PM To: SX L <han...@ho... <mailto:han...@ho...> > Cc: qua...@li... <mailto:qua...@li...> <qua...@li... <mailto:qua...@li...> > Subject: Re: [Quantlib-users] How to expose QuantLibAddin to Python? > I managed to load QuantLibXLL into Python with win32com. That's an interesting exercise to attempt. An XLL is a DLL so I guess there is nothing to prevent you from loading it as such into Python. But the XLL's entry points are designed to be called from Excel so it would be a hassle at best to use from Python. > However, what about Linux side? SWIG? Can gensrc generate C interfaces similar to XL ones? The idea behind gensrc is that you could autogenerate source code for the QuantLibAddin interface for any platform, Excel is just one example. There is a build for C++ but it only supports a subset of the functionality that QuantLibXL supports. So the C++ build is more of a proof of concept. It works on Windows and Linux and is documented here: https://www.quantlib.org/quantlibaddin/build_cpp.html Once upon a time, we implemented a gensrc module to export the QuantLibAddin interface to C, and that facilitated deployment to platforms such as Python that talk C. However that build has not been maintained for a long time and it would not be a trivial task to resurrect it. Regards, Eric On 11/15/20 5:13 PM, SX L wrote: I managed to load QuantLibXLL into Python with win32com. However, what about Linux side? SWIG? Can gensrc generate C interfaces similar to XL ones? _______________________________________________ QuantLib-users mailing list Qua...@li... <mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Teddy O <tm...@ho...> - 2020-11-17 14:03:49
|
When I run it in the powershell it says 64bit. "Import Quantlib" also gives me the same error when I run it here as well. Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information. Sent from Outlook<http://aka.ms/weboutlook> ________________________________ From: Luigi Ballabio <lui...@gm...> Sent: Tuesday, November 17, 2020 8:09 AM To: Teddy O <tm...@ho...> Cc: qua...@li... <qua...@li...> Subject: Re: [Quantlib-users] DLL Load Failed >From the file names and paths, it seems you have the 64-bit version of QuantLib installed but spyder is using 32-bit python. May you check that? Luigi On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: I installed quantlib using "pip install QuantLib" and now I'm getting the below error. I'm using windows 10 and Spyder IDE. I don't see any dll file called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . import _QuantLib ImportError: DLL load failed: The specified module could not be found. These are my path variables: C:\Conda\python38.zip C:\Conda\DLLs C:\Conda\lib C:\Conda C:\Conda\lib\site-packages C:\Conda\lib\site-packages\win32 C:\Conda\lib\site-packages\win32\lib C:\Conda\lib\site-packages\Pythonwin C:\Conda\lib\site-packages\IPython\extensions C:\Users\name t\.ipython Has anyone experienced a similar problem? Thanks Sent from Outlook<http://aka.ms/weboutlook> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: SX L <han...@ho...> - 2020-11-17 13:00:41
|
Yes. I essentially turned Python to VBA. I tried to load the XLL with CDLL, no luck. As for the C bindings, I want to turn it on. Could you please elaborate? XLL bindings are actually C ones. C++ bindings won't work with ctypes. ________________________________ From: Eric Ehlers <eri...@re...> Sent: Monday, November 16, 2020 6:34 PM To: SX L <han...@ho...> Cc: qua...@li... <qua...@li...> Subject: Re: [Quantlib-users] How to expose QuantLibAddin to Python? > I managed to load QuantLibXLL into Python with win32com. That's an interesting exercise to attempt. An XLL is a DLL so I guess there is nothing to prevent you from loading it as such into Python. But the XLL's entry points are designed to be called from Excel so it would be a hassle at best to use from Python. > However, what about Linux side? SWIG? Can gensrc generate C interfaces similar to XL ones? The idea behind gensrc is that you could autogenerate source code for the QuantLibAddin interface for any platform, Excel is just one example. There is a build for C++ but it only supports a subset of the functionality that QuantLibXL supports. So the C++ build is more of a proof of concept. It works on Windows and Linux and is documented here: https://www.quantlib.org/quantlibaddin/build_cpp.html Once upon a time, we implemented a gensrc module to export the QuantLibAddin interface to C, and that facilitated deployment to platforms such as Python that talk C. However that build has not been maintained for a long time and it would not be a trivial task to resurrect it. Regards, Eric On 11/15/20 5:13 PM, SX L wrote: I managed to load QuantLibXLL into Python with win32com. However, what about Linux side? SWIG? Can gensrc generate C interfaces similar to XL ones? _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: SX L <han...@ho...> - 2020-11-17 12:55:05
|
Calling dtor != deleted. As long as nobody is trying to access the deleted instances, it should be fine. I agree the fix is not an ideal solution.
________________________________
From: Peter Caspers <pca...@gm...>
Sent: Monday, November 16, 2020 1:37 AM
To: SX L <han...@ho...>
Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
That makes sense. But then, how does your proposed fix help in this
situation? To me, it looks like the ObservableSettings instance might
still get deleted before the observables?
On Sun, 15 Nov 2020 at 16:30, SX L <han...@ho...> wrote:
>
> My guess is that the shared_ptr of those non-static Observables are stored in another static variable such as OH::Repository. So it depends on which dtor between the two static variables will be called first.
>
> ________________________________
> From: Peter Caspers <pca...@gm...>
> Sent: Saturday, November 14, 2020 8:08 PM
> To: SX L <han...@ho...>
> Cc: Eric Ehlers <eri...@re...>; qua...@li... <qua...@li...>
> Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
>
> Hi Philip, I am just curious and maybe the question is naive, but if
> the ObservableSettings instance is stored as a
> shared_ptr<ObservableSettings> within a static map, how can that
> instance be destroyed before any non-static Observable instance?
> Thanks, Peter
>
> On Sat, 14 Nov 2020 at 09:27, SX L <han...@ho...> wrote:
> >
> > I don't have a github account yet, and I am an old fashion coder still using svn. However, the change is simple as below. If I were to go into multithread later, I would dump or re-design Singleton pattern, which is notorious for multithread.
> >
> > Index: ql/patterns/singleton.hpp
> > ===================================================================
> > --- ql/patterns/singleton.hpp (revision 130)
> > +++ ql/patterns/singleton.hpp (working copy)
> > @@ -160,7 +160,7 @@
> > T& Singleton<T>::instance() {
> >
> > #if (QL_MANAGED == 0) && !defined(QL_SINGLETON_THREAD_SAFE_INIT)
> > - static std::map<ThreadKey, ext::shared_ptr<T> > instances_;
> > + static T instances_;
> > #endif
> >
> > // thread safe double checked locking pattern with atomic memory calls
> > @@ -185,9 +185,7 @@
> > ThreadKey id = 0;
> > #endif
> >
> > - ext::shared_ptr<T>& instance = instances_[id];
> > - if (!instance)
> > - instance = ext::shared_ptr<T>(new T);
> > + T* instance = &instances_;
> >
> > #endif
> >
> > ________________________________
> > From: Eric Ehlers <eri...@re...>
> > Sent: Wednesday, November 11, 2020 4:35 AM
> > To: SX L <han...@ho...>
> > Cc: qua...@li... <qua...@li...>
> > Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >
> >
> > Hi Philip,
> >
> > Would you be willing to submit a pull request?
> >
> > Regards,
> > Eric
> >
> > On 11/10/20 5:21 AM, SX L wrote:
> >
> > Hi Eric,
> >
> > Thanks for looking into this issue. Yes, I identified the issue in my windows x64 debug version. The issue could be hard to reproduce since my release version gives me normal exit code. It really depends on the sequence of calling dtors of those shared pointers at exit.
> >
> > So I would suggest moving away from shared pointers in Singletons. Create a singltonDestroyer or use static instances.
> >
> > Get Outlook for Android
> >
> > ________________________________
> > From: Eric Ehlers <eri...@re...>
> > Sent: Monday, November 9, 2020, 11:42 PM
> > To: SX L
> > Cc: qua...@li...
> > Subject: Re: [Quantlib-users] ObservableSettings is deleted early than Observables.
> >
> > Hi Philip,
> >
> > I tried unsuccessfully to recreate the error. You did not say which operating system you are using but you mention "debug version" which sounds like visual studio so I tested it on Windows - I'm using Visual Studio 2019 on 64-bit WIndows 10. I built it using "Debug (static runtime)" x64 and I ran ClientCppDemo and it behaves as I expected (no access violation). Anything else I can try to recreate the error?
> >
> > I have not examined the code but your remarks sound sensible to me. What resolution would you suggest?
> >
> > Regards,
> > Eric
> >
> > On 10/7/20 6:43 AM, SX L wrote:
> >
> > I was trying the Quantlib Addin. The QLADemo exits abnormally in the debug version with an access violation exception. It turned out to be the case that ObervableSettings is deleted earlier than some observer and observables at exit. So in the dtor of the observer, ObservableSettings is called to check if update is deferred, hence causing the exception. I feel it's unsafe to use shared pointers inside a singleton. Any suggestion? Thanks.
> >
> > Regards,
> >
> > Philip
> >
> >
> > Get Outlook for Android
> >
> >
> > _______________________________________________
> > QuantLib-users mailing list
> > Qua...@li...
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
> >
> >
> > _______________________________________________
> > QuantLib-users mailing list
> > Qua...@li...
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
|