Beispiel #1
0
        internal static List <AccountGroupGNP> GetGroupNetPosition(XmlNode netXmlNode)
        {
            if (netXmlNode == null)
            {
                return(null);
            }
            List <AccountGroupGNP> accountGroups = new List <AccountGroupGNP>();

            foreach (XmlNode groupNode in netXmlNode.ChildNodes)
            {
                Guid            groupId         = new Guid(groupNode.Attributes["ID"].Value);
                string          groupCode       = groupNode.Attributes["Code"].Value;
                AccountGroupGNP accountGroupGNP = new AccountGroupGNP(groupId, groupCode);

                foreach (XmlNode accountNode in groupNode.ChildNodes[0].ChildNodes)
                {
                    Guid        accountId   = new Guid(accountNode.Attributes["ID"].Value);
                    string      accountCode = accountNode.Attributes["Code"].Value;
                    AccountType type        = (AccountType)Enum.ToObject(typeof(AccountType), int.Parse(accountNode.Attributes["Type"].Value));
                    AccountGNP  accountGNP  = new AccountGNP(accountId, accountCode, type);

                    foreach (XmlNode instrumentNode in accountNode.ChildNodes[0].ChildNodes)
                    {
                        Guid          instrumentId      = new Guid(instrumentNode.Attributes["ID"].Value);
                        decimal       lotBalance        = decimal.Parse(instrumentNode.Attributes["LotBalance"].Value);
                        decimal       quantity          = decimal.Parse(instrumentNode.Attributes["Quantity"].Value);
                        decimal       buyQuantity       = decimal.Parse(instrumentNode.Attributes["BuyQuantity"].Value);
                        string        buyAveragePrice   = instrumentNode.Attributes["BuyAveragePrice"].Value;
                        decimal       buyMultiplyValue  = decimal.Parse(instrumentNode.Attributes["BuyMultiplyValue"].Value);
                        decimal       sellQuantity      = decimal.Parse(instrumentNode.Attributes["SellQuantity"].Value);
                        string        sellAveragePrice  = instrumentNode.Attributes["SellAveragePrice"].Value;
                        decimal       sellMultiplyValue = decimal.Parse(instrumentNode.Attributes["SellMultiplyValue"].Value);
                        decimal       sellLot           = decimal.Parse(instrumentNode.Attributes["SellLot"].Value);
                        decimal       buyLot            = decimal.Parse(instrumentNode.Attributes["BuyLot"].Value);
                        decimal       sellSumEl         = decimal.Parse(instrumentNode.Attributes["SellSumEl"].Value);
                        decimal       buySumEl          = decimal.Parse(instrumentNode.Attributes["BuySumEl"].Value);
                        InstrumentGNP instrumentGNP     = new InstrumentGNP(instrumentId);
                        instrumentGNP.LotBalance        = lotBalance;
                        instrumentGNP.Quantity          = quantity;
                        instrumentGNP.BuyQuantity       = buyQuantity;
                        instrumentGNP.BuyAveragePrice   = buyAveragePrice;
                        instrumentGNP.BuyMultiplyValue  = buyMultiplyValue;
                        instrumentGNP.SellQuantity      = sellQuantity;
                        instrumentGNP.SellAveragePrice  = sellAveragePrice;
                        instrumentGNP.SellMultiplyValue = sellMultiplyValue;
                        instrumentGNP.SellLot           = sellLot;
                        instrumentGNP.BuyLot            = buyLot;
                        instrumentGNP.SellSumEl         = sellSumEl;
                        instrumentGNP.BuySumEl          = buySumEl;

                        accountGNP.InstrumentGNPs.Add(instrumentGNP);
                    }
                    accountGroupGNP.AccountGNPs.Add(accountGNP);
                }
                accountGroups.Add(accountGroupGNP);
            }

            return(accountGroups);
        }
        public static List<AccountGroupGNP> GetGroupNetPosition()
        {
            List<AccountGroupGNP> accountGroups = new List<AccountGroupGNP>();
            try
            {
                string xmlPath = GetCommandXmlPath("NetPosition");
                XmlDocument doc = new XmlDocument();
                doc.Load(xmlPath);
                XmlNode netXmlNode = doc.ChildNodes[1].ChildNodes[0];

                foreach (XmlNode groupNode in netXmlNode.ChildNodes)
                {
                    Guid groupId = new Guid(groupNode.Attributes["ID"].Value);
                    string groupCode = groupNode.Attributes["Code"].Value;
                    AccountGroupGNP accountGroupGNP = new AccountGroupGNP(groupId, groupCode);

                    foreach (XmlNode accountNode in groupNode.ChildNodes[0].ChildNodes)
                    {
                        Guid accountId = new Guid(accountNode.Attributes["ID"].Value);
                        string accountCode = accountNode.Attributes["Code"].Value;
                        AccountType type = (AccountType)Enum.ToObject(typeof(AccountType), int.Parse(accountNode.Attributes["Type"].Value));
                        AccountGNP accountGNP = new AccountGNP(accountId, accountCode, type);

                        foreach (XmlNode instrumentNode in accountNode.ChildNodes[0].ChildNodes)
                        {
                            Guid instrumentId = new Guid(instrumentNode.Attributes["ID"].Value);
                            decimal lotBalance = decimal.Parse(instrumentNode.Attributes["LotBalance"].Value);
                            decimal quantity = decimal.Parse(instrumentNode.Attributes["Quantity"].Value);
                            decimal buyQuantity = decimal.Parse(instrumentNode.Attributes["BuyQuantity"].Value);
                            string buyAveragePrice = instrumentNode.Attributes["BuyAveragePrice"].Value;
                            decimal buyMultiplyValue = decimal.Parse(instrumentNode.Attributes["BuyMultiplyValue"].Value);
                            decimal sellQuantity = decimal.Parse(instrumentNode.Attributes["SellQuantity"].Value);
                            string sellAveragePrice = instrumentNode.Attributes["SellAveragePrice"].Value;
                            decimal sellMultiplyValue = decimal.Parse(instrumentNode.Attributes["SellMultiplyValue"].Value);

                            InstrumentGNP instrumentGNP = new InstrumentGNP(instrumentId);
                            instrumentGNP.LotBalance = lotBalance;
                            instrumentGNP.Quantity = quantity;
                            instrumentGNP.BuyQuantity = buyQuantity;
                            instrumentGNP.BuyAveragePrice = buyAveragePrice;
                            instrumentGNP.BuyMultiplyValue = buyMultiplyValue;
                            instrumentGNP.SellQuantity = sellQuantity;
                            instrumentGNP.SellAveragePrice = sellAveragePrice;
                            instrumentGNP.SellMultiplyValue = sellMultiplyValue;

                            accountGNP.InstrumentGNPs.Add(instrumentGNP);
                        }
                        accountGroupGNP.AccountGNPs.Add(accountGNP);
                    }
                    accountGroups.Add(accountGroupGNP);
                }
            }
            catch (Exception ex)
            {
            }

            return accountGroups;
        }
Beispiel #3
0
        private Dictionary <Guid, AccountGroupGNP> BuildAccountGroupDict(DataSet dataSet, Guid[] instrumentIDs, string[] blotterCodeSelecteds)
        {
            DataRowCollection accountDataRowCollection          = dataSet.Tables[0].Rows;
            Dictionary <Guid, AccountGroupGNP> accountgroupDict = new Dictionary <Guid, AccountGroupGNP>(accountDataRowCollection.Count);

            foreach (DataRow dataRow in accountDataRowCollection)
            {
                Guid   accountID   = (Guid)dataRow["AccountID"];
                string accountCode = dataRow["AccountCode"].ToString();
                Guid   groupID     = (Guid)dataRow["GroupID"];
                string groupCode   = dataRow["GroupCode"].ToString();
                this.InitAccount(accountID);
                AccountGroupGNP group;
                if (accountgroupDict.ContainsKey(groupID))
                {
                    group = accountgroupDict[groupID];
                }
                else
                {
                    group = new AccountGroupGNP(groupID, groupCode);
                    accountgroupDict.Add(groupID, group);
                }

                var account = AccountRepository.Default.Get(accountID);
                var trans   = account.GetTrans(instrumentIDs);
                if (trans.Count > 0)
                {
                    Dictionary <Guid, InstrumentGNP> instrumentGNPDict = this.BuildInstrumentGNPDict((Account)account, trans, blotterCodeSelecteds);
                    if (instrumentGNPDict.Count > 0)
                    {
                        AccountGNP accountGNP = new AccountGNP(account.Id, account.Code, account.Type);
                        accountGNP.instrumentGNPs = instrumentGNPDict;
                        group.accountGNPs.Add(account.Id, accountGNP);
                    }
                }
            }
            return(accountgroupDict);
        }
 private void GetGroupNetPositionCallback(List<CommonAccountGroupGNP> accountGroupGNPs)
 {
     this.Dispatcher.BeginInvoke((Action)delegate()
     {
         if (accountGroupGNPs == null) return;
         RootGNP rootGNP = new RootGNP();
         foreach (CommonAccountGroupGNP group in accountGroupGNPs)
         {
             AccountGroupGNP accountGroupGNP = new AccountGroupGNP(group);
             rootGNP.AccountGroupGNPs.Add(accountGroupGNP);
         }
         this._GroupNetPositionModel.RootGNPs.Add(rootGNP);
         string exchangeCode = this._ExchangeComboBox.SelectedItem.ToString();
         this.CalculateLotBalance(exchangeCode);
         this.BindingData();
         if (!this._ReportDataManager.GroupNetPositionModels.ContainsKey(exchangeCode))
         {
             this._ReportDataManager.GroupNetPositionModels.Add(exchangeCode, this._GroupNetPositionModel);
         }
     });
 }
        private void CalculateOIPercentQuantity(AccountGroupGNP accountGroupGNP, bool isCheckBoxColumn, decimal oldOiPercent)
        {
            try
            {
                bool isCheck = accountGroupGNP.IsSelected;
                decimal newOIPercent = accountGroupGNP.OIPercent;

                RootGNP rootGNP = this._GroupNetPositionModel.RootGNPs[0];
                foreach (InstrumentGNP de in this._AllColumns.Values)
                {
                    string columnCode = de.IsSummaryGroup ? de.SummaryGroupCode : de.InstrumentCode;
                    string key = "Item" + columnCode;

                    if (rootGNP.Columns[key] == null || accountGroupGNP.Columns[key] == null) continue;

                    decimal totalSum = (decimal)rootGNP.Columns[key];
                    decimal groupSum = (decimal)accountGroupGNP.Columns[key];
                    if (isCheck)
                    {
                        if (isCheckBoxColumn)
                        {
                            rootGNP.Columns[key] = totalSum + groupSum * newOIPercent / 100;
                        }
                        else
                        {
                            ColumnKeys keys = rootGNP.Columns;
                            keys[key] = totalSum + groupSum * (newOIPercent - oldOiPercent) / 100;
                            rootGNP.Columns = keys;
                        }
                    }
                    else
                    {
                        rootGNP.Columns[key] = totalSum - groupSum * newOIPercent;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "OpenInterestControl.CalculateOIPercentQuantity Error\r\n{0}", ex.ToString());
            }
        }