Ejemplo n.º 1
0
 public Portfolio(string rootName_, DatedDataCollectionGen<double> allocationTo_, double pnlMultiplier_, Portfolio parent_=null)
 {
   RootName = rootName_;
   AllocationToThis = allocationTo_;
   PnlMultiplier = pnlMultiplier_;
   m_parentPortfolio = parent_;
 }
Ejemplo n.º 2
0
    private void subscribeToPortfolio(Portfolio p_, bool do_ = true)
    {
      if (p_ == null) return;

      p_.ChildPortfolioPopulated -= handlePortfolioChildCreated;

      if (!do_) return;

      p_.ChildPortfolioPopulated += handlePortfolioChildCreated;
    }
    public async Task UpdateList(IList<SeriesConfig> list_, ICarbonClient client_)
    {
      // remove current items
      var currentItems = list_.Where(x => x.Source != null && x.Source.ToLower().Equals(SourceName)).ToArray();
      foreach (var item in currentItems)
        list_.Remove(item);

      var portfolio = new Portfolio("ssys.portfolio", null, 10000d);

      await addPortfolio(portfolio, list_, client_);
    }
Ejemplo n.º 4
0
    public async Task Create(CarbonClient cc_, string [] basePortfolioNames_)
    {
      ClearUp();

      m_cc = cc_;

      setupGrid();

      foreach(var basePortfolioName_ in basePortfolioNames_)
      {
        var basePortfolio = new Portfolio(basePortfolioName_, null, DisplayOptions.PnlMultiplier);

        await addPortfolio(parentPortfolio_: null, newPortfolio_: basePortfolio, isInitialLoad_:true);

        await basePortfolio.GetChildren(cc_: cc_, recurse_: true, isInitialLoad_:true);
      }

      setupTimer();
    }
    private async Task addPortfolio(Portfolio p_, IList<SeriesConfig> list_, ICarbonClient cc_)
    {
      if (p_ == null) return;

      var children = await p_.GetChildren(cc_);

      var adjustedMoniker = p_.RootName.Replace("ssys.portfolio.",string.Empty);

      var split = adjustedMoniker.Split('.');

      list_.Add(DataFrameSumColumns.CreateConfig(
        dataframeMoniker_: p_.PnlMoniker,
        treePath_: string.Format(@"Systematic Strategy Pnl\{0}", string.Join(@"\", split)),
        moniker_: string.Format("ssys.{0}.pnl", string.Join(".", split)),
        sourceName_: SourceName));

      if(children!=null)
        foreach (var child in children)
          await addPortfolio(child, list_, cc_);
    }
Ejemplo n.º 6
0
    public async Task Bind(Portfolio p_, PerfRowCol columnClicked_, CarbonClient cc_)
    {
      m_lastLoaded = p_;
      m_cc = cc_;
      m_overrides.ClearOverrides();

      if (p_ == null) return;

      ultraTabControl1.Tabs[0].Text = string.Format("P&&L [{0}]", p_.RootName);

      await loadColumnCharts();

      // period pnl
      {
        PerfRowCol usedCol = columnClicked_;
        var startDate = DateTime.Today;
        var endDate = DateTime.Today;

        var pnl = await p_.GetHistoricPnl(cc_, m_exposureType);

        if (pnl != null && pnl.TimeSeries != null)
        {
          switch (columnClicked_)
          {
            case PerfRowCol.Yesterday:
              startDate = MyCalendar.PrevWeekDay(DateTime.Today);
              endDate = startDate;
              break;
            case PerfRowCol.MTD:
              startDate = DateTime.Today.FirstOfMonth();
              break;
            case PerfRowCol.YTD:
              startDate = DateTime.Today.FirstOfYear();
              break;
            case PerfRowCol.QTD:
              startDate = DateTime.Today.FirstOfQuarter();
              break;
            case PerfRowCol.WTD:
              startDate = DateTime.Today.FirstOfWeek(DayOfWeek.Sunday);
              break;
            default:
              usedCol = PerfRowCol.MTD;
              startDate = DateTime.Today.FirstOfMonth();
              break;
          }
        }

        m_startDate = startDate;
        m_endDate = endDate;
        m_title = usedCol.ToString();

        await applyHistoryPnl();
      }
    }
Ejemplo n.º 7
0
    public void Reset()
    {
      m_meta = null;
      m_alloc = null;
      m_pnl = null;
      m_wts = null;
      m_allocatedWts = null;
      m_allocatedPnl = null;
      m_currentExpBackwards = null;
      m_parentPortfolio = null;

      m_childPortfolios = null;
    }
 public ChildPortfolioPopulatedEventArgs(Portfolio childPortfolio_, bool isInitialLoad_)
 {
   ChildPortfolio = childPortfolio_;
   IsInitialLoad = isInitialLoad_;
 }
Ejemplo n.º 9
0
    private async Task addPortfolio(Portfolio parentPortfolio_, Portfolio newPortfolio_, bool isInitialLoad_)
    {
      var newchildPerfRow = new PerfRow { Underlying = newPortfolio_, Portfolio = newPortfolio_.RootName, Weight = 1d };

      OnProgressUpdated(new ReportProgressArgs(string.Format("Adding {0}...",newPortfolio_.RootName)));

      m_mapOfRowsFromPortfolios.Add(newPortfolio_.RootName, newchildPerfRow);

      subscribeToPortfolio(newPortfolio_);

      if (parentPortfolio_ != null)
      {
        var parentPerfRow = m_mapOfRowsFromPortfolios[parentPortfolio_.RootName];
        parentPerfRow.Rows.Add(newchildPerfRow);

        newchildPerfRow.Portfolio = newPortfolio_.RootName.Split('.').Last();
        var alloc = await parentPerfRow.Underlying.GetAllocationTo(newchildPerfRow.Portfolio, m_cc);
        newchildPerfRow.Weight = alloc == null ? 0d : alloc.ValueOnDate(DateTime.Today);
      }
      else
      {
        m_gridList.Add(newchildPerfRow);
      }

      if (isInitialLoad_)
        Grid.Rows.ExpandAll(true);

      await newchildPerfRow.PopulateFromUnderlying(m_cc);

      OnProgressUpdated(new ReportProgressArgs(string.Empty));
    }