Skip to main content

DataSchema / DataSet

Classes that define the structure of exported data and hold the exported rows.

Namespace: MZpack.NT8.Algo

DataSchema

Defines the column structure of an export — an ordered list of ValueDescriptor instances.

Properties

PropertyTypeDescription
DescriptorsList<ValueDescriptor>Ordered list of column descriptors
DataSetDataSetAssociated DataSet (set during Init)

Adding Columns

DataSchema uses a fluent API — all Append methods return this.

By indicator value:

schema
.Append(IndValue.POC)
.Append(IndValue.Delta)
.Append(IndValue.Volume);

With custom name and kind:

schema.Append("my_poc", ValueKind.Feature, IndValue.POC);

With calculated value:

schema.Append("spread", ValueKind.Feature,
(export, desc, data) => strategy.GetCurrentAsk() - strategy.GetCurrentBid());

With multiple indicator values:

schema.Append("levels", ValueKind.Feature,
new[] { IndValue.VAH, IndValue.VAL, IndValue.POC });

With drawing object mapping:

schema.Append("signal", ValueKind.Label, chartObjectDescriptor);

Key Methods

MethodReturnsDescription
Append(IndValue)DataSchemaAdd column for built-in indicator value
Append(string, ValueKind, IndValue, int)DataSchemaAdd named column with kind and optional shift
Append(string, ValueKind, CalculateExportValueDelegate)DataSchemaAdd calculated single-value column
Append(string, ValueKind, CalculateExportValuesDelegate)DataSchemaAdd calculated multi-value column
Append(string, ValueKind, ChartObjectDescriptor)DataSchemaAdd drawing object column
GetColumnByName(string)intColumn index by name (−1 if not found)
GetColumnByIndValue(IndValue)intColumn index by IndValue (−1 if not found)
GetFeatures()string[]Names of all Feature columns
GetLabels()string[]Names of all Label columns
GetOfKind(ValueKind)List<ValueDescriptor>All descriptors of a given kind
Drop(string, ValueKind)voidRemove descriptor by name and kind
Clone()DataSchemaDeep copy of schema and all descriptors
SaveToXml(string)voidSerialize schema to XML file
LoadFromXml(MZpackStrategyBase, string)DataSchemaDeserialize schema from XML file (static)

DataSet

Container for exported data rows, organized by a DataSchema.

Properties

PropertyTypeDescription
SchemaDataSchemaColumn definitions (setting clears all rows)
RowsList<DataSetRow>All data rows
CursorintIndex of the last added row
ExportGeneralExportParent export instance

Methods

MethodReturnsDescription
AddRow(DateTime)DataSetRowCreate a new row with timestamp
GetValue(int, int)doubleGet value by column and shift from cursor
GetValue(IndValue, int)doubleGet value by IndValue and shift
GetValue(string, int)doubleGet value by column name and shift
SetValue(double, int, int)voidSet value by column and shift
GetLabel(int, int)doubleGet label by column and shift
SetLabel(double, int, int)voidSet label by column and shift
Skip(int)voidRemove first N rows
Append(DataSet)voidAppend rows from another DataSet (schemas must match)
ToEnumerable(ValueKind)List<List<double>>All rows as nested lists, filtered by kind
ToLines(ExportArgs, int)List<string>Convert rows to CSV strings
LastRowToString(ExportArgs)stringLast row as CSV string

DataSetRow

A single row of exported data with a timestamp.

Properties

PropertyTypeDescription
TimeDateTimeRow timestamp
ValuesDataSetRowValuesFeature and Internal values
LabelsDataSetRowValuesLabel values

Methods

MethodReturnsDescription
ToString(ExportArgs)stringRow as a delimited string

DataSetRowValues

Inheritance: DataSetRowValues : List<double>

A list of double values for one row. Extends List<double> with no additional public API.

Index

Simple wrapper for an integer value, used internally for position tracking.

PropertyTypeDescription
ValueintIndex value

Example

// Define schema with POC and Delta columns
var args = new ExportArgs { FileName = "output.csv", IsHeader = true, IsTime = true };
var export = new IndicatorExport(strategy, fpIndicator,
ExportDataSource.Level1, ExportTemporality.Historical,
ExportGranularity.Bar, args);

export.DataSet.Schema
.Append(IndValue.POC)
.Append(IndValue.Delta);

// After export, access data:
double poc = export.DataSet.GetValue(IndValue.POC);
double prevDelta = export.DataSet.GetValue(IndValue.Delta, shift: 1);