Exemple #1
0
        public static double[] computeShareReturns(System.Collections.Generic.List<PricingLibrary.Utilities.MarketDataFeed.DataFeed> dataFeedList, DateTime date, String id, int windowLength)
        {
            double[] shareReturns = new double[windowLength - 1];

            int beginDateIndex = dataFeedList.FindIndex(dataFeed => dataFeed.Date == date) - windowLength;

            decimal previousPrice = dataFeedList[beginDateIndex].PriceList[id];
            for (int index = 0; index < windowLength - 1; ++index)
            {
                decimal currentPrice = dataFeedList[beginDateIndex + 1 + index].PriceList[id];
                shareReturns[index] = Math.Log((double)(currentPrice / previousPrice));
                previousPrice = currentPrice;
            }
            return shareReturns;
        }
		public void FindIndex_PredicateNull ()
		{
			IEnumerable<int> s = new[]{1};
			Func<int, bool>  f = null;
			s.FindIndex (f);
		}
Exemple #3
0
 // Renvoie les prix spots des actifs à une date donnée
 public static double[] shareSpots(System.Collections.Generic.List<PricingLibrary.Utilities.MarketDataFeed.DataFeed> dataFeedList, System.DateTime date)
 {
     if (!dataFeedList.Any(dataFeed => dataFeed.Date == date))
     {
         throw new ParameterException("Not a business date.");
     }
     int index = dataFeedList.FindIndex(dataFeed => dataFeed.Date == date);
     double[] spots = new double[dataFeedList[index].PriceList.Count];
     int i = 0;
     foreach (KeyValuePair<string, decimal> spot in dataFeedList[index].PriceList)
     {
         spots[i] = (double)spot.Value;
         ++i;
     }
     return spots;
 }