示例#1
0
        public void LoadAll()
        {
            List <string> LSProducts = this.GetProducts();

            foreach (TimeFrame TF in LTFrames)
            {
                this.Load(LSProducts, TF);
            }

            foreach (Thread Thrd in LThreadLoad)
            {
                Thrd.Join();
            }

            bIsLoaded = true;
        }
示例#2
0
        public ChartPointPredition PredictNextSpecified(string product, List <ChartPoint> LCPoints, List <ChartPoint> LCPointsToCompare, TimeFrame TFrame, int iRound, double[] IASymiliarities)
        {
            List <DateTime>       LDTSetTime       = (from CP in LCPoints select CP.Time).ToList();
            List <List <double> > LLDSets          = new List <List <double> >();
            List <List <double> > LLDSetsToCampare = new List <List <double> >();
            int iDeep = IASymiliarities.Length;

            //int[] IADeeps = new int[4] { iDeep, iDeep, iDeep, iDeep };

            LLDSets.Add((from CP in LCPoints select Math.Round(CP.Raise, iRound)).ToList());
            LLDSets.Add((from CP in LCPoints select Math.Round(CP.Fall, iRound)).ToList());
            LLDSets.Add((from CP in LCPoints select Math.Round(CP.Peak, iRound)).ToList());
            LLDSets.Add((from CP in LCPoints select Math.Round(CP.Base, iRound)).ToList());
            LLDSetsToCampare.Add((from CP in LCPointsToCompare select Math.Round(CP.Raise, iRound)).ToList());
            LLDSetsToCampare.Add((from CP in LCPointsToCompare select Math.Round(CP.Fall, iRound)).ToList());
            LLDSetsToCampare.Add((from CP in LCPointsToCompare select Math.Round(CP.Peak, iRound)).ToList());
            LLDSetsToCampare.Add((from CP in LCPointsToCompare select Math.Round(CP.Base, iRound)).ToList());

            ConcurrentDictionary <int, List <int> > CDILIMatches = new ConcurrentDictionary <int, List <int> >();
            List <Thread> LThread = new List <Thread>();

            /*for (int i = 0; i < LLDSetsToCampare.Count; i++)
             *  this.AddPredictionSpecified(LLDSets, LLDSetsToCampare, i, ref CDILIMatches, LDTSetTime, IASymiliarities, TFrame);*/

            LThread.Add(new Thread(() => AddPredictionSpecified(LLDSets, LLDSetsToCampare, 0, ref CDILIMatches, LDTSetTime, IASymiliarities, TFrame)));
            LThread.Add(new Thread(() => AddPredictionSpecified(LLDSets, LLDSetsToCampare, 1, ref CDILIMatches, LDTSetTime, IASymiliarities, TFrame)));
            LThread.Add(new Thread(() => AddPredictionSpecified(LLDSets, LLDSetsToCampare, 2, ref CDILIMatches, LDTSetTime, IASymiliarities, TFrame)));
            LThread.Add(new Thread(() => AddPredictionSpecified(LLDSets, LLDSetsToCampare, 3, ref CDILIMatches, LDTSetTime, IASymiliarities, TFrame)));

            foreach (Thread Thrd in LThread)
            {
                Thrd.Priority = ThreadPriority.Highest;
                Thrd.Start();
            }

            foreach (Thread Thrd in LThread)
            {
                Thrd.Join();
            }

            return(new ChartPointPredition(CDILIMatches, LLDSets, TFrame, product, LCPointsToCompare[0]));
        }
示例#3
0
        public void Load(List <string> LSProducts)
        {
            Thread ThrdMain = new Thread(delegate()
            {
                LTread = new List <Thread>();
                foreach (string product in LSProducts)
                {
                    LTread.Add(new Thread(delegate() { this.Update(product); }));
                    LTread.Last().Priority = ThreadPriority.Highest;
                    LTread.Last().Start();
                }

                foreach (Thread Thrd in LTread)
                {
                    Thrd.Join();
                }

                bIsLoaded = true;
            });

            ThrdMain.Priority = ThreadPriority.Highest;
            ThrdMain.Start();
        }
示例#4
0
        public ChartPointsPredition PredictNextSpecified(string product, List <ChartPoint> LCPoints, List <ChartPoint> LCPointsToCompare, TimeFrame TFrame, int iRound, int iMinMatches, double dMinResolution, int ahead, double[] DAWeightFactors)
        {
            List <DateTime> LDTSetTime = (from CP in LCPoints select CP.Time).ToList();

            double[][] DJSets = new double[5][];

            int iDeep     = LCPointsToCompare.Count;
            int iSetCount = LCPoints.Count;

            LCPointsToCompare = LCPointsToCompare.OrderByDescending(CP => CP.Time).ToList();

            for (int id = 0; id < DJSets.Length; id++)
            {
                DJSets[id] = new double[iSetCount];

                for (int i = 0; i < LCPoints.Count; i++)
                {
                    DJSets[id][i] = LCPoints[i].GetParam(id, iRound);
                }
            }

            //DateTime DTStart = DateTime.Now;
            ConcurrentDictionary <int, List <double> > CDILDMatches = new ConcurrentDictionary <int, List <double> >();
            List <Thread> LThread = new List <Thread>();

            LThread.Add(new Thread(() => AddPredictionSpecified(DJSets[0], LCPointsToCompare, 0, ref CDILDMatches, LDTSetTime, TFrame, ahead, DAWeightFactors, iRound)));

            /*  LThread.Add(new Thread(() => AddPredictionSpecified(DJSets[1], LCPointsToCompare, 1, ref CDILDMatches, LDTSetTime, TFrame, ahead, DAWeightFactors, iRound)));
             * LThread.Add(new Thread(() => AddPredictionSpecified(DJSets[2], LCPointsToCompare, 2, ref CDILDMatches, LDTSetTime, TFrame, ahead, DAWeightFactors, iRound)));
             * LThread.Add(new Thread(() => AddPredictionSpecified(DJSets[3], LCPointsToCompare, 3, ref CDILDMatches, LDTSetTime, TFrame, ahead, DAWeightFactors, iRound)));
             */
            foreach (Thread Thrd in LThread)
            {
                Thrd.Priority = ThreadPriority.Lowest; Thrd.Start();
            }
            foreach (Thread Thrd in LThread)
            {
                Thrd.Join();
            }


            int           iCDILDMCount   = CDILDMatches[0].Count;
            List <int>    LISMatches     = new List <int>();
            List <double> LDSimilarities = new List <double>();

            double dSimil = 50;


            List <int> LIMatches = new List <int>();

            for (int i = 0; i < iCDILDMCount; i++)
            {
                double dSimilarity = Math.Min(CDILDMatches[0][i], CDILDMatches[1][i]);    //(CDILDMatches[0][i] * CDILDMatches[1][i] * CDILDMatches[2][i] * CDILDMatches[3][i]) / Math.Pow(100,4-1);
                dSimilarity = Math.Min(dSimilarity, CDILDMatches[2][i]);
                dSimilarity = Math.Min(dSimilarity, CDILDMatches[3][i]);
                if (dSimilarity > dSimil)    // && this.CompareTendency(LCPoints, LCPointsToCompare, i, dSimil))
                {
                    LIMatches.Add(i);
                    LDSimilarities.Add(dSimilarity);
                    i += iDeep - 1;
                }
            }



            // DateTime DTStop = DateTime.Now;  double dMS = (DTStop - DTStart).TotalMilliseconds; double dDisplay = 1 + dMS;//return new ChartPointsPredition(LISMatches, DJSets, TFrame, product, LCPointsToCompare[0], iDeep, ahead, LDSimilarities);
            return(new ChartPointsPredition(LIMatches, DJSets, TFrame, product, LCPointsToCompare[0], iDeep, ahead, LDSimilarities));
        }