public void ExecuteTradeData(object para)
 {
     try
     {
         TodayTraderModel ttm = para as TodayTraderModel;
         if (TodayTraderViewModels.Instance().TodayTraderList.FirstOrDefault(x => x.TradeNumber == ttm.trade_id) != null)
         {
             return;
         }
         if (ttm.bLast)
         {
             Dictionary <string, TodayTraderModelViewModel> dicTTVM = new Dictionary <string, TodayTraderModelViewModel>();
             foreach (TodayTraderModelViewModel item in TodayTraderViewModels.Instance().TodayTraderList)
             {
                 if (!dicTTVM.ContainsKey(item.ContractCode + item.Direction + item.OpenOffset))
                 {
                     TodayTraderModelViewModel ttmvm = item.Clone(item);
                     ttmvm.AllPrice = item.TradePrice * item.TradeVolume;
                     dicTTVM.Add(item.ContractCode + item.Direction + item.OpenOffset, ttmvm);
                 }
                 else
                 {
                     dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].AllPrice    = dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].AllPrice + item.TradePrice * item.TradeVolume;
                     dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradeVolume = dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradeVolume + item.TradeVolume;
                     dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradePrice  = dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].AllPrice / dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradeVolume;
                 }
             }
             foreach (TodayTraderModelViewModel item in dicTTVM.Values)
             {
                 TodayTraderViewModels.Instance().TodayTraderListALL.Add(item);
             }
             return;
         }
         VarietyModel vm     = null;
         string[]     values = ttm.contract_code.Split(' ');
         if (values.Length == 3)
         {
             string varietie = values[1];
             if (ContractVariety.Varieties.ContainsKey(varietie))
             {
                 vm = ContractVariety.Varieties[varietie];
             }
             if (vm != null)
             {
                 ttm.precision = vm.precision;
             }
         }
         //添加持仓集合
         TodayTraderViewModels.Instance().TodayTraderList.Add(new TodayTraderModelViewModel(ttm));
     }
     catch (Exception ex)
     {
         LogHelper.Info(ex.ToString());
     }
 }
Exemplo n.º 2
0
 private void Border_MouseLeftButtonDown_10(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().ALLSorting("OpenOffset", isOpenOffset);
     isOpenOffset = !isOpenOffset;
 }
Exemplo n.º 3
0
 private void Border_MouseLeftButtonDown_9(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().ALLSorting("Direction", isDirection);
     isDirection = !isDirection;
 }
Exemplo n.º 4
0
 private void Border_MouseLeftButtonDown_8(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().ALLSorting("ContractCode", isContractCode);
     isContractCode = !isContractCode;
 }
Exemplo n.º 5
0
 private void Border_MouseLeftButtonDown_7(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().Sorting("ShadowTradeID", ShadowTradeID);
     ShadowTradeID = !ShadowTradeID;
 }
Exemplo n.º 6
0
 private void Border_MouseLeftButtonDown_6(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().Sorting("TradeTime", TradeTime);
     TradeTime = !TradeTime;
 }
Exemplo n.º 7
0
 private void Border_MouseLeftButtonDown_13(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().ALLSorting("TradeVolume", isTradeVolume);
     isTradeVolume = !isTradeVolume;
 }
Exemplo n.º 8
0
 private void Border_MouseLeftButtonDown_12(object sender, MouseButtonEventArgs e)
 {
     TodayTraderViewModels.Instance().ALLSorting("OrderOrderref", OrderOrderref);
     OrderOrderref = !OrderOrderref;
 }
        public void ExecuteTransactionInfoData(object para)
        {
            try
            {
                TransactionInfoModel tim = para as TransactionInfoModel;
                if (tim == null)
                {
                    return;
                }
                if (TodayTraderViewModels.Instance().TodayTraderList.FirstOrDefault(x => x.ShadowTradeID == tim.shadow_tradeID) != null)
                {
                    return;
                }
                TodayTraderModel ttm = new TodayTraderModel();
                ttm.contract_code  = tim.contract_code;
                ttm.direction      = tim.direction;
                ttm.open_offset    = tim.open_offset;
                ttm.order_id       = tim.order_id;
                ttm.price_type     = tim.price_type;
                ttm.shadow_orderID = tim.shadow_orderID;
                ttm.trade_id       = tim.trade_number;
                ttm.contract_id    = tim.contract_id;
                ttm.shadow_tradeID = tim.shadow_tradeID;
                ttm.trade_date     = tim.trade_date;
                ttm.trade_id       = tim.trade_id;
                ttm.trade_price    = tim.trade_price;
                ttm.trade_time     = tim.trade_time;
                ttm.trade_volume   = tim.trade_volume;
                VarietyModel vm     = null;
                string[]     values = ttm.contract_code.Split(' ');
                if (values.Length == 3)
                {
                    string varietie = values[1];
                    if (ContractVariety.Varieties.ContainsKey(varietie))
                    {
                        vm = ContractVariety.Varieties[varietie];
                    }
                    if (vm != null)
                    {
                        ttm.precision = vm.precision;
                    }
                }
                TodayTraderViewModels.Instance().TodayTraderList.Add(new TodayTraderModelViewModel(ttm));
                Dictionary <string, TodayTraderModelViewModel> dicTTVM = new Dictionary <string, TodayTraderModelViewModel>();
                foreach (TodayTraderModelViewModel item in TodayTraderViewModels.Instance().TodayTraderList)
                {
                    if (!dicTTVM.ContainsKey(item.ContractCode + item.Direction + item.OpenOffset))
                    {
                        TodayTraderModelViewModel ttmvm = item.Clone(item);
                        ttmvm.AllPrice = item.TradePrice * item.TradeVolume;
                        dicTTVM.Add(item.ContractCode + item.Direction + item.OpenOffset, ttmvm);
                    }
                    else
                    {
                        dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].AllPrice    = dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].AllPrice + item.TradePrice * item.TradeVolume;
                        dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradeVolume = dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradeVolume + item.TradeVolume;
                        dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradePrice  = dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].AllPrice / dicTTVM[item.ContractCode + item.Direction + item.OpenOffset].TradeVolume;
                    }
                }
                if (dicTTVM != null && dicTTVM.Values.Count > 0)
                {
                    TodayTraderViewModels.Instance().TodayTraderListALL.Clear();

                    foreach (TodayTraderModelViewModel item in dicTTVM.Values)
                    {
                        TodayTraderViewModels.Instance().TodayTraderListALL.Add(item);
                    }
                }
                if (CommParameterSetting.MessageAlert.TradeAlert == "窗口提示")
                {
                    // string msg = "\t合约已成交\t" + "\n\n" + ttm.contract_id + "\n\t" + "方向:" + (ttm.direction == "B" ? "买" : "卖") + "\n\t开平:" + (ttm.open_offset == 1 ? "开仓" : "平仓") + "\n\t成交数量:" + ttm.trade_volume + "\n\t成交价格" + ttm.trade_price;
                    string msg = "     " + ttm.contract_id + "\t" + "    方向:" + (ttm.direction == "B" ? "买" : "卖") + "\t\n     开平:" + (ttm.open_offset == 1 ? "开仓" : "平仓") + "\t    成交数量:" + ttm.trade_volume + "\t\n     成交价格" + ttm.trade_price + "\t" + "    已成交";
                    MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    LogHelper.Info(msg + "成交时间:");
                }
                else if (CommParameterSetting.MessageAlert.TradeAlert == "声音提示")
                {
                    SoundPlayerHelper.Play();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }