Esempio n. 1
0
        public void AddValue(double value, DateTime?dt = null)
        {
            if (Equity.Count == 0)
            {
                Returns.Add(0);
                Changes.Add(0);
            }
            else
            {
                Returns.Add(Equity.Last() != 0 ? value / Equity.Last() - 1 : 0);
                Changes.Add(value - Equity[Equity.Count - 1]);
            }

            Equity.Add(value);
            _maxEquity = Math.Max(_maxEquity, value);
            DrawdownPct.Add(_maxEquity == 0 ? 0 : value / _maxEquity - 1);
            DrawdownAmt.Add(Equity.Last() - _maxEquity);

            if (dt != null)
            {
                AddDrawdownLengths(dt.Value);
            }

            Dates.Add(dt);
        }
Esempio n. 2
0
        public void AddChange(double change, DateTime?dt = null)
        {
            if (Equity.Count == 0)
            {
                Returns.Add(0);
                Equity.Add(change);
            }
            else
            {
                Returns.Add(Equity.Last() != 0 ? change / Equity.Last() : 0);
                Equity.Add(Equity[Equity.Count - 1] + change);
            }

            Changes.Add(change);
            _maxEquity = Math.Max(_maxEquity, Equity.Last());
            DrawdownPct.Add(_maxEquity == 0 ? 0 : Equity.Last() / _maxEquity - 1);
            DrawdownAmt.Add(Equity.Last() - _maxEquity);

            if (dt != null)
            {
                AddDrawdownLengths(dt.Value);
            }

            Dates.Add(dt);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ret">Net Return</param>
        public void AddReturn(double ret, DateTime?dt = null)
        {
            if (Equity.Count == 0)
            {
                Equity.Add(1);
                Changes.Add(0);
            }
            else
            {
                Equity.Add(Equity.Last() * (1 + ret));
                Changes.Add(Equity[Equity.Count - 1] - Equity[Equity.Count - 2]);
            }

            _maxEquity = Math.Max(_maxEquity, Equity.Last());
            Returns.Add(ret);
            DrawdownPct.Add(_maxEquity == 0 ? 0 : Equity.Last() / _maxEquity - 1);
            DrawdownAmt.Add(Equity.Last() - _maxEquity);

            if (dt != null)
            {
                AddDrawdownLengths(dt.Value);
            }

            Dates.Add(dt);
        }
Esempio n. 4
0
        //// Methods ////

        /// <summary>
        /// Generates list with the dates of the chosen month
        /// <para>The list starts on the last monday before the month's start,
        /// and ends on the final sunday after the month</para>
        /// </summary>
        public void GetCalendar()
        {
            //Reads the month and year
            Month = Global.MainWindow.cmbMonth.SelectedIndex + 1;
            Year  = int.Parse(Global.MainWindow.cmbYear.Text);

            //Finds first date of list
            DateTime listStart = new DateTime(Year, Month, 1);

            while (listStart.DayOfWeek != DayOfWeek.Monday)
            {
                listStart = listStart.AddDays(-1);
            }

            //Finds final date of list
            DateTime listEnd = new DateTime(Year, Month, DateTime.DaysInMonth(Year, Month));

            while (listEnd.DayOfWeek != DayOfWeek.Sunday)
            {
                listEnd = listEnd.AddDays(1);
            }

            //Fills list with dates
            DateTime nextDate = listStart;

            while (nextDate.AddDays(-1) != listEnd)
            {
                Dates.Add(new Date(nextDate));
                nextDate = nextDate.AddDays(1);
            }

            MonthName = Global.MainWindow.cmbMonth.Text.ToString();
        }
Esempio n. 5
0
        protected void readData()
        {
            string valsStr;

            while ((valsStr = Reader.ReadLine()) != null)
            {
                string[] valsArr = valsStr.Split(';');
                bool     isFirst = true;
                int      index   = 0;
                foreach (string valStr in valsArr)
                {
                    if (!isFirst)
                    {
                        double val    = Convert.ToDouble(valStr);
                        int    header = Headers[index];
                        Data[header].Avg += val;
                        if (Data[header].Min > val)
                        {
                            Data[header].Min = val;
                        }
                        if (Data[header].Max < val)
                        {
                            Data[header].Max = val;
                        }
                        Data[header].Count++;
                        index++;
                    }
                    else
                    {
                        Dates.Add(DateTime.Parse(valStr));
                    }
                    isFirst = false;
                }
            }
        }
Esempio n. 6
0
 public async Task OnGetAsync()
 {
     for (int i = 15; i <= 21; i++)
     {
         Dates.Add(new DateTime(2019, 04, i));
     }
     Tasks = await new UnitOfWork.CalendarUoW(db).GetTasks(Dates[0], Dates[Dates.Count - 1]);
 }
Esempio n. 7
0
 private void CalendarDatesChangedMethod(SelectedDatesCollection source)
 {
     Dates.Clear();
     foreach (var item in source)
     {
         Dates.Add(item.Date);
     }
 }
Esempio n. 8
0
        public Sequence(string stringvalue) : this()
        {
            try
            {
                if (!String.IsNullOrEmpty(stringvalue.Trim()))
                {
                    var items  = stringvalue.Replace("\"", "").Split(',').ToList();
                    var isdual = TestIsDual(items);
                    if (isdual)
                    {
                        for (var i = 0; i < items.Count; i = i + 2)
                        {
                            if (i + 1 < items.Count)
                            {
                                var      first  = items[i].Trim();
                                var      second = items[i + 1].Trim();
                                DateTime date;
                                if (DateTime.TryParseExact(first, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                                {
                                    var value = double.Parse(second);
                                    Dates.Add(new BrowserDate(date));
                                    Values.Add(value);
                                }
                                else if (DateTime.TryParseExact(first, "d/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                                {
                                    var value = double.Parse(second);
                                    Dates.Add(new BrowserDate(date));
                                    Values.Add(value);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (var i = 0; i < items.Count; ++i)
                        {
                            var first = items[i].Trim();

                            DateTime date;
                            if (DateTime.TryParseExact(first, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                            {
                                Dates.Add(new BrowserDate(date));
                            }
                            else if (DateTime.TryParseExact(first, "d/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                            {
                                Dates.Add(new BrowserDate(date));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ErrorLogger.CreateException(ex);
            }
        }
        public void Add(DateTime date, T[] row)
        {
            Dates.Add(date);
            var len = Math.Min(row.Length, Values.Length);

            for (int i = 0; i < len; i++)
            {
                Values[i].Add(row[i]);
            }
        }
Esempio n. 10
0
        public void sortDates()
        {
            List <Date> tmp = Dates.OrderBy(Date => Date.date).ToList();

            Dates.Clear();
            for (int i = tmp.Count - 1; i >= 0; i--)
            {
                Dates.Add(tmp[i]);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Add/remove today day
        /// </summary>
        public void AddDate()
        {
            if (!Dates.Contains(DateTime.Today))
            {
                Dates.Add(DateTime.Today);
            }
            else
            {
                Dates.Remove(DateTime.Today);
            }

            NotifyPropertyChanged(nameof(Dates));
        }
Esempio n. 12
0
        public ActivitiesPage()
        {
            InitializeComponent();
            this.DataContext = this;

            DateTime now = DateTime.Now.Date;

            for (int i = 0; i > -10; i--)
            {
                String dateStr = now.AddDays(i).ToString("MMMM dd, yyyy");
                Dates.Add(dateStr);
            }
        }
Esempio n. 13
0
 public void Date(string NPC)
 {
     SetDateable(NPC, true);
     if (Modworks.Player.GetFriendshipPoints(NPC) < 2000)
     {
         Modworks.Player.SetFriendshipPoints(NPC, 2000);
     }
     Modworks.Player.SetFriendshipStatus(NPC, FriendshipStatus.Dating);
     Spouses.Remove(NPC);
     Engagements.Remove(NPC);
     Divorces.Remove(NPC);
     Dates.Add(NPC);
 }
Esempio n. 14
0
        /// <summary>
        /// Adds today's date if it is not already added
        /// </summary>
        public void AddDate()
        {
            if (!Dates.Contains(DateTime.Today))
            {
                Dates.Add(DateTime.Today);
            }
            else
            {
                Dates.Remove(DateTime.Today);
            }

            NotifyPropertyChanged("Dates");           // to changed si nyní kolekce Dates zavolá sama
        }
Esempio n. 15
0
        /// <summary>
        /// Generate Dates from the provided StartDate and Duration.
        /// </summary>
        /// <returns>A copy of itself to faciliate chaining.</returns>
        public Configuration GenerateDates()
        {
            DateTime date = DateTime.Parse(StartDate);

            // Loop through the range {StartDate, StartDate + Duration, StartDate + 2*Duration, ..., Today}
            // Ensure we get at least the start date in there even if duration is huge
            do
            {
                Dates.Add(date);
                date = date.AddMonths(Duration);
            } while (date.AddMonths(Duration) <= DateTime.Now);

            return(this);
        }
 private void Initialization(WeatherResponse result)
 {
     CompleteWeatherList = result.list.ToList();
     Lat     = result.city.coord.lat.ToString();
     Long    = result.city.coord.lon.ToString();
     Country = result.city.country;
     foreach (var item in CompleteWeatherList)
     {
         Dates.Add(new DateList()
         {
             Date_Time = item.dt_txt
         });
     }
 }
Esempio n. 17
0
        private void FillDaysCollection()
        {
            for (int i = 0; i < 15; i++)
            {
                DateTime date = DateTime.Today.AddDays(i);

                if (date.DayOfWeek == 0 || date.DayOfWeek == DayOfWeek.Saturday)
                {
                    continue;
                }
                else
                {
                    Dates.Add(date);
                }
            }
        }
Esempio n. 18
0
        public virtual DateValue GetDate(string DateType)
        {
            DateValue DateValue;

            DateValue = Dates.FirstOrDefault(p => p.DateType == DateType);

            if (DateValue == null)
            {
                DateValue = new DateValue()
                {
                    Consumer = this, DateType = DateType
                };
                Dates.Add(DateValue);
            }

            return(DateValue);
        }
Esempio n. 19
0
        /// <summary>
        ///
        /// </summary>
        private void parseStringValue()
        {
            List <String> parts = new List <string>(_Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));

            foreach (String s in parts)
            {
                List <String> seqParts = new List <string>(s.Split(new string[] { "\"", ",", " " }, StringSplitOptions.RemoveEmptyEntries));
                DateTime?     thisDate = parseDate(seqParts[0]);

                if (thisDate.HasValue)
                {
                    Dates.Add(thisDate.Value);
                    double value = -1;
                    double.TryParse(seqParts[1], out value);
                    Values.Add(value);
                }
            }
        }
Esempio n. 20
0
        private void LoadListValues()
        {
            var dateOptionsWrapper = new List <DateOptionWrapper>();

            if (DateEvent.DateOptions != null && DateEvent.DateOptions.Count != 0)
            {
                foreach (DateOption dE in DateEvent.DateOptions)
                {
                    dateOptionsWrapper.Add(new DateOptionWrapper(dE));
                    Dates.Add(dE.Date);
                }

                //It works with CompareTo(DateOptionWrapper)
                dateOptionsWrapper.Sort();

                Dates.Sort();
                DateOptions = new ObservableCollection <DateOptionWrapper>(dateOptionsWrapper);
            }
        }
Esempio n. 21
0
File: Task.cs Progetto: snuuby/P3-
        public Task(string name, Customer assignedCustomer, Address destination,
                    double income, List <DateTime> Ldates, string description, string workPhoneNumber, int phase)
        {
            this.Phase       = phase;
            this.Name        = name;
            this.Customer    = assignedCustomer;
            this.Destination = destination;
            this.Income      = income;
            this.Description = description;
            foreach (DateTime date in Ldates)
            {
                DateTimes temp = new DateTimes();
                temp.Date = date;
                Dates.Add(temp);
            }
            this.WorkPhoneNumber = workPhoneNumber;

            this.IsPaused  = false;
            this.PhotoPath = "assets/images/tasks/placeholder.png";
        }
Esempio n. 22
0
        public void ProcessingData()
        {
            List <string[]> detailedTransactions = new List <string[]>();

            string filePath = @"C:\Users\mindaugas.pikelis\Desktop\SMELIO DEZE\MobilePay\data.txt";

            Transactions = File.ReadAllLines(filePath).ToList();
            Transactions.Sort();

            foreach (string line in Transactions)
            {
                detailedTransactions.Add(line.Split(" "));
            }

            foreach (string[] line in detailedTransactions)
            {
                Dates.Add(DateTime.Parse(line[0]));
                MerchantNames.Add(line[1]);
                Decimal.TryParse(line[2], out decimal value);
                Amounts.Add(value);
            }
        }
Esempio n. 23
0
        private void DetermineDates()
        {
            Dates.Clear();
            DateTime startDate  = GetStartDate();
            int      month      = startDate.Month;
            int      year       = startDate.Year;
            var      dayOfWeek  = (int)startDate.DayOfWeek;
            DateTime time2      = startDate.AddDays(-7.0);
            int      startIndex = StartIndex;

            while (startIndex <= LastIndex)
            {
                double xValue     = startIndex;
                bool   startWeek  = false;
                bool   startMonth = false;
                bool   startYear  = false;
                if (((((int)startDate.DayOfWeek < dayOfWeek) || (startDate.DayOfWeek == DayOfWeek.Monday)) ||
                     (startDate.Subtract(time2).Days >= 7)) &&
                    ((startDate.DayOfWeek != DayOfWeek.Saturday) && (startDate.DayOfWeek != DayOfWeek.Sunday)))
                {
                    time2     = startDate;
                    startWeek = true;
                }
                dayOfWeek = (int)startDate.DayOfWeek;
                if (startDate.Month != month)
                {
                    month      = startDate.Month;
                    startMonth = true;
                }
                if (startDate.Year != year)
                {
                    year      = startDate.Year;
                    startYear = true;
                }
                Dates.Add(new XAxisLabelInfo(startDate, xValue, startWeek, startMonth, startYear));
                GetNextDate(ref startDate, ref startIndex);
            }
        }
Esempio n. 24
0
        /// <summary>
        ///
        /// </summary>
        private void parseStringValue()
        {
            List <String> parts = new List <string>(_Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));

            //foreach (String s in parts)
            for (int i = 0; i < parts.Count; i += 2)
            {
                string s = parts[i];

                List <String> seqParts = new List <string>(s.Split(new string[] { "\"", ",", " " }, StringSplitOptions.RemoveEmptyEntries));
                DateTime?     thisDate = parseDate(seqParts[0]);

                if (thisDate.HasValue)
                {
                    Dates.Add(thisDate.Value);

                    string[] valParts = parts[i + 1].Split(new string[] { "\"", ",", " " }, StringSplitOptions.RemoveEmptyEntries);

                    double value = -1;
                    double.TryParse(valParts[0], out value);
                    Values.Add(value);
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Loads Graph data
        /// Gets the turnovers for each day from a hardcoded Starting point.
        /// </summary>
        private void LoadGlobalGraph()
        {
            DateTime Start = new DateTime(2018, 5, 20);
            TimeSpan ts    = new TimeSpan(24, 0, 0);
            DateTime End   = DateTime.Now;

            TotalGlobalByEvening.Clear();
            TotalVolunteerByEvening.Clear();



            while (Start < (End + ts))
            {
                decimal totalGlobal    = RepositoryLocator.Instance.GetOrderLineRepository().GetGlobalTurnoverByDate(Start);
                decimal totalVolunteer = RepositoryLocator.Instance.GetOrderLineRepository().GetTotalVolunteerByDate(Start);
                TotalGlobalByEvening.Add(totalGlobal);
                TotalVolunteerByEvening.Add(totalVolunteer);
                Dates.Add($"{Start.Day}/{Start.Month}");
                Start = Start + ts;
            }

            SeriesCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Global",
                    Values = new ChartValues <decimal>(TotalGlobalByEvening)
                },

                new LineSeries
                {
                    Title  = "Volunteer",
                    Values = new ChartValues <decimal>(TotalVolunteerByEvening)
                }
            };
        }
Esempio n. 26
0
 protected override void ActivateView(string viewName, IDictionary <string, object> parameters)
 {
     Dates.Add(string.Format("Activated: {0}", DateTime.Now));
     GoToVisualState("ShowState", true);
 }
Esempio n. 27
0
 protected override void InitializeVm()
 {
     Dates.Add(string.Format("Initialized: {0}", DateTime.Now));
     GoToVisualState("HideState", false);
 }
Esempio n. 28
0
 public void AddDate()
 {
     Dates.Add(DateTime.Today);
     NotifyPropertyChanged("Dates");
 }
        private void Create()
        {
            int          duration  = Duration;
            int          sign      = 1;
            Del          compare   = (a, b) => a < b;
            var          ndt       = new BusinessDate(StartDate);
            var          pdt       = new BusinessDate(StartDate);
            BusinessDate beginDate = StartDate;
            BusinessDate endDate   = EndDate;

            if ((Stub == Stub.SHORT_FIRST || Stub == Stub.LONG_FIRST))
            {
                sign      = -1;
                compare   = (a, b) => a > b;
                ndt       = new BusinessDate(EndDate);
                pdt       = new BusinessDate(EndDate);
                beginDate = EndDate;
                endDate   = StartDate;
            }

            int n = 1;

            Dates.Add(ndt);
            while (compare(ndt, endDate))
            {
                switch (Frequency)
                {
                case Frequency.DAY:
                    ndt = beginDate.AddDays(sign * duration * n++);
                    break;

                case Frequency.WEEK:
                    duration = 7;
                    goto case Frequency.DAY;

                case Frequency.FORTNIGHT:
                    duration = 14;
                    goto case Frequency.DAY;

                case Frequency.MONTH:
                    ndt = beginDate.AddMonths(sign * duration * n++);
                    break;

                case Frequency.QUARTER:
                    duration = 3;
                    goto case Frequency.MONTH;

                case Frequency.SEMIANNUAL:
                    duration = 6;
                    goto case Frequency.MONTH;

                case Frequency.YEAR:
                    ndt = beginDate.AddYears(sign * duration * n++);
                    break;
                }

                Dates.Add(ndt);
                Periods.Add(new Period(pdt, ndt));
                pdt = ndt;
            }

            if ((Stub == Stub.SHORT_FIRST || Stub == Stub.LONG_FIRST))
            {
                Dates[0] = StartDate;
            }
            else if ((Stub == Stub.SHORT_LAST || Stub == Stub.LONG_LAST))
            {
                Dates[Dates.Count - 1] = EndDate;
            }
        }
Esempio n. 30
0
        //Parse
        private void ParseRSS()
        {
            try
            {
                XmlDocument rssXmlDoc = new XmlDocument();
                // Load the RSS file from the RSS URL
                rssXmlDoc.Load(URL);
                //Store initial values - title and link
                XmlNode TL = rssXmlDoc.SelectSingleNode("rss/channel");
                this.Title         = TL.SelectSingleNode("title").InnerText.Trim();
                this.Link          = TL.SelectSingleNode("link").InnerText.Trim();
                this.Description   = TL.SelectSingleNode("description").InnerText.Trim();
                this.Language      = TL.SelectSingleNode("language").InnerText.Trim();
                this.Copyright     = TL.SelectSingleNode("copyright").InnerText.Trim();
                this.PublishedDate = TL.SelectSingleNode("pubDate").InnerText.Trim();

                // Parse the Items in the RSS file
                XmlNodeList         rssNodes = rssXmlDoc.SelectNodes("rss/channel/item");
                XmlNamespaceManager dcMgr    = new XmlNamespaceManager(rssXmlDoc.NameTable);
                dcMgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
                foreach (XmlNode rssNode in rssNodes)
                {
                    //Title
                    XmlNode rssSubNode = rssNode.SelectSingleNode("title");
                    string  title      = rssSubNode != null ? rssSubNode.InnerText : "";

                    //Link/Url
                    rssSubNode = rssNode.SelectSingleNode("link");
                    string link = rssSubNode != null ? rssSubNode.InnerText : "";

                    //Description
                    rssSubNode = rssNode.SelectSingleNode("description");
                    string description = rssSubNode != null ? rssSubNode.InnerText : "";

                    //Published date
                    rssSubNode = rssNode.SelectSingleNode("pubDate");
                    string pubDate = rssSubNode != null ? rssSubNode.InnerText : "";

                    //Creator
                    rssSubNode = rssNode.SelectSingleNode("dc:creator", dcMgr);
                    string creator = rssSubNode != null ? rssSubNode.InnerText : "";

                    //Date
                    rssSubNode = rssNode.SelectSingleNode("dc:date", dcMgr);
                    string date = rssSubNode != null ? rssSubNode.InnerText : "";

                    //Categories
                    List <Item.Category> categories = new List <Item.Category>();
                    foreach (XmlNode c in rssNode.SelectNodes("category"))
                    {
                        categories.Add(new Item.Category(c.Attributes["domain"].Value, c.InnerText.Trim()));
                    }

                    Titles.Add(title);
                    Links.Add(link);
                    Descriptions.Add(description);
                    PublishedDates.Add(pubDate);
                    Creators.Add(creator);
                    Dates.Add(date);
                    TitlesLinks.Add(title + " - " + link);

                    Items.Add(new Item(title, link, description, pubDate, creator, date, categories));
                }
            }
            catch (Exception e) { throw e; }
        }