Example #1
0
        /// <summary>
        /// Find closest expectedCount in APcount_dic
        /// </summary>
        /// <param name="currPos">RecordDatePosition in [Dividend_detail]</param>
        /// <param name="depoName">Depository name (used for RSH)</param>
        private DvdCustodian_AP_count GetClosest_dc(decimal currPos, string depoName)
        {
            DvdCustodian_AP_count res = null;

            foreach (DvdCustodian_AP_count dac in this.APcount_dic.Values)
            {
                if (depoName != null)
                {
                    if (!dac.dvdCust.Depositary.Value.Equals(depoName, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                }

                if (dac.expectedCount < currPos)
                {
                    continue;
                }

                if (res == null)
                {
                    res = dac;
                }
                else if (dac.expectedCount - currPos < res.expectedCount - currPos)
                {
                    res = dac;
                }
            }

            return(res);
        }
Example #2
0
        public void SubCal_expectedCount(List <Dividend_Detail_simpleAP> all_dd_list)
        {
            decimal total_dvdCust_reported   = 0;
            List <DividendCustodian> dc_list = this.CheckPrimary(this.dvdCust_dic);

            foreach (DividendCustodian dc in dc_list)
            {
                DvdCustodian_AP_count dac = new DvdCustodian_AP_count(dc);
                this.APcount_dic.Add(dc.CustodianID, dac);
                total_dvdCust_reported += dc.Custodian_Reported.Value;
            }

            if (total_dvdCust_reported <= 0)
            {
                MessageBox.Show("Dividend_func6 error 2: Total Custodian Report shares is " + total_dvdCust_reported);
                return;
            }

            decimal total_detailReported = 0;

            foreach (Dividend_Detail_simpleAP dd in all_dd_list)
            {
                total_detailReported += dd.RecordDatePosition.Value;
            }

            //if detail total grerater then total custodian reported, only auto-prorate custodian total
            if (total_detailReported > total_dvdCust_reported)
            {
                total_detailReported = total_dvdCust_reported;
            }

            foreach (DvdCustodian_AP_count dac in this.APcount_dic.Values)
            {
                dac.pct           = dac.dvdCust.Custodian_Reported.Value / total_dvdCust_reported;
                dac.expectedCount = dac.pct * total_detailReported;
            }

            //Subtract Dividend_Details which has already been assigned CustodianID from expectedCount
            foreach (Dividend_Detail_simpleAP dd in all_dd_list)
            {
                int custID = dd.CustodianID.Value;
                if (this.APcount_dic.ContainsKey(custID))
                {
                    this.APcount_dic[custID].expectedCount -= dd.RecordDatePosition.Value;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Find current max expectedCount in APcount_dic
        /// </summary>
        private DvdCustodian_AP_count GetHighest_dc()
        {
            DvdCustodian_AP_count res = null;

            foreach (DvdCustodian_AP_count dac in this.APcount_dic.Values)
            {
                if (res == null)
                {
                    res = dac;
                }
                else if (dac.expectedCount > res.expectedCount)
                {
                    res = dac;
                }
            }

            return(res);
        }
Example #4
0
        public void Calculate(List <Dividend_Detail_simpleAP> selected_dd_list)
        {
            if (selected_dd_list == null || this.APcount_dic.Count == 0)
            {
                return;
            }

            //Assign CustodianID for RSH first
            foreach (Dividend_Detail_simpleAP detail in selected_dd_list)
            {
                string           DTCnum  = detail.DTC_Number.Value;
                DTC_Participants dtcPart = DTC_Participants_master.Get_DTC_Participants_DTCnum(DTCnum);
                if (dtcPart == null || dtcPart.Type.IsValueEmpty)
                {
                    continue;
                }
                if (!dtcPart.Type.Value.Equals("RSH", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                DvdCustodian_AP_count dcAP = this.GetClosest_dc(detail.RecordDatePosition.Value, dtcPart.Depositary.Value);
                if (dcAP == null)
                {
                    continue;
                }

                DividendCustodian dvdCust = dcAP.dvdCust;
                detail.CustodianID.Value = dvdCust.CustodianID;
                dcAP.expectedCount      -= detail.RecordDatePosition.Value;
                dcAP.dd_list.Add(detail);

                //foreach (int custID in this.APcount_dic.Keys)
                //{
                //    DividendCustodian dvdCust = this.dvdCust_dic[custID];
                //    if (dvdCust.Depositary.Value.Equals(dtcPart.Depositary.Value, StringComparison.OrdinalIgnoreCase))//Try to match Depositary with [Dividend_Custodian]
                //    {
                //        DvdCustodian_AP_count dcAP = this.APcount_dic[custID];
                //        if (dcAP.expectedCount >= detail.RecordDatePosition.Value)
                //        {
                //            detail.CustodianID.Value = dvdCust.CustodianID;
                //            dcAP.expectedCount -= detail.RecordDatePosition.Value;
                //            dcAP.dd_list.Add(detail);
                //        }
                //        break;
                //    }
                //}
            }

            //Assign CustodianID for non-RSH
            foreach (Dividend_Detail_simpleAP detail in selected_dd_list)
            {
                string DTCnum = detail.DTC_Number.Value;
                if (DTCnum != null && DTCnum.StartsWith("RSH", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                DvdCustodian_AP_count dcAP = this.GetHighest_dc();
                if (dcAP.expectedCount < detail.RecordDatePosition.Value)
                {
                    continue;
                }

                DividendCustodian dvdCust = dcAP.dvdCust;
                detail.CustodianID.Value = dvdCust.CustodianID;
                dcAP.expectedCount      -= detail.RecordDatePosition.Value;
                dcAP.dd_list.Add(detail);
            }
        }