Ejemplo n.º 1
0
        public ResponseExchangeDashboardCoinDataModel GetCoinData(EnumLib.RealTimeCoinCode ctype)
        {
            ResponseExchangeDashboardCoinDataModel item = new ResponseExchangeDashboardCoinDataModel();

            try
            {
                int i = CoinData.Where(w => w.Key == ctype).Count();
                if (i != 0)
                {
                    item = CoinData[ctype];
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
            return(item);
        }
Ejemplo n.º 2
0
 public void SetCoinData(EnumLib.RealTimeCoinCode ctype, ResponseExchangeDashboardCoinDataModel item)
 {
     try
     {
         int i = CoinData.Where(w => w.Key == ctype).Count();
         if (i == 0)
         {
             CoinData.Add(ctype, item);
         }
         else
         {
             CoinData[ctype] = item;
         }
     }
     catch (Exception ex)
     {
         SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
     }
 }
Ejemplo n.º 3
0
        private void Process(string message)
        {
            try
            {
                var response = new JavaScriptSerializer().Deserialize <dynamic>(message);

                string marketType = response["mt"];
                string marketCode = response["mc"];
                string curcyCd    = response["cd"];
                string dt         = response["dt"];

                if (MainViewModel.CoinData == null)
                {
                    return;
                }

                switch (dt)
                {
                //코인별 시세
                case "cr":
                    using (var tempWsCoinPriceData = new WsCoinPriceDataModel())
                    {
                        tempWsCoinPriceData.marketType = marketType;
                        tempWsCoinPriceData.marketCode = marketCode;

                        var tempWsCoinPriceData1 = Jss.Deserialize <MqCoinPriceModel>(message).data;

                        foreach (var item in tempWsCoinPriceData1.list)
                        {
                            string floatFormat = "n8";
                            if (marketCode == CommonLib.StandardCurcyCd)
                            {
                                ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == item.cd).FirstOrDefault();
                                floatFormat = "n" + (cl == null ? "0" : cl.CashDecimal.ToString());
                            }

                            tempWsCoinPriceData.list.Add(new WsCoinPriceListModel()
                            {
                                curcyCd = item.cd, coinPrc = item.cp, maxPrc = item.bp, minPrc = item.sp, ytdPrc = item.yp, floatFormat = floatFormat
                            });
                        }

                        if (WsCoinPriceData2.ToList().Where(w => w.Key.Key == marketCode && w.Key.Value == marketCode).Count() == 0)
                        {
                            WsCoinPriceData2.Add(new KeyValuePair <string, string>(marketCode, marketCode), tempWsCoinPriceData);
                        }
                        else
                        {
                            WsCoinPriceData2[new KeyValuePair <string, string>(marketCode, marketCode)] = tempWsCoinPriceData;
                        }

                        if (WsCoinPriceData2 != null)
                        {
                            Messenger.Default.Send(tempWsCoinPriceData);
                        }
                    };
                    break;

                //거래소 실시간 코인시세
                case "rp":
                    using (var tempCoinPriceData = new ResponseExchangeDashboardCoinDataModel())
                    {
                        tempCoinPriceData.Time       = curcyCd;
                        tempCoinPriceData.marketType = marketType;
                        tempCoinPriceData.marketCode = marketCode;

                        var tempCoinPriceData1 = Jss.Deserialize <MqExchangeDashboardCoinModel>(message).data;

                        foreach (var item in tempCoinPriceData1.list)
                        {
                            string floatFormat = "n8";
                            if (marketCode == CommonLib.StandardCurcyCd)
                            {
                                ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == item.cd).FirstOrDefault();
                                floatFormat = "n" + (cl == null ? "0" : cl.CashDecimal.ToString());
                            }

                            tempCoinPriceData.list.Add(new ResponseExchangeDashboardCoinListModel()
                            {
                                curcyCd = item.cd, coinNm = item.cn, coinPrc = item.cp, chgPrc = item.hp, volume = item.vo, svcTranPrc = item.tc, svcTranAmt = item.sa, floatFormat = floatFormat
                            });
                        }

                        if (CoinPriceData2.ToList().Where(w => w.Key.Key == marketCode && w.Key.Value == tempCoinPriceData.Time).Count() == 0)
                        {
                            CoinPriceData2.Add(new KeyValuePair <string, string>(marketCode, tempCoinPriceData.Time), tempCoinPriceData);
                        }
                        else
                        {
                            CoinPriceData2[new KeyValuePair <string, string>(marketCode, tempCoinPriceData.Time)] = tempCoinPriceData;
                        }

                        if (tempCoinPriceData != null)
                        {
                            Messenger.Default.Send(tempCoinPriceData);
                        }
                    };
                    break;

                //전체 주문내역
                case "ob":
                    using (var tempOrderData = new ResponseExchangeDashboardOrderDataModel())
                    {
                        tempOrderData.curcyCd    = curcyCd;
                        tempOrderData.marketType = marketType;
                        tempOrderData.marketCode = marketCode;

                        var tempOrderData1 = Jss.Deserialize <MqExchangeDashboardOrderModel>(message).data;

                        string floatFormat = "n8";
                        if (marketCode == CommonLib.StandardCurcyCd)
                        {
                            ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == curcyCd).FirstOrDefault();
                            floatFormat = "n" + (cl == null ? "0" : cl.CashDecimal.ToString());
                        }

                        foreach (var item in tempOrderData1.list)
                        {
                            tempOrderData.list.Add(new ResponseExchangeDashboardOrderListModel()
                            {
                                buyCnAmt = item.ba, buyTranPrc = item.bp, sellCnAmt = item.sa, sellTranPrc = item.sp, floatFormat = floatFormat
                            });
                        }

                        if (OrderData2.ToList().Where(w => w.Key.Key == marketCode && w.Key.Value == tempOrderData.curcyCd).Count() == 0)
                        {
                            OrderData2.Add(new KeyValuePair <string, string>(marketCode, tempOrderData.curcyCd), tempOrderData);
                        }
                        else
                        {
                            OrderData2[new KeyValuePair <string, string>(marketCode, tempOrderData.curcyCd)] = tempOrderData;
                        }

                        if (tempOrderData != null)
                        {
                            Messenger.Default.Send(tempOrderData);
                        }
                    };
                    break;

                //전체 체결 내역
                case "oc":
                    using (var tempFillData = new ResponseExchangeDashboardFillDataModel())
                    {
                        tempFillData.curcyCd    = curcyCd;
                        tempFillData.marketType = marketType;
                        tempFillData.marketCode = marketCode;

                        var tempFillData1 = Jss.Deserialize <MqExchangeDashboardFillModel>(message).data;

                        string floatFormat = "n8";
                        if (marketCode == CommonLib.StandardCurcyCd)
                        {
                            ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == curcyCd).FirstOrDefault();
                            floatFormat = "n" + (cl == null ? "0" : cl.CashDecimal.ToString());
                        }

                        foreach (var item in tempFillData1.list)
                        {
                            tempFillData.list.Add(new ResponseExchangeDashboardFillListModel()
                            {
                                tradeTime = item.tt, coinPrc = item.cp, cnAmt = item.ca, tradePrc = item.tp, curcyCd = item.cd, orderCd = item.oc == "B" ? "CMMC00000000197" : "CMMC00000000198", floatFormat = floatFormat
                            });
                        }

                        if (FillData2.ToList().Where(w => w.Key.Key == marketCode && w.Key.Value == tempFillData.curcyCd).Count() == 0)
                        {
                            FillData2.Add(new KeyValuePair <string, string>(marketCode, tempFillData.curcyCd), tempFillData);
                        }
                        else
                        {
                            FillData2[new KeyValuePair <string, string>(marketCode, tempFillData.curcyCd)] = tempFillData;
                        }

                        if (tempFillData != null)
                        {
                            Messenger.Default.Send(tempFillData);
                        }
                    };
                    break;

                //코인 체결 정보
                case "ci":
                    using (var tempCoinInfoData = new ResponseCoinInfoDataModel())
                    {
                        var tempCoinInfoData1 = Jss.Deserialize <MqCoinInfoModel>(message).data;

                        ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == curcyCd).FirstOrDefault();
                        string floatFormat       = "n" + (cl == null ? "0" : cl.CashDecimal.ToString());

                        tempCoinInfoData.curcyCd     = curcyCd;
                        tempCoinInfoData.marketType  = marketType;
                        tempCoinInfoData.marketCode  = marketCode;
                        tempCoinInfoData.nowPrc      = tempCoinInfoData1.cp;
                        tempCoinInfoData.ytdPrc      = tempCoinInfoData1.yp;
                        tempCoinInfoData.ytdPer      = tempCoinInfoData1.yr;
                        tempCoinInfoData.maxPrc      = tempCoinInfoData1.mp;
                        tempCoinInfoData.maxPer      = tempCoinInfoData1.mr;
                        tempCoinInfoData.minPrc      = tempCoinInfoData1.np;
                        tempCoinInfoData.minPer      = tempCoinInfoData1.nr;
                        tempCoinInfoData.totAmt      = tempCoinInfoData1.ta;
                        tempCoinInfoData.ytdAmt      = tempCoinInfoData1.ya;
                        tempCoinInfoData.totPrc      = tempCoinInfoData1.tc;
                        tempCoinInfoData.ytdTotPrc   = tempCoinInfoData1.yc;
                        tempCoinInfoData.volume      = tempCoinInfoData1.vo;
                        tempCoinInfoData.svcTranAmt  = tempCoinInfoData1.sa;
                        tempCoinInfoData.floatFormat = floatFormat;

                        if (CoinInfoData2.ToList().Where(w => w.Key.Key == marketCode && w.Key.Value == tempCoinInfoData.curcyCd).Count() == 0)
                        {
                            CoinInfoData2.Add(new KeyValuePair <string, string>(marketCode, tempCoinInfoData.curcyCd), tempCoinInfoData);
                        }
                        else
                        {
                            CoinInfoData2[new KeyValuePair <string, string>(marketCode, tempCoinInfoData.curcyCd)] = tempCoinInfoData;
                        }

                        if (tempCoinInfoData != null)
                        {
                            Messenger.Default.Send(tempCoinInfoData);
                        }
                    };
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
        public void CoinSocketData(ResponseExchangeDashboardCoinDataModel item)
        {
            try
            {
                if (!IsLoad)
                {
                    return;
                }

                if (item.marketCode == HeaderCode && int.Parse(SelectTime.Value) == int.Parse(item.Time))
                {
                    DispatcherService.BeginInvoke(() =>
                    {
                        ObservableCollection <ResponseExchangeDashboardCoinListModel> deleteItemList = new ObservableCollection <ResponseExchangeDashboardCoinListModel>();

                        for (int i = 0; i < item.list.Count; i++)
                        {
                            if (item.list[i].chgPrc > 0)
                            {
                                item.list[i].Image = "/Images/ico_up_arr_red.png";
                            }
                            else if (item.list[i].chgPrc == 0)
                            {
                                item.list[i].Image = "/Images/ico_stop_change.png";
                            }
                            else if (item.list[i].chgPrc < 0)
                            {
                                item.list[i].Image = "/Images/ico_down_arr_blue.png";
                            }

                            if (SelectCoinCode == EnumLib.ExchangeCurrencyCode.KRW)
                            {
                                CmdSelectCoin(item.list[0]);
                            }
                            else
                            {
                                if ((tempCoin != StringEnum.GetStringValue(SelectCoinCode)) && (item.list[i].curcyCd == StringEnum.GetStringValue(SelectCoinCode)))
                                {
                                    tempCoin = StringEnum.GetStringValue(SelectCoinCode);
                                    if (SelectItem == null)
                                    {
                                        CmdSelectCoin(item.list[i]);
                                    }
                                    SelectItem = item.list[i];
                                }
                                else if (item.list[i].curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                                {
                                    txt_Quotes = item.list[i].coinPrc;
                                    txt_Rate   = item.list[i].volume;
                                    txt_Volume = item.list[i].svcTranAmt;
                                }
                            }

                            if (item.list[i].curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                            {
                                item.list[i].bold_Gb = FontWeights.Bold;
                            }
                            else
                            {
                                item.list[i].bold_Gb = FontWeights.Normal;
                            }
                            item.list[i].coinImage = "/Images/ico_nav_" + item.list[i].coinNm + ".png";
                            //item.list[i].ieoImage = "/Images/btn_ieo_s.png";
                            item.list[i].coinNmView = item.list[i].coinNm + "/" + HeaderName;

                            //if (item.list[i].coinNm.Equals("ADM"))
                            //{
                            //    item.list[i].ieoVisible = Visibility.Visible;
                            //}

                            if (item.list[i].coinNm == HeaderName)
                            {
                                ResponseExchangeDashboardCoinListModel temp = item.list.Where(x => x.coinNm == HeaderName).First();
                                if (temp != null)
                                {
                                    deleteItemList.Add(item.list[i]);
                                }
                            }

                            if (item.list[i].coinNm.Equals("USDT"))
                            {
                                deleteItemList.Add(item.list[i]);
                            }
                        }

                        foreach (var dItem in deleteItemList)
                        {
                            item.list.Remove(dItem);
                        }

                        CoinPriceData = item.list;
                    });
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }