"invalid vector<T> subscript" error

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

"invalid vector<T> subscript" error

Nicholas Manganaro-2

I am using QuantLibXL 1.3.0 in a fixed rate bond analysis.

 

I have found that if I have an EffectiveDate in the same month as the TerminationDate in the Schedule for a fixed rate bond, set up as below for example, I get what looks like a valid schedule ID. However, I get a an error that says: “qlFixedRate – invalid vector<T> subscript” for the qlFixedRateBond for which I have created the schedule, which seems to be generated from “vector” in “C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\”.

 

If I use the “False” setting for the EndOfMonth value for the FixedRateBond, no error is thrown. Please note, I am looking at Treasuries, so I think the “True” setting is accurate.

 

I tried moving both the EffectiveDate and TerminationDate a year later, so the termination date would not fall on a weekend. In that case, the error is still thrown if the EOM setting is True and the EffectiveDate and TerminationDate are in the same month.

 

Please let me know what about the EndOfMonth setting would lead to the error, and if the error is what you would expect for the security logically, not programmatically.

 

Naively, it seems that representing a principal payment and a coupon payment within a month from the effective date should not be as complicated as many of the other wonders in QuantLib.

Thanks,

Nick

 

FixedRateBond

#NUM!

Error

qlFixedRateBond - invalid vector<T> subscript

ObjectID

912827E81v

Description

FixedRateBondID

Currency

USD

SettlementDays

1

FaceAmount

100

ScheduleID

ScheduleID#0046

Coupons

7.2500%

DayCounter

Actual/Actual (ISMA)

PaymentBDC

Unadjusted

Redemption

100

IssueDate

9/3/1991

PaymentCalendar

UnitedStates::GovernmentBond

Permanent

FALSE

Trigger

 

Schedule

ScheduleID#0046

Error

 

ObjectID

ScheduleID

EffectiveDate

8/22/1996

TerminationDate

8/31/1996

Tenor

6M

Calendar

UnitedStates::GovernmentBond

Convention

Unadjusted

TermDateConv

Unadjusted

GenRule

Backward

EndOfMonth

TRUE

FirstDate

 

NextToLastDate

 

Permanent

FALSE

Trigger

 

 


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: "invalid vector<T> subscript" error

Luigi Ballabio
Hi Nicholas,
    it's a bug in the schedule generation. With the parameters you specified, the library generates a Schedule with just one date (the termination date). With EOM = False, the schedule is correct and contains both effective and termination date.  It looks like the start date is adjusted to the end of the month (which shouldn't happen, the way I understand it) and then removed since it equals the termination date. We'll have to fix it.

Thanks for the heads-up,
    Luigi

P.S. Note to self, or to whoever tackles this: here are a few test cases.

correct:
In [2]: s = Schedule(Date(22,8,1996), Date(31,8,1996), Period(6, Months),
   ...:              UnitedStates(UnitedStates.GovernmentBond),
   ...:              Unadjusted, Unadjusted,
   ...:              DateGeneration.Backward, False)

In [3]: list(s)
Out[3]: [Date(22,8,1996), Date(31,8,1996)]

wrong (just one date):
In [4]: s = Schedule(Date(22,8,1996), Date(31,8,1996), Period(6, Months),
   ...:              UnitedStates(UnitedStates.GovernmentBond),
   ...:              Unadjusted, Unadjusted,
   ...:              DateGeneration.Backward, True)

In [5]: list(s)
Out[5]: [Date(31,8,1996)]

correct:
In [6]: s = Schedule(Date(22,8,1995), Date(31,8,1996), Period(6, Months),
   ...:              UnitedStates(UnitedStates.GovernmentBond),
   ...:              Unadjusted, Unadjusted,
   ...:              DateGeneration.Backward, False)

In [7]: list(s)
Out[7]: [Date(22,8,1995), Date(31,8,1995), Date(29,2,1996), Date(31,8,1996)]

wrong (first two dates are the same):
In [8]: s = Schedule(Date(22,8,1995), Date(31,8,1996), Period(6, Months),
             UnitedStates(UnitedStates.GovernmentBond),
             Unadjusted, Unadjusted,
             DateGeneration.Backward, True)

In [9]: list(s)
Out[9]: [Date(31,8,1995), Date(31,8,1995), Date(29,2,1996), Date(31,8,1996)]







On Wed, Feb 5, 2014 at 4:36 AM, Nicholas Manganaro <[hidden email]> wrote:

I am using QuantLibXL 1.3.0 in a fixed rate bond analysis.

 

I have found that if I have an EffectiveDate in the same month as the TerminationDate in the Schedule for a fixed rate bond, set up as below for example, I get what looks like a valid schedule ID. However, I get a an error that says: “qlFixedRate – invalid vector<T> subscript” for the qlFixedRateBond for which I have created the schedule, which seems to be generated from “vector” in “C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\”.

 

If I use the “False” setting for the EndOfMonth value for the FixedRateBond, no error is thrown. Please note, I am looking at Treasuries, so I think the “True” setting is accurate.

 

I tried moving both the EffectiveDate and TerminationDate a year later, so the termination date would not fall on a weekend. In that case, the error is still thrown if the EOM setting is True and the EffectiveDate and TerminationDate are in the same month.

 

Please let me know what about the EndOfMonth setting would lead to the error, and if the error is what you would expect for the security logically, not programmatically.

 

Naively, it seems that representing a principal payment and a coupon payment within a month from the effective date should not be as complicated as many of the other wonders in QuantLib.

Thanks,

Nick

 

FixedRateBond

#NUM!

Error

qlFixedRateBond - invalid vector<T> subscript

ObjectID

912827E81v

Description

FixedRateBondID

Currency

USD

SettlementDays

1

FaceAmount

100

ScheduleID

ScheduleID#0046

Coupons

7.2500%

DayCounter

Actual/Actual (ISMA)

PaymentBDC

Unadjusted

Redemption

100

IssueDate

9/3/1991

PaymentCalendar

UnitedStates::GovernmentBond

Permanent

FALSE

Trigger

 

Schedule

ScheduleID#0046

Error

 

ObjectID

ScheduleID

EffectiveDate

8/22/1996

TerminationDate

8/31/1996

Tenor

6M

Calendar

UnitedStates::GovernmentBond

Convention

Unadjusted

TermDateConv

Unadjusted

GenRule

Backward

EndOfMonth

TRUE

FirstDate

 

NextToLastDate

 

Permanent

FALSE

Trigger

 

 


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: "invalid vector<T> subscript" error

Nicholas Manganaro-2

I am sure I could learn something by taking a look at this. Please advise on where I would find the code that actually builds the schedule, given parameters passed.

Might it be the “MakeSchedule::operator” in C:\. . .\QuantLib\ql\time\schedule.cpp ?

Nick

 

From: Luigi Ballabio [mailto:[hidden email]]
Sent: Wednesday, February 19, 2014 9:17 AM
To: [hidden email]
Cc: QuantLib users
Subject: Re: [Quantlib-users] "invalid vector<T> subscript" error

 

Hi Nicholas,

    it's a bug in the schedule generation. With the parameters you specified, the library generates a Schedule with just one date (the termination date). With EOM = False, the schedule is correct and contains both effective and termination date.  It looks like the start date is adjusted to the end of the month (which shouldn't happen, the way I understand it) and then removed since it equals the termination date. We'll have to fix it.

 

Thanks for the heads-up,

    Luigi

 

P.S. Note to self, or to whoever tackles this: here are a few test cases.

 

correct:

In [2]: s = Schedule(Date(22,8,1996), Date(31,8,1996), Period(6, Months),

   ...:              UnitedStates(UnitedStates.GovernmentBond),

   ...:              Unadjusted, Unadjusted,

   ...:              DateGeneration.Backward, False)

 

In [3]: list(s)

Out[3]: [Date(22,8,1996), Date(31,8,1996)]

 

wrong (just one date):

In [4]: s = Schedule(Date(22,8,1996), Date(31,8,1996), Period(6, Months),

   ...:              UnitedStates(UnitedStates.GovernmentBond),

   ...:              Unadjusted, Unadjusted,

   ...:              DateGeneration.Backward, True)

 

In [5]: list(s)

Out[5]: [Date(31,8,1996)]

 

correct:

In [6]: s = Schedule(Date(22,8,1995), Date(31,8,1996), Period(6, Months),

   ...:              UnitedStates(UnitedStates.GovernmentBond),

   ...:              Unadjusted, Unadjusted,

   ...:              DateGeneration.Backward, False)

 

In [7]: list(s)

Out[7]: [Date(22,8,1995), Date(31,8,1995), Date(29,2,1996), Date(31,8,1996)]

 

wrong (first two dates are the same):

In [8]: s = Schedule(Date(22,8,1995), Date(31,8,1996), Period(6, Months),

             UnitedStates(UnitedStates.GovernmentBond),

             Unadjusted, Unadjusted,

             DateGeneration.Backward, True)

 

In [9]: list(s)

Out[9]: [Date(31,8,1995), Date(31,8,1995), Date(29,2,1996), Date(31,8,1996)]

 

 

 

 

 

 

On Wed, Feb 5, 2014 at 4:36 AM, Nicholas Manganaro <[hidden email]> wrote:

I am using QuantLibXL 1.3.0 in a fixed rate bond analysis.

 

I have found that if I have an EffectiveDate in the same month as the TerminationDate in the Schedule for a fixed rate bond, set up as below for example, I get what looks like a valid schedule ID. However, I get a an error that says: “qlFixedRate – invalid vector<T> subscript” for the qlFixedRateBond for which I have created the schedule, which seems to be generated from “vector” in “C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\”.

 

If I use the “False” setting for the EndOfMonth value for the FixedRateBond, no error is thrown. Please note, I am looking at Treasuries, so I think the “True” setting is accurate.

 

I tried moving both the EffectiveDate and TerminationDate a year later, so the termination date would not fall on a weekend. In that case, the error is still thrown if the EOM setting is True and the EffectiveDate and TerminationDate are in the same month.

 

Please let me know what about the EndOfMonth setting would lead to the error, and if the error is what you would expect for the security logically, not programmatically.

 

Naively, it seems that representing a principal payment and a coupon payment within a month from the effective date should not be as complicated as many of the other wonders in QuantLib.

Thanks,

Nick

 

FixedRateBond

#NUM!

Error

qlFixedRateBond - invalid vector<T> subscript

ObjectID

912827E81v

Description

FixedRateBondID

Currency

USD

SettlementDays

1

FaceAmount

100

ScheduleID

ScheduleID#0046

Coupons

7.2500%

DayCounter

Actual/Actual (ISMA)

PaymentBDC

Unadjusted

Redemption

100

IssueDate

9/3/1991

PaymentCalendar

UnitedStates::GovernmentBond

Permanent

FALSE

Trigger

 

Schedule

ScheduleID#0046

Error

 

ObjectID

ScheduleID

EffectiveDate

8/22/1996

TerminationDate

8/31/1996

Tenor

6M

Calendar

UnitedStates::GovernmentBond

Convention

Unadjusted

TermDateConv

Unadjusted

GenRule

Backward

EndOfMonth

TRUE

FirstDate

 

NextToLastDate

 

Permanent

FALSE

Trigger

 

 


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



 

--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: "invalid vector<T> subscript" error

Luigi Ballabio

The file is the right one, but the code is in the constructor of the Schedule class.

Luigi

On Feb 20, 2014 6:59 PM, "Nicholas Manganaro" <[hidden email]> wrote:

I am sure I could learn something by taking a look at this. Please advise on where I would find the code that actually builds the schedule, given parameters passed.

Might it be the “MakeSchedule::operator” in C:\. . .\QuantLib\ql\time\schedule.cpp ?

Nick

 

From: Luigi Ballabio [mailto:[hidden email]]
Sent: Wednesday, February 19, 2014 9:17 AM
To: [hidden email]
Cc: QuantLib users
Subject: Re: [Quantlib-users] "invalid vector<T> subscript" error

 

Hi Nicholas,

    it's a bug in the schedule generation. With the parameters you specified, the library generates a Schedule with just one date (the termination date). With EOM = False, the schedule is correct and contains both effective and termination date.  It looks like the start date is adjusted to the end of the month (which shouldn't happen, the way I understand it) and then removed since it equals the termination date. We'll have to fix it.

 

Thanks for the heads-up,

    Luigi

 

P.S. Note to self, or to whoever tackles this: here are a few test cases.

 

correct:

In [2]: s = Schedule(Date(22,8,1996), Date(31,8,1996), Period(6, Months),

   ...:              UnitedStates(UnitedStates.GovernmentBond),

   ...:              Unadjusted, Unadjusted,

   ...:              DateGeneration.Backward, False)

 

In [3]: list(s)

Out[3]: [Date(22,8,1996), Date(31,8,1996)]

 

wrong (just one date):

In [4]: s = Schedule(Date(22,8,1996), Date(31,8,1996), Period(6, Months),

   ...:              UnitedStates(UnitedStates.GovernmentBond),

   ...:              Unadjusted, Unadjusted,

   ...:              DateGeneration.Backward, True)

 

In [5]: list(s)

Out[5]: [Date(31,8,1996)]

 

correct:

In [6]: s = Schedule(Date(22,8,1995), Date(31,8,1996), Period(6, Months),

   ...:              UnitedStates(UnitedStates.GovernmentBond),

   ...:              Unadjusted, Unadjusted,

   ...:              DateGeneration.Backward, False)

 

In [7]: list(s)

Out[7]: [Date(22,8,1995), Date(31,8,1995), Date(29,2,1996), Date(31,8,1996)]

 

wrong (first two dates are the same):

In [8]: s = Schedule(Date(22,8,1995), Date(31,8,1996), Period(6, Months),

             UnitedStates(UnitedStates.GovernmentBond),

             Unadjusted, Unadjusted,

             DateGeneration.Backward, True)

 

In [9]: list(s)

Out[9]: [Date(31,8,1995), Date(31,8,1995), Date(29,2,1996), Date(31,8,1996)]

 

 

 

 

 

 

On Wed, Feb 5, 2014 at 4:36 AM, Nicholas Manganaro <[hidden email]> wrote:

I am using QuantLibXL 1.3.0 in a fixed rate bond analysis.

 

I have found that if I have an EffectiveDate in the same month as the TerminationDate in the Schedule for a fixed rate bond, set up as below for example, I get what looks like a valid schedule ID. However, I get a an error that says: “qlFixedRate – invalid vector<T> subscript” for the qlFixedRateBond for which I have created the schedule, which seems to be generated from “vector” in “C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\”.

 

If I use the “False” setting for the EndOfMonth value for the FixedRateBond, no error is thrown. Please note, I am looking at Treasuries, so I think the “True” setting is accurate.

 

I tried moving both the EffectiveDate and TerminationDate a year later, so the termination date would not fall on a weekend. In that case, the error is still thrown if the EOM setting is True and the EffectiveDate and TerminationDate are in the same month.

 

Please let me know what about the EndOfMonth setting would lead to the error, and if the error is what you would expect for the security logically, not programmatically.

 

Naively, it seems that representing a principal payment and a coupon payment within a month from the effective date should not be as complicated as many of the other wonders in QuantLib.

Thanks,

Nick

 

FixedRateBond

#NUM!

Error

qlFixedRateBond - invalid vector<T> subscript

ObjectID

912827E81v

Description

FixedRateBondID

Currency

USD

SettlementDays

1

FaceAmount

100

ScheduleID

ScheduleID#0046

Coupons

7.2500%

DayCounter

Actual/Actual (ISMA)

PaymentBDC

Unadjusted

Redemption

100

IssueDate

9/3/1991

PaymentCalendar

UnitedStates::GovernmentBond

Permanent

FALSE

Trigger

 

Schedule

ScheduleID#0046

Error

 

ObjectID

ScheduleID

EffectiveDate

8/22/1996

TerminationDate

8/31/1996

Tenor

6M

Calendar

UnitedStates::GovernmentBond

Convention

Unadjusted

TermDateConv

Unadjusted

GenRule

Backward

EndOfMonth

TRUE

FirstDate

 

NextToLastDate

 

Permanent

FALSE

Trigger

 

 


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



 

--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users