Exemplo n.º 1
0
        public List <ChartPointPredition> BestPredictions(TimeFrame TFrame, int minMatches, double minPropability)
        {
            List <ChartPointPredition> LCPBestPredictions = new List <ChartPointPredition>();
            List <ChartPointPredition> LCPPredictions     = this.GetList(TFrame);

            if (LCPPredictions.Count == 0)
            {
                return(LCPBestPredictions);
            }

            List <string> LSInUse = (from Ds in ODBlotter.GetData select Ds.PRODUCT).ToList();


            for (int i = 0; i < LCPPredictions.Count; i++)
            {
                ChartPointPredition CPP = LCPPredictions[i];

                if (!LSInUse.Contains(CPP.Product) &&
                    CPP.IsActual &&
                    CPP.Matches >= minMatches &&
                    CPP.Propability >= minPropability &&
                    CPP.Type != ChartPointPredition.Kind.Uncertain &&
                    CPP.Type != ChartPointPredition.Kind.Average)
                {
                    LCPBestPredictions.Add(CPP);
                }
            }


            return(LCPBestPredictions);
        }
Exemplo n.º 2
0
        private bool TryUpdate(ChartPointPredition CPPrediction)
        {
            lock (DATA)
            {
                if (!CPPrediction.IsActual)
                {
                    return(false);
                }

                if (DATA[CPPrediction.Frame].ContainsKey(CPPrediction.Product))
                {
                    while (!DATA[CPPrediction.Frame].TryUpdate(CPPrediction.Product, CPPrediction, DATA[CPPrediction.Frame][CPPrediction.Product]))
                    {
                        ;
                    }
                }
                else
                {
                    while (!DATA[CPPrediction.Frame].TryAdd(CPPrediction.Product, CPPrediction))
                    {
                        ;
                    }
                }

                return(true);
            }
        }
Exemplo n.º 3
0
        public List <ChartPointPredition> GetList(TimeFrame TFrame)
        {
            if (!DATA.ContainsKey(TFrame))
            {
                return(null);
            }

            List <ChartPointPredition> LCPPredictions = new List <ChartPointPredition>();

            string[] SAKeys = DATA[TFrame].Keys.ToArray();
            for (int i = 0; i < SAKeys.Length; i++)
            {
                ChartPointPredition CPPrediction;
                while (!DATA[TFrame].TryGetValue(SAKeys[i], out CPPrediction))
                {
                    ;
                }
                ChartPointPredition CPP = CPPrediction.Clone();

                LCPPredictions.Add(CPP);
            }


            return(LCPPredictions);
        }
Exemplo n.º 4
0
        public void Predict(TimeFrame TFrame, double[] IASymiliarities)
        {
            if (this.AvalaibleMeans() <= 0)
            {
                return;
            }

            //int iMinutes = ABBREVIATIONS.ToMinutes(TFrame);

            List <string> LSLiquids = ANALYSIS.GetLiquids(ARCHIVE.GetProducts(), ORBlotter, 60, 30, dSpreadFactor, TFrame); //Chooce only those products whose Activity in last 5 minutes is above 0.5 of spread //List<string> LSLiquidsLive = ANALYSIS.GetLiquidsLive(ORBlotter, 50, 3, 0.2, TFrame);

            if (LSLiquids.Count < 10 && dSpreadFactor > 0.35)
            {
                dSpreadFactor -= 0.0025;
            }
            else if (LSLiquids.Count > 20)
            {
                dSpreadFactor += 0.0025;
            }



            //List<Thread> LThrdLiquid = new List<Thread>();
            foreach (string product in LSLiquids)//ORBlotter.GetProducts)
            {
                //LThrdLiquid.Add(new Thread(delegate() {

                List <ChartPoint> LCPoints          = ARCHIVE.GetDATA(TFrame, product);
                ChartPoint        CPLAst            = LCPoints.Last();
                List <ChartPoint> LCPointsSpecified = ORBlotter.Archive.Get(product, TFrame, IASymiliarities.Length);

                if (LCPointsSpecified != null)
                {
                    ChartPointPredition      CPPrediction = ANALYSIS.PredictNextSpecified(product, LCPoints, LCPointsSpecified, TFrame, ORBlotter.Get(product).Decimals, IASymiliarities);
                    ChartPointPredition.Kind CPPKind      = CPPrediction.Prognosis();


                    if (CPPKind != ChartPointPredition.Kind.Uncertain)
                    {
                        this.TryUpdate(CPPrediction);
                    }
                }
                //  }));
                // LThrdLiquid.Last().Priority = ThreadPriority.BelowNormal;
                // LThrdLiquid.Last().Start();
            }

            //foreach (Thread Thrd in LThrdLiquid)  Thrd.Join();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Clones object without list and sub classes
        /// </summary>
        /// <returns>Clonned dumb object.</returns>
        public ChartPointPredition Clone()
        {
            ChartPointPredition CPP = new ChartPointPredition();

            /*CPP.ABBREVIATION = ABBREVIATION;
             * CPP.ANALISIS = ANALISIS;*/
            CPP.bAnalised = bAnalised;
            //CPP.CPOrigin = CPOrigin;
            CPP.dBase             = dBase;
            CPP.dBaseDeviation    = dBaseDeviation;
            CPP.dChange           = dChange;
            CPP.dChangeDeviation  = dChangeDeviation;
            CPP.dPeak             = dPeak;
            CPP.dPeakDeviation    = dPeakDeviation;
            CPP.dPropability      = dPropability;
            CPP.dPropabilityDown  = dPropabilityDown;
            CPP.dPropabilityEqual = dPropabilityEqual;
            CPP.dPropabilityUp    = dPropabilityEqual;
            CPP.dPropabilityUp    = dPropabilityUp;
            CPP.DTPredictedTime   = DTPredictedTime;
            CPP.iMinutesPredicted = iMinutesPredicted;
            CPP.iStrength         = iStrength;
            CPP.KType             = KType;
            CPP.dMatches          = dMatches;

            /*CPP.LDBasesChangesAverage = LDBasesChangesAverage;
             * CPP.LDBasesChangesDown = LDBasesChangesDown;ss
             * CPP.LDBasesChangesUp = LDBasesChangesUp;
             * CPP.LDChangesAverage = LDChangesAverage;
             * CPP.LDChangesDown = LDChangesUp;
             * CPP.LDMatchCommons = LDMatchCommons;
             * CPP.LDPeaksChangesAverage = LDPeaksChangesDown;
             * CPP.LDPeaksChangesUp = LDPeaksChangesUp;
             * CPP.LLDSets = LLDSets;*/
            CPP.sProduct = sProduct;
            CPP.TFrame   = TFrame;

            return(CPP);
        }
Exemplo n.º 6
0
        private void TimrControls_Tick(object sender, EventArgs e)
        {
            int InLbxPairs = LbxCCYPairs.Items.Count;
            int InLbxDeals = LbxDealsOpened.Items.Count;

            List <Rates> LRATES  = ORBlotter.GetData;
            List <Deals> LDEALS  = ODBlotter.GetData;
            int          LRCount = LRATES.Count;


            if (InLbxPairs < LRCount)
            {
                if (InLbxPairs > 0)
                {
                    LbxCCYPairs.Items.Clear();
                }


                for (int i = 0; i < LRCount; i++)
                {
                    LbxCCYPairs.Items.Add(LRATES[i].CCY_Pair);
                }
            }

            if (LbxDealsOpened.SelectedIndex >= 0)
            {
                Deals DEAL = ODBlotter.Get(LbxDealsOpened.SelectedItem.ToString());

                TbxDealPair.Text = DEAL.PRODUCT;

                if (DEAL.BUY)
                {
                    TbxDealKind.Text = "BUY ";
                }
                else
                {
                    TbxDealKind.Text = "SELL";
                }

                TbxDealProfitOrLoss.Text = AUTOTREADER.ConvertToUSD(DEAL.PRODUCT, DEAL.BUY, ACCOUNT.CalculateProfitOrLoss(DEAL, ORBlotter.Get(DEAL.PRODUCT))) + "";

                ChartPointPredition CPP = AUTOTREADER.TryGet(DEAL.PRODUCT, TimeFrame.ONE_MINUTE);


                if (CPP == null || CPP.Type == ChartPointPredition.Kind.Uncertain || !CPP.IsActual)
                {
                    TbxDealPredictionKind.Text       = "Uncertain";
                    TbxDealPredictionPercentage.Text = "";
                    TbxDealPredictionValue.Text      = "";
                }
                else
                {
                    if (CPP.Type == ChartPointPredition.Kind.Average)
                    {
                        TbxDealPredictionKind.Text = "Average";
                    }
                    else if (CPP.Type == ChartPointPredition.Kind.Down)
                    {
                        TbxDealPredictionKind.Text = "Down";
                    }
                    else if (CPP.Type == ChartPointPredition.Kind.Up)
                    {
                        TbxDealPredictionKind.Text = "Up";
                    }

                    TbxDealPredictionPercentage.Text = Math.Round(CPP.Propability, 2).ToString();
                    TbxDealPredictionValue.Text      = Math.Round(CPP.Change, 5).ToString();
                }
            }



            if (this.IsConnected())
            {
                this.UpdateMargin();
                this.UpdateAction();
            }

            if (!OSBlotter.IsLoaded)
            {
                BtnAutoTrader.Enabled = false;
                BtnBuy.Enabled        = false;
                BtnClose.Enabled      = false;
                BtnSell.Enabled       = false;
            }
            else
            {
                BtnAutoTrader.Enabled = true;
                BtnBuy.Enabled        = true;
                BtnClose.Enabled      = true;
                BtnSell.Enabled       = true;
            }
        }