Exemplo n.º 1
0
        /// <inheritdoc />
        public override void PreCloneInitialize(PriceFactorList factors, BaseTimeGrid baseTimes, RequiredResults requiredResults)
        {
            base.PreCloneInitialize(factors, baseTimes, requiredResults);

            fItems.PreCloneInitialize(factors, baseTimes, requiredResults);

            int fixedCount = fFixedCashflowList.Count();
            int floatCount = fFloatCashflowList.Count();

            fDates = new DateList();

            // Get a list of all the relevant dates for the deal.
            for (int i = 0; i < fixedCount; i++)
            {
                var fixedDate = fFixedCashflowList[i].Payment_Date;
                fDates.Add(fixedDate);
            }

            for (int i = 0; i < floatCount; i++)
            {
                var payDate   = fFloatCashflowList[i].Payment_Date;
                var startDate = fFloatCashflowList[i].Resets[0].Rate_Start_Date;

                if (!fDates.Contains(payDate))
                {
                    fDates.Add(payDate);
                }

                if (!fDates.Contains(startDate))
                {
                    fDates.Add(startDate);
                }
            }

            int count = fDates.Count;

            fFixedCouponWeight = new double[count];
            fFixedCouponRate   = new double[count];

            // Calucate the static parts of the coefficients
            foreach (var cf in fFixedCashflowList)
            {
                int idx = fDates.IndexOf(cf.Payment_Date);
                fFixedCouponWeight[idx] += cf.Accrual_Year_Fraction * cf.Notional;
                fFixedCouponRate[idx]    = cf.Rate;
            }

            fFloatingCouponWeight = new double[count];

            foreach (var cf in fFloatCashflowList)
            {
                int    idx = fDates.IndexOf(cf.Payment_Date);
                double rateYearFraction  = cf.Resets[0].Rate_Year_Fraction;
                double yearFractionRatio = (rateYearFraction < CalcUtils.TINY) ? 1.0 : cf.Accrual_Year_Fraction / rateYearFraction;
                fFloatingCouponWeight[idx] += cf.Notional * yearFractionRatio;
            }
        }
Exemplo n.º 2
0
        private void addNewSlide()
        {
            var index = DateListCarousel.Position;
            if (index == DateList.Count() - 1)
            {
                DateList.Add(new DateItem
                {
                    Date = DateList[index].Date.AddDays(1),
                    Text = WicketHelper.ConvertDate(DateList[index].Date.AddDays(1)),
                    MatchList = WicketHelper.GetMatchList(DateList[index].Date.AddDays(1)),
                    Loading = false,
                });
            }
            else if (DateListCarousel.Position == 0)
            {
                DateList.Insert(0, new DateItem
                {
                    Date = DateList[index].Date.AddDays(-1),
                    Text = WicketHelper.ConvertDate(DateList[index].Date.AddDays(-1)),
                    MatchList = WicketHelper.GetMatchList(DateList[index].Date.AddDays(-1)),
                    Loading = false,
                });
            }

        }
Exemplo n.º 3
0
        public void WriteIndexing(int index, object _value)
        {
            switch (index)
            {
            case 0:
                ProductId = int.Parse(_value.ToString());
                break;

            case 1:
                ASIN = _value.ToString();
                break;

            case 2:
                DateList.Add(new DateTime());
                DateList[DateList.Count - 1] = (DateTime)_value;
                break;

            case 3:
                Status.Add("");
                Status[Status.Count - 1] = _value.ToString();
                break;

            case 4:
                Notes.Add("");
                Notes[Notes.Count - 1] = _value.ToString();
                break;
            }
        }
Exemplo n.º 4
0
        // adds appointment
        internal void AddAppointment(Appointment appointment)
        {
            DateTime start = appointment.Start.Date;
            DateTime end   = (appointment.End == start) ? start.AddMinutes(1) : appointment.End;

            while (start < end)
            {
                if (this.Contains(start))
                {
                    this[start].AddAppointment(appointment);
                }
                if (appointment.RecurrenceState != RecurrenceStateEnum.Removed)
                {
                    _boldedDates.Add(start);
                }
                start = start.AddDays(1);
            }
        }
Exemplo n.º 5
0
 public MainViewModel(string phone)
 {
     or.HistoryInitiator(phone);
     foreach (Item date in or.Dates)
     {
         hvm = new HistoryViewModel(date);
         DateList.Add(hvm);
     }
 }
Exemplo n.º 6
0
        private void SplitDataIntoDateAndTime(List <string> receiveDataList)
        {
            try
            {
                for (var i = 1; i < receiveDataList.Count - 1; i++)
                {
                    var dateTime = receiveDataList[i].Split(',');

                    DateList.Add(dateTime[0]);
                    TimeList.Add(dateTime[1]);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e + "Date Cannot be split into Date and Time");
                throw;
            }
        }
Exemplo n.º 7
0
 private void addNextSlide()
 {
     int index;
     if (DateListCarousel.Position == DateList.Count() - 1)
     {
         index = DateList.Count() - 1;
         DateList.Add(new DateItem
         {
             Date = DateList[index].Date.AddDays(1),
             Text = WicketHelper.ConvertDate(DateList[index].Date.AddDays(1)),
             MatchList = WicketHelper.GetMatchList(DateList[index].Date.AddDays(1)),
         });
         DateListCarousel.Position = index + 1;
     }
     else
     {
         index = DateListCarousel.Position + 1;
         DateListCarousel.Position = DateListCarousel.Position + 1;
     }
     DateLabel.Text = WicketHelper.ConvertDate(DateList[index].Date);
 }
Exemplo n.º 8
0
 protected void createDateListandSumsList(List <StampsRecord> inList)
 {
     for (int i = 0; i < inList.Count; i++)
     {
         StampsRecord workingRecord = inList.ElementAt(i);
         DateTime     date          = workingRecord.Date;
         if (workingRecord.User != "eBay Amazon" &&
             workingRecord.User != "JBMorris master account" &&
             workingRecord.User != "Kickstarter 2")
         {
             if (SumsList.ContainsKey(date))
             {
                 SumsList[date] += workingRecord.Cost;
             }
             else
             {
                 SumsList.Add(date, workingRecord.Cost);
                 DateList.Add(date);
             }
         }
     }
 }
        public Tuple <MemberList, DateList, DateList> content()
        {
            MemberList importedMember  = new MemberList();
            DateList   importedExam    = new DateList();
            DateList   importedSeminar = new DateList();

            string           sql     = "select rowid, firstname, lastname, strftime('%d.%m.%Y ', datetime(birthday, 'unixepoch')) as birthday,  strftime('%d.%m.%Y ', datetime(accession, 'unixepoch')) as accession, active, groupid, email, adress from members order by active desc, groupid asc, lastname asc, firstname asc;";
            SQLiteCommand    command = new SQLiteCommand(sql, DatabaseConnection.instance);
            SQLiteDataReader reader  = command.ExecuteReader();
            Member           member;

            while (reader.Read())
            {
                int      id        = Convert.ToInt32(reader["rowid"]);
                string   firstName = Convert.ToString(reader["firstname"]);
                string   lastName  = Convert.ToString(reader["lastname"]);
                DateTime?birthday  = null;
                if (reader["birthday"] != DBNull.Value)
                {
                    birthday = Convert.ToDateTime(reader["birthday"]);
                }
                DateTime?accession = null;
                if (reader["accession"] != DBNull.Value)
                {
                    accession = Convert.ToDateTime(reader["accession"]);
                }
                bool active = true;
                if (reader["active"] != DBNull.Value)
                {
                    active = Convert.ToBoolean(reader["active"]);
                }
                int    group  = Convert.ToInt32(reader["groupid"]);
                string email  = Convert.ToString(reader["email"]);
                string adress = Convert.ToString(reader["adress"]);
                member = new Member {
                    firstName = firstName, lastName = lastName, birthday = birthday, accession = accession, active = active, group = group, email = email, adress = adress
                };
                member.setID(id);
                importedMember.Add(member);
            }

            sql     = "select rowid, strftime('%d.%m.%Y ', datetime(date, 'unixepoch')) as date from exam order by datetime(date, 'unixepoch') asc;";
            command = new SQLiteCommand(sql, DatabaseConnection.instance);
            reader  = command.ExecuteReader();
            DateItem exam;

            while (reader.Read())
            {
                int id = Convert.ToInt32(reader["rowid"]);

                DateTime?date = null;
                if (reader["date"] != DBNull.Value)
                {
                    date = Convert.ToDateTime(reader["date"]);
                }
                exam = new DateItem(id, date);
                importedExam.Add(exam);
            }

            sql     = "select rowid, strftime('%d.%m.%Y ', datetime(date, 'unixepoch')) as date, description from seminar order by datetime(date, 'unixepoch') asc;";
            command = new SQLiteCommand(sql, DatabaseConnection.instance);
            reader  = command.ExecuteReader();
            DateItem seminar;

            while (reader.Read())
            {
                int id = Convert.ToInt32(reader["rowid"]);

                DateTime?date = null;
                if (reader["date"] != DBNull.Value)
                {
                    date = Convert.ToDateTime(reader["date"]);
                }
                string description = Convert.ToString(reader["description"]);
                seminar = new DateItem(id, date, description);
                importedSeminar.Add(seminar);
            }

            Tuple <MemberList, DateList, DateList> imported = new Tuple <MemberList, DateList, DateList>(importedMember, importedExam, importedSeminar);

            return(imported);
        }
        private static void ExtractNERTags(CoreDocument coredoc, Lucene.Net.Documents.Document document)
        {
            //I have no clue as to why NER-tagged messages are stored like that. I guess there is some deep idea behind copying the same info over and over again (or, most likely, this is because some documents have more than one sentence. even tho its stil really stupid)
            if (coredoc != null)
            {
                List nerList = coredoc.entityMentions();
                if (nerList.size() > 0)
                {
                    for (int j = 0; j < nerList.size(); j++)
                    {
                        CoreEntityMention em = (CoreEntityMention)nerList.get(j);
                        //Does this need to be a switch case?
                        if (em.entityType() == "DATE")
                        {
                            var datekey = document.GetField("id").GetInt32Value().Value;
                            if (!DateList.ContainsKey(datekey))
                            {
                                DateList.Add(datekey, em.text());
                            }
                            else
                            {
                                DateList.TryUpdate(datekey, DateList[datekey] + ", " + em.text());
                            }
                        }
                        if (em.entityType() == "TIME")
                        {
                            var timekey = document.GetField("id").GetInt32Value().Value;
                            if (!TimeList.ContainsKey(timekey))
                            {
                                TimeList.Add(timekey, em.text());
                            }
                            else
                            {
                                TimeList.TryUpdate(timekey, TimeList[timekey] + ", " + em.text());
                            }
                        }

                        if (em.entityType() == "LOCATION")
                        {
                            var lockey = document.GetField("id").GetInt32Value().Value;
                            if (!LocList.ContainsKey(lockey))
                            {
                                LocList.Add(lockey, em.text());
                            }
                            else
                            {
                                LocList.TryUpdate(lockey, LocList[lockey] + ", " + em.text());
                            }
                        }
                        if (em.entityType() == "ORGANIZATION")
                        {
                            var orgkey = document.GetField("id").GetInt32Value().Value;
                            if (!OrgList.ContainsKey(orgkey))
                            {
                                OrgList.Add(orgkey, em.text());
                            }
                            else
                            {
                                OrgList.TryUpdate(orgkey, OrgList[orgkey] + ", " + em.text());
                            }
                        }

                        if (em.entityType() == "URL")
                        {
                            var urlkey = document.GetField("id").GetInt32Value().Value;
                            if (!URLList.ContainsKey(urlkey))
                            {
                                URLList.Add(urlkey, em.text());
                            }
                            else
                            {
                                URLList.TryUpdate(urlkey, OrgList[urlkey] + ", " + em.text());
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Prepare for valuation anything that is not dependent upon the scenario.
        /// </summary>
        public override void PreCloneInitialize(PriceFactorList factors, BaseTimeGrid baseTimes, RequiredResults requiredResults)
        {
            base.PreCloneInitialize(factors, baseTimes, requiredResults);

            CallableBondForward deal = (CallableBondForward)Deal;

            double           firstCallDate   = deal.First_Call_Date;
            double           lastCallDate    = deal.Last_Call_Date;
            double           baseDate        = factors.BaseDate;
            double           issueDate       = deal.Issue_Date;
            double           settlementDate  = deal.Settlement_Date;
            double           priceDate       = Math.Max(baseDate, settlementDate + 1.0); // bond cashflows before priceDate do not contribute to bond price
            double           maturityDate    = deal.Bond_Maturity_Date;
            double           couponInterval  = deal.Coupon_Interval;
            double           notional        = deal.Notional;
            IHolidayCalendar holidayCalendar = deal.GetHolidayCalendar();

            DateGenerationParams dateGenerationParams = new DateGenerationParams
            {
                EffectiveDate         = issueDate,
                MaturityDate          = maturityDate,
                AccrualDayCount       = deal.Accrual_Day_Count,
                FirstCouponDate       = deal.First_Coupon_Date,
                PenultimateCouponDate = deal.Penultimate_Coupon_Date,
                Amortisation          = deal.Amortisation,
                CouponPeriod          = couponInterval,
                Principal             = notional,
                PrincipalExchange     = PrincipalExchange.Start_Maturity,
                AccrualCalendar       = holidayCalendar
            };

            CashflowListDetail detail = CashflowGeneration.GenerateCashflowListDetail(dateGenerationParams);

            // Collect reset dates as we loop.
            var resetDates = new DateList(detail.Coupon_Details.Count);

            // Create cashflow list
            fCashflowList             = new CFFixedInterestList();
            fCashflowList.Compounding = YesNo.No;

            foreach (CouponDetail couponDetail in detail.Coupon_Details)
            {
                if (couponDetail.Payment_Date < priceDate)
                {
                    continue;
                }

                foreach (AccrualDetail accrualDetail in couponDetail.Accrual_Details)
                {
                    resetDates.Add(accrualDetail.Accrual_Start_Date);

                    if (couponDetail.Payment_Date < priceDate)
                    {
                        continue;
                    }

                    var cashflow = new CFFixedInterest
                    {
                        Payment_Date          = couponDetail.Payment_Date,
                        Notional              = accrualDetail.Notional,
                        Accrual_Start_Date    = accrualDetail.Accrual_Start_Date,
                        Accrual_End_Date      = accrualDetail.Accrual_End_Date,
                        Accrual_Year_Fraction = accrualDetail.Accrual_Year_Fraction,
                        Rate = deal.Coupon_Rate * Percentage.PercentagePoint,
                        Accrual_Day_Count = deal.Accrual_Day_Count,
                        Discounted        = YesNo.No
                    };

                    fCashflowList.Items.Add(cashflow);
                }
            }

            IRBaseDealSkin.ApplyRateSchedule(fCashflowList.Items, deal.Coupon_Rate_Schedule, Percentage.PercentagePoint, holidayCalendar, DateAdjustmentMethod.Modified_Following);

            // Calculate fixed interest cashflows.
            fCashflowList.CalculateInterest(baseDate);

            fFixedCashflowList = PrincipalCashflows(priceDate, issueDate, maturityDate, PrincipalExchange.Start_Maturity, notional, deal.Amortisation, 1.0);

            fSettlementAmount = 0.0;
            fAccrued          = 0.0;
            bool payDatesRequired = requiredResults.CashRequired();

            if (settlementDate >= baseDate)
            {
                double settlementPrincipal = CFFixedInterestListValuation.GetPrincipal(fCashflowList, settlementDate);
                fSettlementAmount = settlementPrincipal * deal.Price * Percentage.PercentagePoint;

                for (int i = 0; i < fCashflowList.Items.Count; ++i)
                {
                    CFFixedInterest cashflow = fCashflowList[i];

                    if (cashflow.Accrual_Start_Date >= settlementDate)
                    {
                        break;
                    }

                    if (settlementDate < cashflow.Accrual_End_Date)
                    {
                        fAccrued += cashflow.Interest() * (settlementDate - cashflow.Accrual_Start_Date) / (cashflow.Accrual_End_Date - cashflow.Accrual_Start_Date);
                    }
                }

                if (deal.Price_Is_Clean == YesNo.Yes)
                {
                    fSettlementAmount += fAccrued; // add accrued interest
                }
                fT.AddPayDate(settlementDate, payDatesRequired);
            }

            // Add the floating and fixed cashflow dates to the time grid.
            fT.AddPayDates <CFFixedInterest>(fCashflowList, payDatesRequired);
            fT.AddPayDates <CFFixed>(fFixedCashflowList, payDatesRequired);

            // We only need an option pricer if callable on or after the settlement date.
            fSwaptionPricer = null;
            if (lastCallDate >= settlementDate)
            {
                // Snap call dates to grid of reset dates and
                // ensure that first call date is on or after settlement date
                int iLast = resetDates.IndexOfNextDate(lastCallDate);
                lastCallDate = resetDates[iLast];
                int iFirst = resetDates.IndexOfNextDate(firstCallDate);

                while ((iFirst < resetDates.Count - 1) && (resetDates[iFirst] < settlementDate))
                {
                    // move first exercise date forward
                    iFirst++;
                }

                firstCallDate = resetDates[iFirst];
                int      paySign      = deal.Call_Put == OptionType.Put ? +1 : -1;
                RateList exerciseFees = new RateList();

                foreach (Rate price in deal.Call_Prices)
                {
                    Rate fee = new Rate();
                    fee.Value = paySign * (Percentage.OverPercentagePoint - price.Value);
                    fee.Date  = price.Date;
                    exerciseFees.Add(fee);
                }

                var amortisation = AllocateAmortisationToPaymentDates <CFFixedInterest>(deal.Amortisation, fCashflowList.Items);

                fSwaptionPricer = new SwaptionPricer(issueDate, maturityDate, couponInterval, couponInterval,
                                                     deal.Accrual_Day_Count, holidayCalendar, DayCount.ACT_365, holidayCalendar, firstCallDate, lastCallDate, baseDate,
                                                     paySign, paySign, 0.0, null, notional, amortisation, deal.Coupon_Rate, null, deal.Coupon_Rate_Schedule, exerciseFees,
                                                     null, OptionStyle2.Bermudan, Max_Nodes, Step_Size, fT, true, requiredResults.CashRequired());
            }

            if (NeedSurvivalProb())
            {
                fRecoveryList = new CFRecoveryList();
                fRecoveryList.PopulateRecoveryCashflowList(baseDate, settlementDate, fCashflowList);
            }
        }