Пример #1
0
        /// <summary>
        /// 请求收费方式
        /// </summary>
        public void ReqDetType()
        {
            // Thread.Sleep(2000);
            ReqPotion rpd = new ReqPotion();

            rpd.cmdcode = RequestCmdCode.ReqCalcDeposit;
            rpd.content = null;
            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rpd));
        }
Пример #2
0
        /// <summary>
        /// 请求合约品种
        /// </summary>
        private void ReqVariety()
        {
            // Thread.Sleep(2000);
            ReqPotion rpd = new ReqPotion();

            rpd.cmdcode = RequestCmdCode.SelectVariety;
            rpd.content = null;
            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rpd));
        }
Пример #3
0
        private void LoadData()
        {
            ReqPotion rpd = new ReqPotion();

            rpd.cmdcode = RequestCmdCode.SelectPotionDetialCode;
            rpd.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };
            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rpd));
        }
Пример #4
0
        /// <summary>
        /// 请求保证金
        /// </summary>
        public void ReqMargin()
        {
            ReqPotion rp = new ReqPotion();

            rp.cmdcode = RequestCmdCode.ReqMargin;
            rp.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };
            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
        }
Пример #5
0
        public void ReqTcp(int cmdcode, string userid)
        {
            ReqPotion trm = new ReqPotion();

            trm.cmdcode         = cmdcode;
            trm.content         = new ReqLoginName();
            trm.content.user_id = userid;
            string msg = JsonConvert.SerializeObject(trm);

            _scoketManager.SendTradeWSInfo(msg);
        }
        private void LoadData()
        {
            //成交明细
            ReqPotion rp = new ReqPotion();

            rp.cmdcode = RequestCmdCode.ToDayTradeCode;
            rp.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };

            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
        }
        public void LoadData()
        {
            //条件单
            ReqPotion rp = new ReqPotion();

            rp.cmdcode = RequestCmdCode.SelectConditionBill;
            rp.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };

            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
        }
Пример #8
0
        private void SendConditionBill(bool isClear = true)
        {
            ReqPotion rp = new ReqPotion();

            rp.cmdcode = RequestCmdCode.SelectConditionBill;
            rp.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };

            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
            if (isClear)
            {
                UCConditionBillViewModel.Instance().ConditionBillList.Clear();
            }
        }
Пример #9
0
        private void SendOrderCancel(bool isClear = true)
        {
            ReqPotion rpd = new ReqPotion();

            rpd.cmdcode = RequestCmdCode.SelectOrderCancel;
            rpd.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };
            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rpd));
            if (isClear)
            {
                OrderCancelViewModel.Instance().KCDelegations.Clear();
                OrderCancelViewModel.Instance().Delegations.Clear();
            }
        }
Пример #10
0
        private void ToDayTrade(bool isClear = true)
        {
            //成交明细
            ReqPotion rp = new ReqPotion();

            rp.cmdcode = RequestCmdCode.ToDayTradeCode;
            rp.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };

            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
            if (isClear)
            {
                TodayTraderViewModels.Instance().TodayTraderList.Clear();
            }
        }
Пример #11
0
        private void SendPotion(bool isClear = true)
        {
            ReqPotion rpd = new ReqPotion();

            rpd.cmdcode = RequestCmdCode.SelectPotionDetialCode;
            rpd.content = new ReqLoginName()
            {
                user_id = UserInfoHelper.UserId
            };
            ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rpd));
            if (isClear)
            {
                PositionAllViewModel.Instance().DetPMList.Clear();
                PositionAllViewModel.Instance().PMList.Clear();
                PositionViewModel.Instance().PMList.Clear();
            }
        }
        public void ExecutePositionDetialData(object para)
        {
            try
            {
                PotionDetailModel    pm   = para as PotionDetailModel;
                PositionAllViewModel pavm = PositionAllViewModel.Instance();
                if (pavm.DetPMList.FirstOrDefault(x => x.PsitionId == pm.position_id) != null)
                {
                    return;
                }
                if (pm.bLast)
                {
                    PotionDetailModelViewModel[] temp = pavm.DetPMList.ToArray();
                    //合约名加方向作为K
                    Dictionary <string, PotionDetailModelViewModel> dicod = new Dictionary <string, PotionDetailModelViewModel>();
                    foreach (PotionDetailModelViewModel item in temp)
                    {
                        PotionDetailModelViewModel pm1 = item.Clone(item);
                        if (!dicod.Keys.Contains(pm1.ContractCode + pm1.Direction))
                        {
                            pm1.AllPrice = pm1.OpenPrice * pm1.PositionVolume;
                            dicod.Add(pm1.ContractCode + pm1.Direction, pm1);
                            MainViewModel.GetInstance().SubscribedStocks.Add(pm1.ContractCode);
                        }
                        else
                        {
                            dicod[item.ContractCode + item.Direction].AbleVolume         = dicod[item.ContractCode + item.Direction].AbleVolume + item.AbleVolume;
                            dicod[item.ContractCode + item.Direction].PositionProfitLoss = dicod[item.ContractCode + item.Direction].PositionProfitLoss + item.PositionProfitLoss;
                            dicod[item.ContractCode + item.Direction].PositionVolume     = dicod[item.ContractCode + item.Direction].PositionVolume + item.PositionVolume;
                            dicod[item.ContractCode + item.Direction].UseMargin          = dicod[item.ContractCode + item.Direction].UseMargin + item.UseMargin;
                            dicod[item.ContractCode + item.Direction].SysUseMargin       = dicod[item.ContractCode + item.Direction].SysUseMargin + item.SysUseMargin;
                            dicod[item.ContractCode + item.Direction].AllPrice          += item.PositionVolume * item.OpenPrice;
                            dicod[item.ContractCode + item.Direction].OpenPrice          = dicod[item.ContractCode + item.Direction].AllPrice / dicod[item.ContractCode + item.Direction].PositionVolume;
                        }
                    }
                    if (dicod.Keys.Count > 0)
                    {
                        foreach (PotionDetailModelViewModel item in dicod.Values)
                        {
                            pavm.PMList.Add(item);
                            PositionViewModel.Instance().PMList.Add(item);
                        }
                    }
                    ScoketManager.GetInstance().SendSubscribeInfo(7, MainViewModel.GetInstance().SubscribedStocks);
                    //发送命令
                    ReqPotion rp = new ReqPotion();
                    rp.cmdcode = RequestCmdCode.SelectStopLoss;
                    rp.content = new ReqLoginName()
                    {
                        user_id = UserInfoHelper.UserId
                    };
                    ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
                    //PositionViewModel.Instance().JSAbleVolume();
                    TransactionViewModel.Instance().FigureUpNum(TransactionViewModel.Instance()._futures);
                    return;
                }

                VarietyModel vm     = null;
                string[]     values = pm.contract_id.Split(' ');
                if (values.Length == 3)
                {
                    string varietie = values[1];
                    if (ContractVariety.Varieties.ContainsKey(varietie))
                    {
                        vm = ContractVariety.Varieties[varietie];
                    }
                    if (vm != null)
                    {
                        pm.precision = vm.precision;
                    }
                }

                PotionDetailModelViewModel pvm = new PotionDetailModelViewModel(pm);
                pavm.DetPMList.Add(pvm);
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }