本文整理汇总了C#中IDataSet类的典型用法代码示例。如果您正苦于以下问题:C# IDataSet类的具体用法?C# IDataSet怎么用?C# IDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataSet类属于命名空间,在下文中一共展示了IDataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Calculation
var adClosePrice = new double[Bars];
for (int bar = 1; bar < Bars; bar++)
if (Time[bar - 1].Day != Time[bar].Day)
adClosePrice[bar - 1] = Close[bar - 1];
// Check the last bar
TimeSpan tsBarClosing = Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int) Period, 0));
var tsDayClosing = new TimeSpan(24, 0, 0);
if (tsBarClosing == tsDayClosing)
adClosePrice[Bars - 1] = Close[Bars - 1];
// Saving the components
Component = new IndicatorComp[1];
Component[0] = new IndicatorComp
{
CompName = "Closing price of the day",
DataType = IndComponentType.ClosePrice,
ChartType = IndChartType.NoChart,
FirstBar = 2,
Value = adClosePrice
};
}
示例2: Create
// single layer network
public static NeuralNetwork<Vector> Create(IDataSet<Vector, Vector> dataSet, IActivator activator)
{
var workLayer = new FullyConnectedLayer(dataSet.FirstInput.Size, dataSet.FirstOutput.Size, activator);
var outputLayer = new OutputLayer<Vector>();
var layers = new CompositeLayer<Vector, Vector, Vector>(workLayer, outputLayer);
return new NeuralNetwork<Vector>(layers);
}
示例3: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
var price = (BasePrice) IndParam.ListParam[1].Index;
double margin = IndParam.NumParam[0].Value*Point;
int prvs = IndParam.CheckParam[0].Checked ? 1 : 0;
// TimeExecution
if (price == BasePrice.Open && Math.Abs(margin - 0) < Epsilon)
IndParam.ExecutionTime = ExecutionTime.AtBarOpening;
else if (price == BasePrice.Close && Math.Abs(margin - 0) < Epsilon)
IndParam.ExecutionTime = ExecutionTime.AtBarClosing;
// Calculation
double[] adBasePr = Price(price);
var adUpBand = new double[Bars];
var adDnBand = new double[Bars];
int firstBar = 1 + prvs;
for (int iBar = firstBar; iBar < Bars; iBar++)
{
adUpBand[iBar] = adBasePr[iBar - prvs] + margin;
adDnBand[iBar] = adBasePr[iBar - prvs] - margin;
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp
{
CompName = "Up Price",
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = adUpBand
};
Component[1] = new IndicatorComp
{
CompName = "Down Price",
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = adDnBand
};
switch (IndParam.ListParam[0].Text)
{
case "Enter long after an upward move":
Component[0].DataType = IndComponentType.OpenLongPrice;
Component[1].DataType = IndComponentType.OpenShortPrice;
break;
case "Enter long after a downward move":
Component[0].DataType = IndComponentType.OpenShortPrice;
Component[1].DataType = IndComponentType.OpenLongPrice;
break;
}
}
示例4: RowIndex
public RowIndex(int index, IDataSet mainContainer = null, IRowIndex parent = null)
{
Index = index;
Parent = parent;
MainContainer = mainContainer;
Weight = 1.0;
}
示例5: TestIndicator
private void TestIndicator(IIndicator indicator, SlotTypes slotType, IDataSet dataSet, Random random)
{
indicator.Initialize(slotType);
// List parameters
foreach (ListParam list in indicator.IndParam.ListParam)
if (list.Enabled)
{
list.Index = random.Next(list.ItemList.Length);
list.Text = list.ItemList[list.Index];
}
// Numeric parameters
foreach (NumericParam num in indicator.IndParam.NumParam)
if (num.Enabled)
{
double step = Math.Pow(10, -num.Point);
double minimum = num.Min;
double maximum = num.Max;
double value = minimum + step * random.Next((int)((maximum - minimum) / step));
num.Value = Math.Round(value, num.Point);
}
indicator.Calculate(dataSet);
}
示例6: LogisticRegressionClassifierTraining
public LogisticRegressionClassifierTraining(int featuresCount, double regularizationParameter, IDataSet<bool, double> dataSet)
{
if (featuresCount <= 0)
{
throw new ArgumentOutOfRangeException("featuresCount", featuresCount, "Features count must be positive number.");
}
if (regularizationParameter < 0)
{
throw new ArgumentOutOfRangeException("regularizationParameter", regularizationParameter, "Regularization parameter must be non negative number.");
}
if (dataSet == null)
{
throw new ArgumentNullException("dataSet");
}
this.featuresCount = featuresCount;
this.regularizationParameter = regularizationParameter;
this.dataSet = dataSet;
this.samplesCount = dataSet.GetTrainingSamplesCount();
if (this.samplesCount <= 0)
{
throw new ArgumentOutOfRangeException("dataSet.GetTrainingSamplesCount()", this.samplesCount, "Samples count must be positive integer.");
}
}
示例7: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Calculation
const int firstBar = 2;
var adIb = new double[Bars];
for (int iBar = 2; iBar < Bars; iBar++)
{
adIb[iBar] = ((High[iBar - 1] < High[iBar - 2]) && (Low[iBar - 1] > Low[iBar - 2])) ? 1 : 0;
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp
{
CompName = "Allow long entry",
DataType = IndComponentType.AllowOpenLong,
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = adIb
};
Component[1] = new IndicatorComp
{
CompName = "Allow short entry",
DataType = IndComponentType.AllowOpenShort,
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = adIb
};
}
示例8: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
if (!IsBacktester)
{
// FST sends the N bars for exit to the expert. Expert watches the position and closes it.
return;
}
var nExit = (int) IndParam.NumParam[0].Value;
// Saving the components
Component = new IndicatorComp[1];
Component[0] = new IndicatorComp
{
CompName = "N Bars Exit (" + nExit.ToString(CultureInfo.InvariantCulture) + ")",
DataType = IndComponentType.ForceClose,
ChartType = IndChartType.NoChart,
ShowInDynInfo = true,
FirstBar = 1,
Value = new double[Bars]
};
}
示例9: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
var entryHour = (int) IndParam.NumParam[0].Value;
var entryMinute = (int) IndParam.NumParam[1].Value;
var entryTime = new TimeSpan(entryHour, entryMinute, 0);
// Calculation
const int firstBar = 1;
var adBars = new double[Bars];
// Calculation of the logic
for (int bar = firstBar; bar < Bars; bar++)
{
adBars[bar] = Time[bar].TimeOfDay == entryTime ? Open[bar] : 0;
}
// Saving the components
Component = new IndicatorComp[1];
Component[0] = new IndicatorComp
{
CompName = "Entry hour",
DataType = IndComponentType.OpenPrice,
ChartType = IndChartType.NoChart,
ShowInDynInfo = false,
FirstBar = firstBar,
Value = adBars
};
}
示例10: NormalizeComponents
/// <summary>
/// Converts indicator components to strategy data set time.
/// </summary>
public void NormalizeComponents(IDataSet strategyDataSet)
{
foreach (IndicatorComp indicatorComp in Component)
{
indicatorComp.Value = NormalizeComponentValue(indicatorComp.Value, strategyDataSet.Time);
indicatorComp.FirstBar = NormalizeComponentFirstBar(indicatorComp.FirstBar, strategyDataSet.Time);
}
}
示例11: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
if (IsBacktester)
CalculateForBacktester();
else
CalculateForTrader();
}
示例12: RemoveRatings
///
public virtual void RemoveRatings(IDataSet ratings_to_delete)
{
for (int i = 0; i < ratings_to_delete.Count; i++)
{
int index;
if (Ratings.TryGetIndex(ratings_to_delete.Users[i], ratings_to_delete.Items[i], out index))
Ratings.RemoveAt(index);
}
}
示例13: Calculate
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
var fromHour = (int) IndParam.NumParam[0].Value;
var fromMin = (int) IndParam.NumParam[1].Value;
var untilHour = (int) IndParam.NumParam[2].Value;
var untilMin = (int) IndParam.NumParam[3].Value;
var fromTime = new TimeSpan(fromHour, fromMin, 0);
var untilTime = new TimeSpan(untilHour, untilMin, 0);
// Calculation
const int firstBar = 1;
var adBars = new double[Bars];
// Calculation of the logic
for (int bar = firstBar; bar < Bars; bar++)
{
if (fromTime < untilTime)
adBars[bar] = Time[bar].TimeOfDay >= fromTime &&
Time[bar].TimeOfDay < untilTime
? 1
: 0;
else if (fromTime > untilTime)
adBars[bar] = Time[bar].TimeOfDay >= fromTime ||
Time[bar].TimeOfDay < untilTime
? 1
: 0;
else
adBars[bar] = 1;
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp
{
CompName = "Is long entry allowed",
DataType = IndComponentType.AllowOpenLong,
ChartType = IndChartType.NoChart,
ShowInDynInfo = false,
FirstBar = firstBar,
Value = adBars
};
Component[1] = new IndicatorComp
{
CompName = "Is short entry allowed",
DataType = IndComponentType.AllowOpenShort,
ChartType = IndChartType.NoChart,
ShowInDynInfo = false,
FirstBar = firstBar,
Value = adBars
};
}
示例14: AddDataSet
/// <summary>
/// Adds a data set to the aggregate.
/// </summary>
/// <param name="dataSet">The data set to add.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="dataSet"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown if <paramref name="dataSet"/> is already a member of this aggregate.</exception>
public virtual void AddDataSet(IDataSet dataSet)
{
if (dataSet == null)
throw new ArgumentNullException("dataSet");
if (dataSets == null)
dataSets = new List<IDataSet>();
else if (dataSets.Contains(dataSet))
throw new ArgumentException("The data set is already a member of the aggregate.", "dataSet");
dataSets.Add(dataSet);
}
示例15: CalculateIndicatorWithRandomParameters
public void CalculateIndicatorWithRandomParameters(IIndicator indicator, IDataSet dataSet, int testPerSlot)
{
Random random = new Random(DateTime.Now.Second);
var types = (SlotTypes[])Enum.GetValues(typeof(SlotTypes));
foreach (var type in types)
if (indicator.TestPossibleSlot(type))
for (int i = 0; i < testPerSlot; i++)
{
TestIndicator(indicator, type, dataSet, random);
ShowResult(indicator);
}
}