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


C# ConstructGen.GetValue方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例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_)
    {
      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

示例6: 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

示例7: 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

示例8: getOHLCSeriesFromBbg

        public static ConstructGen<double> getOHLCSeriesFromBbg(DateTime firstDate_, string ticker_, bool insertNan_ = true)
        {
            var ret = new ConstructGen<double>(new string[] { "PX_OPEN", "PX_HIGH", "PX_LOW", "PX_CLOSE_1D" });
            DateTime[] bbgDates = null;
            for (int i = 0; i < ret.ColumnHeadings.Length; ++i)
            {
                DateTime start;
                if (i == 3)
                    start = firstDate_.AddDays(1);
                else
                    start = firstDate_;

                var b = BbgTalk.HistoryRequester.GetHistory(start, ticker_, ret.ColumnHeadings[i], false);

                if (b == null || b.Length == 0)
                {
                    throw new Exception(string.Format("No data retrieved for given ticker '{0}'", ticker_.ToUpper()));
                }
                else
                    b = HelperMethods.ensureAllWeekdays(b, insertNan_);

                if (i == 3)
                {
                    var closeData = bbgDates.Length > b.Dates.Length ? b.Data : b.Data.Skip(1).ToArray();
                    ret.SetColumnValues(i, bbgDates.SkipLast().ToArray(), closeData);
                }
                else
                {
                    ret.SetColumnValues(i, b.Dates, b.Data);
                    bbgDates = b.Dates;
                }
            }
            
            foreach (var d in ret.Dates.OrderByDescending(d => d))
            {
                if (ret.GetValue(d, 3) == 0)
                {
                    ret.RemoveValues(d);
                }
                else break;                
            }

            return ret;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:44,代码来源:BbgData.cs

示例9: FXCarry_5_20

    public FXCarry_5_20()
    {
      m_dailyCarry = Singleton<FXCarry>.Instance.GetData(
        startDate_: DataConstants.DATA_START,
        endDate_: DateTime.Today,
        forceRefresh_:true);

      StartDate = MyCalendar.NextDayOfWeek(m_dailyCarry.Dates.First().AddDays(30d), DayOfWeek.Tuesday);

      EER = (ccy_, date_) =>
      {
        int endIndex = m_dailyCarry.Dates.Contains(date_)
          ? m_dailyCarry.Dates.IndexOf(date_) - 1
          : m_dailyCarry.Dates.Count - 1;

        var carryLength = ccy_.IsGroup(FXGroup.NDF) ? 20 : 5;

        double sum = 0d;
        for (int i = 0; i < carryLength; ++i)
          sum += m_dailyCarry.GetValue(m_dailyCarry.Dates[endIndex - i], ccy_.ArrayIndex);

        var result = sum/Convert.ToDouble(carryLength);

        return result;
      };

      USDMin = -0.00001;
      USDMax = 0.00001;

      USDMin = USDMax = 0d;

      TargetVol = 0.06;

      LowerLimit = (ccy_, date_) => !ccy_.IsGroup(FXGroup.G10)
        ? -TargetVol*10d
        : -TargetVol*25d;

      UpperLimit = (ccy_, date_) => !ccy_.IsGroup(FXGroup.G10)
        ? TargetVol*10d
        : TargetVol*25d;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:41,代码来源:FXCarry_5_20.cs

示例10: 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

示例11: Create

    public void Create(ConstructGen<double> candleData_, int openIndex_ = 0, int highIndex_ = 1, int lowIndex_ = 2, int closeIndex_ = 3)
    {
      var dt = new DataTable();
      dt.Rows.Clear();
      dt.Columns.Clear();

      dt.Columns.Add("Label", typeof(string));
      dt.Columns.Add("Date", typeof(DateTime));
      dt.Columns.Add("Open", typeof(double));
      dt.Columns.Add("High", typeof(double));
      dt.Columns.Add("Low", typeof(double));
      dt.Columns.Add("Close", typeof(double));
      dt.Columns.Add("Volume", typeof (double));

      CandleSeries cs = (CandleSeries)ultraChart1.CompositeChart.Series[0];

      var setupStarts = DeMarkAnalysis.GetSetups(candleData_);

      for(int i=0;i<candleData_.Dates.Count;++i)
      {
        var date = candleData_.Dates[i];
        var arr = candleData_.GetValues(date);
        dt.LoadDataRow(new object[]
        {
          ((dt.Rows.Count+1) % 10).ToString(),
          date,
          arr[openIndex_],
          arr[highIndex_],
          arr[lowIndex_],
          arr[closeIndex_],
          0d
        }, true);

        // any mark for this date?
        var mark = setupStarts.FirstOrDefault(x => x.Date == date);

        if (mark != null)
        {
          switch (mark.EventType)
          {
            case DeMarkEventType.BuySetupStart:
            {
              var annotation = createAnnotation("BuySetup", i + 0.5d, candleData_.GetValue(date, lowIndex_) - 1,
                Color.Green);
              ultraChart1.Annotations.Add(annotation);
            }
              break;
            case DeMarkEventType.SellSetupStart:
            {
              var annotatio = createAnnotation("SellSetup", i + 0.5d, candleData_.GetValue(date, highIndex_) + 1,
                Color.Red);
              ultraChart1.Annotations.Add(annotatio);
            }
              break;
          }
        }
      }

      cs.Data.LabelColumn = "Label";
      cs.Data.LowColumn = "Low";
      cs.Data.HighColumn = "High";
      cs.Data.OpenColumn = "Open";
      cs.Data.CloseColumn = "Close";
      cs.Data.DateColumn = "Date";
      cs.Data.VolumeColumn = "Volume";
      cs.Data.DataSource = dt;

      ultraChart1.InvalidateLayers();

      //EstablishDefaultTooltip((hash) =>
      //{
      //  return null;
      //});
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:74,代码来源:DeMarkChart2.cs

示例12: Go


//.........这里部分代码省略.........
      // convert to returns:
      var euroReturns = euroSeries.ToReturns();
      var cumulative = euroReturns.ToCumulative();

      var stdFromMean = euroSeries.ToStdevFromMean(meanWindowLength_: 21, sdWindowLength_: 126);

      // I've also done a load of stuff to transform this series, take a look at HelperMethods.
      
      // often, we don't deal with individual price series, though we need inline data

      // for this I have made something called ConstructGen<T>, where again, T is normally a double

      var firstConstruct = new ConstructGen<double>(9);

      // this has made a construct that is set up to store dated values for 9 different variables

      // it's good to set the columnHeadings on the construct so you know what they refer to

      var headings = new string[] {"AUD", "CAD", "CHF", "EUR", "GBP", "JPY", "NOK", "NZD", "SEK"};
      firstConstruct.ColumnHeadings = headings;

      // (I'll show you how to do this more easily in a bit...

      // let's look at what we can do with construct and how we use it

      DateTime conDate = new DateTime(2014, 1, 1);

      firstConstruct.SetValue(conDate, 0, 100.2);

      // this has set the value for the first column (AUD) on the given Date

      // we get it out by:

      var v1 = firstConstruct.GetValue(conDate, 0);

      // set the second value:

      firstConstruct.SetValue(conDate, 1, 45.6);

      // this has set the value for the given date for 'CAD'

      // we could set all values at once using SetValues rather than SetValue

      firstConstruct.SetValues(conDate, new double[] {1, 2, 3, 4, 5, 6, 7, 8, 9});

      // and we could get them out using:

      double[] allValuesOnDate = firstConstruct.GetValues(conDate);

      // there are lots of methods on Construct<T> to make our life easier when dealing with data

      // we can fill it up randomly using the SetValues, and then just call SortKeys() to ensure teh dates are in order

      firstConstruct.SortKeys();

      // this means that we will be iterate over the dates in order when we go through it

      // e.g.

      foreach (DateTime date in firstConstruct.Dates)
      {
        var datesVAlues = firstConstruct.GetValues(date);

        // here we could process them...
      }
开发者ID:heimanhon,项目名称:researchwork,代码行数:66,代码来源:L1.cs

示例13: getWeights

    private ConstructGen<double>[] getWeights(TraderArgs args_, List<DateTime> rebalDates_, ConstructGen<double> filter_)
    {
      if (m_resultsWts.Count == 0)
        return null;

      ConstructGen<double>[] allWts = new ConstructGen<double>[args_.WtIndicators.Count];

      // go through all wtIndicators - will normally only be one
      for (int i = 0; i < args_.WtIndicators.Count; ++i)
      {
        ConstructGen<double> all_c,rebal_c;

        int length = args_.Products.Count;

        all_c = new ConstructGen<double>(length);
        rebal_c = new ConstructGen<double>(length);

        for (int j = 0; j < args_.Products.Count; ++j)
        {
          // extract the signal series for this wtIndicator and product
          DatedDataCollectionGen<double> dataForProductAndIndicator = m_resultsWts[args_.Products[j]][i];

          // put the data in the contruct that represents the signal at every point
          for (int y = 0; y < dataForProductAndIndicator.Length; ++y)
            all_c.SetValue(
              dataForProductAndIndicator.Dates[y],
              j,
              dataForProductAndIndicator.Data[y]);

          // put the data in the construct that represents the signal just on rebal days
          // NOTE: is offset by 1 day so not in sample
          foreach (DateTime d in rebalDates_)
          {
            //if (d == new DateTime(2010, 3, 19))
            //  System.Diagnostics.Debugger.Break();
            if (args_.Products[j].IsValid(d))
              rebal_c.SetValue(d, j, dataForProductAndIndicator.ValueOnDate(d, args_.DayOffset));
          }
        }

        // c is now a representation of the signal for all products on all days

        // do we want the product of the weights to determine which products can have positions on different days?
        if (args_.UseWeightsForFilter)
        {
          foreach (DateTime d in rebalDates_)
          {
            for (int ii = 0; ii < rebal_c.ArrayLength; ++ii)
              if (double.IsNaN(rebal_c.GetValue(d, ii)))
                filter_.SetValue(d, ii, double.NaN);
          }
        }

        // multiply it by the filter to get rid of non-eligible days

        rebal_c = multiply(rebal_c, filter_,false);

        //ConstructDisplay.Show(rebal_c, args_.Products.ToArray(), "raw signal * filter");

        // now need to scale the weights based on the weighting scheme supplied on the signal indicator 

        // create a construct which will be the multiple

        foreach (SI.Research.Backtest.Builder.Model.WtScheme transform in args_.WtIndicators[i].TransformList)
        {
          ConstructGen<double> wts = new ConstructGen<double>(length);
          wts.InitialiseToValue(rebalDates_,1d);

          transform.DoWeights(rebal_c, all_c, wts, args_.Products,filter_);

          wts = multiply(wts, filter_, true);

          rebal_c = wts;

          //ConstructDisplay.Show(rebal_c, args_.Products.ToArray(), "weights");
        }

        //ConstructDisplay.Show(rebal_c, new object[] { "wts" }, "transformed weights");

        allWts[i] = rebal_c;
      }

      return allWts;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:84,代码来源:Trader.cs

示例14: agreeSign

    private ConstructGen<double> agreeSign(ConstructGen<double> a_, ConstructGen<double> b_)
    {
      ConstructGen<double> ret = new ConstructGen<double>(a_.ArrayLength);

      foreach (DateTime d in a_.Dates)
      {
        for (int i = 0; i < ret.ArrayLength; ++i)
        {
          double valA = a_.GetValue(d, i);
          double valB = b_.GetValue(d, i);

          if (double.IsNaN(valA)
            || double.IsNaN(valB)
            || ((valA > 0) && (valB < 0))
            || ((valA < 0) && (valB > 0))
            || ((valA==0) && (valB !=0))
            || ((valB==0) && (valA!=0)))
          {
            ret.SetValue(d, i, 0.0);
          }
          else
          {
            ret.SetValue(d, i, valA + valB);
          }
        }
      }
      return ret;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:28,代码来源:Trader.cs

示例15: AllConstantMaturityPrices

    public ConstructGen<double> AllConstantMaturityPrices()
    {
      if (m_allFuturePrices != null)
        return m_allFuturePrices;

      // get the quarterlyin contracts
      var allIMMs = Underlying.IMM_Contracts();

      // build up the list of prices for all contracts

      ConstructGen<double> subCon;
      {
        var con = new ConstructGen<double>(allIMMs.Select(x => x.SymmetryCode).ToArray());
        {
          for (int i = 0; i < con.ArrayLength; ++i)
            con.SetColumnValues(i, allIMMs[i].GetPrices(marketSnapCode_:MarketSnapCode,quoteSource_:QuoteSourceCode,priceType_:1));

          con.SortKeys();
        }

        var dates = SI.Strategy.RatesSpreads.DateHelper.GetBusinessDates(CurveNames.USD3M);

        subCon = new ConstructGen<double>(con.ColumnHeadings);

        foreach (var date in dates)
          if (con.Dates.Contains(date))
            subCon.SetValues(date, con.GetValues(date));
      }

      // create the construct that will hode the constant maturity prices
      // is NumContracts+1 as first column will be interest rate fixing

      m_allFuturePrices =
        new ConstructGen<double>(
          ExtensionMethods.CreateArrayRep(Underlying.FutureStart, NumContracts+1)
            .Select((x, i) => string.Format("{0}cm{1}", x.ToUpper(), i))
            .ToArray());

      foreach (var date in subCon.Dates)
      {
        // set the fixing
        m_allFuturePrices.SetValue(date, 0, Underlying.FixingInstrmnet.GetPrices().ValueOnDate(date)*100d);

        for (int pointIndex = 0; pointIndex < NumContracts; ++pointIndex)
        {
          var daysForward = Convert.ToDouble(pointIndex + 1)*DaysSpan;
          var forwardDate = date.AddDays(daysForward);

          int beforeIndex=-1, afterIndex=-1;
          for (int i = 0; i < allIMMs.Count-1; ++i)
          {
            if(allIMMs[i].Maturity.Value==forwardDate)
            {
              beforeIndex = i;
              afterIndex = i;
              break;
            }
            else if (allIMMs[i].Maturity.Value < forwardDate && allIMMs[i+1].Maturity.Value > forwardDate)
            {
              beforeIndex = i;
              afterIndex = i + 1;
            }
          }

          // were the indexes of the contract that straddle the forward date found?
          if (beforeIndex >= 0)
          {
            if (beforeIndex == afterIndex)
            {
              m_allFuturePrices.SetValue(date, pointIndex+1, 100d-subCon.GetValue(date, beforeIndex));
            }
            else
            {
              var beforeValue = subCon.GetValue(date, beforeIndex);
              var afterValue = subCon.GetValue(date, afterIndex);

              if (beforeValue == 0d || afterValue == 0d)
                continue;

              var width = allIMMs[afterIndex].Maturity.Value - allIMMs[beforeIndex].Maturity.Value;

              var w1 = forwardDate - allIMMs[beforeIndex].Maturity.Value;

              var propAfter = w1.TotalDays/width.TotalDays;

              var interpValue = (afterValue*propAfter) + (beforeValue*(1d - propAfter));

              m_allFuturePrices.SetValue(date, pointIndex+1, 100d-interpValue);
            }
          }
        }
      }

      return m_allFuturePrices;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:95,代码来源:ConstantMaturityFutures.cs


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