Пример #1
0
    public void RunAndDisplayResult()
    {
      var v = Run();

      Dictionary<string, System.Windows.Forms.Control> dict = new Dictionary<string, System.Windows.Forms.Control>
      {
        {string.Format("{0} weights", StrategyCode), v.Key.DisplayInGrid(StrategyCode.ToString(), false)},
        {string.Format("{0} perf", StrategyCode), v.Value.GetReturnsDisplay()}
      };

      dict.DisplayInShowForm(StrategyCode.ToString());
    }
    public static void Reconcile(DateTime date)
    {
      var dict_source_To_DB = new Dictionary<ConstituentRowCompare.Source, string>();

      dict_source_To_DB.Add(ConstituentRowCompare.Source.DS, DBNames.SQLSERVER_LOCAL_SYMMETRYTS);
      dict_source_To_DB.Add(ConstituentRowCompare.Source.MLP, DBNames.SQLSERVER_SYMMETRYTS);


      var listofTenors = new[] { 0, 2, 3, 5, 7, 10, 30 };

      var curveNameGens = new[]
        {
          "de_<tenor>_eur.6m.euribor",
          "de_<tenor>_eur.ois.eonia",
          "fr_<tenor>_eur.6m.euribor",
          "fr_<tenor>_eur.ois.eonia",
          "ust_<tenor>_usd.3m.libor",
          "ust_<tenor>_usd.3m.libor.oisd",
          "ust_<tenor>_usd.ois.fedfunds"
        };

      var curve_To_Grid = new Dictionary<string, Control>();

      //var curveNameGen = "ust_<tenor>_usd.3m.libor";


      foreach (var curveNameGen in curveNameGens)
      {

        var listOfComparisons = new List<ConstituentRowCompare>();
        foreach (var source in dict_source_To_DB.Keys)
        {
          var list = new List<ConstituentRow>();


          foreach (var tenor in listofTenors)
          {
            var curveName = curveNameGen.Replace("<tenor>", tenor.ToString());

            var sql = string.Format("select * from SObject where MonikerDate='{0}' and MonikerType = 'bondcurveconstituents' and MonikerName='{1}'", date.ToString("dd-MMM-yyyy"), curveName);

            var ds = Singleton<ConnMngr>.Instance.Execute(dict_source_To_DB[source], sql);

            if (!ConnMngr.HasResult(ds))
              continue;

            var dt = getTable(ds.Tables[0].Rows[0]["Content"] as string);
            string csv = dt.ToCsv();

            byte[] arr = Encoding.ASCII.GetBytes(csv);
            MemoryStream ms = new MemoryStream(arr);
            StreamReader reader = new StreamReader(ms);

            foreach (var v in CsvFile.Read<ConstituentRow>(reader))
            {
              list.Add(v);

              var comp = listOfComparisons.Where(x => x.ISIN.Equals(v.ISIN)).FirstOrDefault();

              if (comp == null)
              {
                comp = new ConstituentRowCompare(v);
                listOfComparisons.Add(comp);
              }

              comp.SetPrices(source, v);
            }
          }
        }

        var grid = listOfComparisons.DisplayInBoundGrid(null, false);
        grid.SetHeaderClickSort();
        curve_To_Grid.Add(curveNameGen, grid);

      }

      curve_To_Grid.DisplayInShowForm(date.ToString("dd-MMM-yyyy"));

      {
        var wb = new Infragistics.Documents.Excel.Workbook(Infragistics.Documents.Excel.WorkbookFormat.Excel2007);

        foreach (var curve in curve_To_Grid.Keys)
        {
          var grid = (BoundInfraGrid)curve_To_Grid[curve];
          grid.ExportToExcelWorkBook(wb, curve);
        }

        wb.Save(string.Format(@"c:\temp\MarkDate_{0}__At_{1}.xlsx", date.ToString("dd-MMM-yyyy"), DateTime.Now.ToString("dd-MMM-yyyy_HH_mm_ss")));
      }

    }
      protected override void OnClick(EventArgs e)
      {
        var dict = new Dictionary<string, Control>();

        LongShortResultDisplay lsrd = new LongShortResultDisplay();
        lsrd.Create(m_analyzer);
        dict.Add("Per Instrument", lsrd);

        OverallLongShortDisplay olsd = new OverallLongShortDisplay();
        olsd.Create(m_analyzer);
        dict.Add("Overall portfolio", olsd);

        OverallPersistenceDisplay olpd = new OverallPersistenceDisplay();
        olpd.Create(m_analyzer);
        dict.Add("Position persistence", olpd);

        if (m_isFX)
        {
          RegionSidePnlChart rspc = new RegionSidePnlChart();
          rspc.Create(m_analyzer);
          dict.Add("Regional Pnl / Positioning", rspc);

          USDWeightRegionalBreakdownDisplay uwrbd = new USDWeightRegionalBreakdownDisplay();
          uwrbd.Create(m_analyzer.SourceWts, new FXGroup[] { FXGroup.G10, FXGroup.EMEA, FXGroup.LATAM, FXGroup.ASIA });
          dict.Add("Region concentration", uwrbd);
        }

        dict.DisplayInShowForm(m_analyzer.Name);
      }
Пример #4
0
    public static void ShowHistoricWeights(this Signal sig_)
    {
      try
      {
        var dict = new Dictionary<string, System.Windows.Forms.Control>();

        var wts = sig_.GetWeightsProviderDefault().GetData(DataConstants.DATA_START, DateTime.Today, false);
        {
          var grid = wts.DisplayInGrid(title_: null, displayInShowForm_: false);
          grid.ApplyDisplayDoubleFormat("##0.0#%;(##0.0#%);-");
          grid.ColourNegativesRed();
          grid.Grid.DisplayLayout.Bands[0].Columns[0].Format = "dd-MMM-yyyy HH:mm";
          grid.AutoSizeGridColumns();
          dict.Add("Raw Weights", grid);
        }

        {
          var hp = WtsHelpers.GenerateHoldingPeriods(wts);
          var c = hp.DisplayInBoundGrid(formTitle_: null, showInForm_: false);


          c.Grid.DisplayLayout.Bands[0].SummaryFooterCaption = "Signal level averages";
          var s = c.Grid.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Average, c.Grid.DisplayLayout.Bands[0].Columns["LongAvg"]);
          //s.DisplayFormat = "Signal Average Long Holding Period: {0:##0.0#}";
          s.DisplayFormat = "{0:##0.0#}";
          s = c.Grid.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Average, c.Grid.DisplayLayout.Bands[0].Columns["ShortAvg"]);
          s.DisplayFormat = "{0:##0.0#}";
          s = c.Grid.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Average, c.Grid.DisplayLayout.Bands[0].Columns["FlatAvg"]);
          s.DisplayFormat = "{0:##0.0#}";

          c.AutoSizeGridColumns();

          dict.Add("Holding Periods", c);
        }

        var sf = dict.DisplayInShowForm(string.Format("{0} historical weights", sig_.DisplayName));
        sf.Icon = Util.BmpToIcon(Properties.Resources.grid);


        //var sf = grid.DisplayInShowForm(string.Format("{0} historical weights", sig_.Name), Util.BmpToIcon(Properties.Resources.grid));
      }
      catch
      { }
    }
Пример #5
0
    public static void Go()
    {
      //var group = Singleton<IntradayFutureGroups>.Instance.FirstOrDefault(
      //  x => x.BbgStart.Equals("ES") && String.Compare("Index", x.Suffix, StringComparison.OrdinalIgnoreCase) == 0);

      var eventRel = EventRelative.Post;

      var pointsAroundEvent = 60;
      var pointOfFirstPeriod = 10;

      var listOfFutures = new List<Tuple<string, string>>();
      listOfFutures.Add(new Tuple<string, string>("ED", "Comdty"));
      listOfFutures.Add(new Tuple<string, string>("TY", "Comdty"));
      listOfFutures.Add(new Tuple<string, string>("ES", "Index"));

      var listOfEvents = new string[] {"FOMC", "NFP"};

      foreach (var futureStartEnd in listOfFutures)
      {
        var futureGroup = Singleton<IntradayFutureGroups>.Instance.FirstOrDefault(
          x => x.BbgStart.Equals(futureStartEnd.Item1) && String.Compare(futureStartEnd.Item2, x.Suffix, StringComparison.OrdinalIgnoreCase) == 0);

        var dict = new Dictionary<string, System.Windows.Forms.Control>();

        foreach (var evCode in listOfEvents)
        {
          var eventDef =
            Singleton<EventDefs>.Instance.FirstOrDefault(
              x => string.Compare(evCode, x.EventCode, StringComparison.OrdinalIgnoreCase) == 0);

          var rangeLength = Convert.ToInt32((pointsAroundEvent)/2);

          var hArgs = new SI.Strategy.SeasonalityAnalysis.HelperRequestArgs()
          {
            EventDates = eventDef.GetEvents(TZ.LN, new CarbonClient("uat")).Result.Where(x => x.Year <= 2014 && x.Year >= 2012).ToArray(),
            FrequencyOfPricing = new TimeSpan(0, 1, 0),
            FutureGroup = futureGroup,
            NumDataPointsAroundEvent = pointsAroundEvent,
            Timezone = TZ.LN
          };

          var eventStudies = SI.Strategy.SeasonalityAnalysis.Helper.Go(hArgs).ToArray();

          var con = new ConstructGen<double>(new[] {"Period1", "Period2"});

          foreach (var studay in eventStudies)
          {
            if (studay.RawRawDataAroundEvent == null)
              continue;

            int firstStartIndex, firstEndIndex, secondStartIndex, secondEndIndex;

            {
              firstStartIndex = 0;
              firstEndIndex = pointOfFirstPeriod;
              secondStartIndex = pointOfFirstPeriod + 1;
              secondEndIndex = pointsAroundEvent - 1;
            }

            if(eventRel==EventRelative.Post)
            {
              firstStartIndex += (rangeLength*2) + 1;
              firstEndIndex += (rangeLength * 2) + 1;
              secondStartIndex += (rangeLength * 2) + 1;
              secondEndIndex += (rangeLength * 2) + 1;
            }

            try
            {
              var first = studay.RawRawDataAroundEvent.Data[firstEndIndex].Value -
                          studay.RawRawDataAroundEvent.Data[firstStartIndex].Value;
              var second = studay.RawRawDataAroundEvent.Data[secondEndIndex].Value -
                           studay.RawRawDataAroundEvent.Data[secondStartIndex].Value;

              if (first == 0d || second == 0d)
                continue;

              con.SetValues(studay.EventDate.Date, new[] {first, second});
            }
            catch
            {
            }
          }

          if (con.Dates.Any() == false)
            continue;

          var chart = new SI.Controls.SimpleStackedColumnChart();
          chart.Create(values_: con, datesAlongBottom_: true);

          var title = string.Format("{0} - {1} ({2})", futureGroup, evCode, pointsAroundEvent);

          dict.Add(title, chart);
        }

        dict.DisplayInShowForm(futureGroup.ToString());
      }

    }