Пример #1
0
        private void _GetAnalysis(List <DateModel> dateModels, string tiker)
        {
            IndexModel indexModel = new IndexModel();

            //DateTime date = new DateTime(2019, 1, 10, 19, 00, 00);
            //if ((dateModels.Find(i => i.Scale == "60").Points.Last().Date == date) && (tiker == "YNDX")) { MessageBox.Show("!"); }

            if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
            {
                IAnalysis analysis1 = new Analysis1(dateModels.Find(i => i.Scale == "D"), "Analysis1");
                analysis1.GetAnalysis();
            }


            string A1Result = GetResult(dateModels.Find(i => i.Scale == "D"), "Analysis1");

            Analysis2 analysis2 = new Analysis2(dateModels.Find(i => i.Scale == "D"), "Analysis2", tiker, A1Result);

            analysis2.GetAnalysis();

            // Удаляем ордер если сигнала нет
            if (A1Result == "")
            {
                int itemDeal = orderModels.FindIndex(i => i.Tiker == tiker & i.IsActive == true);
                if (itemDeal != -1)
                {
                    orderModels[itemDeal].IsActive = false;
                    orderModels[itemDeal].EndDate  = dateModels[0].Points.Last().Date;
                }
            }
            // Проверяем на наличие копий ордера и открытых позиций
            if (analysis2.HaveOrder)
            {
                int itemDeal = dealModels.FindIndex(i => i.Tiker == tiker & i.InMarket == true);
                if (itemDeal == -1)
                {
                    itemDeal = orderModels.FindIndex(i => i.Tiker == tiker & i.IsActive == true);
                    if (itemDeal == -1)
                    {
                        orderModels.Add(analysis2.OrderModels);
                    }
                    else
                    {
                        orderModels[itemDeal].Price = analysis2.OrderModels.Price;
                    }
                }
            }
            // Обработка открытой позиции
            Analysis3 analysis3 = new Analysis3(dateModels.Find(i => i.Scale == "D"), "Analysis3", tiker, A1Result);

            analysis3.GetAnalysis();
            int indexDeal = dealModels.FindIndex(i => i.Tiker == tiker & i.InMarket == true);

            if (indexDeal != -1)
            {
                dealModels[indexDeal].StopPrice = analysis3.StopOrder;
            }
        }
Пример #2
0
        private void GetAnalysis(List <DateModel> dateModels, string tiker)
        {
            IndexModel indexModel = new IndexModel();

            if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
            {
                IAnalysis analysis1 = new Analysis1(dateModels.Find(i => i.Scale == "D"), "Analysis1");
                analysis1.GetAnalysis();
            }



            int    item          = dateModels.FindIndex(i => i.Scale == "D");
            int    itemAnalysis1 = dateModels[item].Points.Last().AnalysisResults.FindIndex(i => i.Name == "Analysis1");
            string A1Result      = "";

            if (itemAnalysis1 != -1)
            {
                A1Result = dateModels[item].Points.Last().AnalysisResults[itemAnalysis1].Result;
            }
            else
            {
                int count = dateModels[item].Points.Count();
                itemAnalysis1 = dateModels[item].Points[count - 2].AnalysisResults.FindIndex(i => i.Name == "Analysis1");
                if (itemAnalysis1 != -1)
                {
                    A1Result = dateModels[item].Points[count - 2].AnalysisResults[itemAnalysis1].Result;
                }
                else
                {
                    A1Result = "";
                }
            }

            //if (item >= 0)
            //{
            //    item = dateModels[item].Points.Last().AnalysisResults.FindIndex(i => i.Name == "Analysis1");
            //    if (item >= 0)
            //    {
            //A1Result = dateModels.Find(i => i.Scale == "D").Points.Last().AnalysisResults[item].Result;
            //if (tiker == "GAZP") { }
            Analysis2 analysis2 = new Analysis2(dateModels.Find(i => i.Scale == "60"), "Analysis2", tiker, A1Result);

            analysis2.GetAnalysis();
            // Удаляем ордер если сигнала нет
            int itemDeal = 0;

            if (analysis2.GetResult() == "")
            {
                itemDeal = orderModels.FindIndex(i => i.Tiker == tiker & i.IsActive == true);
                if (itemDeal != -1)
                {
                    orderModels[itemDeal].IsActive = false;
                    orderModels[itemDeal].EndDate  = dateModels[0].Points.Last().Date;
                }
            }
            // проверяем на наличие копий ордера И открытых позиций
            if (analysis2.HaveOrder)
            {
                itemDeal = dealModels.FindIndex(i => i.Tiker == tiker & i.InMarket == true);
                if (itemDeal == -1)
                {
                    itemDeal = orderModels.FindIndex(i => i.Tiker == tiker & i.IsActive == true);
                    if (itemDeal == -1)
                    {
                        orderModels.Add(analysis2.OrderModels);
                    }
                    else
                    {
                        orderModels[itemDeal].Price = analysis2.OrderModels.Price;
                        //orderModels.Add(analysis2.OrderModels);
                    }
                }
            }

            itemDeal = dealModels.FindIndex(i => i.Tiker == tiker & i.InMarket == true);
            if (itemDeal != -1)
            {
                if (A1Result != "")
                {
                    if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
                    {
                        //dealModels[itemDeal].StopPrice = dateModels.Find(i => i.Scale == "D").Points.Last().IndexPoint.Find(i => i.Name == "EMA16").Value[0].Value;
                        double tmp  = dateModels.Find(i => i.Scale == "60").Points.Last().IndexPoint.Find(i => i.Name == "ATR").Value.Find(i1 => i1.Name == "ATR").Value;
                        double stop = (indexModel.GetMax(dateModels.Find(i => i.Scale == "60").Points, 22) - (tmp * 2.5));
                        if (stop > 0)
                        {
                            dealModels[itemDeal].StopPrice = stop;
                        }
                        else
                        {
                            dealModels[itemDeal].StopPrice = (indexModel.GetMax(dateModels.Find(i => i.Scale == "60").Points, 22) - (tmp * 2.5));
                        }
                    }
                }
                else
                {
                    //double tmp = dateModels.Find(i => i.Scale == "D").Points.Last().IndexPoint.Find(i => i.Name == "ATR").Value.Find(i1 => i1.Name == "ATR").Value;
                    if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
                    {
                        //dealModels[itemDeal].StopPrice = (indexModel.GetMax(dateModels.Find(i => i.Scale == "60").Points, 22) - (tmp * 3));
                        dealModels[itemDeal].StopPrice = dateModels.Find(i => i.Scale == "60").Points.Last().Close;         //IndexPoint.Find(i => i.Name == "EMA8").Value[0].Value;
                    }
                }
                //Analysis3 analysis3 = new Analysis3(dateModels.Find(i => i.Scale == "60"), "Analysis3", tiker, A1Result);
                //analysis3.GetAnalysis();
                //if (analysis3.StopOrder != 0)
                //{
                //    dealModels.Find(i => i.Tiker == tiker & i.InMarket == true).StopPrice = analysis3.StopOrder;
                //}
                //    }
                //}
            }
        }