コード例 #1
0
 public void onHedgeCashCalculated(HedgeCashEventArgs he)
 {
     if (HedgeCashDataLoaded != null)
     {
         HedgeCashDataLoaded(this, he);
     }
 }
コード例 #2
0
        public void LoadHedgeCashData(DateTime dt)
        {
            try
            {
                HedgeCollateralViewDA HCDA = new HedgeCollateralViewDA();

                List <HedgeCollateralView_AlanPledger> HCVList = new List <HedgeCollateralView_AlanPledger>();
                HCDA.Load(HCVList, dt);

                List <HedgeMarkTotalView_AlanPledger> HMTVList = new List <HedgeMarkTotalView_AlanPledger>();
                HedgeMarkTotalViewDA HMTVDA = new HedgeMarkTotalViewDA();
                HMTVDA.Load(HMTVList, dt);

                double markTotal = 0;
                HMTVList.ForEach(x => markTotal += x.Total);

                double borrowPosition5239 = 0;
                double borrowPosition269  = 0;
                double loanPosition5239   = 0;
                double loanPosition269    = 0;

                foreach (var h in HCVList)
                {
                    if (h.BorrowLoan == "B")
                    {
                        if (h.ClearingNo == "05239")
                        {
                            borrowPosition5239 = h.total.Value;
                        }
                        if (h.ClearingNo == "00269")
                        {
                            borrowPosition269 = h.total.Value;
                        }
                    }
                    else if (h.BorrowLoan == "L")
                    {
                        if (h.ClearingNo == "05239")
                        {
                            loanPosition5239 = h.total.Value;
                        }
                        if (h.ClearingNo == "00269")
                        {
                            loanPosition269 = h.total.Value;
                        }
                    }
                }

                borrowPosition5239 *= -1;
                borrowPosition269  *= -1;

                double spread269  = borrowPosition269 + loanPosition269;
                double spread5239 = borrowPosition5239 + loanPosition5239;

                double difference  = (spread269 + spread5239);
                double hedgeMark   = markTotal;
                double hedgeSpread = difference - hedgeMark;

                HedgeCashEventArgs he = new HedgeCashEventArgs();
                he.borrowPosition269  = borrowPosition269;
                he.borrowPosition5239 = borrowPosition5239;
                he.loanPosition269    = loanPosition269;
                he.loanPosition5239   = loanPosition5239;
                he.spread269          = spread269;
                he.spread5239         = spread5239;
                he.difference         = difference;
                he.hedgeMark          = hedgeMark;
                he.hedgeSpread        = hedgeSpread;

                onHedgeCashCalculated(he);
            }
            catch (Exception e)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    MessageBox.Show("Message: " + e.Message + Environment.NewLine + "Inner Exception: ");
                }));

                Utils.LogError("Hedge Cash Issue " + e.Message + Environment.NewLine + "Inner Exception: ");
            }
        }