Beispiel #1
0
        private void dgv5239_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            PositionSummaryObject p = (PositionSummaryObject)dgv5239.CurrentRow.DataBoundItem;

            DtcChannel.Instance.CusipSelected(p.Cusip);
        }
Beispiel #2
0
        private void ServerForm_Load(object sender, EventArgs e)
        {
            dgv5239.DataSource     = filtered5239;
            dgv269.DataSource      = positions269;
            dgvExpected.DataSource = expected;

            helper.Add(new DgvHelper(dgv5239, this.Name, true));
            helper.Add(new DgvHelper(dgv269, this.Name, true));
            helper.Add(new DgvHelper(dgvExpected, this.Name, true));

            cbxFilter.Items.Add("All");
            cbxFilter.Items.Add("OverBorrows");
            cbxFilter.Items.Add("OverLoans");

            cbxFilter.SelectedIndex = 0;

            try
            {
                txtBorrowPosition269.Text  = "$0";
                txtBorrowPosition5239.Text = "$0";
                txtDifference.Text         = "$0";
                txtHedgeMark.Text          = "$0";
                txtHedgeSpread.Text        = "$0";
                txtLoanPosition269.Text    = "$0";
                txtLoanPosition5239.Text   = "$0";
                txtSpread269.Text          = "$0";
                txtSpread5239.Text         = "$0";

                //calc mark
                HedgeMarkTotalViewParam hmp = new HedgeMarkTotalViewParam();
                hmp.ActivityDate_Date.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -1));

                hmvf.Load(marks, hmp);

                double markTotal = 0;

                marks.ForEach(m => markTotal += m.Total.Value);

                //load collateral values
                HedgeCollateralViewParam hcp = new HedgeCollateralViewParam();
                hcp.ActivityDate_Date.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -1));

                hcvf.Load(collateral, hcp);

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

                foreach (HedgeCollateralViewObject h in collateral)
                {
                    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;
                        }
                    }
                }

                txtBorrowPosition5239.Text = borrowPosition5239.ToString("c0");
                txtBorrowPosition269.Text  = borrowPosition269.ToString("c0");
                txtLoanPosition5239.Text   = loanPosition5239.ToString("c0");
                txtLoanPosition269.Text    = loanPosition269.ToString("c0");

                double spread269   = borrowPosition269 - loanPosition269;
                double spread5239  = borrowPosition5239 - loanPosition5239;
                double hedgeMark   = Math.Abs(markTotal);
                double difference  = (spread269 + spread5239);
                double hedgeSpread = difference - hedgeMark;

                txtSpread269.Text  = spread269.ToString("c0");
                txtSpread5239.Text = spread5239.ToString("c0");
                txtHedgeMark.Text  = hedgeMark.ToString("c0");

                txtDifference.Text = difference.ToString("c0");

                if (borrowPosition5239 > loanPosition5239)
                {
                    txtHedgeSpread.Text = hedgeSpread.ToString("c0") + "\r\n" + "OverBorrow";
                }
                else
                {
                    txtHedgeSpread.Text = hedgeSpread.ToString("c0") + "\r\n" + "OverLoan";
                }
                //calculate over borrows and loans
                HedgePositionSummaryViewFactory       hpsf     = new HedgePositionSummaryViewFactory();
                List <HedgePositionSummaryViewObject> hedgePos = new List <HedgePositionSummaryViewObject>();
                HedgePositionSummaryViewParam         hpsp     = new HedgePositionSummaryViewParam();
                List <PositionSummaryObject>          temp     = new List <PositionSummaryObject>();

                hpsp.ActivityDate.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -1));

                hpsf.Load(hedgePos, hpsp);

                foreach (HedgePositionSummaryViewObject h in hedgePos)
                {
                    PositionSummaryObject p = temp.Find(t => t.Cusip == h.Cusip &&
                                                        t.ClearingNo == h.ClearingNo);

                    //does not exist
                    if (p == null)
                    {
                        PositionSummaryObject t = new PositionSummaryObject(h);
                        temp.Add(t);
                    }
                    else
                    {
                        if (h.BorrowLoan == "B")
                        {
                            p.StartingBorrowQty   += h.Quantity.Value;
                            p.StartingBorrowValue += h.ContractValue.Value;
                        }

                        if (h.BorrowLoan == "L")
                        {
                            p.StartingLoanQty   += h.Quantity.Value;
                            p.StartingLoanValue += h.ContractValue.Value;
                        }
                    }
                }

                foreach (PositionSummaryObject p in temp)
                {
                    if (p.ClearingNo == "05239")
                    {
                        positions5239.Add(p);
                    }
                    if (p.ClearingNo == "00269")
                    {
                        positions269.Add(p);
                    }
                }

                //now calculate what the current positions are
                foreach (IncomingDeliveryOrderObject ido in calc.AllDtcActivity)
                {
                    CalcSummary(ido, "00005239", positions5239);
                    CalcSummary(ido, "00000269", positions269);
                }

                UpdateFilter(positions5239, filtered5239);
                UpdateFilter(positions269, filtered269);

                CalculateExpected();
                CalcSpread();

                filtered5239.Sort("SortField", ListSortDirection.Descending);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex, TraceEnum.LoggedError);
                MessageBox.Show("Error starting app: \r\n" + ex.ToString());
            }
        }