Exemplo n.º 1
0
 protected void AddTimeSeriesControl(TrendChartDashboardElement elem, WAFPanel container)
 {
     WAFPanel pnlTimeSeriesContainer = new WAFPanel();
     pnlTimeSeriesContainer.Width = new Unit(98, UnitType.Percentage);
     pnlTimeSeriesContainer.Inline = true;
     pnlTimeSeriesContainer.Border = true;
     pnlTimeSeriesContainer.Text = Utils.GetFriendlyName(elem.TrendElementClass.Replace("TimeSeries", "") + " - " + WAFContext.Session.GetEnumName(elem.Period));
     pnlTimeSeriesContainer.Height = new Unit(440);
     pnlTimeSeriesContainer.ScrollBars = ScrollBars.None;
     TimeSeriesChart timeSeriesChart = new TimeSeriesChart();
     timeSeriesChart.Width = new Unit(870, UnitType.Pixel);
     timeSeriesChart.Period = elem.Period;
     timeSeriesChart.MinimumTickSize = WAF.Presentation.Web.Controls.Charts.TimeSeriesTickSize.Day;
     timeSeriesChart.TimeSeriesClass = elem.TrendElementClass;
     timeSeriesChart.Height = new Unit(400, UnitType.Pixel);
     pnlTimeSeriesContainer.Controls.Add(timeSeriesChart);
     container.Controls.Add(pnlTimeSeriesContainer);
 }
Exemplo n.º 2
0
        /// <summary>
        /// This code is based on the code developed by Chris Bayley
        /// </summary>
        public void Example02()
        {
            Console.WriteLine("Running Example02...");

            // Setup
            var statName = "jSharpe";
            var low      = 1.5M;
            var high     = 2.5M;
            var howManySystemsInResult = 20;

            H1 = String.Format("Best by {0} of 2015. ( {1} < {0} < {2} )", statName, low, high);

            // Select systems according our setup
            var selectedStats = from stat in C2STATS
                                where stat.StatName == statName
                                //                  && stat.CalcedWhen.Year == 2015
                                && stat.StatValueVal > low &&
                                stat.StatValueVal < high
                                select stat;

            // See tmp result:
            TABLE = selectedStats;

            Console.WriteLine("------ selectedStats --------");
            foreach (var stat in selectedStats)
            {
                Console.WriteLine($" StatName: {stat.StatName}, Value: {stat.StatValueVal}");
            }

            H3 = String.Format("We have {0} systems in the range", selectedStats.Count());

            // Sort DESC and take first highest values
            var takeBest = (from stat in selectedStats
                            orderby stat.StatValueVal descending
                            select stat).Take(howManySystemsInResult);

            // See tmp result:
            TABLE = takeBest; HR();

            Console.WriteLine("------ takeBest --------");
            foreach (var stat in takeBest)
            {
                Console.WriteLine($" StatName: {stat.StatName}, Value: {stat.StatValueVal}");
            }

            // Add names
            var withNames = from statItem in takeBest
                            join syst in C2SYSTEMS on statItem.SystemId equals syst.SystemId
                            select new
            {
                Name       = syst.SystemName,
                Statistics = statItem.StatValueVal,
                ID         = statItem.SystemId,
                Added      = syst.Added
            };

            H2    = "The best";
            TABLE = withNames; HR();

            // Get just systems ids
            var systemsIds = from item in withNames.ToList() select item.ID;

            systemsIds = systemsIds.ToList();


            // Equities in one chart:
            H1 = "A common chart";

            ITimeSeriesChart commonChart = new TimeSeriesChart();

            commonChart.Name = "Equities";
            commonChart.Add(GetEquities(systemsIds));
            TSCHART = commonChart; HR();

            // Stop ("return") here for now and look at results.
            // Select some good systems and look at them then.
            // return;

            // =======================================================
            // Continuing after the first run.
            // =======================================================

            /*
             * It seems good systems are:
             * - "ASCENDANT TY" - 90325773
             * - "Super Model II" - 91758928
             * - "Midcap Daytrader ITF"  - 84939785
             * - "DJ Profit" - 92914206
             *
             * So look at them:
             *
             */
            H1 = "Selected systems";



            Console.WriteLine("------ creating charts --------");
            foreach (var id in systemsIds.ToArray())
            {
                var sysChart = GetC2SYSTEM(id).SystemChart();
                sysChart.Height = 1000;
                sysChart.Width  = 1000;
                CHART           = sysChart;

                Console.WriteLine($" System: {id}, sysChart.Name: {sysChart.Name}");

                /*
                 * HR();
                 * FRAME = new Frame(){
                 *        Src = "https://collective2.com/system" + id.ToString(),
                 *        Height = 600,
                 *        Width = 800
                 * };
                 * HR();
                 */
            }

            Console.WriteLine("Example02 done. Press ENTER");
            Console.ReadLine();
        }