当前位置: 首页>>代码示例>>C#>>正文


C# ConstructGen.MultValue方法代码示例

本文整理汇总了C#中ConstructGen.MultValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructGen.MultValue方法的具体用法?C# ConstructGen.MultValue怎么用?C# ConstructGen.MultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConstructGen的用法示例。


在下文中一共展示了ConstructGen.MultValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      double posSum;
      double negSum;
      int posCount;
      int negCount;

      foreach (DateTime date in wts_.Dates)
      {
        posSum=0.0;
        negSum=0.0;
        posCount=0;
        negCount=0;

        for (int i = 0; i < wts_.ArrayLength; ++i)
        {
          double val = signalResults_.GetValue(date, i);

          if (val == 0)
            continue;

          if (val > 0)
          {
            posSum+=val;
            ++posCount;
          }
          else
          {
            negSum+=val;
            ++negCount;
          }
        }

        double negAv = negSum / negCount;
        double posAv = posSum / posCount;

        for (int i = 0; i < wts_.ArrayLength; ++i)
        {
          double val = signalResults_.GetValue(date, i);

          if (val == 0)
          {
            wts_.MultValue(date, i, 0.0, false);
          }
          else if (val > 0)
          {
            double mult = val / posAv;
            double wt = 1.0 - (1.0 - (1.0 / mult));
            wts_.MultValue(date, i, wt,false);
          }
          else
          {
            double mult = val / negAv;
            double wt = 1.0 - (1.0 - (1.0 / mult));
            wts_.MultValue(date, i, wt,false);
          }
        }
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:59,代码来源:WtBenjo.cs

示例2: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      List<SortHelpClass> list = new List<SortHelpClass>();

      foreach (DateTime date in signalResults_.Dates)
      {
        //wts_.MultValue(date, i, val, val < 0);

        list.Clear();

        for (int i = 0; i < signalResults_.ArrayLength; ++i)
        {
          double val = signalResults_.GetValue(date, i);

          if (double.IsNaN(val) == false)
            list.Add(new SortHelpClass(val, i, m_abs,false,false));
        }

        QuickSort.Sort<SortHelpClass>(list);



        for (int i = 0; i < wts_.ArrayLength && i < list.Count; ++i)
        {
          wts_.MultValue(date, list[i].ArrayIndex, list[i].Value, list[i].Value < 0);
        }

      }

    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:30,代码来源:WtImpactValue.cs

示例3: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      for (int i = 0; i < products_.Count; ++i)
      {
        double avg = 0;
        for (int j = 0; j < signalResults_.Dates.Count; ++j)
        {
          if(j<WindowLength)
          {
            wts_.SetValue(signalResults_.Dates[j],i,0);
            continue;
          }

          // if the product is not valid on this date then the weight is zero.
          if (double.IsNaN(filters_.GetValue(signalResults_.Dates[j],i)))
          {
            wts_.SetValue(signalResults_.Dates[j], i, 0.0);
          }
          else
          {
            for (int y = 0; y < WindowLength; ++y)
              avg += signalResults_.GetValue(signalResults_.Dates[j - y], i);
            avg /= WindowLength;

            double val = signalResults_.GetValue(signalResults_.Dates[j], i) / avg;

            wts_.MultValue(signalResults_.Dates[j], i, val, false);
          }
        }
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:31,代码来源:WtImpactDemeaning.cs

示例4: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      double[] sigToday = new double[products_.Count];

      foreach (DateTime date in signalResults_.Dates)
      {
        double[] filterToday = filters_.GetValues(date);
        int productValidCount = 0;
        double sum = 0;

        for (int i = 0; i < sigToday.Length; ++i)
        {
          sigToday[i] = signalResults_.GetValue(date, i);
          if (double.IsNaN(filterToday[i]) == false && double.IsNaN(sigToday[i]) == false)
          {
            ++productValidCount;
            sum += sigToday[i];
          }
        }

        var avg = sum / Convert.ToDouble(productValidCount);

        for (int i = 0; i < sigToday.Length; ++i)
        {
          if (double.IsNaN(filterToday[i]) == false && double.IsNaN(sigToday[i]) == false)
            wts_.MultValue(date, i, sigToday[i] - avg);
        }
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:WtImpactCrossSectionalDemeaning.cs

示例5: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      // go through each rebal date
      foreach (DateTime date in wts_.Dates)
      {
        for (int i = 0; i < wts_.ArrayLength; ++i)
        {
          if (products_[i].IsValid(date))
          {
            wts_.MultValue(date, i, signalResults_.GetValue(date, i) / Math.Pow(products_[i].GetVol(date, m_volType, m_windowLength), m_power), false);
          }
        }
      }

    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:15,代码来源:WtImpactVol.cs

示例6: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      foreach (DateTime date in signalResults_.Dates)
      {
        for (int i = 0; i < signalResults_.ArrayLength; ++i)
        {
          double val = signalResults_.GetValue(date, i);

          if (val < 0 && GoShort == false)
            wts_.SetValue(date, i, 0.0);
          else if (val > 0 && GoLong == false)
            wts_.SetValue(date, i, 0.0);
          else
            wts_.MultValue(date, i, val, false);
        }
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:17,代码来源:WtImpactSide.cs

示例7: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      double[] sigToday = new double[products_.Count];
      double sum;

      foreach (DateTime date in signalResults_.Dates)
      {
        double[] filterToday = filters_.GetValues(date);
        sum = 0;

        for (int i = 0; i < sigToday.Length; ++i)
          if(double.IsNaN(filterToday[i])==false)
            sum += signalResults_.GetValue(date, i);

        for (int i = 0; i < sigToday.Length; ++i)
          if(double.IsNaN(filterToday[i])==false)
            wts_.MultValue(date, i, signalResults_.GetValue(date, i) / sum, false);
      }

    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:20,代码来源:WtImpactNormalise.cs

示例8: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      foreach (DateTime date in signalResults_.Dates)
        for (int i = 0; i < products_.Count; ++i)
        {
          double v = signalResults_.GetValue(date, i);

          v = (v == 0) ? 0.0 : (v < 0) ? -1.0 : 1.0;
          v = (m_reverse) ? -v : v;

          if (m_scaleSignDifferently && v != 0)
          {
            v = (v < 0) ? (v * m_negScale) : (v * m_posScale);

            wts_.MultValue(date, i, v, v < 0);
          }
          else
          {
            wts_.SetValue(date, i, v);
            //wts_.SetToSign(date, i, v);
          }
        }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:23,代码来源:WtImpactSign.cs


注:本文中的ConstructGen.MultValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。