Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OnDemandPageEpisodesRent" /> class.
 /// </summary>
 /// <param name="active">Whether all the videos on the On Demand page can be rented as a whole. (required).</param>
 /// <param name="period">The rental period for the video.  Option descriptions:  * &#x60;1 day&#x60; - The rental period is one day.  * &#x60;1 month&#x60; - The rental period is one month.  * &#x60;1 week&#x60; - The rental period is one week.  * &#x60;1 year&#x60; - The rental period is one year.  * &#x60;2 day&#x60; - The rental period is two days.  * &#x60;24 hour&#x60; - The rental period is 24 hours.  * &#x60;3 day&#x60; - The rental period is three days.  * &#x60;3 month&#x60; - The rental period is three months.  * &#x60;30 day&#x60; - The rental period is 30 days.  * &#x60;48 hour&#x60; - The rental period is 48 hours.  * &#x60;6 month&#x60; - The rental period is six months.  * &#x60;60 day&#x60; - The rental period is 60 days.  * &#x60;7 day&#x60; - The rental period is 7 days.  * &#x60;72 hour&#x60; - The rental period is 72 hours.  (required).</param>
 /// <param name="price">The default price to rent an episode. (required).</param>
 public OnDemandPageEpisodesRent(bool active = default(bool), PeriodEnum period = default(PeriodEnum), decimal?price = default(decimal?))
 {
     this.Active = active;
     this.Period = period;
     // to ensure "price" is required (not null)
     this.Price = price ?? throw new ArgumentNullException("price is a required property for OnDemandPageEpisodesRent and cannot be null");
 }
 public Period(XmlNode xmlNode)
 {
     XmlNodeList periodMultiplierNodeList = xmlNode.SelectNodes("periodMultiplier");
     if (periodMultiplierNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in periodMultiplierNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 periodMultiplierIDRef = item.Attributes["id"].Name;
                 XsdTypeInteger ob = XsdTypeInteger();
                 IDManager.SetID(periodMultiplierIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 periodMultiplierIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 periodMultiplier = new XsdTypeInteger(item);
             }
         }
     }
     
 
     XmlNodeList periodNodeList = xmlNode.SelectNodes("period");
     if (periodNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in periodNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 periodIDRef = item.Attributes["id"].Name;
                 PeriodEnum ob = PeriodEnum();
                 IDManager.SetID(periodIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 periodIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 period = new PeriodEnum(item);
             }
         }
     }
     
 
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Advances the given <see cref="DateTime"/> the given
        /// <paramref name="periodMultiplier"/> of time <paramref name="period"/>.
        /// </summary>
        /// <param name="date">The <see cref="DateTime"/> that is to be advanced.</param>
        /// <param name="periodMultiplier">The number of time period to advance.</param>
        /// <param name="period">The <see cref="PeriodEnum"/> used.</param>
        /// <param name="dayType">Type of the day.</param>
        /// <param name="businessDayConvention">The business day convention.</param>
        /// <returns>
        /// Returns the resulting <see cref="DateTime"/>.
        /// </returns>
        /// <overloads>
        /// Advances the given <see cref="DateTime"/>.
        /// </overloads>
        private DateTime Advance(DateTime date, int periodMultiplier, PeriodEnum period, DayTypeEnum dayType, BusinessDayConventionEnum businessDayConvention)
        {
            #region Assert validity of parameters

            if ((dayType != DayTypeEnum.Business) & (dayType != DayTypeEnum.Calendar))
            {
                throw new ArgumentOutOfRangeException(nameof(dayType), dayType, "Only 'DayTypeEnum.Business' and 'DayTypeEnum.Calendar' day types are currently supported.");
            }

            //  We can only use Business dayType for days intervals.
            //
            if ((dayType == DayTypeEnum.Business) & (period != PeriodEnum.D))
            {
                throw new NotSupportedException();
            }

            #endregion

            if (periodMultiplier == 0)
            {
                return(Roll(date, businessDayConvention));
            }
            if ((period == PeriodEnum.D) & DayTypeEnum.Business == dayType) //Business days
            {
                DateTime returnValue = date;
                if (periodMultiplier > 0)
                {
                    while (periodMultiplier > 0)
                    {
                        returnValue = returnValue.AddDays(1);
                        while (IsHoliday(returnValue))
                        {
                            returnValue = returnValue.AddDays(1);
                        }
                        periodMultiplier--;
                    }
                }
                else
                {
                    while (periodMultiplier < 0)
                    {
                        returnValue = returnValue.AddDays(-1);
                        while (IsHoliday(returnValue))
                        {
                            returnValue = returnValue.AddDays(-1);
                        }
                        periodMultiplier++;
                    }
                }
                return(returnValue);
            }
            var interval = new Period {
                period = period, periodMultiplier = periodMultiplier.ToString()
            };
            return(Roll(Add(date, interval), businessDayConvention));
        }
        public override void onKLineEvent(string symbol, PeriodEnum periodEnum)
        {
            var channel     = IdaxApiConstants.CHANNEL_KLINE;
            var sendMessage = new SendMessage();

            sendMessage.eventType = EventTypeEnum.ADD_CHANNEL.GetDisplayAttribute();
            sendMessage.channel   = channel.Replace("{symbol}", symbol).Replace("{period}", periodEnum.GetDisplayAttribute());

            createNewWebSocket(channel, sendMessage);
        }
Ejemplo n.º 5
0
        public void ParseTest0()
        {
            PeriodEnum actual = EnumHelper.Parse <PeriodEnum>('D');

            Assert.AreEqual(PeriodEnum.D, actual);

            try
            {
                actual = EnumHelper.Parse <PeriodEnum>('d');
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                //pass
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the month multiplier.
        /// </summary>
        /// <param name="period">The period.</param>
        /// <returns></returns>
        private static int GetMonthMultiplier(PeriodEnum period)
        {
            int multiplier = 1;

            switch (period)
            {
            case PeriodEnum.M:
                break;

            case PeriodEnum.Y:
                multiplier = 12;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(period), "period does not translate to a whole month");
            }
            return(multiplier);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Получаем отсортированный список курсов для выбранного периода и курса из переданного списка курсов в БД
        /// </summary>
        /// <param name="cursesDb"> список курсов из БД </param>
        /// <param name="periodEnum"> период за который необходимо взять информацию </param>
        /// <param name="curseRequest"> валюта </param>
        /// <returns></returns>
        private static CurseResponse GetCursesByTime(IEnumerable <Curse> cursesDb, PeriodEnum periodEnum, CurseRequest curseRequest)
        {
            var result = cursesDb.Where(x => x.Created >= DateTime.Now.AddMinutes(-(int)periodEnum) &&
                                        x.CurrenciesFrom == curseRequest.From &&
                                        x.CurrenciesTo == curseRequest.To)
                         .OrderBy(x => x.Created)
                         .Select(x => x.Value).ToList();

            return(new CurseResponse
            {
                Key = curseRequest.ToStringCurse(),
                FirstValue = result.FirstOrDefault(),
                LastValue = result.LastOrDefault(),
                MaxValue = !result.Any() ? 0 : result.Max(),
                MinValue = !result.Any() ? 0 : result.Min(),
                PeriodEnum = periodEnum
            });
        }
Ejemplo n.º 8
0
        public TeamStatisticModel GetTeamPeriodStatistics(int TeamId, PeriodEnum period, ExpectedLineUp expectedLinup, int secondaryTeamId, bool NoCache, int MinFullTeamRanking, int?ignoreTeamId = null)
        {
            var result  = new TeamStatisticModel();
            var dTo     = DateTime.Now;
            var dFrom   = new DateTime();
            var mapList = new List <string> {
                "nuke", "overpass", "cobblestone", "train", "inferno", "mirage", "cache", "vertigo", "ancient"
            };

            switch (period)
            {
            case PeriodEnum.ThreeMonths:
                dFrom         = dTo.AddMonths(-3);
                result.Period = "3 Months";
                break;

            case PeriodEnum.SixMonths:
                dFrom         = dTo.AddMonths(-6);
                result.Period = "6 Months";
                break;

            case PeriodEnum.Year:
                dFrom         = dTo.AddYears(-1);
                result.Period = "Year";
                break;
            }

            result.Maps = GetMapStatistics(TeamId, dFrom, dTo, expectedLinup, secondaryTeamId, NoCache, MinFullTeamRanking, ignoreTeamId);

            foreach (var map in mapList)
            {
                if (!result.Maps.Where(p => p.Map.ToLower() == map).Any())
                {
                    result.Maps.Add(new MapStatisticModel
                    {
                        Map = map,
                        FirstRound1HWinPercent = new Tuple <double, string>(0, ""),
                        FirstRound2HWinPercent = new Tuple <double, string>(0, "")
                    });
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
        ///<summary>
        ///</summary>
        ///<param name="startDate"></param>
        ///<param name="periodType"></param>
        ///<param name="periodMultiplier"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentOutOfRangeException"></exception>
        public static DateTime DateAdd(DateTime startDate, PeriodEnum periodType, int periodMultiplier)
        {
            switch (periodType)
            {
            case PeriodEnum.D:
                return(startDate.AddDays(periodMultiplier));

            case PeriodEnum.W:
                return(startDate.AddDays(periodMultiplier * 7));

            case PeriodEnum.M:
                return(startDate.AddMonths(periodMultiplier));

            case PeriodEnum.Y:
                return(startDate.AddYears(periodMultiplier));

            default:
                throw new ArgumentOutOfRangeException(nameof(periodType));
            }
        }
Ejemplo n.º 10
0
        private static string PeriodInterpereted(PeriodEnum per)
        {
            switch (per)
            {
            case PeriodEnum.CurrentYear:
                return("current year");

            case PeriodEnum.FromSignUp:
                return("sign up");

            case PeriodEnum.Last14Days:
                return("last 14 days");

            case PeriodEnum.Last7Days:
                return("last 7 days");

            case PeriodEnum.CustomDate:
                return("a custom date");

            default:
                return("");
            }
        }
 /// <summary>
 /// Intervals the string.
 /// </summary>
 /// <param name="periodLength">Length of the period.</param>
 /// <param name="periodTimeUnit">The period time unit.</param>
 /// <returns></returns>
 protected static string IntervalString(string periodLength, PeriodEnum periodTimeUnit)
 {
     return($"{periodLength}{periodTimeUnit}");
 }
Ejemplo n.º 12
0
        // Different time periods for activation of unit groups.
        // Set the lower triangle of matrix for recurrent weights to zero.

        public void setPeriods(PeriodEnum periodEnum)
        {
            switch (periodEnum)
            {
            case PeriodEnum.ALL_SAME:
                for (int i = 0; i < Owner.NeuronGroups; i++)
                {
                    Owner.Periods.Host[i] = 1;
                    for (int j = 0; j < Owner.NeuronsPerGroup; j++)
                    {
                        for (int k = 0; k < i * Owner.NeuronsPerGroup; k++)
                        {
                            Owner.RecurrentWeights.Host[i * Owner.HIDDEN_UNITS * Owner.NeuronsPerGroup
                                                        + j * Owner.HIDDEN_UNITS + k] = 0;
                        }
                    }
                }
                return;

            case PeriodEnum.EXPONENTIAL:
                for (int i = 0; i < Owner.NeuronGroups; i++)
                {
                    Owner.Periods.Host[i] = (int)Math.Pow(2, i);
                    for (int j = 0; j < Owner.NeuronsPerGroup; j++)
                    {
                        for (int k = 0; k < i * Owner.NeuronsPerGroup; k++)
                        {
                            Owner.RecurrentWeights.Host[i * Owner.HIDDEN_UNITS * Owner.NeuronsPerGroup
                                                        + j * Owner.HIDDEN_UNITS + k] = 0;
                        }
                    }
                }

                return;

            case PeriodEnum.FIBONACCI:
                for (int i = 0; i < Owner.NeuronGroups; i++)
                {
                    if (i == 0 || i == 1)
                    {
                        Owner.Periods.Host[i] = 1;
                    }
                    else
                    {
                        Owner.Periods.Host[i] = Owner.Periods.Host[(i - 1)]
                                                + Owner.Periods.Host[(i - 2)];
                    }
                    for (int j = 0; j < Owner.NeuronsPerGroup; j++)
                    {
                        for (int k = 0; k < i * Owner.NeuronsPerGroup; k++)
                        {
                            Owner.RecurrentWeights.Host[i * Owner.HIDDEN_UNITS * Owner.NeuronsPerGroup
                                                        + j * Owner.HIDDEN_UNITS + k] = 0;
                        }
                    }
                }
                return;

            case PeriodEnum.RANDOM_SERIE:
                Random rnd    = new Random();
                int    last   = 1;
                int    number = 1;
                for (int i = 0; i < Owner.NeuronGroups; i++)
                {
                    while (number == last)
                    {
                        number = rnd.Next(last, 2 + last);
                    }
                    if (i == 0)
                    {
                        Owner.Periods.Host[i] = 1;
                    }
                    else
                    {
                        Owner.Periods.Host[i] = number;
                    }
                    for (int j = 0; j < Owner.NeuronsPerGroup; j++)
                    {
                        for (int k = 0; k < i * Owner.NeuronsPerGroup; k++)
                        {
                            Owner.RecurrentWeights.Host[i * Owner.HIDDEN_UNITS * Owner.NeuronsPerGroup
                                                        + j * Owner.HIDDEN_UNITS + k] = 0;
                        }
                    }
                    last = number;
                }
                return;

            case PeriodEnum.QUADRATIC:
                for (int i = 0; i < Owner.NeuronGroups; i++)
                {
                    Owner.Periods.Host[i] = (int)Math.Pow(i + 1, 2);
                    for (int j = 0; j < Owner.NeuronsPerGroup; j++)
                    {
                        for (int k = 0; k < i * Owner.NeuronsPerGroup; k++)
                        {
                            Owner.RecurrentWeights.Host[i * Owner.HIDDEN_UNITS * Owner.NeuronsPerGroup
                                                        + j * Owner.HIDDEN_UNITS + k] = 0;
                        }
                    }
                }
                return;
            }
        }
Ejemplo n.º 13
0
 /**
  * onKLineEvent
  *
  * @param symbol     market (one or coma-separated) symbol(s) to subscribe to
  * @param periodEnum kline period {@link PeriodEnum periodEnum}
  */
 public abstract void onKLineEvent(string symbol, PeriodEnum periodEnum);