本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}