예제 #1
0
 public int CompareTo(object obj)
 {
     try
     {
         //Order by pctof_equity Desc
         AssetPosition p = (AssetPosition)obj;
         if (this.Pctof_Portfolio > p.Pctof_Portfolio)
         {
             return(-1);
         }
         else
         {
             return(1);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        private void loadCashPositions()
        {
            AssetPosition p;

            CashAllPositionAmt = 0;

            //活期存款
            int idxPosition = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashDeposit_HQ); });
            int idxInterest = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashInterest_HQ); });

            if (idxPosition >= 0)
            {
                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_CashDeposit_HQ; //现金代码6位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "活期存款";
                p.HoldingMarketValue = _GZBList[idxPosition].HoldingMarketValue;
                p.Pctof_Nav          = _GZBList[idxPosition].HoldingMVPctofNAV;

                if (idxInterest >= 0)
                {
                    p.AccruedInterestAndDividend = _GZBList[idxInterest].HoldingMarketValue;
                }

                this.CashPositionList.Add(p);
                CashAllPositionAmt += p.HoldingMarketValue;
            }

            //定期存款
            idxPosition = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashDeposit_DQ); });
            idxInterest = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashInterest_DQ); });
            if (idxPosition >= 0)
            {
                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_CashDeposit_DQ; //现金代码6位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "定期存款";
                p.HoldingMarketValue = _GZBList[idxPosition].HoldingMarketValue;
                p.Pctof_Nav          = _GZBList[idxPosition].HoldingMVPctofNAV;

                if (idxInterest >= 0)
                {
                    p.AccruedInterestAndDividend = _GZBList[idxInterest].HoldingMarketValue;
                }

                this.CashPositionList.Add(p);
                CashAllPositionAmt += p.HoldingMarketValue;
            }

            //协定存款
            idxPosition = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashDeposit_XD); });
            idxInterest = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashInterest_XD); });
            if (idxPosition >= 0)
            {
                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_CashDeposit_XD; //现金代码6位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "协定存款";
                p.HoldingMarketValue = _GZBList[idxPosition].HoldingMarketValue;
                p.Pctof_Nav          = _GZBList[idxPosition].HoldingMVPctofNAV;

                if (idxInterest >= 0)
                {
                    p.AccruedInterestAndDividend = _GZBList[idxInterest].HoldingMarketValue;
                }

                this.CashPositionList.Add(p);
                CashAllPositionAmt += p.HoldingMarketValue;
            }

            //通知存款
            idxPosition = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashDeposit_TZ); });
            idxInterest = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_CashInterest_TZ); });
            if (idxPosition >= 0)
            {
                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_CashDeposit_TZ; //现金代码6位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "通知存款";
                p.HoldingMarketValue = _GZBList[idxPosition].HoldingMarketValue;
                p.Pctof_Nav          = _GZBList[idxPosition].HoldingMVPctofNAV;

                if (idxInterest >= 0)
                {
                    p.AccruedInterestAndDividend = _GZBList[idxInterest].HoldingMarketValue;
                }

                this.CashPositionList.Add(p);
                CashAllPositionAmt += p.HoldingMarketValue;
            }

            //清算备付金(数值上面已经计算)
            if (this.CashLiqReserveAmt > 0)
            {
                idxInterest = _GZBList.FindIndex(delegate(GZBItem gzb) { return(gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.C_GZB_KMBM_LiqReserveInt); });

                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_LiqReserve; //现金代码4位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "清算备付金";
                p.HoldingMarketValue = this.CashLiqReserveAmt;
                p.Pctof_Nav          = this.CashLiqReservePct;

                if (idxInterest >= 0)
                {
                    p.AccruedInterestAndDividend = _GZBList[idxInterest].HoldingMarketValue;
                }

                this.CashPositionList.Add(p);
                CashAllPositionAmt += p.HoldingMarketValue;
            }

            //存出保证金(数值上面已经计算)
            if (this.CashMarginAmt > 0)
            {
                //没有利息
                //idxInterest = _GZBList.FindIndex(delegate(GZBItem gzb) { return (gzb.ItemDate == this.ReportDate && gzb.ItemCode == DBConsts.); });

                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_Margin; //现金代码4位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "存出保证金";
                p.HoldingMarketValue = this.CashMarginAmt;
                p.Pctof_Nav          = this.CashMarginPct;

                //没有利息
                //if (idxInterest >= 0)
                //    p.AccruedInterestAndDividend = _GZBList[idxInterest].HoldingMarketValue;

                this.CashPositionList.Add(p);
                CashAllPositionAmt += p.HoldingMarketValue;
            }

            //证券清算款(数值上面已经计算)
            if (this.CashSettlementAmt != 0)
            {
                p                    = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = DBConsts.C_GZB_KMBM_Settlement; //现金代码4位
                p.WindCode           = p.Code + ".CD";
                p.Name               = "证券清算款";
                p.HoldingMarketValue = this.CashSettlementAmt;
                p.Pctof_Nav          = this.CashSettlementPct;
                this.CashPositionList.Add(p);

                //不计入现金头寸
                //CashAllPositionAmt += p.HoldingMarketValue;
            }

            //Sort
            this.CashPositionList.Sort();
        }
예제 #3
0
        private void parsePositionDetail(GZBItem gzbItem)
        {
            #region 定制字母数字转换表
            if (_htCodeDict == null)
            {
                _htCodeDict = new Hashtable();
                _htCodeDict.Add("A", "10");
                _htCodeDict.Add("B", "11");
                _htCodeDict.Add("C", "12");
                _htCodeDict.Add("D", "13");
                _htCodeDict.Add("E", "14");
                _htCodeDict.Add("F", "15");
                _htCodeDict.Add("G", "16");
                _htCodeDict.Add("H", "17");
                _htCodeDict.Add("I", "18");
                _htCodeDict.Add("J", "19");
                _htCodeDict.Add("K", "20");
                _htCodeDict.Add("L", "21");
                _htCodeDict.Add("M", "22");
                _htCodeDict.Add("N", "23");
                _htCodeDict.Add("O", "24");
                _htCodeDict.Add("P", "25");
                _htCodeDict.Add("Q", "26");
                _htCodeDict.Add("R", "27");
                _htCodeDict.Add("S", "28");
                _htCodeDict.Add("T", "29");
                _htCodeDict.Add("U", "30");
                _htCodeDict.Add("V", "31");
                _htCodeDict.Add("W", "32");
                _htCodeDict.Add("X", "33");
                _htCodeDict.Add("Y", "34");
                _htCodeDict.Add("Z", "35");
            }
            #endregion

            //==============================
            //输入项目代码必须14位及以上
            //==============================
            try
            {
                //1102 01 01    600060
                //股票 沪  成本  代码
                string itemCode           = gzbItem.ItemCode;
                string itemCostOrInterest = itemCode.Substring(6, 2);
                string assetCode8         = itemCode.Substring(0, 8);
                string assetCode4         = itemCode.Substring(0, 4);
                string tradeCode          = gzbItem.ItemCode.Substring(8); //交易所6位,银行间7-9位
                string windCode           = tradeCode;

                if (itemCostOrInterest != "01")   //成本01  利息10
                {
                    return;
                }

                #region 查询资产类别
                AssetCategory assetCategory = AssetCategory.Other;
                switch (assetCode4)
                {
                case DBConsts.C_GZB_KMBM_CashDeposit:
                    assetCategory = AssetCategory.CashDeposit;
                    break;

                case DBConsts.C_GZB_KMBM_RevRepo:
                    assetCategory = AssetCategory.Repo;
                    break;

                case DBConsts.C_GZB_KMBM_Stock:
                    assetCategory = AssetCategory.Equity;
                    break;

                case DBConsts.C_GZB_KMBM_Bond:
                    assetCategory = AssetCategory.Bond;
                    break;

                case DBConsts.C_GZB_KMBM_Fund:
                    assetCategory = AssetCategory.Fund;
                    break;

                case DBConsts.C_GZB_KMBM_Warrant:
                    assetCategory = AssetCategory.Warrant;
                    break;

                default:
                    assetCategory = AssetCategory.Other;
                    break;
                }
                #endregion

                #region 查询资产后缀
                switch (assetCode8)
                {
                case DBConsts.C_GZB_KMBM_Stock_SH:
                case DBConsts.C_GZB_KMBM_IPO_SH:
                case DBConsts.C_GZB_KMBM_SEO_SH:
                case DBConsts.C_GZB_KMBM_Bond_SH_CB:
                case DBConsts.C_GZB_KMBM_Bond_SH_UZ:
                case DBConsts.C_GZB_KMBM_Bond_SH_Corp:
                case DBConsts.C_GZB_KMBM_Bond_SH_Govn:
                case DBConsts.C_GZB_KMBM_Repo_SH_PL:
                case DBConsts.C_GZB_KMBM_Repo_SH_BO:
                case DBConsts.C_GZB_KMBM_Fund_SH:
                    windCode += ".SH";
                    break;

                case DBConsts.C_GZB_KMBM_Stock_SZ:
                case DBConsts.C_GZB_KMBM_Stock_CY:
                case DBConsts.C_GZB_KMBM_SEO_SZ:
                case DBConsts.C_GZB_KMBM_IPO_SZ:
                case DBConsts.C_GZB_KMBM_Bond_SZ_CB:
                case DBConsts.C_GZB_KMBM_Bond_SZ_Corp:
                case DBConsts.C_GZB_KMBM_Bond_SZ_Govn:
                case DBConsts.C_GZB_KMBM_Repo_SZ_PL:
                case DBConsts.C_GZB_KMBM_Repo_SZ_BO:
                case DBConsts.C_GZB_KMBM_Fund_SZ:
                case DBConsts.C_GZB_KMBM_Bond_SZ_STFB:
                    windCode += ".SZ";
                    break;

                case DBConsts.C_GZB_KMBM_Bond_IB_Govn:
                case DBConsts.C_GZB_KMBM_Bond_IB_FinB:
                case DBConsts.C_GZB_KMBM_Bond_IB_Bill:
                case DBConsts.C_GZB_KMBM_Bond_IB_POFB:
                case DBConsts.C_GZB_KMBM_Repo_IB_PL:
                case DBConsts.C_GZB_KMBM_Repo_IB_BO:
                    windCode += ".IB";
                    break;

                case DBConsts.C_GZB_KMBM_Bond_IB_Corp:
                    windCode  = tradeCode;
                    windCode  = windCode.Replace("A", "10");
                    windCode  = windCode.Replace("B", "11");
                    windCode  = windCode.Replace("C", "12");
                    windCode  = windCode.Replace("D", "13");
                    windCode  = windCode.Replace("E", "14");
                    windCode += ".IB";
                    break;

                case DBConsts.C_GZB_KMBM_Bond_IB_STFB:
                    //对于04 11 64 004这种债券,代码结构为券种(两位)+发行年份(两位)+发行机构(两位)+发行期数(三位)可以采用以下方式:
                    //  券种两位转换为一位04则为4,年份两位转换为一位11则为B,发行主体不变,期数转换为两位004则为04。
                    //  041164004则为4B6404
                    string bondCode   = "0" + tradeCode.Substring(0, 1);
                    string yearCode   = tradeCode.Substring(1, 1);
                    string issuerCode = tradeCode.Substring(2, 2);
                    string termCode1  = tradeCode.Substring(4, 1);
                    string termCode2  = tradeCode.Substring(5, 1);

                    if (_htCodeDict.Contains(yearCode))
                    {
                        yearCode = _htCodeDict[yearCode].ToString();
                    }

                    if (_htCodeDict.Contains(termCode1))
                    {
                        termCode1 = _htCodeDict[termCode1].ToString();
                    }
                    else
                    {
                        termCode1 = "0" + termCode1;
                    }

                    windCode = bondCode + yearCode + issuerCode + termCode1 + termCode2 + ".IB";
                    break;

                case DBConsts.C_GZB_KMBM_Fund_OF:
                case DBConsts.C_GZB_KMBM_Fund_OF_M:
                    windCode += ".OF";
                    break;

                //case DBConsts.C_GZB_KMBM_SEO_SZ:
                //case DBConsts.C_GZB_KMBM_SEO_SH:
                //    //增发项目:忽略之;股份收到后会自动记入股票项目
                //    return;
                default:
                    throw new Exception("未知的金融资产:" + gzbItem.ItemCode + "|" + gzbItem.ItemName);
                }
                #endregion

                AssetPosition p = new AssetPosition();
                p.ReportDate         = this.ReportDate;
                p.Code               = tradeCode;
                p.WindCode           = windCode;
                p.Name               = gzbItem.ItemName;
                p.Price.TradeDate    = gzbItem.ItemDate;
                p.Price.Close        = gzbItem.CurrentPrice;
                p.HoldingQuantity    = gzbItem.HoldingQuantity;
                p.HoldingCost        = gzbItem.HoldingCost;
                p.HoldingMarketValue = gzbItem.HoldingMarketValue;
                p.Pctof_Nav          = gzbItem.HoldingMVPctofNAV;
                p.Category           = assetCategory;

                switch (assetCategory)
                {
                case AssetCategory.Equity:
                    p.Pctof_Portfolio = p.HoldingMarketValue / this.EquityPositionAmt;
                    this.EquityPositionList.Add(p);
                    break;

                case AssetCategory.Bond:
                    p.Pctof_Portfolio = p.HoldingMarketValue / this.BondPositionAmt;

                    //区分转债与纯债
                    switch (assetCode8)
                    {
                    case DBConsts.C_GZB_KMBM_Bond_SH_CB:
                    case DBConsts.C_GZB_KMBM_Bond_SZ_CB:
                        p.Category = AssetCategory.ConvertableBond;
                        break;

                    default:
                        break;
                    }

                    this.BondPositionList.Add(p);
                    break;

                case AssetCategory.Repo:
                case AssetCategory.Fund:
                case AssetCategory.Warrant:
                    p.Pctof_Portfolio = p.HoldingMarketValue / (this.RevRepoPositionAmt + this.FundPositionAmt + this.WarrantPositionAmt);
                    this.OtherPositionList.Add(p);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(DBConsts.C_ErrMsg_ErrorPositionDetail + ex.Message, ex);
            }
        }
예제 #4
0
        public List <AssetPosition> GetPositionList(DataTable dtPositionInfo)
        {
            //==================================================================================================
            //Wind字段名
            //trade_dt, s_con_windcode, i_weight,industriescode, industriesname
            //s_info_name,sw_ind_code1,sw_ind_name1, s_info_indexcode, s_share_freeshares(万股)
            //b_info_maturitydated
            //==================================================================================================

            try
            {
                string strDate = "";
                List <AssetPosition> positionList = new List <AssetPosition>();

                if (dtPositionInfo != null && dtPositionInfo.Rows.Count > 0)
                {
                    foreach (DataRow oRow in dtPositionInfo.Rows)
                    {
                        AssetPosition p = new AssetPosition();

                        foreach (DataColumn oCol in dtPositionInfo.Columns)
                        {
                            switch (oCol.ColumnName.ToLower())
                            {
                            case DBConsts.C_Mkt_ColumnName_Trade_Date:
                                strDate      = oRow[oCol].ToString();
                                p.ReportDate = new DateTime(
                                    Convert.ToInt16(strDate.Substring(0, 4))
                                    , Convert.ToInt16(strDate.Substring(4, 2))
                                    , Convert.ToInt16(strDate.Substring(6, 2))
                                    );
                                break;

                            case DBConsts.C_Mkt_ColumnName_ConWindCode:
                            case DBConsts.C_Mkt_ColumnName_WindCode:
                                p.Code     = oRow[oCol].ToString();
                                p.WindCode = p.Code;
                                break;

                            case DBConsts.C_Mkt_ColumnName_StockName:
                                p.Name = oRow[oCol].ToString();
                                break;

                            case DBConsts.C_Mkt_ColumnName_SWIndustryName:
                            case DBConsts.C_Mkt_ColumnName_IndustryName:
                                p.SWIndustryName = oRow[oCol].ToString();
                                break;

                            case DBConsts.C_Mkt_ColumnName_SWIndustryIndexCode:
                                p.SWIndustryIndex = oRow[oCol].ToString();
                                break;

                            case DBConsts.C_Mkt_ColumnName_ConWeight:
                                p.Pctof_Portfolio = Convert.ToDouble(oRow[oCol]) / 100;      //%
                                break;

                            case DBConsts.C_Mkt_ColumnName_FreeFloatCapital:
                                p.FreefloatCapital = Convert.ToDouble(oRow[oCol]) * 10000;
                                break;

                            case DBConsts.C_Mkt_ColumnName_MaturityDate:
                                strDate            = oRow[oCol].ToString();
                                p.BondMaturityDate = new DateTime(
                                    Convert.ToInt16(strDate.Substring(0, 4))
                                    , Convert.ToInt16(strDate.Substring(4, 2))
                                    , Convert.ToInt16(strDate.Substring(6, 2))
                                    );
                                break;

                            default:
                                break;
                            }
                        }

                        positionList.Add(p);
                    }
                }

                return(positionList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }