public CovContToRiskResult CalcContToRisk(SysTimeSeries exposures_, DateTime asOf_) { // extract exposure on date var expOnDate = exposures_.Data.GetValues(asOf_); return CalcContToRisk(exposures_.Data.ColumnHeadings, expOnDate); }
private static void unpackSeries(SysTimeSeries series_) { var dates = series_.Data.Keys.ToArray(); for (int i = 0; i < series_.Data.ColumnHeadings.Length; ++i) { var sec = series_.Data.ColumnHeadings[i]; var s = series_.Data.GetColumnValues(i); if (s != null && s.Length > 0 && s[s.Length - 1].IsZero()) { m_list[sec] = new DatedDataCollectionGen<double>(dates.Slice(0, dates.Length - 1), s.Slice(0, s.Length - 1)); } else { m_list[sec] = new DatedDataCollectionGen<double>(dates, s); } } }
public bool LooselyEquals(SysTimeSeries other_) { bool different = other_ == null; different = different || (HasData != other_.HasData); different = different || (Data.ArrayLength != other_.Data.ArrayLength); different = different || (Data.Keys.Count != other_.Data.Keys.Count); different = different || (Data.LastKey() != other_.Data.LastKey()); different = different || (!Data.LastValues().SequenceEqual(other_.Data.LastValues())); return !different; }
//public double[] CalcLatestContToRisk(SysTimeSeries exposures_) //{ // if (exposures_ == null || exposures_.Data == null || exposures_.Data.Keys.Count == 0) return null; // return CalcContToRisk(exposures_, exposures_.Data.Keys[exposures_.Data.Keys.Count - 1]); //} //public double[] CalcContToRisk(SysTimeSeries exposures_, DateTime asOf_) //{ // // extract exposure on date // var expOnDate = exposures_.Data.GetValues(asOf_); // return CalcContToRisk(exposures_.Data.ColumnHeadings, expOnDate); //} //public double[] CalcContToRisk(string[] exposureNames_, double[] exposureValues_) //{ // // get indexes for instruments in covariance // var indexes = new int[exposureNames_.Length]; // for (int i = 0; i < indexes.Length; ++i) // if (exposureValues_[i].IsZero()) // indexes[i] = -1; // else // indexes[i] = FindIndexOfInstrument(exposureNames_[i]); // // translate up the exposures into same dimensions as covariance // var exposuresInCovarianceDimensions = new double[Keys.Count]; // for (int i = 0; i < indexes.Length; ++i) // { // if (indexes[i] == -1) continue; // exposuresInCovarianceDimensions[indexes[i]] = exposureValues_[i]; // } // // calculate contributions to risk // var contToRisk = GetContToVar(exposuresInCovarianceDimensions); // // translate back into porfolio dimensions // var riskInPortfolioDimensions = new double[exposureValues_.Length]; // for (int i = 0; i < riskInPortfolioDimensions.Length; ++i) // { // if (indexes[i] == -1) continue; // riskInPortfolioDimensions[i] = contToRisk[indexes[i]]; // } // return riskInPortfolioDimensions; //} public CovContToRiskResult CalcLatestContToRisk(SysTimeSeries exposures_) { if (exposures_ == null || exposures_.Data == null || exposures_.Data.Keys.Count == 0) return null; return CalcContToRisk(exposures_, exposures_.Data.Keys[exposures_.Data.Keys.Count - 1]); }
public double CalcVol(SysTimeSeries exposures_, DateTime asOf_) { // extract exposure on date var expOnDate = exposures_.Data.GetValues(asOf_); return CalcVol(exposures_.Data.ColumnHeadings, expOnDate); }
public double CalcLatestVol(SysTimeSeries exposures_) { if (exposures_ == null || exposures_.Data == null || exposures_.Data.Keys.Count == 0) return double.NaN; return CalcVol(exposures_, exposures_.Data.Keys[exposures_.Data.Keys.Count - 1]); }