Syntax
public static double[] ToArray(this DataSeries ds)
Parameter Description
Description
LINQ provides a convenient and terse way to write SQL-like queries, allowing to filter, aggregate, group, sort and so on. While Wealth-Lab's
DataSeries doesn't support LINQ natively, Community.Components users can employ the so called
extension method .ToArray() to run LINQ queries on DataSeries.
There also is a companion method
ToList with identical syntax.
Example
The following quick example shows the average price of a DataSeries by virtue of LINQ's
Average function.
Note: Add reference to
System.Core before using the sample code:
Example:using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using System.Linq;
/*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions, 2012.10 or later***/
namespace WealthLab
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
var ds2List = Bars.Close.ToArray();
var dsAverage = ds2List.Average( i => i );
PrintDebug(dsAverage);
}
}
}