public void LoadOptions(TimeFrame TFrame, List <string> LSProducts, int count)
        {
            for (int i = 0; i < LSProducts.Count; i++)
            {
                string product = LSProducts[i];

                if (this.HaveOptions(product))
                {
                    continue;
                }

                int    iShift             = 0;
                int    iShiftAlternative  = 0;
                string alternative        = "";
                string alternativeCounter = "";
                bool   bFound             = ANALYSIS.AlternateProduct(ORBlotter, TFrame, count, product, ref iShift, ref iShiftAlternative, 2, ref alternative, ref alternativeCounter);

                if (!bFound)
                {
                    return;
                }

                DSSAlternatives.Add(product, alternative);
                DSSCounterAlternatives.Add(product, alternativeCounter);
            }
        }
Exemple #2
0
 public AddAnalisisWindow(ANALYSIS analysis)
 {
     InitializeComponent();
     DataContext  = new AddAnalysisWindowViewModel(analysis);
     TextUpdated += ((AddAnalysisWindowViewModel)DataContext).TextUpdated;
     ((AddAnalysisWindowViewModel)DataContext).closeWindow += WindowClose;
 }
        private ChartPointsPredition Predict(TimeFrame TFrame, string product, int deep, int ahead, int position, List <ChartPoint> LCPoints)
        {
            int iDeep  = deep;
            int iAhead = ahead;

            if (position < iDeep)
            {
                return(null);
            }


            int               iDecimals       = int.Parse(OSBlotter.Get(product).DecimalPlaces);
            int               iMinMatches     = 1;
            double            dMinResolution  = 1;
            List <ChartPoint> LCPSub          = LCPoints.GetRange(0, position);
            List <ChartPoint> LCPSubSpecified = LCPoints.GetRange(position - iDeep, iDeep);
            //List<ChartPoint> LCPSubPredicted = LCPoints.GetRange(position, iAhead);//TODO comment



            ChartPointsPredition CPsP = ANALYSIS.PredictNextSpecified(product, LCPSub, LCPSubSpecified, TFrame, iDecimals, iMinMatches, dMinResolution, iAhead, new double[] { 0, 0, 0, 0, 0 });

            CPsP.Prognosis(0);
            CPsP.Position = position;
            return(CPsP);
        }
        private void Next()
        {
            Save();
            if (error)
            {
                error = false;
                return;
            }
            WindowOrgAnalysis_2 wo2 = new WindowOrgAnalysis_2();

            wo2.Title       = "Работа - " + TextOrganization;
            wo2.DataContext = this;

            analysis      = new ObservableCollection <ANALYSIS>(methodsEntities.ANALYSIS.Where(p => p.ANL_ORG_ID == org_id));
            anl_id        = 0;
            analysis_new  = new ANALYSIS();
            closeWindow2 += wo2.WindowClose;
            focusName2   += wo2.focusName;

            wo2.ShowDialog();
            if (prev)
            {
                prev = false;
                focusName();
            }
            else
            {
                closeWindow();
            }
        }
Exemple #5
0
 public AddAnalysisWindowViewModel(ANALYSIS analysis)
 {
     this.analysis = analysis;
     if (!String.IsNullOrEmpty(analysis.ANL_INVOICE))
     {
         invoice = analysis.ANL_INVOICE;
     }
 }
 private void PrepareNewAnalysis()
 {
     //подготовка к новому вводу
     TextAnalysis = String.Empty;
     RaisePropertyChanged(() => TextAnalysis);
     analysis_new = new ANALYSIS();
     focusName2(); //установка фокуса на поле ввода
 }
Exemple #7
0
        private void CheckupTendencyToday(ref ChartPointsPredition CPsP)
        {
            List <ChartPoint> LCPToday = ARCHIVE.GetDATA(CPsP.TimeFrame, CPsP.Product, CPsP.DTOriginal.Date, CPsP.DTOriginal);
            //List<double> LDChanges = (from CP in LCPToday select CP.Change).ToList();

            double dExtremumTodayDistance;

            CPsP.TendencyToday         = ANALYSIS.TendencyLastExtremum(LCPToday, out dExtremumTodayDistance);//ANALYSIS.Tendency(LDChanges, LDChanges.Count);
            CPsP.ExtremumTodayDistance = dExtremumTodayDistance;
        }
Exemple #8
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();
        }
Exemple #9
0
        public double Resolute(string product, int minResolutions, int index)
        {
            ChartPointsPredition CPsPOriginal = DATA[product][index];

            if (CPsPOriginal == null || CPsPOriginal.Type == ChartPointsPredition.Kind.Uncertain || CPsPOriginal.Type == ChartPointsPredition.Kind.Average || CPsPOriginal.Tendency == 50 || CPsPOriginal.TendencyToday == 50 || CPsPOriginal.TendencyComplementary == 50)
            {
                return(0);
            }

            List <ChartPointsPredition> LCPsPAll = this.ExtractType(DATA[product].GetRange(0, index), CPsPOriginal); //All of type


            //1 - 67%//ExtractTendencyToTendencyComplementary ExtractTendenciesDirectted ExtractTendencyUncertainity
            //1-3 - 67%
            LCPsPAll = this.ExtractTendencyToTendencyComplementary(LCPsPAll, CPsPOriginal);

            //0.87 ratio - ExtractTendencyToTendencyComplementary

            double[] DAParametersOryginal = CPsPOriginal.Parameters;

            List <double[]> LDAPStrikes = this.ExtractParameters(LCPsPAll, CPsPOriginal, true, false);
            List <double[]> LDAPFails   = this.ExtractParameters(LCPsPAll, CPsPOriginal, false, false);

            double dRatio = ((double)LDAPStrikes.Count / LCPsPAll.Count()) * 100;

            if (LDAPStrikes.Count < minResolutions || LDAPFails.Count < minResolutions || dRatio < 25)
            {
                return(0);
            }

            double dSFS = ANALYSIS.SimilarityFactor(LDAPStrikes, DAParametersOryginal);
            double dSFF = ANALYSIS.SimilarityFactor(LDAPFails, DAParametersOryginal);// *((double)LDAPFails.Count() / LCPsPAll.Count());


            if (dSFS > dSFF)
            {
                return(((double)dSFS / dSFF) * 100 * ((double)LDAPStrikes.Count() / LCPsPAll.Count()));
            }
            else
            {
                return(0);
            }
        }
Exemple #10
0
        private bool CheckupTest(ref ChartPointsPredition CPsP)//, List<ChartPoint> LCPointsToPredict, double spread)
        {
            if (CPsP.Type == ChartPointsPredition.Kind.Uncertain)
            {
                return(false);
            }

            List <ChartPoint> LCPointsToPredict = DLSCPoints[CPsP.Product].GetRange(CPsP.Position, CPsP.Ahead);


            this.CheckupTendencyToday(ref CPsP);
            // this.CheckupTendencyComplementary(ref CPsP);
            this.CheckupStrengthFactor(ref CPsP);


            bool bStrike = false;

            double dRealTendency = 50;

            if (CPsP.Type == ChartPointsPredition.Kind.Down)
            {
                dRealTendency = ANALYSIS.Tendency(LCPointsToPredict, false);

                if (CPsP.Tendency < 50 && dRealTendency < 50)
                {
                    bStrike = true;
                }
            }
            else if (CPsP.Type == ChartPointsPredition.Kind.Up)
            {
                dRealTendency = ANALYSIS.Tendency(LCPointsToPredict, true);

                if (CPsP.Tendency > 50 && dRealTendency > 50)
                {
                    bStrike = true;
                }
            }

            CPsP.Strike = bStrike;
            //CPsP.Accuracity = Accuracity;
            return(true);
        }
        private void Next(Object o)
        {
            prev = true;
            if (!String.IsNullOrEmpty(TextOrganization))
            {
                Save();
                if (error)
                {
                    error = false;
                    return;
                }
            }
            WindowOrgAnalysis_2 wo2 = new WindowOrgAnalysis_2();

            if (org_id != 0)
            {
                wo2.Title = "Работа - " + Organizations.Where(p => p.ORG_ID == org_id).FirstOrDefault().ORG_NAME;
                analysis  = new ObservableCollection <ANALYSIS>(methodsEntities.ANALYSIS.Where(p => p.ANL_ORG_ID == org_id));
                anl_id    = analysis.Any() ? analysis[0].ANL_ID : 0;
            }
            wo2.DataContext = this;
            analysis_new    = new ANALYSIS();
            TextAnalysis    = String.Empty;
            RaisePropertyChanged(() => TextAnalysis);
            closeWindow2 += wo2.WindowClose;
            focusName2   += wo2.focusName;

            wo2.ShowDialog();
            if (prev)
            {
                prev = false;
                focusName();
            }
            else
            {
                closeWindow();
            }
        }
Exemple #12
0
        private void CheckupTendencyComplementary(ref ChartPointsPredition CPsP)
        {
            List <ChartPoint> LCPToday = ARCHIVE.GetDATA(CPsP.TimeFrame, CPsP.Product, CPsP.DTOriginal.Date, CPsP.DTOriginal);

            int iPosition = ANALYSIS.ExtremumComplementaryPosition(LCPToday, LCPToday.Count, (double)CPsP.Deep / 2);
            //int iPositionBefore = ANALYSIS.ExtremumComplementaryPosition(LCPToday, iPosition + 1, (double)CPsP.Deep / 2);
            int iShiftCount = LCPToday.Count - iPosition;

            if (iShiftCount <= 0 || iPosition >= LCPToday.Count || iPosition - iShiftCount < 0)
            {
                CPsP.ExtremumConplementaryDistance = -1;
                CPsP.TendencyComplementary         = 50;
                return;
            }
            else
            {
                //List<double> LDChanges = (from CP in LCPToday select CP.Change).ToList(); int iCount = LDChanges.Count - iPosition; CPsP.TendencyComplementary = ANALYSIS.Tendency(LDChanges, iPosition, iCount);

                List <ChartPoint> LDCPRanged       = LCPToday.GetRange(iPosition, iShiftCount);
                List <ChartPoint> LDCPRangedBefore = LCPToday.GetRange(iPosition - iShiftCount, iShiftCount);


                double dTendency       = ANALYSIS.Tendency(LDCPRanged);
                double dTendencyBefore = ANALYSIS.Tendency(LDCPRangedBefore);

                if (dTendency < 50 && dTendencyBefore > 50 || dTendency > 50 && dTendencyBefore < 50)
                {
                    CPsP.ExtremumConplementaryDistance = -1;
                    CPsP.TendencyComplementary         = 50;
                    return;
                }

                CPsP.ExtremumConplementaryDistance = (LDCPRanged.Last().Time - LDCPRanged[0].Time).TotalMinutes;
                CPsP.TendencyComplementary         = (dTendency / dTendencyBefore) * 100;
            }
        }
Exemple #13
0
        public double ResoluteTest(string product, int minResolutions, int index)
        {
            ChartPointsPredition CPsPOriginal = DATA[product][index];

            if (CPsPOriginal.Type == ChartPointsPredition.Kind.Uncertain || CPsPOriginal.Type == ChartPointsPredition.Kind.Average)
            {
                return(0);
            }

            //ExtractTypeExtremumTendencyTest
            List <ChartPointsPredition> LCPsPAll         = this.ExtractTypeTest(DATA[product].GetRange(0, index), CPsPOriginal, false); //All of type
            List <ChartPointsPredition> LCPsPAllReversed = this.ExtractTypeTest(DATA[product].GetRange(0, index), CPsPOriginal, true);  //All of type

            // LCPsPAll = this.ExtractSimilarityTest(LCPsPAll); LCPsPAllReversed = this.ExtractSimilarityTest(LCPsPAllReversed);
            // LCPsPAll = this.ExtractTypeExtremumTendencyTest(LCPsPAll); LCPsPAllReversed = this.ExtractTypeExtremumTendencyTest(LCPsPAllReversed);
            //LCPsPAll = this.ExtractTestContinuous(LCPsPAll); LCPsPAllReversed = this.ExtractTestContinuous(LCPsPAllReversed);
            //LCPsPAll = this.ExtractTestContinuousTendency(LCPsPAll); LCPsPAllReversed = this.ExtractTestContinuousTendency(LCPsPAllReversed);

            double[] DAParametersOryginal = CPsPOriginal.Parameters;

            List <double[]> LDAPStrikes = this.ExtractParameters(LCPsPAll, CPsPOriginal, true, false);
            List <double[]> LDAPFails   = this.ExtractParameters(LCPsPAll, CPsPOriginal, false, false);

            List <double[]> LDAPStrikesReversed = this.ExtractParameters(LCPsPAllReversed, CPsPOriginal, true, true);
            List <double[]> LDAPFailsReversed   = this.ExtractParameters(LCPsPAllReversed, CPsPOriginal, false, true);

            double dRatio         = ((double)LDAPStrikes.Count / LCPsPAll.Count()) * 100;
            double dRatioReversed = ((double)LDAPStrikesReversed.Count / LCPsPAllReversed.Count()) * 100;

            //50.14-50.85 - clear

            if (LDAPStrikesReversed.Count < minResolutions || LDAPFailsReversed.Count < minResolutions)
            {
                return(0);
            }

            if (LDAPStrikes.Count < minResolutions || LDAPFails.Count < minResolutions)
            {
                return(0);
            }

            if (dRatio < 45 || dRatioReversed < 45)
            {
                //throw new Exception("Something is f****d up !");
            }

            for (int i = 0; i < LDAPStrikes.Count; i++)
            {
                if (LDAPStrikes[i] == null)
                {
                    var v = 0;
                    var P = 1 + v;
                }
            }
            for (int i = 0; i < LDAPFails.Count; i++)
            {
                if (LDAPFails[i] == null)
                {
                    var v = 0;
                    var P = 1 + v;
                }
            }

            return(1);

            double dSFS = ANALYSIS.SimilarityFactor(LDAPStrikes, DAParametersOryginal);
            double dSFF = ANALYSIS.SimilarityFactor(LDAPFails, DAParametersOryginal);// *((double)LDAPFails.Count() / LCPsPAll.Count());

            return(1);

            if (dSFS > dSFF)
            {
                return(((double)dSFS / dSFF) * 100 * ((double)LDAPStrikes.Count() / LCPsPAll.Count()));
            }
            else
            {
                return(0);
            }
        }
Exemple #14
0
        private void TimrAutoTraderSquare_Tick(object sender, EventArgs e)
        {
            if (ODBlotter.COUNT == 0)
            {
                return;
            }
            else
            {
                TimeFrame    TFrame = TimeFrame.ONE_MINUTE;
                List <Deals> LDeals = ODBlotter.GetData.ToList();

                for (int i = 0; i < LDeals.Count; i++)
                {
                    Deals  DEAL    = LDeals[i];
                    string product = DEAL.PRODUCT;
                    List <ChartPointsPredition> LCPsPSimulated = this.LCPsPTestSelected.OrderByDescending(CPsP => CPsP.Resolution).ToList();
                    ChartPointsPredition        CPsPrediction  = null;
                    List <Rates> LRAll = ORBlotter.Archive.TryGet(product);

                    for (int i2 = 0; i2 < LCPsPSimulated.Count; i2++)
                    {
                        if (LCPsPSimulated[i2].Product == product)
                        {
                            CPsPrediction = LCPsPSimulated[i2];
                            break;
                        }
                    }



                    double dMinDeal = 0, dMaxDeal = 0;
                    if (!this.Extrema(DEAL, 10, ref dMinDeal, ref dMaxDeal))
                    {
                        return;
                    }

                    bool   bBUY                 = DEAL.BUY;
                    Rates  RATE                 = ORBlotter.Get(DEAL.PRODUCT);
                    double onePip               = Math.Pow(10, -RATE.Decimals);
                    int    iSpread              = ANALYSIS.SpreadPips(DEAL, RATE.Decimals, true) + 2;
                    double dLevel               = (double)iSpread;
                    bool   bLooseWarning        = false;
                    double dGainLoosePercentage = 75;
                    double dStartSpread         = (double)(DEAL.ASK - DEAL.BID) / onePip;

                    if (CPsPrediction != null && CPsPrediction.IsActual)
                    {
                        if ((bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Down) ||
                            (!bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Up))
                        {
                            DEAL.LooseWaring     = true;
                            dGainLoosePercentage = 85;
                        }
                        else if ((!bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Down) ||
                                 (bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Up))
                        {
                            dGainLoosePercentage = 60;
                        }
                    }

                    if (bBUY)
                    {
                        double dPLMax = (double)(dMaxDeal - DEAL.ASK) / onePip;
                        double dPLNow = (double)(RATE.BID - DEAL.ASK) / onePip;



                        if (dPLMax > 0 && dPLNow > 0)
                        {
                            double dGainPercentage = ((double)(dPLNow + dStartSpread) / (dPLMax + dStartSpread)) * 100;

                            if (dGainPercentage < dGainLoosePercentage || DEAL.LooseWaring)
                            {
                                bLooseWarning = true;
                            }
                        }
                    }
                    else//sell for bid, buy for ask
                    {
                        double dPLMin = (double)(DEAL.BID - dMinDeal) / onePip;
                        double dPLNow = (double)(DEAL.BID - RATE.ASK) / onePip;


                        if (dPLMin > 0 && dPLNow > 0)
                        {
                            double dGainPercentage = ((double)(dPLNow + dStartSpread) / (dPLMin + dStartSpread)) * 100;

                            if (dGainPercentage < dGainLoosePercentage || DEAL.LooseWaring)
                            {
                                bLooseWarning = true;
                            }
                        }
                    }

                    if (bLooseWarning)
                    {
                        this.CloseDeal(DEAL);
                        Thread ThrdBeep = new Thread(delegate() { Console.Beep(200, 50); Console.Beep(200, 50); }); ThrdBeep.Start();
                    }
                    return;
                }
            }
        }
Exemple #15
0
        private void TimrAutoTrader_Tick(object sender, EventArgs e)
        {
            //if (ThrdAutoTread != null && ThrdAutoTread.IsAlive) return;

            List <ChartPointsPredition> LCPsPSimulated = this.LCPsPTestSelected.OrderByDescending(CPsP => CPsP.Resolution).ToList();


            if (LCPsPSimulated.Count < 1)
            {
                return;
            }

            ChartPointsPredition CPsPBest = null;

            List <Deals> LDeals = ODBlotter.GetData;

            for (int i = 0; i < LCPsPSimulated.Count; i++)
            {
                if (!LCPsPSimulated[i].IsActual)
                {
                    continue;
                }
                //if ((LCPsPSimulated[i].Tendency <= 50 && LCPsPSimulated[i].TendencyToday >= 50) ||  (LCPsPSimulated[i].Tendency >= 50 && LCPsPSimulated[i].TendencyToday <= 50)) continue;

                bool found = false;
                for (int i2 = 0; i2 < LDeals.Count; i++)
                {
                    try
                    {
                        if (LDeals[i2].PRODUCT == LCPsPSimulated[i].Product)
                        {
                            found = true;
                            break;
                        }
                    }
                    catch
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    CPsPBest = LCPsPSimulated[i];
                    break;
                }
            }

            if (CPsPBest == null)
            {
                return;
            }

            string       product   = CPsPBest.Product;
            DateTime     DTLastGMT = CPsPBest.DTOriginal.AddMinutes(ABBREVIATIONS.ToMinutes(TimeFrame.ONE_MINUTE));
            List <Rates> LRAll     = ORBlotter.Archive.Get(product, DTLastGMT);

            // double dExecutionDataCount = (double)(ABBREVIATIONS.GreenwichMeanTime - DTLastGMT).TotalSeconds / 5;

            if (LRAll == null || LRAll.Count < 7)//dExecutionDataCount)
            {
                if (LRAll != null)
                {
                    TsslInfo2.Text = "Missing Execution Data ";               // +LRAll.Count + " / " + (int)dExecutionDataCount;
                }
                return;
            }



            //double dMin = 0, dMax = 0;  if (!this.Extrema(product, 60, ref dMin, ref dMax)) return;
            //List<ChartPoint> LCPAll = ARCHIVE.GetDATA(TFrame, product, ABBREVIATIONS.GreenwichMeanTime.Date);
            //double dTendencyGlobal = ANALYSIS.Tendency(LCPAll, -1, false);
            //double dTendencyLoacl = ANALYSIS.Tendency(LCPAll, 15, true);

            bool bBUY = false;

            if (CPsPBest.Type == ChartPointsPredition.Kind.Up)
            {
                bBUY = true;
            }

            int iLRCount = LRAll.Count;

            bool   bMatch = true;
            double dTendencyNow, dTendencyPrev;


            if (bBUY)
            {
                dTendencyPrev = 0;
            }
            else
            {
                dTendencyPrev = 100;
            }

            int iOFFTendencies = 0; int iOKTendencies = 0;
            int iSteps = 2;

            for (int i = iLRCount - 1; i > 2 && iSteps-- > 0; i /= 2)
            {
                dTendencyNow = ANALYSIS.Tendency(LRAll, i);

                if (bBUY && dTendencyNow < dTendencyPrev)
                {
                    bMatch = false;
                    break;
                }
                else if (!bBUY && dTendencyNow > dTendencyPrev)
                {
                    bMatch = false;
                    break;
                }

                dTendencyPrev = dTendencyNow;
                if ((dTendencyPrev >= 50 && bBUY) || (dTendencyPrev <= 50 && !bBUY))
                {
                    ++iOFFTendencies;
                }
                else
                {
                    ++iOKTendencies;
                }
            }

            double dOPRatio = ((double)iOFFTendencies / (iOFFTendencies + iOKTendencies)) * 100;

            //if (dOPRatio >= 40) return;

            if (!bMatch)
            {
                return;         // && dOPRatio > 40
            }
            this.Action(product, bBUY);



            Thread ThrdBeep = new Thread(delegate() { Console.Beep(250, 100); }); ThrdBeep.Start();
        }