Log in to see Cloud of Tags

Wealth-Lab Wiki

DataSeries.ToArray

RSS

Syntax

public static double[] ToArray(this DataSeries ds)

Parameter Description

dsDataSeries object

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); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.