Exemplo n.º 1
0
 public static Currencies getCurrency(Irate ir)
 {
     switch (ir)
     {
         case Irate.Euribor:
             return Currencies.EUR;
         case Irate.Hibor:
             return Currencies.HKD;
         case Irate.LiborCHF:
             return Currencies.CHF;
         case Irate.LiborGBP:
             return Currencies.GBP;
         case Irate.LiborUSD:
             return Currencies.USD;
         default:
             return Currencies.EUR;
     }
 }
Exemplo n.º 2
0
 public static KeyValuePair<string, string> getCodeQuandl(Irate interestRate)
 {
     switch (interestRate)
     {
         case Irate.LiborUSD:
             return new KeyValuePair<string, string>("FRED", "USD3MTD156N");
         case Irate.Hibor:
             return new KeyValuePair<string, string>("WSJ", "HIB1M"); 
         case Irate.LiborGBP:
             return new KeyValuePair<string, string>("FRED", "GBP3MTD156N");
         case Irate.LiborCHF:
             return new KeyValuePair<string, string>("FRED", "CHF3MTD156N");
         case Irate.Euribor:
             return new KeyValuePair<string, string>("FRED", "EUR3MTD156N");
         default:
             return new KeyValuePair<string, string>();
     }
 }
Exemplo n.º 3
0
 public static DateTime GetLastData(Irate interestRate)
 {
     using (var context = new qpcptfaw())
     {
         //double l;
         int id = getInterestRateIdFromIrate(interestRate);
         var rates = from p in context.Rates //est ce bien forexRate
                     where p.RateDBId == id
                     select p;
         if (rates.Count() == 0) return DBInitialisation.DBstart;
         return rates.OrderByDescending(x => x.date).First().date;
     }
 }
Exemplo n.º 4
0
 public static int getInterestRateIdFromIrate(Irate ir)
 {
     int id = -1;
     using (var context = new qpcptfaw())
     {
         var a = from irate in context.InteresRatesType
                 where irate.rate == ir
                 select irate;
         if (a.Count() == 0) throw new ArgumentException("symbol does not exist in the database", ir.ToString());
         if (a.Count() > 1) throw new ArgumentException("duplicate symbol in the database", ir.ToString());
         id = a.First().RateDBId;
         return id;
     }
 }
Exemplo n.º 5
0
 public static bool InterestRateContains(Irate ir)
 {
     using (var context = new qpcptfaw())
     {
         var interestRate = from f in context.InteresRatesType
                          where f.rate == ir
                          select f;
         if (interestRate.Count() == 1) return true;
         if (interestRate.Count() == 0) return false;
         throw new Exception("The data should be unique. Problem in the database.");
     }
 }