Changeset 227
- Timestamp:
- 08/03/08 20:09:17 (4 months ago)
- Files:
-
- trunk/QLNet/QLNet/Indexes/Indexmanager.cs (modified) (3 diffs)
- trunk/QLNet/QLNet/Instruments/Bonds/FloatingRateBond.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/QLNet/QLNet/Indexes/Indexmanager.cs
r203 r227 34 34 //! returns whether historical fixings were stored for the index 35 35 public bool hasHistory(string name) { 36 return data_.ContainsKey(name) ;36 return data_.ContainsKey(name) && data_[name].value().Count > 0; 37 37 } 38 38 39 39 //! returns the (possibly empty) history of the index fixings 40 40 public ObservableValue<TimeSeries<double>> getHistory(string name) { 41 if (!hasHistory(name)) 42 data_.Add(name, new ObservableValue<TimeSeries<double>>()); 41 checkExists(name); 43 42 return data_[name]; 44 43 } … … 46 45 //! stores the historical fixings of the index 47 46 public void setHistory(string name, ObservableValue<TimeSeries<double>> history) { 48 if (!hasHistory(name)) 49 data_.Add(name, null); 47 checkExists(name); 50 48 data_[name].Assign(history); 51 49 } 52 50 53 //! observer notifying of changes in the index fixings 54 public ObservableValue<TimeSeries<double>> notifier(string name) { 55 if (!hasHistory(name)) 56 data_.Add(name, new ObservableValue<TimeSeries<double>>()); 57 return data_[name]; 58 } 51 //! observer notifying of changes in the index fixings; in .NET it has the same logic as getHistory 52 public ObservableValue<TimeSeries<double>> notifier(string name) { return getHistory(name); } 59 53 60 54 //! returns all names of the indexes for which fixings were stored … … 76 70 clearHistory(s); 77 71 } 72 73 // checks whether index exists and adds it otherwise; for interal use only 74 private void checkExists(string name) { 75 if (!data_.ContainsKey(name)) 76 data_.Add(name, new ObservableValue<TimeSeries<double>>()); 77 } 78 78 } 79 79 } trunk/QLNet/QLNet/Instruments/Bonds/FloatingRateBond.cs
r225 r227 26 26 //! \test calculations are tested by checking results against cached values. 27 27 public class FloatingRateBond : Bond { 28 public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter) 28 public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, 29 DayCounter paymentDayCounter) 29 30 : this(settlementDays, faceAmount, schedule, index, paymentDayCounter, BusinessDayConvention.Following, 30 0, new List<double>() { 1 }, new List<double>() { 1}, new List<double>(), new List<double>(),31 0, new List<double>() { 1 }, new List<double>() { 0 }, new List<double>(), new List<double>(), 31 32 false, 100, null) { } 33 public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, 34 DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, int fixingDays, 35 List<double> gearings, List<double> spreads) 36 : this(settlementDays, faceAmount, schedule, index, paymentDayCounter, BusinessDayConvention.Following, 37 fixingDays, gearings, spreads, new List<double>(), new List<double>(), false, 100, null) { } 32 38 public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter, 33 39 BusinessDayConvention paymentConvention, int fixingDays, List<double> gearings, List<double> spreads,