Beispiel #1
0
        /// <summary>
        /// Public entry point
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public ChartValues <DateTimePoint> BackFillList(ChartValues <DateTimePoint> list)
        {
            list.ToList().ForEach(x => x.DateTime = RoundDown(x.DateTime, TimeSpan.FromMinutes(datePointTimeIntervalDays)));
            ChartValues <DateTimePoint> completeList = GetListAllDates(list);

            return(SortList(completeList));
        }
        private void Read3()
        {
            // double x = 1528.5;
            // double y = 6.55733501913825e-46;
            float x;
            float y;
            List <(ushort x, ushort y)> ulist  = new List <(ushort x, ushort y)>();
            List <(float x, float y)>   fllist = new List <(float x, float y)>();
            var list = ChartValues.ToList();

            while (IsReading)
            {
                Thread.Sleep(500);
                ushort[] b = ModbusCommand.command.Operation(Getter.channel_spectral_ch1);
                ulist.Add((b[0], b[1]));
                x = ((float)b[0]) / 1000 + 1520;
                y = Utility.GetSingle(0, b[1]);

                fllist.Add((x, y));
                MeasureModel m = new MeasureModel
                {
                    ValueX = (double)x,
                    ValueY = (double)y
                };
                list.Add(m);
                try
                {
                    list = list.OrderBy(t => t.ValueX).ToList();
                    ChartValues.Clear();
                    ChartValues.AddRange(list);
                }
                catch (Exception e)
                {
                    var t = e;
                }
                //   ChartValues = v1;
                //ChartValues.Add(new MeasureModel
                //{
                //    ValueX = x,
                //    ValueY = y

                //    //     DateTime = now,
                //    //    Value = _trend
                //});
                // SetAxisLimits(now);
                //  if (ChartValues.Count > 100) ChartValues.RemoveAt(0);
            }


            //var x1 = fllist.Select(b => b.x);
            //var y1 = fllist.Select(b => b.y);
            //float maxx = x1.Max();
            //float minx = x1.Min();
            //float maxy = y1.Max();
            //float miny = y1.Min();
        }
        private void Read1()
        {
            // double x = 1528.5;
            // double y = 6.55733501913825e-46;
            double x = 1528;
            double y;
            var    r = new Random();
            var    v = ChartValues.ToList();

            while (IsReading)
            {
                Thread.Sleep(150);

                x = r.Next(1528, 1629) + r.NextDouble();
                y = r.Next(5, 6) + r.NextDouble();
                MeasureModel m = new MeasureModel
                {
                    ValueX = x,
                    ValueY = y
                };
                v.Add(m);
                try
                {
                    v = v.OrderBy(t => t.ValueX).ToList();
                    ChartValues.Clear();
                    ChartValues.AddRange(v);
                }
                catch (Exception e) {
                    var t = e;
                }
                //   ChartValues = v1;
                //ChartValues.Add(new MeasureModel
                //{
                //    ValueX = x,
                //    ValueY = y

                //    //     DateTime = now,
                //    //    Value = _trend
                //});
                // SetAxisLimits(now);
                if (ChartValues.Count > 100)
                {
                    ChartValues.RemoveAt(0);
                }
            }
        }
        public void PopulateChartPrice(string ticker)
        {
            // Get historical data
            List <Object> result = bbH.GetPriceVolumeValue(ticker, null, "20180101", "20180220");
            List <double> price  = (List <double>)result[1];

            ChartValues <double> valueChart = new ChartValues <double>();

            for (int i = 0; i < price.Count; i++)
            {
                valueChart.Add(price[i]);
            }

            // Compute Volatility
            ChartValues <double> valueVolatility = new ChartValues <double>();
            double V0 = price[0];

            for (int i = 0; i < price.Count; i++)
            {
                double Vt = price[i];
                valueVolatility.Add(((Vt / V0) - 1) * 100); // peut etre *100 à voir selon le résultat
            }

            NameAsset = ticker;

            // Compute Performance
            ChartValues <double> valuePerformance = new ChartValues <double>();

            for (int i = 0; i < price.Count; i++)
            {
                double resultPerf = PopulationStandardDeviation(valueVolatility.Take(i).ToList());
                valuePerformance.Add(resultPerf);
            }


            AssetValue = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Asset Value",
                    Values = valueChart
                }
            };

            AssetValuePerformance = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Performance",
                    Values = valuePerformance
                }
            };

            AssetValueVolatility = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Volatility",
                    Values = valueVolatility
                }
            };


            // Here for AssetReaserch
            AssetResarch.ValuePerformance = valuePerformance.ToList();
            AssetResarch.Value            = valueChart.ToList();
            AssetResarch.ValueVolatility  = valueVolatility.ToList();
        }