コード例 #1
0
 public EngineType(
     string model,
     Manufacturer manufacturer,
     TypeOfEngine engine,
     NoiseLevel noise,
     double consumptation,
     long price,
     int maxspeed,
     int ceiling,
     double runway,
     double range,
     Period<int> produced)
 {
     Model = model;
     Manufacturer = manufacturer;
     Engine = engine;
     ConsumptationModifier = consumptation;
     Price = price;
     MaxSpeed = maxspeed;
     Ceiling = ceiling;
     RunwayModifier = runway;
     RangeModifier = range;
     Produced = produced;
     Types = new List<AirlinerType>();
     Noise = noise;
 }
コード例 #2
0
ファイル: Clocks.cs プロジェクト: bttalic/BitcampStudentTest
 public Clocks(string name, string description, int price, string manufacturer, Period period, Material material)
     : base(name, description, price)
 {
     this.manufacturer = manufacturer;     
     this.material = material;
     this.period = period;
 }
コード例 #3
0
    public CorrelationAnalyzer(DatedDataCollectionGen<double> series1_, DatedDataCollectionGen<double> series2_, Period p_, int numOfPeriods_)
    {
      m_series1 = series1_;
      m_series2 = series2_;
      m_period = p_;
      m_numPeriod = numOfPeriods_;

      // find common dates

      List<DateTime> commonDates = new List<DateTime>();
      List<DateTime> stratDates = new List<DateTime>(m_series1.Dates);
      foreach (DateTime date in m_series2.Dates)
        if (stratDates.Contains(date))
          commonDates.Add(date);

      QuickSort.Sort<DateTime>(commonDates);

      List<double> first = new List<double>();
      List<double> second = new List<double>();

      // get the values for each of the common dates

      foreach (DateTime date in commonDates)
      {
        first.Add(m_series1.ValueOnDate(date));
        second.Add(m_series2.ValueOnDate(date));
      }

      m_series1 = new DatedDataCollectionGen<double>(commonDates.ToArray(), first.ToArray());
      m_series2 = new DatedDataCollectionGen<double>(commonDates.ToArray(), second.ToArray());

      recalc();
    }
コード例 #4
0
 public AirlinerTypeConfiguration(string name, AirlinerType type, Period<DateTime> period, Boolean standard)
     : base(ConfigurationType.AirlinerType, name, standard)
 {
     Airliner = type;
     Period = period;
     Classes = new List<AirlinerClassConfiguration>();
 }
コード例 #5
0
        private GUIStyle getGeeAccumStyle(KeepFitCrewMember crew, Period period, GeeLoadingAccumulator accum)
        {
            GameConfig gameConfig = scenarioModule.GetGameConfig();

            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.normal.textColor = Color.green;
            style.wordWrap = false;

            GeeToleranceConfig tolerance = gameConfig.GetGeeTolerance(period);
            if (tolerance == null)
            {
                return style;
            }

            float geeWarn = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.warn, crew, gameConfig);
            float geeFatal = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.fatal, crew, gameConfig);

            float gee = accum.GetLastGeeMeanPerSecond();
            if (gee > geeFatal)
            {
                style.normal.textColor = Color.red;
            }
            else
            {
                if (gee > geeWarn)
                {
                    style.normal.textColor = Color.yellow;
                }
            }

            return style;
        }
コード例 #6
0
            public void SingleDay_PeriodOfSingleDay()
            {
                var period = new Period(new DateTime(2010, 1, 1), new DateTime(2010, 1, 1));
                var expected = new[] { "01/01/2010 - 01/01/2010" };

                AssertPeriodBasedOnToStrings(period, expected);
            }
コード例 #7
0
            public void SingleMonth_PeriodOfTwoFullMonths()
            {
                var period = new Period(new DateTime(2010, 1, 1), new DateTime(2010, 1, 31));
                var expected = new[] {"01/01/2010 - 01/31/2010"};

                AssertPeriodBasedOnToStrings(period, expected);
            }
コード例 #8
0
    // получаем период в формате - название месяца + год
    public Period getPeriod(int month_id, int year)
    {
        SqlConnection conn = new SqlConnection(this.ConnectionString);
        string sql = "SELECT * FROM rolf_timeboard_periods WHERE (month_id = @month_id) AND (year = @year)";
        SqlCommand cmd = new SqlCommand(sql, conn);
        cmd.Parameters.Add(new SqlParameter("@month_id", SqlDbType.Int, 4));
        cmd.Parameters["@month_id"].Value = month_id;
        cmd.Parameters.Add(new SqlParameter("@year", SqlDbType.VarChar, 8));
        cmd.Parameters["@year"].Value = year;

        Period period = null;

        try
        {
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            reader.Read();
            period = new Period((int)reader["id"], (int)reader["month_id"], (string)reader["month"], (int)reader["year"], (int)reader["is_closed"]);
            reader.Close();

        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        }
        finally
        {
            conn.Close();
        }
        return period;
    }
コード例 #9
0
ファイル: BrushlessMotor.cs プロジェクト: ianlee74/Omnicopter
 /// <summary>
 /// Use higher period, means faster response, not supported by all ESC
 /// </summary>
 /// <param name="pin">PWM pin</param>
 /// <param name="period">Period</param>
 public BrushlessMotor(PWM.Pin pin, Period period)
 {
     _precalc = (Max - Min) / _scale;
     Period = (uint)period;
     this._pwmPin = new PWM(pin);
     this._pwmPin.SetPulse(Period, Min);
 }
コード例 #10
0
        /// <summary>
        /// 建構式
        /// </summary>
        /// <param name="Rows"></param>
        /// <param name="Messages"></param>
        public TeacherBusyTimeConflictHelper(List<IRowStream> Rows,RowMessages Messages)
        {
            this.mTeacherPeriods = new Dictionary<string, List<Period>>();
            this.mMessages = Messages;

            foreach(IRowStream Row in Rows)
            {
                string TeacherFullName = Row.GetValue(constTeacehrName) + Row.GetValue(constTeacherNickName);

                if (!mTeacherPeriods.ContainsKey(TeacherFullName))
                    mTeacherPeriods.Add(TeacherFullName, new List<Period>());

                DateTime Date = K12.Data.DateTimeHelper.ParseDirect(Row.GetValue(constDate));
                string StartTime = Row.GetValue(constStartTime);
                string EndTime = Row.GetValue(constEndTime);

                Tuple<DateTime, int> StorageTime = Utility.GetStorageTime(StartTime, EndTime);

                DateTime BeginDatetime = StorageTime.Item1;
                int Duration = StorageTime.Item2;

                Period Period = new Period();
                Period.Date= Date;
                Period.Hour = BeginDatetime.Hour;
                Period.Minute = BeginDatetime.Minute;
                Period.Duration = Duration;
                Period.Position = Row.Position;

                mTeacherPeriods[TeacherFullName].Add(Period);
            }
        }
コード例 #11
0
 public HistoricalPriceRequest(string ticker, DateTime start_date, DateTime end_date, Period period)
 {
     Ticker = ticker;
     StartDate = start_date;
     EndDate = end_date;
     Period = period;
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Subscription"/> class.
 /// If the activated date is before the start date, a pro-rated amount is calculated.
 /// If the activated date is after the start date, they are swapped and a pro-rated amount is calculated.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="start">The starting date.</param>
 /// <param name="end">The ending date.</param>
 /// <param name="activated">The activated date.</param>
 /// <param name="billingPeriod">The billing period.</param>
 /// <param name="billingAmount">The billing amount.</param>
 /// <param name="trialPeriod">The trial period.</param>
 public Subscription(string name, DateTime start, DateTime end, DateTime activated, Period billingPeriod,
                     Money billingAmount, Period trialPeriod)
     : this(name, start, end, billingPeriod, billingAmount)
 {
     ApplyTrialPeriod(trialPeriod, 1);
     ApplyProratedAmount(start, billingAmount, activated);
 }
コード例 #13
0
ファイル: PeriodsMenu.cs プロジェクト: LongoMatch/longomatch
 void CreateMenu()
 {
     additem = new MenuItem (Catalog.GetString ("Add period"));
     additem.Activated += (sender, e) => {
         string periodname = App.Current.Dialogs.QueryMessage (Catalog.GetString ("Period name"), null,
                                 (project.Periods.Count + 1).ToString (),
                                 null).Result;
         if (periodname != null) {
             project.Dashboard.GamePeriods.Add (periodname);
             Period p = new Period { Name = periodname };
             p.Nodes.Add (new TimeNode {
                 Name = periodname,
                 Start = new Time { TotalSeconds = time.TotalSeconds - 10 },
                 Stop = new Time { TotalSeconds = time.TotalSeconds + 10 }
             });
             project.Periods.Add (p);
             if (timertimeline != null) {
                 timertimeline.AddTimer (p);
             }
         }
     };
     Add (additem);
     delitem = new MenuItem (Catalog.GetString ("Delete period"));
     delitem.Activated += (sender, e) => {
         project.Periods.Remove (timer as Period);
         if (timertimeline != null) {
             timertimeline.RemoveTimer (timer);
             selectionCanvas.ClearSelection ();
         }
     };
     Add (delitem);
     ShowAll ();
 }
コード例 #14
0
        public AirportProfile(
            string name,
            string code,
            string icaocode,
            AirportType type,
            Period<DateTime> period,
            Town town,
            TimeSpan offsetGMT,
            TimeSpan offsetDST,
            Coordinates coordinates,
            GeneralHelpers.Size cargo,
            double cargovolume,
            Weather.Season season)
        {
            PaxValues = new List<PaxValue>();

            Expansions = new List<AirportExpansion>();
            Name = name;
            Period = period;
            IATACode = code;
            ICAOCode = icaocode;
            Type = type;
            Town = town;
            Coordinates = coordinates;
            CargoVolume = cargovolume;
            MajorDestionations = new Dictionary<string, int>();
            Cargo = cargo;
            Logo = "";
            OffsetDST = offsetDST;
            OffsetGMT = offsetGMT;
            Season = season;
            ID =
                $"{char.ConvertToUtf32(IATACode, 0):00}-{char.ConvertToUtf32(IATACode, 1):00}-{char.ConvertToUtf32(IATACode, 2):00}-{name.Length:00}-{char.ConvertToUtf32(Name, Name.Length/2):00}-{(int) Cargo:00}";
        }
コード例 #15
0
        public List<WayBill> GetCookBills(string userName, string item,
            DateTime periodStart = new DateTime(), DateTime periodEnd = new DateTime())
        {
            List<WayBill> userBills=new List<WayBill>();
            List<WayBill> userBillsByPeriod = new List<WayBill>();
            period = new Period { Start = periodStart, End = periodEnd };
            userBills = GetUserBills(userName).ToList();
             userBills = new List<WayBill>(userBills.OrderByDescending(bill => bill.Id));
            if (item == "1")
            {

                if ((period.Start == Convert.ToDateTime("01.01.0001 0:00:00")) ||
                    (period.End == Convert.ToDateTime("01.01.0001 0:00:00")))
                    return userBills;

                if (period.Start == period.End)
                {
                    userBillsByPeriod.AddRange(userBills.Where(bill => ((DateTime)(bill.Date)).Day == period.End.Day));
                    return userBillsByPeriod;
                } //LINQ it's POWER!!!
                userBillsByPeriod.AddRange(userBills.Where(bill => (bill.Date >= period.Start) && (bill.Date <= period.End)));
                return userBillsByPeriod;
            }

            //TODO: Различные запросы
            return userBills;
        }
コード例 #16
0
ファイル: Painting.cs プロジェクト: Nadar13/PredavanjaNET
 public Painting(string name, string description,
     string author, Period period)
     : base(name, description)
 {
     this.author = author;
     this.period = period;
 }
コード例 #17
0
 public AirlinerPassengerType(Manufacturer manufacturer, string name,string family, int seating, int cockpitcrew, int cabincrew, double speed, long range, double wingspan, double length, double consumption, long price, int maxAirlinerClasses, long minRunwaylength, long fuelcapacity, BodyType body, TypeRange rangeType, EngineType engine, Period<DateTime> produced, int prodRate, Boolean standardType = true)
     : base(manufacturer,TypeOfAirliner.Passenger,name,family,cockpitcrew,speed,range,wingspan,length,consumption,price,minRunwaylength,fuelcapacity,body,rangeType,engine,produced, prodRate,standardType)
 {
     this.MaxSeatingCapacity = seating;
     this.CabinCrew = cabincrew;
     this.MaxAirlinerClasses = maxAirlinerClasses;
 }
コード例 #18
0
ファイル: BarChartProxy.cs プロジェクト: kuritka/MarketLoader
 /// <summary>
 /// Reads the chart with price box. over the chart
 /// Data for this chart are added inside tag chartDiv
 /// PriceBox contains open, close, min, max records
 /// Things shown inside the priceBox are shown by javascripts on the client side.
 /// !! There is css class called barchartStyle is inside, you can set how will price box looks like
 /// </summary>
 /// <param name="contractCode">The contract code.</param>
 /// <param name="periodSize">BarChartProxy.Constants.PeriodSize.Monthly next parameters are dayly, weekly</param>
 /// <param name="frameSize">Size of the frame.</param>
 /// <param name="movingAverages">add indicators higher than 1</param>
 /// <returns></returns>
 public string GetChart(string contractCode, Period periodSize, FrameSize frameSize, List<int> movingAverages)
 {
     //http://www.barchart.com/chart.php?sym=KCZ10&indicators=
     //http://www.barchart.com/chart.php?sym={0}&style=technical{1}&d=M&sd=&ed=&size=M&log=0&t=BAR&v=2&g=1&evnt=1&late=1&o1=&o2=&o3=&sh=100{2}&txtDate=#jump
     var address = GetChartPath(contractCode, periodSize, frameSize, movingAverages);
     return GetChart(contractCode, address,  frameSize,periodSize, movingAverages);
 }
コード例 #19
0
ファイル: Performance.cs プロジェクト: QuenZhan/EWP
 public void begin(Troop host,Troop challenger)
 {
     var p=new Period();
     p.type="begin";
     queuePeriod.Add(p);
     play();
 }
コード例 #20
0
ファイル: RMilestoneStatus.cs プロジェクト: mnatte/Planner
        /// <summary>
        /// OBSOLETE
        /// </summary>
        /// <param name="ms"></param>
        /// <param name="startDate"></param>
        public static void GetBurnDownData(this RMilestoneStatus ms, DateTime startDate)
        {
            var rep = new ReleaseRepository();
            var result = rep.GetArtefactsProgress(ms.Release.Id);

            // determine amount days till milestone
            var period = new Period { StartDate = startDate, EndDate = ms.Date };
            var workingDays = period.AmountWorkingDays;

            // get progress data for milestone
            var count = 0;
            var totalProgress = result.Where(x => ms.Id == x.MilestoneId).Select(x => new { HoursRemaining = x.HoursRemaining, StatusDate = x.StatusDate, DayNumber = count++ }).ToList().OrderBy(x => x.StatusDate);

            // determine slope of known status data
            var amountDays = totalProgress.Count();
            var avgDays = totalProgress.Select(x => x.DayNumber).Average();
            var avgHours = totalProgress.Select(x => x.HoursRemaining).Average();
            var deviations = totalProgress.Select(x => new { xDeviation = x.DayNumber - avgDays, yDeviation = x.HoursRemaining - avgHours, xDevTimesyDev = (x.DayNumber - avgDays) * (x.HoursRemaining - avgHours), xDevSquare = (x.DayNumber - avgDays) * (x.DayNumber - avgDays) }).ToList();
            // divide SUM( (x - avgX) * (y - avgY) ) by SUM( (x - avgX) * (x - avgX) )
            var slope = deviations.Select(x => x.xDevTimesyDev).Sum() / deviations.Select(x => x.xDevSquare).Sum();

            // determine intercept: avgY = (slope * avgX) + intercept -> intercept = -((slope * avgX) - avgY)
            var intercept = -((slope * avgDays) - avgHours);

            // formula best fitted line: amtHours = slope * amtDays + intercept
        }
コード例 #21
0
            public void Period_EqualsSamePeriod()
            {
                var period = new Period(new DateTime(2010, 1, 1), new DateTime(2010, 1, 31));

                Assert.True(period.Equals(period));
                Assert.True(((object)period).Equals(period));
                Assert.Equal(period.GetHashCode(), period.GetHashCode());
            }
コード例 #22
0
 protected PaypalSubscriptionRequest()
 {
     EditMode = PayPalSubscriptionEditMode.CreateOnly;
     SubscriptionPeriod = new Period { Price = 1, Length = 1, Unit = PayPalSubscriptionPeriodUnit.Month };
     Recurs = PayPalSubscriptionRecurrance.On;
     Shipping = PayPalShippingMode.Disabled;
     ReturnUrlMethod = PayPalReturnUrlMethod.Post;
 }
コード例 #23
0
ファイル: PeriodGroup.cs プロジェクト: gwandalf/Congress
 /// <summary>
 /// Deactivates all the periods, except the specified one.
 /// </summary>
 /// <param name="exception">Period to not deactivate.</param>
 public void deactivateAllButOne(Period exception)
 {
     foreach(Period p in periods.Values)
     {
         if (exception != p)
             p.setActive(false);
     }
 }
コード例 #24
0
 public static void Rule(AdditionalProgramStatements lhs, Period period, OptionalProgramStatement optionalProgramStatement, AdditionalProgramStatements additionalProgramStatements)
 {
     if (optionalProgramStatement.CodeSentence != null)
     {
         lhs.CodeSentences.Add(optionalProgramStatement.CodeSentence);
     }
     lhs.CodeSentences.AddRange(additionalProgramStatements.CodeSentences);
 }
コード例 #25
0
ファイル: Performance.cs プロジェクト: QuenZhan/EWP
 public void die(Chess chess)
 {
     var p=new Period();
     p.type="die";
     p.chesses=new Chess[]{chess};
     p.time=0f;
     queuePeriod.Add(p);
 }
コード例 #26
0
ファイル: YoYInflationLeg.cs プロジェクト: ammachado/QLNet
 public YoYInflationLeg(Schedule schedule, Calendar cal, YoYInflationIndex index, Period observationLag)
 {
     schedule_ = schedule;
     index_ = index;
     observationLag_ = observationLag;
     paymentAdjustment_ = BusinessDayConvention.ModifiedFollowing;
     paymentCalendar_ = cal;
 }
コード例 #27
0
 public PlanContinuingProcessResource(RHumanResource resource, Process process, Deliverable deliverable, Activity activity, Period period, double dedication)
 {
     _resource = resource;
     _process = process;
     _deliverable = deliverable;
     _activity = activity;
     _dedication = dedication;
     _period = period;
 }
コード例 #28
0
 public List<Appointment> GenerateCalendar(Period period, List<Schedule> schedules)
 {
     List<Appointment> appointments = new List<Appointment>();
     for (DateTime checkDate = period.Start; checkDate <= period.End; checkDate = checkDate.AddDays(1))
     {
         AddAppointmentsForDate(checkDate, schedules, appointments);
     }
     return appointments.OrderBy(a => a.Time).ToList();
 }
コード例 #29
0
ファイル: UnAssignResource.cs プロジェクト: mnatte/Planner
 public UnAssignResource(RHumanResource resource, Release release, Project project, Milestone milestone, Deliverable deliverable, Activity activity, Period period)
 {
     _resource = resource;
     _release = release;
     _milestone = milestone;
     _deliverable = deliverable;
     _activity = activity;
     _period = period;
     _project = project;
 }
コード例 #30
0
            public void Period_EqualsEqualPeriod()
            {
                var firstPeriod = new Period(new DateTime(2010, 1, 1), new DateTime(2010, 1, 31));
                var secondPeriod = new Period(new DateTime(2010, 1, 1), new DateTime(2010, 1, 31));

                Assert.True(firstPeriod.Equals(secondPeriod));
                Assert.True(((object)firstPeriod).Equals(secondPeriod));
                Assert.Equal(firstPeriod.GetHashCode(), secondPeriod.GetHashCode());
                Assert.True(firstPeriod == secondPeriod);
            }
コード例 #31
0
 private string FormatDayName(Period period)
 {
     return(period.Start.DayOfWeek.ToString().Substring(0, 1));
 }
コード例 #32
0
 private IEnumerable <Developer> GetAvailableDevelopersOfPeriod(Period period)
 {
     return(_developers.Where(q => q.LastParticipationPeriodId >= period.Id && q.FirstParticipationPeriodId <= period.Id));
 }
コード例 #33
0
        private static IEnumerable <SimulatedLeaver> FilterDevelopersBasedOnLeaverType(Period period, Dictionary <string, DeveloperContribution> developersContributions, string leaversType, IEnumerable <SimulatedLeaver> leavers)
        {
            var isCore = leaversType == LeaversType.Core;

            foreach (var leaver in leavers)
            {
                if (leaversType == LeaversType.All)
                {
                    yield return(leaver);
                }
                else
                {
                    var developerContribution = developersContributions.GetValueOrDefault(period.Id + "-" + leaver.NormalizedName);

                    // some of the devs have no contribution,
                    // because they authored files with unknown extensions
                    // or we have ignored they knowledge because of mega commits or mega PRs
                    // or their knowledge is rewritten by someone else
                    if (developerContribution == null)
                    {
                        continue;
                    }

                    if (developerContribution.IsCore == isCore)
                    {
                        yield return(leaver);
                    }
                }
            }
        }
コード例 #34
0
        private bool IsFileSavedByReview(string filePath, ReviewBasedKnowledgeMap reviewBasedKnowledgeMap, Period period)
        {
            var reviewers = reviewBasedKnowledgeMap.GetReviewsOfFile(filePath);

            if (reviewers == null)
            {
                return(false);
            }

            foreach (var reviewDetail in reviewers.Values)
            {
                if (reviewDetail.Periods.Min(q => q.Id) <= period.Id && reviewDetail.Developer.LastParticipationPeriodId > period.Id)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #35
0
        public static DateTime AddPeriod(DateTime date, Period interval, int numberOfIntervals)
        {
            DateTime result = interval.Multiply(numberOfIntervals).Add(date);

            return(result);
        }
        public double yoyRate(Date d, Period instObsLag)
        {
            double ret = NQuantLibcPINVOKE.YoYInflationTermStructure_yoyRate__SWIG_2(swigCPtr, Date.getCPtr(d), Period.getCPtr(instObsLag));

            if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
            {
                throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #37
0
 public void Can_Use_NodaTime_Period_In_Static_Index_Negative()
 {
     Can_Use_NodaTime_Period_In_Static_Index2(Period.FromHours(-5));
 }
コード例 #38
0
 public void Can_Use_NodaTime_Period_In_Static_Index_Positive()
 {
     Can_Use_NodaTime_Period_In_Static_Index1(Period.FromHours(2));
 }
コード例 #39
0
 private IEnumerable <SimulatedLeaver> GetLeaversOfPeriod(LossSimulation lossSimulation, Period period, IEnumerable <Developer> availableDevelopers)
 {
     return(GetLeavers(period, availableDevelopers, _developersContributionsDic, lossSimulation));
 }
コード例 #40
0
 private string FormatYear(Period period)
 {
     return(period.Start.Year.ToString());
 }
コード例 #41
0
 private string FormatMonth(Period period)
 {
     return(period.Start.ToString("MMMM") + " " + period.Start.Year.ToString());
 }
コード例 #42
0
 public static IEnumerable <T> CutPeriodChunk <T>(
     this IEnumerable <T> data,
     Period period
     ) where T : IDated =>
 data.Where(d => d.In(period));
コード例 #43
0
 public async Task <IActionResult> Create([FromBody] Period input)
 {
     return(await SendCommandAsync(new CreatePeriod(PeriodName.From(input.Month, input.Year))));
 }
コード例 #44
0
ファイル: Shibor.cs プロジェクト: OpenDerivatives/QLCore
 public Shibor(Period tenor, Handle <YieldTermStructure> h)
     : base("Shibor", tenor, (tenor == new Period(1, TimeUnit.Days) ? 0 : 1), new CNYCurrency(),
            new China(China.Market.IB), shiborConvention(tenor), false,
            new Actual360(), h)
 {
 }
コード例 #45
0
 public Cdor(Period tenor, Handle <YieldTermStructure> h)
     : base("CDOR", tenor, 2, new CADCurrency(), new Canada(), BusinessDayConvention.ModifiedFollowing, false, new Actual360(), h)
 {
 }
コード例 #46
0
ファイル: Shibor.cs プロジェクト: OpenDerivatives/QLCore
 public Shibor(Period tenor)
     : this(tenor, new Handle <YieldTermStructure>())
 {
 }
        public double yoyRate(Date d, Period instObsLag, bool forceLinearInterpolation, bool extrapolate)
        {
            double ret = NQuantLibcPINVOKE.YoYInflationTermStructure_yoyRate__SWIG_0(swigCPtr, Date.getCPtr(d), Period.getCPtr(instObsLag), forceLinearInterpolation, extrapolate);

            if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
            {
                throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #48
0
 public RetryPolicyPeriodAndDuration(Period minimalRetryInterval, Period allowableDuration)
 {
     this.MinimalRetryInterval = minimalRetryInterval;
     this.AllowableDuration    = allowableDuration;
 }
コード例 #49
0
 /// <summary>
 /// Create a key from a Coordinate
 /// </summary>
 /// <param name="expiry"></param>
 /// <param name="tenor"></param>
 /// <param name="strike"></param>
 public ExpiryTenorStrikeKey(Period expiry, Period tenor, decimal strike)
 {
     Expiry = expiry;
     Tenor  = tenor;
     Strike = strike;
 }
コード例 #50
0
ファイル: Cache.cs プロジェクト: RemSoftDev/Wouter
 public static Amount GetPeriodPropertyValue(DateTime date, Period period, Property property)
 {
     return(GetDayObject(date).GetPeriodPropertyValue(period, property));
 }
コード例 #51
0
        private IEnumerable <SimulatedAbondonedFile> GetAbandonedFiles(Period period, IEnumerable <SimulatedLeaver> leavers, IEnumerable <Developer> availableDevelopers, KnowledgeDistributionMap knowledgeMap, LossSimulation lossSimulation)
        {
            var leaversDic             = leavers.ToDictionary(q => q.Developer.NormalizedName);
            var availableDevelopersDic = availableDevelopers.ToDictionary(q => q.NormalizedName);

            var authorsFileBlames = knowledgeMap.BlameBasedKnowledgeMap.GetSnapshopOfPeriod(period.Id);

            foreach (var filePath in authorsFileBlames.FilePaths)
            {
                var isFileSavedByReview = IsFileSavedByReview(filePath, knowledgeMap.ReviewBasedKnowledgeMap, period);
                if (isFileSavedByReview)
                {
                    continue;
                }

                var fileTotalLines = (double)authorsFileBlames[filePath].Sum(q => q.Value.TotalAuditedLines);

                var remainingBlames = authorsFileBlames[filePath].Values.Where(q => availableDevelopersDic.ContainsKey(q.NormalizedDeveloperName))
                                      .OrderByDescending(q => q.TotalAuditedLines)
                                      .ToArray();

                var abandonedBlames = remainingBlames.Where(q => leaversDic.ContainsKey(q.NormalizedDeveloperName)).ToArray();

                var remainingTotalLines = remainingBlames.Sum(q => q.TotalAuditedLines);
                var abandonedTotalLines = abandonedBlames.Sum(q => q.TotalAuditedLines);

                var remainingPercentage = remainingTotalLines / fileTotalLines;
                var abandonedPercentage = abandonedTotalLines / fileTotalLines;

                var leftKnowledgePercentage = 1 - (remainingPercentage - abandonedPercentage);

                if (leftKnowledgePercentage >= lossSimulation.FilesAtRiksOwnershipThreshold)
                {
                    yield return(new SimulatedAbondonedFile()
                    {
                        FilePath = filePath,
                        PeriodId = period.Id,
                        TotalLinesInPeriod = remainingTotalLines,
                        LossSimulationId = lossSimulation.Id,
                        AbandonedLinesInPeriod = abandonedTotalLines,
                        SavedLinesInPeriod = remainingTotalLines - abandonedTotalLines,
                        RiskType = "abandoned"
                    });
                }

                var nonAbandonedBlames     = remainingBlames.Where(q => !leaversDic.ContainsKey(q.NormalizedDeveloperName)).ToArray();
                var totalNonAbandonedLines = (double)nonAbandonedBlames.Sum(q => q.TotalAuditedLines);

                var topOwnedPortion = 0.0;
                for (var i = 0; i < nonAbandonedBlames.Count() && i < lossSimulation.FilesAtRiksOwnersThreshold; i++)
                {
                    topOwnedPortion += nonAbandonedBlames[i].TotalAuditedLines / totalNonAbandonedLines;
                }

                if (topOwnedPortion >= lossSimulation.FilesAtRiksOwnershipThreshold)
                {
                    yield return(new SimulatedAbondonedFile()
                    {
                        FilePath = filePath,
                        PeriodId = period.Id,
                        TotalLinesInPeriod = remainingTotalLines,
                        LossSimulationId = lossSimulation.Id,
                        AbandonedLinesInPeriod = abandonedTotalLines,
                        SavedLinesInPeriod = remainingTotalLines - abandonedTotalLines,
                        RiskType = "hoarded"
                    });
                }
            }
        }
コード例 #52
0
 public IssuesRequest(string organizationSlug, string projectSlug, string queryString, Period period)
     : base(organizationSlug, projectSlug)
 {
     Period      = period;
     QueryString = queryString;
 }
コード例 #53
0
        private IEnumerable <SimulatedLeaver> GetLeavers(Period period, IEnumerable <Developer> availableDevelopers, Dictionary <string, DeveloperContribution> developersContributions, LossSimulation lossSimulation)
        {
            var allPotentialLeavers = GetPotentialLeavers(period, availableDevelopers, developersContributions, lossSimulation).ToArray();

            return(FilterDevelopersBasedOnLeaverType(period, developersContributions, lossSimulation.LeaversType, allPotentialLeavers).ToArray());
        }
コード例 #54
0
 /// <summary>
 /// Initializes a new instance of the OrganisationBody class.
 /// </summary>
 public OrganisationBody(System.Guid?bodyOrganisationId = default(System.Guid?), System.Guid?bodyId = default(System.Guid?), string bodyName = default(string), Period validity = default(Period))
 {
     BodyOrganisationId = bodyOrganisationId;
     BodyId             = bodyId;
     BodyName           = bodyName;
     Validity           = validity;
 }
コード例 #55
0
 public NZDLibor(Period tenor, YieldTermStructureHandle h) : this(NQuantLibcPINVOKE.new_NZDLibor__SWIG_0(Period.getCPtr(tenor), YieldTermStructureHandle.getCPtr(h)), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #56
0
 private string FormatDay(Period period)
 {
     return(period.Start.Day.ToString());
 }
コード例 #57
0
ファイル: ReportsService.cs プロジェクト: Zilib/Watchman
 //TODO unit test
 public StatisticsReport CreateReport(List <Message> serverMessages, Period period)
 {
     if (!serverMessages.Any())
     {
         return(default);
コード例 #58
0
 public void Can_Use_NodaTime_Period_In_Document_Positive()
 {
     Can_Use_NodaTime_Period_In_Document(Period.FromHours(2));
 }
コード例 #59
0
        protected override IEnumerable <ResultPack> EvaluateArticleResults(TargetItem evalTarget, ConfigBase evalConfig, ISourceValues evalValues, Period evalPeriod, IPeriodProfile evalProfile, IEnumerable <ResultPair> evalResults)
        {
            if (InternalEvaluate == null)
            {
                return(EvaluateUtils.DecoratedError(ARTICLE_DESCRIPTION_ERROR_FORMAT, EXCEPTION_RESULT_NONE_TEXT));
            }
            var sourceBuilder = new EvaluateSource.SourceBuilder(evalValues);
            var resultBuilder = new EvaluateSource.ResultBuilder(evalTarget, evalResults);

            var bundleValues = PrepareConceptValues <EvaluateSource>(sourceBuilder, resultBuilder);

            if (bundleValues.IsFailure)
            {
                return(EvaluateUtils.DecoratedError(ARTICLE_DESCRIPTION_ERROR_FORMAT, bundleValues.Error));
            }
            return(InternalEvaluate(evalConfig, evalPeriod, evalProfile, bundleValues));
        }
        static IsdaCompliantCreditCurveCalibratorBase()
        {
            ImmutableList.Builder <IsdaCreditCurveNode> dscNodeBuilder = ImmutableList.builder();
            for (int i = 0; i < NUM_MM; i++)
            {
                Tenor tenor = Tenor.ofMonths(MM_MONTHS[i]);
                dscNodeBuilder.add(DepositIsdaCreditCurveNode.of(QuoteId.of(StandardId.of("OG", ID_VALUES[i])), ADJ_3D, BUS_ADJ, tenor, ACT_360));
            }
            for (int i = NUM_MM; i < NUM_INSTRUMENTS; i++)
            {
                Tenor tenor = Tenor.ofYears(SWAP_YEARS[i - NUM_MM]);
                dscNodeBuilder.add(SwapIsdaCreditCurveNode.of(QuoteId.of(StandardId.of("OG", ID_VALUES[i])), ADJ_3D, BUS_ADJ, tenor, THIRTY_U_360, Frequency.P12M));
            }
            DSC_NODES       = dscNodeBuilder.build();
            EXP_NODE_CDS    = new ResolvedCdsTrade[NUM_TESTS][];
            NODE_CDS        = new CdsIsdaCreditCurveNode[NUM_TESTS][];
            CDS_MARKET_DATA = new ImmutableMarketData[NUM_TESTS];
            SPREADS         = new double[NUM_TESTS][];
            YIELD_CURVES    = new ImmutableCreditRatesProvider[NUM_TESTS];
            // case0
            LocalDate tradeDate0 = LocalDate.of(2011, 6, 19);
            LocalDate startDate0 = LocalDate.of(2011, 3, 21);

            YIELD_CURVES[0] = createRatesProvider(tradeDate0, tradeDate0, 1d, 0.4);
            Period[] tenors  = new Period[] { Period.ofMonths(6), Period.ofYears(1), Period.ofYears(3), Period.ofYears(5), Period.ofYears(7), Period.ofYears(10) };
            int      nTenors = tenors.Length;

            EXP_NODE_CDS[0] = new ResolvedCdsTrade[nTenors];
            NODE_CDS[0]     = new CdsIsdaCreditCurveNode[nTenors];
            ImmutableMarketDataBuilder builderCredit0 = ImmutableMarketData.builder(tradeDate0);

            SPREADS[0] = new double[] { 0.00886315689995649, 0.00886315689995649, 0.0133044689825873, 0.0171490070952563, 0.0183903639181293, 0.0194721890639724 };
            for (int i = 0; i < nTenors; ++i)
            {
                Cds product = Cds.of(BUY, LEGAL_ENTITY, EUR, 1d, startDate0, LocalDate.of(2011, 6, 20).plus(tenors[i]), Frequency.P3M, DEFAULT_CALENDAR, SPREADS[0][i]);
                EXP_NODE_CDS[0][i] = CdsTrade.builder().info(TradeInfo.builder().settlementDate(product.SettlementDateOffset.adjust(tradeDate0, REF_DATA)).build()).product(product).build().resolve(REF_DATA);
                CdsConvention conv = ImmutableCdsConvention.of("conv", EUR, ACT_360, Frequency.P3M, BUS_ADJ, CDS_SETTLE_STD);
                CdsTemplate   temp = DatesCdsTemplate.of(startDate0, LocalDate.of(2011, 6, 20).plus(tenors[i]), conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", tenors[i].ToString()));
                NODE_CDS[0][i] = CdsIsdaCreditCurveNode.ofParSpread(temp, id, LEGAL_ENTITY);
                builderCredit0.addValue(id, SPREADS[0][i]);
            }
            CDS_MARKET_DATA[0] = builderCredit0.build();
            // case1
            LocalDate tradeDate1 = LocalDate.of(2011, 3, 21);
            LocalDate snapDate1  = LocalDate.of(2011, 3, 18);
            LocalDate effDate1   = LocalDate.of(2011, 3, 20);   //note this is a Sunday - for a standard CDS this would roll to the Monday.

            YIELD_CURVES[1] = createRatesProvider(tradeDate1, snapDate1, 1d, 0.4);
            tenors          = new Period[] { Period.ofMonths(6), Period.ofYears(1), Period.ofYears(3), Period.ofYears(5), Period.ofYears(7), Period.ofYears(10) };
            nTenors         = tenors.Length;
            NODE_CDS[1]     = new CdsIsdaCreditCurveNode[nTenors];
            ImmutableMarketDataBuilder builderCredit1 = ImmutableMarketData.builder(tradeDate1);

            EXP_NODE_CDS[1] = new ResolvedCdsTrade[nTenors];
            SPREADS[1]      = new double[] { 0.027, 0.018, 0.012, 0.009, 0.007, 0.006 };
            for (int i = 0; i < nTenors; ++i)
            {
                Cds product = Cds.of(BUY, LEGAL_ENTITY, EUR, 1d, effDate1, LocalDate.of(2011, 6, 20).plus(tenors[i]), P3M, DEFAULT_CALENDAR, SPREADS[1][i]);
                EXP_NODE_CDS[1][i] = CdsTrade.builder().info(TradeInfo.builder().settlementDate(product.SettlementDateOffset.adjust(tradeDate1, REF_DATA)).build()).product(product).build().resolve(REF_DATA);
                CdsConvention conv = ImmutableCdsConvention.builder().name("conv").currency(EUR).dayCount(ACT_360).paymentFrequency(P3M).startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).businessDayAdjustment(BUS_ADJ).settlementDateOffset(CDS_SETTLE_STD).build();
                CdsTemplate   temp = DatesCdsTemplate.of(effDate1, LocalDate.of(2011, 6, 20).plus(tenors[i]), conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", tenors[i].ToString()));
                NODE_CDS[1][i] = CdsIsdaCreditCurveNode.ofParSpread(temp, id, LEGAL_ENTITY);
                builderCredit1.addValue(id, SPREADS[1][i]);
            }
            CDS_MARKET_DATA[1] = builderCredit1.build();
            // case2
            LocalDate tradeDate2 = LocalDate.of(2011, 5, 30);
            LocalDate snapDate2  = LocalDate.of(2011, 5, 29);

            YIELD_CURVES[2] = createRatesProvider(tradeDate2, snapDate2, 1d, 0.25);
            LocalDate[] matDates2  = new LocalDate[] { LocalDate.of(2011, 6, 20), LocalDate.of(2012, 5, 30), LocalDate.of(2014, 6, 20), LocalDate.of(2016, 6, 20), LocalDate.of(2018, 6, 20) };
            int         nMatDates2 = matDates2.Length;

            NODE_CDS[2] = new CdsIsdaCreditCurveNode[nMatDates2];
            ImmutableMarketDataBuilder builderCredit2 = ImmutableMarketData.builder(tradeDate2);

            EXP_NODE_CDS[2] = new ResolvedCdsTrade[nMatDates2];
            SPREADS[2]      = new double[] { 0.05, 0.05, 0.05, 0.05, 0.05 };
            for (int i = 0; i < nMatDates2; ++i)
            {
                Cds product = Cds.of(BUY, LEGAL_ENTITY, EUR, 1d, tradeDate2.plusDays(1), matDates2[i], P3M, DEFAULT_CALENDAR, SPREADS[2][i]).toBuilder().dayCount(THIRTY_U_360).build();
                EXP_NODE_CDS[2][i] = CdsTrade.builder().info(TradeInfo.builder().settlementDate(product.SettlementDateOffset.adjust(tradeDate2, REF_DATA)).build()).product(product).build().resolve(REF_DATA);
                CdsConvention conv = ImmutableCdsConvention.builder().name("conv").currency(EUR).dayCount(THIRTY_U_360).paymentFrequency(P3M).rollConvention(RollConventions.NONE).businessDayAdjustment(BUS_ADJ).settlementDateOffset(CDS_SETTLE_STD).build();
                CdsTemplate   temp = DatesCdsTemplate.of(tradeDate2.plusDays(1), matDates2[i], conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", matDates2[i].ToString()));
                NODE_CDS[2][i] = CdsIsdaCreditCurveNode.ofParSpread(temp, id, LEGAL_ENTITY);
                builderCredit2.addValue(id, SPREADS[2][i]);
            }
            CDS_MARKET_DATA[2] = builderCredit2.build();
            // case3
            LocalDate tradeDate3 = LocalDate.of(2011, 5, 30);
            LocalDate snapDate3  = LocalDate.of(2011, 5, 29);
            LocalDate effDate3   = LocalDate.of(2011, 7, 31);

            YIELD_CURVES[3] = createRatesProvider(tradeDate3, snapDate3, 1d, 0.25);
            LocalDate[] matDates3  = new LocalDate[] { LocalDate.of(2011, 11, 30), LocalDate.of(2012, 5, 30), LocalDate.of(2014, 5, 30), LocalDate.of(2016, 5, 30), LocalDate.of(2018, 5, 30), LocalDate.of(2021, 5, 30) };
            int         nMatDates3 = matDates3.Length;

            NODE_CDS[3] = new CdsIsdaCreditCurveNode[nMatDates3];
            ImmutableMarketDataBuilder builderCredit3 = ImmutableMarketData.builder(tradeDate3);

            EXP_NODE_CDS[3] = new ResolvedCdsTrade[nMatDates3];
            SPREADS[3]      = new double[] { 0.07, 0.06, 0.05, 0.055, 0.06, 0.065 };
            for (int i = 0; i < nMatDates3; ++i)
            {
                Cds product = Cds.builder().buySell(BUY).legalEntityId(LEGAL_ENTITY).currency(EUR).dayCount(ACT_365F).fixedRate(SPREADS[3][i]).notional(1d).paymentSchedule(PeriodicSchedule.builder().businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, DEFAULT_CALENDAR)).startDate(effDate3).endDate(matDates3[i]).startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).frequency(Frequency.P6M).rollConvention(RollConventions.NONE).stubConvention(StubConvention.LONG_INITIAL).build()).paymentOnDefault(PaymentOnDefault.ACCRUED_PREMIUM).protectionStart(ProtectionStartOfDay.BEGINNING).stepinDateOffset(DaysAdjustment.ofCalendarDays(1)).settlementDateOffset(CDS_SETTLE_STD).build();
                EXP_NODE_CDS[3][i] = CdsTrade.builder().info(TradeInfo.builder().settlementDate(product.SettlementDateOffset.adjust(tradeDate3, REF_DATA)).build()).product(product).build().resolve(REF_DATA);
                CdsConvention conv = ImmutableCdsConvention.builder().name("conv").currency(EUR).dayCount(ACT_365F).paymentFrequency(Frequency.P6M).rollConvention(RollConventions.NONE).stubConvention(StubConvention.LONG_INITIAL).startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, DEFAULT_CALENDAR)).settlementDateOffset(CDS_SETTLE_STD).build();
                CdsTemplate   temp = DatesCdsTemplate.of(effDate3, matDates3[i], conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", matDates3[i].ToString()));
                NODE_CDS[3][i] = CdsIsdaCreditCurveNode.ofParSpread(temp, id, LEGAL_ENTITY);
                builderCredit3.addValue(id, SPREADS[3][i]);
            }
            CDS_MARKET_DATA[3] = builderCredit3.build();
            // case4: designed to trip the low rates/low spreads branch
            LocalDate tradeDate4 = LocalDate.of(2014, 1, 14);
            LocalDate snapDate4  = LocalDate.of(2014, 1, 13);

            YIELD_CURVES[4] = createRatesProvider(tradeDate4, snapDate4, 1d / 1000d, 0.4);
            int nSpreads4 = 6;

            NODE_CDS[4] = new CdsIsdaCreditCurveNode[nSpreads4];
            ImmutableMarketDataBuilder builderCredit4 = ImmutableMarketData.builder(tradeDate4);

            SPREADS[4] = new double[nSpreads4];
            Arrays.fill(SPREADS[4], 1.0e-4);
            EXP_NODE_CDS[4] = new ResolvedCdsTrade[nSpreads4];
            for (int i = 0; i < nSpreads4; ++i)
            {
                Cds product = Cds.of(BUY, LEGAL_ENTITY, EUR, 1d, LocalDate.of(2013, 12, 20), LocalDate.of(2014, 3, 20).plus(tenors[i]), P3M, DEFAULT_CALENDAR, SPREADS[4][i]);
                EXP_NODE_CDS[4][i] = CdsTrade.builder().info(TradeInfo.builder().settlementDate(product.SettlementDateOffset.adjust(tradeDate4, REF_DATA)).build()).product(product).build().resolve(REF_DATA);
                CdsConvention conv = ImmutableCdsConvention.of("conv", EUR, ACT_360, P3M, BUS_ADJ, CDS_SETTLE_STD);
                CdsTemplate   temp = DatesCdsTemplate.of(LocalDate.of(2013, 12, 20), LocalDate.of(2014, 3, 20).plus(tenors[i]), conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", tenors[i].ToString()));
                NODE_CDS[4][i] = CdsIsdaCreditCurveNode.ofParSpread(temp, id, LEGAL_ENTITY);
                builderCredit4.addValue(id, SPREADS[4][i]);
            }
            CDS_MARKET_DATA[4] = builderCredit4.build();
        }