/// <summary>
 /// 设置帮助信息(这里函数需要在Presenter初始化完成之后调用)
 /// </summary>
 /// <param name="modelInfo"></param>
 public void SetHelperInfo(HelperModel modelInfo)
 {
     if (modelInfo != null)
     {
         Model = modelInfo;               // 重新拉取数据
         ViewLogic.LayoutView(modelInfo); // 刷新界面
     }
 }
Example #2
0
 public void SetTip(HZHDialogModel modelInfo)
 {
     if (modelInfo != null)
     {
         Model = modelInfo;            // 重新拉取数据
         ViewLogic.ShowTip(modelInfo); // 刷新界面
     }
 }
Example #3
0
        public ActionResult Search(int id, string search)
        {
            ViewLogic log  = new ViewLogic();
            var       data = log.SearchView(id, search);

            ViewBag.Id     = id;
            ViewBag.Search = search;
            return(View(data.Tables[0]));
        }
        public void SwitchCaseTest_InDiv_X45_Y0_OutMean0()
        {
            string arg = "/";
            double x   = 45;
            double y   = 0;
            double mean;

            Assert.IsFalse(ViewLogic.SwitchCase(arg, x, y, out mean));
        }
        public void SwitchCaseTest_InPlus_XMinValu_YMinValu_OutMean0()
        {
            string arg = "+";
            double x   = double.MinValue;
            double y   = double.MinValue;
            double mean;

            Assert.IsFalse(ViewLogic.SwitchCase(arg, x, y, out mean));
        }
        public void SwitchCaseTest_InMulti_X343_Y30_OutMeanResul()
        {
            string arg = "*";
            double x   = -343;
            double y   = -30;
            double mean;

            Assert.IsTrue(ViewLogic.SwitchCase(arg, x, y, out mean));
            Assert.AreNotEqual(0, mean);
        }
        public void SwitchCaseTest_InDiv_X0_Y56_OutMean0()
        {
            string arg = "/";
            double x   = 0;
            double y   = 56;
            double mean;

            Assert.IsTrue(ViewLogic.SwitchCase(arg, x, y, out mean));
            Assert.AreEqual(0, mean);
        }
        public CommonResponse AutoFilter()
        {
            if (WebOperationContext.Current.IncomingRequest.Headers == null)
            {
                throw new Exception("Can not get current WebOpreationContext.");
            }

            var viewLogic = new ViewLogic();
            var result    = new CommonResponse();

            viewLogic.AutoFilter();

            return(result);
        }
        public CommonResponse ViewExecute(ViewExecuteReq req)
        {
            if (WebOperationContext.Current.IncomingRequest.Headers == null)
            {
                throw new Exception("Can not get current WebOpreationContext.");
            }

            var result = new CommonResponse();

            var jsonObj = new JsonObject(new KeyValuePair <string, JsonValue>("name", req.name), new KeyValuePair <string, JsonValue>("member_id", req.member_id));

            var viewLogic = new ViewLogic();

            result.code = "200"; result.message = viewLogic.Execute(jsonObj);

            return(result);
        }
Example #10
0
        public CommonResponse AutoAnalysis(string period, string state, string name)
        {
            if (WebOperationContext.Current.IncomingRequest.Headers == null)
            {
                throw new Exception("Can not get current WebOpreationContext.");
            }

            var viewLogic = new ViewLogic();
            var result    = new CommonResponse();

            try
            {
                result.code = "200";
                var stock_list = name == null ? new List <string>() : name.Split(',').ToList();
                result.message = viewLogic.AutoAnalysis(period == null ? string.Empty : period.ToLower(), "avg", stock_list);
            }
            catch (Exception ex)
            {
                result.code = "400";
                Console.WriteLine(ex.ToString());
            }

            return(result);
        }
Example #11
0
        public void Receive(Dictionary <string, string> paylaod)
        {
            var text      = paylaod["text"];
            var user_id   = paylaod["user_id"];
            var user_name = paylaod["user_name"];

            var words = text.Split(' ').ToList <string>();

            var date_param = DateTime.Now;
            var parameters = new List <string>();
            var keyword    = new List <string>();

            foreach (var word in words)
            {
                if (word.Contains("빅앤츠"))
                {
                    continue;
                }

                if (word.Contains("분석"))
                {
                    keyword.Add("분석");
                }
                else if (word.Contains("추천"))
                {
                    keyword.Add("추천");
                }
                else if (word.Contains("등록"))
                {
                    keyword.Add("등록");
                }
                else if (word.Contains("감시"))
                {
                    keyword.Add("감시");
                }
                else
                {
                    try
                    {
                        var test = DateTime.Parse(word);
                        date_param = test;
                    }
                    catch
                    {
                        parameters.Add(word);
                    }
                }
            }
            var respond_cnt = 0;

            foreach (var key in keyword)
            {
                var message = new JsonObject();
                if (key == "추천")
                {
                    var recommaned_report = new StringBuilder();
                    var query             = string.Empty;
                    if (parameters.Contains("하락"))
                    {
                        message.Add("text", "*" + date_param.ToString("yyyy-MM-dd") + " 빅앤츠 시그널 추천 종목*");
                        query = "SELECT CONCAT(current.최근갯수, ' 단계 하락 종목') as `title`, GROUP_CONCAT(current.종목명) as `text`" +
                                " FROM (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + (date_param.DayOfWeek == DayOfWeek.Monday ? date_param.AddDays(-3).ToString("yyyy-MM-dd") :
                                                                          date_param.AddDays(-1).ToString("yyyy-MM-dd")) + "' AND unixtime <= '"
                                + date_param.ToString("yyyy-MM-dd") + "' ) as result1 WHERE (전체상태 = '횡보' OR 전체상태 = '하락')" +
                                " AND 현재상태 = '하락' AND 종가 >= `20평균가`) as prev," +
                                " (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + date_param.ToString("yyyy-MM-dd") + "' AND unixtime <= '"
                                + date_param.AddDays(1).ToString("yyyy-MM-dd") + "' ) as result2" +
                                " WHERE (전체상태 = '횡보' OR 전체상태 = '상승')" +
                                " AND 현재상태 = '하락' AND 종가 >= `20평균가`) as current" +
                                " WHERE prev.category = current.category GROUP BY current.최근갯수";
                    }
                    else if (parameters.Contains("상승"))
                    {
                        message.Add("text", "*" + date_param.ToString("yyyy-MM-dd") + " 빅앤츠 시그널 추천 종목*");
                        query = "SELECT CONCAT(current.최근갯수, ' 단계 상승 종목') as `title`, GROUP_CONCAT(current.종목명) as `text`" +
                                " FROM (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + (date_param.DayOfWeek == DayOfWeek.Monday ? date_param.AddDays(-3).ToString("yyyy-MM-dd") :
                                                                          date_param.AddDays(-1).ToString("yyyy-MM-dd")) + "' AND unixtime <= '"
                                + date_param.ToString("yyyy-MM-dd") + "' ) as result1 WHERE (전체상태 = '횡보' OR 전체상태 = '하락')" +
                                " AND 현재상태 = '상승' AND 종가 >= `20평균가`) as prev," +
                                " (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + date_param.ToString("yyyy-MM-dd") + "' AND unixtime <= '"
                                + date_param.AddDays(1).ToString("yyyy-MM-dd") + "' ) as result2" +
                                " WHERE (전체상태 = '횡보' OR 전체상태 = '상승')" +
                                " AND 현재상태 = '상승' AND 종가 >= `20평균가`) as current" +
                                " WHERE prev.category = current.category GROUP BY current.최근갯수";
                    }
                    else if (parameters.Contains("전환"))
                    {
                        message.Add("text", "*" + date_param.ToString("yyyy-MM-dd") + " 빅앤츠 시그널 추천 종목*");
                        query = "SELECT CONCAT(current.최근갯수, ' 단계 전환 종목') as `title`, GROUP_CONCAT(current.종목명) as `text`" +
                                " FROM (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + (date_param.DayOfWeek == DayOfWeek.Monday ? date_param.AddDays(-3).ToString("yyyy-MM-dd") :
                                                                          date_param.AddDays(-1).ToString("yyyy-MM-dd")) + "' AND unixtime <= '"
                                + date_param.ToString("yyyy-MM-dd") + "' ) as result1 WHERE (전체상태 = '횡보' OR 전체상태 = '하락')" +
                                " AND 현재상태 = '하락' AND 종가 >= `20평균가`) as prev," +
                                " (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + date_param.ToString("yyyy-MM-dd") + "' AND unixtime <= '"
                                + date_param.AddDays(1).ToString("yyyy-MM-dd") + "' ) as result2" +
                                " WHERE (전체상태 = '상승')" +
                                " AND 현재상태 = '상승' AND 종가 >= `20평균가`) as current" +
                                " WHERE prev.category = current.category GROUP BY current.최근갯수";
                    }
                    else
                    {
                        message.Add("text", "*" + date_param.ToString("yyyy-MM-dd") + " 신규 추천 종목*");
                        query = "SELECT CONCAT(current.최근갯수, ' 단계 상승 종목') as `title`, GROUP_CONCAT(current.종목명) as `text`" +
                                " FROM (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + (date_param.DayOfWeek == DayOfWeek.Monday ? date_param.AddDays(-3).ToString("yyyy-MM-dd") :
                                                                          date_param.AddDays(-1).ToString("yyyy-MM-dd")) + "' AND unixtime <= '"
                                + date_param.ToString("yyyy-MM-dd") + "' ) as result1 WHERE (전체상태 = '횡보' OR 전체상태 = '하락')" +
                                " AND 현재상태 = '상승' AND 최근갯수 > 1 AND 과거갯수 > 1 AND 종가 > `20평균가`) as prev," +
                                " (" +
                                " SELECT *" +
                                " FROM (SELECT category, column_get(rawdata, '종목명' as char) as `종목명`," +
                                " column_get(rawdata, '종가' as double) as `종가`," +
                                " column_get(rawdata, '20평균가' as double) as `20평균가`," +
                                " column_get(rawdata, '60평균가' as double) as `60평균가`," +
                                " column_get(rawdata, '전체상태' as char) as `전체상태`," +
                                " column_get(rawdata, '현재상태' as char) as `현재상태`," +
                                " column_get(rawdata, 'V패턴_비율' as double) as `V패턴`," +
                                " column_get(rawdata, 'A패턴_비율' as double) as `A패턴`," +
                                " column_get(rawdata, '강도' as double) as `강도`," +
                                " column_get(rawdata, '최근갯수' as double) as `최근갯수`," +
                                " column_get(rawdata, '과거갯수' as double) as `과거갯수`" +
                                " FROM past_stock WHERE unixtime >= '" + date_param.ToString("yyyy-MM-dd") + "' AND unixtime <= '"
                                + date_param.AddDays(1).ToString("yyyy-MM-dd") + "' ) as result2" +
                                " WHERE (전체상태 = '횡보' OR 전체상태 = '하락')" +
                                " AND 현재상태 = '상승' AND 최근갯수 > 1 AND 과거갯수 > 1 AND 종가 > `20평균가`) as current" +
                                " WHERE prev.category = current.category GROUP BY current.최근갯수";
                    }
                    var down_recommaned = MariaDBConnector.Instance.GetJsonArray("DynamicQueryExecuter", query);

                    message.Add("attachments", down_recommaned);
                    this.SendMessage(message.ToString());
                    respond_cnt++;
                }
                else if (key == "분석" || key == "등록")
                {
                    foreach (var param in parameters)
                    {
                        message = new JsonObject();
                        if (key == "분석")
                        {
                            var search_result = stock_list.FirstOrDefault(p => p.Value["name"].ReadAs <string>().Contains(param) || p.Value["code"].ReadAs <string>().Contains(param));
                            if (search_result.Key != null)
                            {
                                var period = "day";
                                if (parameters.Find(p => p.Contains("주간")) != null)
                                {
                                    period = "week";
                                }

                                var view_instance = new ViewLogic();
                                var resultArr     = JsonObject.Parse(view_instance.AutoAnalysis(period, "avg",
                                                                                                new List <string>()
                                {
                                    search_result.Value["code"].ReadAs <string>()
                                },
                                                                                                null, date_param.AddDays(1).ToString("yyyy-MM-dd"), false));
                                if (resultArr.Count > 0)
                                {
                                    var result = resultArr[0];

                                    #region 주가 분석 레포트
                                    var price                 = result["종가"].ReadAs <double>();
                                    var highest               = result["최고가"].ReadAs <double>();
                                    var lowest                = result["최저가"].ReadAs <double>();
                                    var life_price            = result["생명선"].ReadAs <double>();
                                    var price_location        = Math.Round(result["주가위치"].ReadAs <double>(), 2);
                                    var price_analysis_report = new StringBuilder();
                                    price_analysis_report.AppendFormat("```현재 가격은 {0}원이며, 생명 가격인 {1}원 {2}에 위치해 있습니다.\n",
                                                                       price.ToString(), life_price.ToString(), life_price <= price ? "위" : "아래");
                                    price_analysis_report.AppendFormat("최저가 {0}원, 최고가는 {1}원으로 {2}%로 {3} 위치에 도달해 있습니다.```",
                                                                       lowest.ToString(), highest.ToString(), price_location.ToString(), price_location < 30 ? "낮은" : (price_location < 70 ? "중간" : "높은"));
                                    #endregion
                                    #region 거래량 분석 레포트
                                    var amount                 = result["상장주식수"].ReadAs <double>();
                                    var volume                 = result["거래량"].ReadAs <double>();
                                    var volume_oscillator      = Math.Round(result["VOLUME_OSCILLATOR"].ReadAs <double>(), 2);
                                    var volume_analysis_report = new StringBuilder();
                                    volume_analysis_report.AppendFormat("```{0}천주 대비 현재 거래되는 주식수는 {1}천주로 {2}%의 거래가 이루어지고 있고,\n",
                                                                        Math.Round(amount / 1000, 2).ToString(), Math.Round(volume / 1000, 2).ToString(), Math.Round(volume / amount * 100, 2).ToString());
                                    volume_analysis_report.AppendFormat("5일 거래량 대비 20일 거래량 비교했을때, {0}%만큼 {1}하였습니다.```",
                                                                        volume_oscillator.ToString(), volume_oscillator > 0 ? "증가" : "감소");
                                    #endregion
                                    #region 추세 분석 레포트
                                    var rsi                   = result["RSI"].ReadAs <double>();
                                    var rsi_state             = Math.Round(rsi) <= 30 ? "과매도" : (Math.Round(rsi) >= 70 ? "과매수" : "저항/지지");
                                    var total_state           = result["전체상태"].ReadAs <string>();
                                    var current_state         = result["현재상태"].ReadAs <string>();
                                    var current_count         = result["현재상태_유지횟수"].ReadAs <int>();
                                    var past_count            = result["과거상태_유지횟수"].ReadAs <int>();
                                    var trend_analysis_report = new StringBuilder();
                                    trend_analysis_report.AppendFormat("```현재 {0} 중이며, 전체적으로는 {1}을 유지하고 있습니다.\n", current_state, total_state);
                                    trend_analysis_report.AppendFormat("{0} 단계만큼 {1}하였고, 과거에는 {2} 단계만큼 {3}하였습니다.\n",
                                                                       current_count.ToString(), current_state, past_count, current_state == "상승" ? "하락" : "상승");
                                    trend_analysis_report.AppendFormat("최근 14일 동안 RSI가 {0}인 것으로 보아, {1} 상태로 판단되어 집니다.```",
                                                                       Math.Round(rsi, 2).ToString(), rsi_state);
                                    #endregion
                                    #region 저항과 지지 및 종합 분석 레포트
                                    var v_pattern  = result["V패턴_비율"].ReadAs <double>();
                                    var a_pattern  = result["A패턴_비율"].ReadAs <double>();
                                    var va_pretext = new StringBuilder();
                                    va_pretext.AppendFormat("`V패턴 : {0}%`      `A패턴 : {1}%`", Math.Round(v_pattern, 2), Math.Round(a_pattern, 2));
                                    var total_support    = new List <int>();
                                    var total_resistance = new List <int>();
                                    if (result.ContainsKey("반전지지"))
                                    {
                                        foreach (var item in JsonArray.Parse(result["반전지지"].ReadAs <string>()))
                                        {
                                            var test   = item.Value.ReadAs <int>();
                                            var length = item.Value.ReadAs <int>().ToString().Length - 3;
                                            if (length > 0)
                                            {
                                                var sampling = int.Parse(Math.Pow(10, length).ToString());
                                                test = test / sampling * sampling;
                                            }
                                            if (!total_support.Contains(test))
                                            {
                                                total_support.Add(test);
                                            }
                                        }
                                    }
                                    if (result.ContainsKey("실제지지"))
                                    {
                                        foreach (var item in JsonArray.Parse(result["실제지지"].ReadAs <string>()))
                                        {
                                            var test   = item.Value.ReadAs <int>();
                                            var length = item.Value.ReadAs <int>().ToString().Length - 3;
                                            if (length > 0)
                                            {
                                                var sampling = int.Parse(Math.Pow(10, length).ToString());
                                                test = test / sampling * sampling;
                                            }
                                            if (!total_support.Contains(test))
                                            {
                                                total_support.Add(test);
                                            }
                                        }
                                    }
                                    if (result.ContainsKey("반전저항"))
                                    {
                                        foreach (var item in JsonArray.Parse(result["반전저항"].ReadAs <string>()))
                                        {
                                            var test   = item.Value.ReadAs <int>();
                                            var length = item.Value.ReadAs <int>().ToString().Length - 3;
                                            if (length > 0)
                                            {
                                                var sampling = int.Parse(Math.Pow(10, length).ToString());
                                                test = test / sampling * sampling;
                                            }
                                            if (!total_resistance.Contains(test))
                                            {
                                                total_resistance.Add(test);
                                            }
                                        }
                                    }
                                    if (result.ContainsKey("실제저항"))
                                    {
                                        foreach (var item in JsonArray.Parse(result["실제저항"].ReadAs <string>()))
                                        {
                                            var test   = item.Value.ReadAs <int>();
                                            var length = item.Value.ReadAs <int>().ToString().Length - 3;
                                            if (length > 0)
                                            {
                                                var sampling = int.Parse(Math.Pow(10, length).ToString());
                                                test = test / sampling * sampling;
                                            }
                                            if (!total_resistance.Contains(test))
                                            {
                                                total_resistance.Add(test);
                                            }
                                        }
                                    }
                                    var support_pretext = new StringBuilder("```지지 가격 :");
                                    foreach (var support in total_support.OrderByDescending(p => p))
                                    {
                                        support_pretext.Append(" ").Append(support.ToString()).Append("원");
                                    }
                                    var resistance_pretext = new StringBuilder("```저항 가격 :");
                                    foreach (var support in total_resistance.OrderBy(p => p))
                                    {
                                        resistance_pretext.Append(" ").Append(support.ToString()).Append("원");
                                    }

                                    if (result.ContainsKey("바닥"))
                                    {
                                        support_pretext.Append("\n바닥 가격 :");
                                        foreach (var bottom in result["바닥"].ReadAs <JsonArray>())
                                        {
                                            support_pretext.Append(" ").Append(bottom.ToString());
                                        }
                                    }
                                    if (result.ContainsKey("천장"))
                                    {
                                        resistance_pretext.Append("\n천장 가격 :");
                                        foreach (var up in result["천장"].ReadAs <JsonArray>())
                                        {
                                            resistance_pretext.Append(" ").Append(up.ToString());
                                        }
                                    }
                                    support_pretext.Append("``` ");
                                    resistance_pretext.Append("``` ");
                                    var action_state          = "매수";
                                    var total_analysis_report = new StringBuilder();
                                    if (total_state == "상승")
                                    {
                                        if (current_state == "상승")
                                        {
                                            total_analysis_report.Append("강한 상승 중입니다.");
                                            action_state = "매도";
                                        }
                                        else
                                        {
                                            total_analysis_report.Append("고점 확인 후 조정 구간입니다.");
                                            action_state = "매수";
                                        }
                                    }
                                    else if (total_state == "하락")
                                    {
                                        if (current_state == "상승")
                                        {
                                            total_analysis_report.Append("저점 확인 후 바닥 형성 구간입니다.");
                                            action_state = "매수";
                                        }
                                        else
                                        {
                                            total_analysis_report.Append("강한 하락 중입니다.");
                                            action_state = "관심";
                                        }
                                    }
                                    else if (total_state == "횡보")
                                    {
                                        if (current_state == "상승")
                                        {
                                            total_analysis_report.Append("상승 전환 구간입니다.");
                                            action_state = "매수";
                                        }
                                        else
                                        {
                                            total_analysis_report.Append("하락 전환 구간입니다.");
                                            action_state = "관심";
                                        }
                                    }
                                    total_analysis_report.AppendFormat("\n거래량 분석({0}%만큼 {1})에 따라 현재 상태에 대한 신뢰성이 결정되고,\n" +
                                                                       "RSI({2})에 따라 매수타이밍을 포착하시기 바랍니다.\n" +
                                                                       "추가적으로 추세분석에서 나온 상승/하락의 단계에 따라 저항/지지 가격을 결정하시면 됩니다.",
                                                                       volume_oscillator.ToString(), volume_oscillator > 0 ? "증가" : "감소", rsi.ToString());
                                    #endregion
                                    #region 캔들 분석 레포트
                                    var curr_start = result["curr_start"].ReadAs <double>();
                                    var curr_end   = result["curr_end"].ReadAs <double>();
                                    var curr_high  = result["curr_high"].ReadAs <double>();
                                    var curr_low   = result["curr_low"].ReadAs <double>();

                                    var prev_start = result["prev_start"].ReadAs <double>();
                                    var prev_end   = result["prev_end"].ReadAs <double>();
                                    var prev_high  = result["prev_high"].ReadAs <double>();
                                    var prev_low   = result["prev_low"].ReadAs <double>();

                                    // Single Candle Analysis
                                    var curr_candle_direct = curr_start > curr_end ? "음봉" : curr_start < curr_end ? "양봉" : "도지";
                                    var curr_candle_weight = Math.Abs(curr_start - curr_end);
                                    var curr_low_weight    = Math.Abs((curr_start > curr_end ? curr_end : curr_start) - curr_low);
                                    var curr_high_weight   = Math.Abs((curr_start > curr_end ? curr_start : curr_end) - curr_high);
                                    // Dual Candle Analysis
                                    var prev_candle_direct    = prev_start > prev_end ? "음봉" : prev_start < prev_end ? "양봉" : "도지";
                                    var prev_candle_weight    = Math.Abs(prev_start - prev_end);
                                    var prev_low_line_weight  = Math.Abs((prev_start > prev_end ? prev_end : prev_start) - prev_low);
                                    var prev_high_line_weight = Math.Abs((prev_start > prev_end ? prev_start :prev_end) - prev_high);

                                    var total_range            = prev_end * 0.6;
                                    var price_movement         = curr_candle_weight + curr_low_weight + curr_high_weight;
                                    var candle_movement        = Math.Round(price_movement / total_range * 100, 2);
                                    var high_per               = ((curr_candle_direct == "음봉" ? curr_candle_weight : 0) + curr_high_weight) / price_movement * 100;
                                    var low_per                = ((curr_candle_direct == "양봉" ? curr_candle_weight : 0) + curr_low_weight) / price_movement * 100;
                                    var candle_analysis_report = new StringBuilder();
                                    candle_analysis_report.AppendFormat("```현재 주가는 {0}%({1}원) 유동성을 보이고 있습니다.\n", candle_movement.ToString(), price_movement.ToString());
                                    candle_analysis_report.AppendFormat("현재 캔들은 {0}({4}원) 형태이며, (위꼬리:{1}% / 아래꼬리:{2}%)인 것으로 보아 {3}가 우위에 있습니다.\n",
                                                                        curr_candle_direct, Math.Round(high_per, 2), Math.Round(low_per, 2), low_per > high_per ? "매수세" : "매도세", curr_end - curr_start);

                                    var test1 = curr_start - prev_end;
                                    var test2 = curr_end - curr_start;
                                    var test3 = prev_end - prev_start;
                                    if (test1 <= 0 && test2 < 0)
                                    {
                                        candle_analysis_report.Append(prev_candle_direct + " 후 하락 추세 캔들" +
                                                                      (prev_candle_direct == "음봉" ? " (200%이상 부정)" : " (50%이하 부정)") + "\n");
                                    }
                                    else if (test1 > 0 && test2 < 0)
                                    {
                                        candle_analysis_report.Append(prev_candle_direct + " 후 하락 반격 캔들" +
                                                                      (prev_candle_direct == "음봉" ? " (100%이상 부정)" : " (50%이하 부정)") + "\n");
                                    }
                                    else if (test1 >= 0 && test2 > 0)
                                    {
                                        candle_analysis_report.Append(prev_candle_direct + " 후 상승 추세 캔들" +
                                                                      (prev_candle_direct == "음봉" ? " (50%이하 긍정)" :" (200%이상 긍정)") + "\n");
                                    }
                                    else if (test1 < 0 && test2 > 0)
                                    {
                                        candle_analysis_report.Append(prev_candle_direct + " 후 상승 반격 캔들" +
                                                                      (prev_candle_direct == "음봉" ? " (50%이하 긍정)" : " (100%이상 긍정)") + "\n");
                                    }
                                    else
                                    {
                                        candle_analysis_report.Append(prev_candle_direct + " 후 도지 캔들\n");
                                    }
                                    candle_analysis_report.AppendFormat("강도 : {1}원 대비 {0}%", (test1 + test2 + test3) / test3 * 100, prev_candle_weight);
                                    candle_analysis_report.Append("```");
                                    #endregion

                                    message.Add("text", "*" + date_param.ToString("yyyy-MM-dd") + " " + param + " 분석결과*");
                                    message.Add("attachments", new JsonArray(
                                                    new JsonObject(
                                                        //new KeyValuePair<string, JsonValue>("color", "#00ff00"),
                                                        //new KeyValuePair<string, JsonValue>("pretext", "pre_text"),
                                                        new KeyValuePair <string, JsonValue>("title", "주가 분석"),
                                                        new KeyValuePair <string, JsonValue>("text", price_analysis_report.ToString()),
                                                        //new KeyValuePair<string, JsonValue>("fields", price_fields),
                                                        new KeyValuePair <string, JsonValue>("mrkdwn_in", new JsonArray("text", "pretext", "fields"))
                                                        ), new JsonObject(
                                                        //new KeyValuePair<string, JsonValue>("color", "#ff0000"),
                                                        //new KeyValuePair<string, JsonValue>("pretext", "pre_text"),
                                                        new KeyValuePair <string, JsonValue>("title", "거래량 분석"),
                                                        new KeyValuePair <string, JsonValue>("text", volume_analysis_report.ToString()),
                                                        new KeyValuePair <string, JsonValue>("mrkdwn_in", new JsonArray("text", "pretext", "fields"))
                                                        ), new JsonObject(
                                                        //new KeyValuePair<string, JsonValue>("color", "#0000ff"),
                                                        new KeyValuePair <string, JsonValue>("pretext", va_pretext.ToString()),
                                                        new KeyValuePair <string, JsonValue>("title", "추세 분석"),
                                                        new KeyValuePair <string, JsonValue>("text", trend_analysis_report.ToString()),
                                                        new KeyValuePair <string, JsonValue>("mrkdwn_in", new JsonArray("text", "pretext", "fields"))
                                                        ), new JsonObject(
                                                        //new KeyValuePair<string, JsonValue>("color", "#0000ff"),
                                                        new KeyValuePair <string, JsonValue>("title", "캔들 분석"),
                                                        new KeyValuePair <string, JsonValue>("text", candle_analysis_report.ToString()),
                                                        new KeyValuePair <string, JsonValue>("mrkdwn_in", new JsonArray("text", "pretext", "fields"))
                                                        ), new JsonObject(
                                                        //new KeyValuePair<string, JsonValue>("color", "#ffffff"),
                                                        new KeyValuePair <string, JsonValue>("pretext", support_pretext.ToString() + resistance_pretext.ToString()),
                                                        new KeyValuePair <string, JsonValue>("title", "종합 소견"),
                                                        new KeyValuePair <string, JsonValue>("text", "```" + total_analysis_report.ToString() + "```"),
                                                        new KeyValuePair <string, JsonValue>("mrkdwn_in", new JsonArray("text", "pretext", "fields"))
                                                        )));
                                }
                                this.SendMessage(message.ToString());
                                respond_cnt++;
                            }
                        }
                        else if (key.Contains("등록"))
                        {
                            var search_result = stock_list.FirstOrDefault(p => p.Value["name"].ReadAs <string>().Contains(param) || p.Value["code"].ReadAs <string>().Contains(param));

                            if (search_result.Key != null)
                            {
                                search_result.Value["state"] = true;
                                var resultPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory);
                                System.IO.File.WriteAllText(Path.Combine(resultPath, "stocklist.json"), stock_list.ToString());
                                message.Add("text", "*" + search_result.Value["name"].ReadAs <string>() + " 등록 완료*");
                                this.SendMessage(message.ToString());
                                respond_cnt++;
                            }
                        }
                    }
                }
            }
            if (respond_cnt == 0)
            {
                var message = new JsonObject();
                message.Add("text", "제가 이해할 수 있게 명령해주세요.");
                this.SendMessage(message.ToString());
                message["text"] = ">>>1. 빅앤츠 (주식명) 분석해\n2. 빅앤츠 (상승,하락,전환,신규) 추천해봐";
                this.SendMessage(message.ToString());
            }
        }
Example #12
0
 /// <summary>
 ///  界面获取焦点
 /// </summary>
 public void Activate()
 {
     ViewLogic.Activate();
 }
Example #13
0
 /// <summary>
 ///  显示界面
 /// </summary>
 public void Show()
 {
     ViewLogic.Show();
 }
Example #14
0
        protected override void OnMessage(MessageEventArgs e)
        {
            var result  = new JsonObject();
            var reqInfo = JsonValue.Parse(e.Data);

            foreach (var item in reqInfo)
            {
                result.Add(new KeyValuePair <string, JsonValue>(item.Key, item.Value));
            }
            JsonValue returnString = string.Empty;
            var       target       = reqInfo["target"].ReadAs <string>();
            var       method       = reqInfo["method"].ReadAs <string>();

            switch (target.ToLower())
            {
                #region Member
            case "member":
            {
                var memberLogic = new MemberLogic(ref this.sendEvent, ref this.sendQueue);
                switch (method.ToLower())
                {
                case "schema":
                {
                    returnString = memberLogic.Schema();
                    break;
                }

                case "access":
                {
                    returnString = memberLogic.Access(reqInfo["parameters"]);
                    break;
                }

                case "getlist":
                {
                    returnString = memberLogic.GetList();
                    break;
                }

                case "create":
                {
                    returnString = memberLogic.Create(reqInfo["parameters"]);
                    break;
                }

                case "modify":
                {
                    returnString = memberLogic.Modify(reqInfo["parameters"]);
                    break;
                }

                case "delete":
                {
                    returnString = memberLogic.Delete(reqInfo["parameters"]);
                    break;
                }
                }
                break;
            }
                #endregion

                #region Collection
            case "collection":
            {
                var collectionLogic = new CollectionLogic(ref this.sendEvent, ref this.sendQueue);
                switch (method.ToLower())
                {
                case "schema":
                {
                    returnString = collectionLogic.Schema();
                    break;
                }

                case "getlist":
                {
                    returnString = collectionLogic.GetList();
                    break;
                }

                case "create":
                {
                    returnString = collectionLogic.Create(reqInfo["parameters"]);
                    break;
                }

                case "modify":
                {
                    returnString = collectionLogic.Modify(reqInfo["parameters"]);
                    break;
                }

                case "delete":
                {
                    returnString = collectionLogic.Delete(reqInfo["parameters"]);
                    break;
                }

                case "execute":
                {
                    returnString = collectionLogic.Execute(reqInfo["parameters"]);
                    break;
                }
                }
                break;
            }
                #endregion

                #region Analysis
            case "analysis":
            {
                var analysisLogic = new AnalysisLogic(ref this.sendEvent, ref this.sendQueue);
                switch (method.ToLower())
                {
                case "schema":
                {
                    returnString = analysisLogic.Schema();
                    break;
                }

                case "getlist":
                {
                    returnString = analysisLogic.GetList();
                    break;
                }

                case "create":
                {
                    returnString = analysisLogic.Create(reqInfo["parameters"]);
                    break;
                }

                case "modify":
                {
                    returnString = analysisLogic.Modify(reqInfo["parameters"]);
                    break;
                }

                case "delete":
                {
                    returnString = analysisLogic.Delete(reqInfo["parameters"]);
                    break;
                }

                case "execute":
                {
                    returnString = analysisLogic.Execute(reqInfo["parameters"]);
                    break;
                }
                }
                break;
            }
                #endregion

                #region DataView
            case "view":
            {
                var viewLogic = new ViewLogic(ref this.sendEvent, ref this.sendQueue);
                switch (method.ToLower())
                {
                case "schema":
                {
                    returnString = viewLogic.Schema(reqInfo["parameters"]["privilege"].ReadAs <string>());
                    break;
                }

                case "getlist":
                {
                    returnString = viewLogic.GetList(reqInfo["parameters"]);
                    break;
                }

                case "create":
                {
                    returnString = viewLogic.Create(reqInfo["parameters"]);
                    break;
                }

                case "modify":
                {
                    returnString = viewLogic.Modify(reqInfo["parameters"]);
                    break;
                }

                case "delete":
                {
                    returnString = viewLogic.Delete(reqInfo["parameters"]);
                    break;
                }

                case "execute":
                {
                    returnString = viewLogic.Execute(reqInfo["parameters"]);
                    break;
                }

                case "execute_item":
                {
                    returnString = viewLogic.ExecuteItem(reqInfo["parameters"]);
                    break;
                }

                case "download":
                {
                    returnString = viewLogic.Download(reqInfo["parameters"]);
                    break;
                }
                }
                break;
            }
                #endregion

                #region Input
            case "input":
            {
                var inputLogic = new InputLogic(ref this.sendEvent, ref this.sendQueue);
                switch (method.ToLower())
                {
                case "getlist":
                {
                    returnString = inputLogic.GetList(reqInfo["parameters"]);
                    break;
                }

                case "create":
                {
                    returnString = inputLogic.Create(reqInfo["parameters"]);
                    break;
                }

                case "modify":
                {
                    returnString = inputLogic.Modify(reqInfo["parameters"]);
                    break;
                }

                case "delete":
                {
                    returnString = inputLogic.Delete(reqInfo["parameters"]);
                    break;
                }
                }
                break;
            }
                #endregion

                #region Cluster
            case "cluster":
            {
                var clusterLogic = new ClusterLogic(ref this.sendEvent, ref this.sendQueue);
                switch (method.ToLower())
                {
                case "schema":
                {
                    break;
                }

                case "getlist":
                {
                    returnString = clusterLogic.GetList(reqInfo["parameters"]);
                    break;
                }

                case "gettab":
                {
                    returnString = clusterLogic.GetTab(reqInfo["parameters"]);
                    break;
                }

                case "getplayback":
                {
                    returnString = clusterLogic.GetPlayback(reqInfo["parameters"]);
                    break;
                }
                }
                break;
            }
                #endregion
            }

            result.Add(new KeyValuePair <string, JsonValue>("result", returnString));
            this.Send(result.ToString());
        }