Create and manage 2D Matrix of different DataTypes with a Headline for csv Export

Created at 28 Mar 2017, 20:30
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Mikro's avatar

Mikro

Joined 20.06.2015

Create and manage 2D Matrix of different DataTypes with a Headline for csv Export
28 Mar 2017, 20:30


Hi all,
To analyse Data in different Variables in a Bot I want to output them to a csv-File for further Analysis. The tricky Part is collecting the Data it seems.

Data to be analysed/stored

The Data (Strings, Doubles, Longs, ...) is created asynchronuosly during a single Tick, also the number of the arriving Data varies.

Current Aproach

During each Tick I want to store the Data to a Matrix, and after buffering a certain amount I want to flush the buffer to a .csv .
To achieve this I am sending the Data from the different Methods to my FileExport-Class tagged with an Identifier (string) to each DataStream like so:

myFileExporter.LogData(string Sender, type Data);

In the FileExport-Class I want to store the Data in a 2D Matrix.
To find the right Column to store the Data to I have one list<string> csvHeader

and a 2D Matrix.

    private List<string> csvHeader = new List<string>()
        {
            "Date",
            "Time",
            "Bid",
            "Ask",
        }
    private List<object> csvMatrix = new List<object>()
        {
            new List<DateTime>(),
            new List<DateTime>(),
            new List<double>(),
            new List<double>()
        };

To store the Data I query the column and then want to add the Data to the Matrix

int dataColumn = csvHeader.FindIndex(x => x == header);

Here I am stuck adding the Data to the `list<list<>>`.

csvMatrix[columnPos].Add

does not work?

Any Ideas on how to add the Data to the 2D List or may be a smarter Approach to collecting and exporting Data?

cheers

Mikro

 


@Mikro