public override Control Reconcile(IEnumerable<PricingItem> mlpSource_, IEnumerable<PricingItem> dsSource_)
    {
      var allCodes = mlpSource_.Union(dsSource_).Select(x => x.SymmetryCode).Distinct();

      var lines = new System.ComponentModel.BindingList<CloseItem>();

      foreach (var symcode in allCodes)
      {

        var line = new CloseItem();
        line.SymmetryCode = symcode;

        {
          var mlpitem = mlpSource_.Where(x => x.SymmetryCode.Equals(symcode)).FirstOrDefault();
          if (mlpitem != null) line.MLPPrice = mlpitem.Value;
        }

        {
          var dsItem = dsSource_.Where(x => x.SymmetryCode.Equals(symcode)).FirstOrDefault();
          if (dsItem != null) line.DSPrice = dsItem.Value;
        }

        lines.Add(line);
      }

      var grid = lines.DisplayInGrid(m_name,displayInShowForm_:false);
      grid.SetHeaderClickSort();
      return grid;
    }
Exemple #2
0
    public static void Test()
    {

      var model = new RvolSolveModel(
        targetVol_: 0.0121519,
        cov_: Singleton<SI.Data.CovarianceSource>.Instance.GetCovariance(DateTime.Today.AddDays(-1d)),
        ccys_: Singleton<SI.Data.FXIDs>.Instance.Select(x => new CurrencyLine(
          ccy_: x,
          expectedReturn_: 0.1,
          minWt_: x.IsGroup(Data.FXGroup.G10) ? -0.31 : -0.1215914,
          maxWeight_: x.IsGroup(Data.FXGroup.G10) ? 0.31 : 0.1215914)).ToArray()
        )
      {
        SumOfWeightsMin = 0d,
        SumOfWeightsMax = 1d,
      };

      new RvolSolver().SolveQuadratic(model);

      Console.WriteLine("ben");

      return;

      var result = Singleton<ExcelOptimizer>.Instance.DoIt(
        model.CurrencyLines.Length,
        model.TargetVol,
        model.Covar.Data,
        model.CurrencyLines.Select(x => x.ExpectedReturn).ToArray(),
        ExtensionMethods.CreateArrayRep<double>(0d, model.CurrencyLines.Length),
        ExtensionMethods.CreateArrayRep<double>(0d, model.CurrencyLines.Length),
        model.CurrencyLines.Select(x => x.MinWeight).ToArray(),
        model.CurrencyLines.Select(x => x.MaxWeight).ToArray(),
        1d,
        1d,
        "2W",
        DateTime.Today);

      Singleton<ExcelOptimizer>.Instance.Dispose();

      var list = new System.ComponentModel.BindingList<CompareResult>();

      for (int i = 0; i < model.CurrencyLines.Length; ++i)
      {
        list.Add(
          new CompareResult()
          {
            Currency = model.CurrencyLines[i].Ccy.Code,
            SolverFoundation = model.CurrencyLines[i].Weight,
            XLL = result.Wts[i]
          });
      }

      list.DisplayInGrid("result comparison");
    }