Exemple #1
0
        internal void DetSorting(string name, bool isDesc)
        {
            List <PotionDetailModelViewModel> temp = null;

            switch (name)
            {
            case "ContractCode":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.ContractCode).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.ContractCode).ToList();
                }

                break;

            case "Direction":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.Direction).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.Direction).ToList();
                }

                break;

            case "PositionVolume":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.PositionVolume).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.PositionVolume).ToList();
                }

                break;

            case "AbleVolume":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.AbleVolume).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.AbleVolume).ToList();
                }

                break;

            case "OpenPrice":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.OpenPrice).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.OpenPrice).ToList();
                }

                break;

            case "ShadowTradeId":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.ShadowTradeId).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.ShadowTradeId).ToList();
                }

                break;

            case "PositionProfitLoss":
                if (isDesc)
                {
                    temp = DetPMList.OrderBy(x => x.PositionProfitLoss).ToList();
                }
                else
                {
                    temp = DetPMList.OrderByDescending(x => x.PositionProfitLoss).ToList();
                }

                break;
            }
            DetPMList.Clear();
            foreach (var item in temp)
            {
                DetPMList.Add(item);
            }
        }
Exemple #2
0
        /// <summary>
        /// 提供行情信息 显示要交易的期货行情的信息
        /// </summary>
        /// <param name="futures"></param>
        public void SendMarket(QuotationEntity futures)
        {
            if (futures == null)
            {
                return;
            }
            if (PMList.Count == 0)
            {
                return;
            }
            List <PotionDetailModelViewModel> items = PMList.Where(x => x.ContractId == futures.cd).ToList();
            VarietyModel  vm = null;
            ParitiesModel pm = null;

            lock (DetPMList)
            {
                foreach (PotionDetailModelViewModel itemde in DetPMList)
                {
                    if (itemde.ContractCode == futures.cd)
                    {
                        string[] values = futures.cd.Split(' ');
                        if (values.Length != 3)
                        {
                            return;
                        }
                        string varietie = values[1];
                        if (ContractVariety.Varieties.ContainsKey(varietie))
                        {
                            vm = ContractVariety.Varieties[varietie];
                        }
                        if (vm == null)
                        {
                            continue;
                        }
                        if (itemde.Direction == "B")
                        {
                            if (futures.lp > 0)
                            {
                                itemde.PositionProfitLoss = (futures.lp - itemde.OpenPrice) * itemde.PositionVolume * vm.multiple;//合约乘数
                            }
                            else if (futures.lp == 0 && futures.pslp > 0)
                            {
                                itemde.PositionProfitLoss = (futures.pslp - itemde.OpenPrice) * itemde.PositionVolume * vm.multiple;//合约乘数
                            }
                            else if (futures.lp == 0 && futures.pslp == 0)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (futures.lp > 0)
                            {
                                itemde.PositionProfitLoss = (itemde.OpenPrice - futures.lp) * itemde.PositionVolume * vm.multiple;//合约乘数
                            }
                            else if (futures.lp == 0 && futures.pslp > 0)
                            {
                                itemde.PositionProfitLoss = (itemde.OpenPrice - futures.pslp) * itemde.PositionVolume * vm.multiple;//合约乘数
                            }
                            else if (futures.lp == 0 && futures.pslp == 0)
                            {
                                continue;
                            }
                        }
                    }
                }
                if (items != null)
                {
                    foreach (var item in items)
                    {
                        string[] values = futures.cd.Split(' ');
                        if (values.Length != 3)
                        {
                            return;
                        }
                        string varietie = values[1];
                        if (ContractVariety.Varieties.ContainsKey(varietie))
                        {
                            vm = ContractVariety.Varieties[varietie];
                        }
                        if (vm == null)
                        {
                            return;
                        }

                        //  if (item.Direction == "B")
                        item.PositionProfitLoss = Math.Round(DetPMList.Where(x => x.ContractId == item.ContractId && x.Direction == item.Direction).Sum(x => x.PositionProfitLoss), vm.precision);//合约乘数
                        if (ContractVariety.Parities.ContainsKey(vm.currency_code))
                        {
                            pm = ContractVariety.Parities[vm.currency_code];
                        }
                        if (pm == null)
                        {
                            return;
                        }
                        // if (item.Direction == "B")
                        item.PositionProfitLossJB = DetPMList.Where(x => x.ContractId == item.ContractId && x.Direction == item.Direction).Sum(x => x.PositionProfitLoss) * pm.exchange_rate; //合约乘数*汇率
                                                                                                                                                                                              // item.PositionProfitLossJB = (item.OpenPrice - futures.lastPrice) * item.PositionVolume * vm.multiple * pm.exchange_rate;//合约乘数*汇率
                    }
                    CommParameterSetting.StartAutoStopLoss(futures);
                }
            }
        }