本文整理汇总了C#中ConstructGen.AvgRows方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructGen.AvgRows方法的具体用法?C# ConstructGen.AvgRows怎么用?C# ConstructGen.AvgRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstructGen
的用法示例。
在下文中一共展示了ConstructGen.AvgRows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ATMVolsRankGroup
protected ATMVolsRankGroup(FXGroup group_)
{
var currencies = Singleton<FXIDs>.Instance.Where(x => x.IsGroup(group_)).ToArray();
var oneWeek = new ConstructGen<double>(currencies.Select(x => x.Code).ToArray());
var oneMonth = new ConstructGen<double>(currencies.Select(x => x.Code).ToArray());
for (int i = 0; i < currencies.Length; ++i)
{
{
var vols = BbgTalk.HistoryRequester.GetHistory(DataConstants.DATA_START, currencies[i].AtTheMoneyVolTicker_1W, "PX_LAST", false);
oneWeek.SetColumnValues(i, vols);
}
{
var vols = BbgTalk.HistoryRequester.GetHistory(DataConstants.DATA_START, currencies[i].AtTheMoneyVolTicker_1M, "PX_LAST", false);
oneMonth.SetColumnValues(i, vols);
}
}
{
oneWeek.SortKeys();
var avg1W = oneWeek.AvgRows();
ATM_1W_Avg = avg1W;
ATM_1W_o6M = avg1W.ToPercentileRanked(126);
ATM_1W_o1Y = avg1W.ToPercentileRanked(252);
}
{
oneMonth.SortKeys();
var avg1M = oneMonth.AvgRows();
ATM_1M_Avg = avg1M;
ATM_1M_o6M = avg1M.ToPercentileRanked(126);
ATM_1M_o1Y = avg1M.ToPercentileRanked(252);
}
}
示例2: GetIndicator
//.........这里部分代码省略.........
// break;
//case IndicType.VolSlope_pr252:
// {
// DatedDataCollectionGen<double> dd = BbgTalk.Core.Instance.GetHistory(Environment.UserName, DataConstants.DATA_START, ".VSL INDEX", "PX_LAST", true);
// ret = new DatedDataCollectionGen<double>(dd.Dates, dd.Data).ToPercentileRanked(252);
// }
// break;
case IndicType.AvgCarry_actual:
{
var spots = Singleton<FXSpots>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true);
var fwds = Singleton<FXForwards1Wk>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true);
Currency[] ccys = Singleton<FXIDs>.Instance.ToArray();
ConstructGen<double> con = new ConstructGen<double>(ccys.Select(x=>x.Code).ToArray());
for (int d = 0; d < spots.Dates.Count; ++d)
{
DateTime date = spots.Dates[d];
double ccyCarry = 0d;
for (int c = 0; c < ccys.Length; ++c)
{
if (ccys[c].IsValid(date) == false)
continue;
if (ccys[c].Convention == 1)
ccyCarry = ((spots.GetValue(date, c) / fwds.GetValue(date, c)) - 1d) * (252d / 5d);
else
ccyCarry = ((fwds.GetValue(date, c) / spots.GetValue(date, c)) - 1d) * (252d / 5d);
con.SetValue(date, c, ccyCarry);
}
}
ret = con.AvgRows();
for (int i = 1; i < ret.Length; ++i)
{
if (double.IsInfinity(ret.Data[i]))
ret.Data[i] = ret.Data[i - 1];
ret.Data[i] = Math.Max(ret.Data[i], -0.01);
}
}
break;
//case IndicType.sigNumRebals21:
// {
// DateTime[] allDates = Singleton<FXSpots>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true).Dates;
// double[] rebalInd = new double[allDates.Length];
// for (int i = 0; i < allDates.Length; ++i)
// if (sigWeights_.Dates.Contains(allDates[i]))
// rebalInd[i] = 1d;
// ret = new DatedDataCollectionGen<double>(allDates, rebalInd).ToRollingSum(21);
// }
// break;
//case IndicType.sigTurnover21:
// {
// List<DateTime> allDates = new List<DateTime>(Singleton<FXSpots>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true).Dates);
// double[] tOver = new double[allDates.Count];
// double[] prevweights = sigWeights_.GetValues(sigWeights_.Dates[0]);
// for (int i = 0; i < sigWeights_.Dates.Count; ++i)
// {
// DateTime date = sigWeights_.Dates[i];
// int index = allDates.IndexOf(date);